function CalcCourtCosts () {
//New spec per Chuck 10/16/09
//Letter plus 6 numbers, then court costs = special
//Letter plus 5 numbers, the court costs = same as present schedule, based only on the letter

 var TicketNum = '';
 var Letter='';
 var CC=0.00;
 var Ret = 0;

TicketNum = document.CalcForm.courtcost.value.toUpperCase();
Letter = document.CalcForm.courtcost.value.toUpperCase().substr(0,1);
 //Letter = document.CalcForm.courtcost.value.toUpperCase().substr(0,1);
 
//OK checks -----------------------------------------
//Check that input is not null
 if (Letter == '')
  {
    alert("Please enter the ticket number.");
    CalcForm.courtcost.focus();
    return (false);
  }
 
 //check that the first char is alpha
 if (!isAlphabeticChar(Letter))
   {
   alert("The first character of the ticket number should be a letter.");
   return (false);
   }
 
// Check that there are 6 or 7 char
if (TicketNum.length < 6)
 {
   alert("The ticket number must be at least 6 characters, and no more than 7 characters long.");
   return (false);
 }
if (TicketNum.length > 7)
 {
   alert("The ticket number must be at least 6 characters, and no more than 7 characters long.");
   return (false);
 }
 
 //check that the remaining char are numeric
 if (!isNumberString(TicketNum.substr(1,100)) == 1)
  {
   alert("The ticket number must be 1 letter followed by 5 or 6 numbers.");
   return (false);
  }
 




// do the math and calc the Court Costs
if (TicketNum.length == 7)           //THis is part of the new spec.
  {
  //write court costs
  document.CalcForm.courtcost1.value= 104.00; 
  return(true);
  }

//   document.CalcForm.mphover.value=mphOver;         //If length of ticket number is 6 do this
 if (Letter == 'T') {
   CC=109.00;
 }         
 else if (Letter == 'U') {
   CC=109.00;
 }         
 else if (Letter == 'V') {
   CC=104.00;
 }         
 else if (Letter == 'W') {
   CC=104.00;
 }         
 else if (Letter == 'X') {
   CC=109.00;
 }         
 else if (Letter == 'Y') {
   CC=109.00;
 }         
 else if (Letter == 'Z') {
   CC=107.00;
 }         
 else {
   CC=104.00;
 }
 //write court costs
 document.CalcForm.courtcost1.value= CC; 
 return(true);
}

function isAlphabeticChar (InString)  {
	if(InString.length!=1) 
		return (false);
	InString=InString.toLowerCase ()
	RefString="abcdefghijklmnopqrstuvwxyz";
	if (RefString.indexOf (InString, 0)==-1) 
		return (false);
	return (true);
}

function isAlphabeticString (InString)  {
	if(InString.length==0)
		return (false);
	InString=InString.toLowerCase ()
	RefString="abcdefghijklmnopqrstuvwxyz";
	for (Count=0; Count < InString.length; Count++)  {
		TempChar= InString.substring(Count, Count+1);
		if (RefString.indexOf(TempChar, 0)==-1) 
			return (false);
	}
	return (true);
}

function isBlank (InString) {
	if (InString==null) return (!false)
	if (InString.length!=0)
		return (!true);
	else
		return (!false);
}

function isNotBlank (InString) {
	if (InString==null) return (false)
	if (InString.length!=0)
		return (true);
	else
		return (false);
}
	

function isNumberChar (InString)  {
	if(InString.length!=1) 
		return (false);
	RefString="1234567890";
	if (RefString.indexOf (InString, 0)==-1) 
		return (false);
	return (true);
}

function isNumberString (InString)  {
	if(InString.length==0) 
		return (false);
	RefString="1234567890";
	for (Count=0; Count < InString.length; Count++)  {
		TempChar= InString.substring (Count, Count+1);
		if (RefString.indexOf (TempChar, 0)==-1)  
			return (false);
	}
	return (true);
}

function testForLength (InString, Abs, LTE, GTE) {
	if (Abs != -1) {if(InString.length==Abs) return(true);} else
	if (LTE != -1) {if(InString.length<=LTE) return(true);} else
	if (GTE != -1) {if(InString.length>=GTE) return(true);} 
		return (false);
}
