
<!--
var Numeric="0123456789";
var Seperator="/,. ";
var Alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var errMsg=new Array(1);
var errNum=0;
var alertString="";
var firstError="";

var Cards = new makeArray(8);
Cards[0] = new CardType("Mastercard", "51,52,53,54,55", "16");
var MasterCard = Cards[0];
Cards[1] = new CardType("Visa", "4", "13,16");
var Visa = Cards[1];
Cards[2] = new CardType("AmExCard", "34,37", "15");
var AmExCard = Cards[2];
Cards[3] = new CardType("DinersClubCard", "30,36,38", "14");
var DinersClubCard = Cards[3];
Cards[4] = new CardType("DiscoverCard", "6011", "16");
var DiscoverCard = Cards[4];
Cards[5] = new CardType("enRouteCard", "2014,2149", "15");
var enRouteCard = Cards[5];
Cards[6] = new CardType("JCBCard", "3088,3096,3112,3158,3337,3528", "16");
var JCBCard = Cards[6];
var LuhnCheckSum = Cards[7] = new CardType();

function valCardNumberByType(CardTypeIn,CardNumberIN)
{

CheckCardNumber(CardTypeIn,CardNumberIN);
return;


}

function CardType() {
  var n;
  var argv = CardType.arguments;
  var argc = CardType.arguments.length;

  this.objname = "object CardType";

  var tmpcardtype = (argc > 0) ? argv[0] : "CardObject";
  var tmprules = (argc > 1) ? argv[1] : "0,1,2,3,4,5,6,7,8,9";
  var tmplen = (argc > 2) ? argv[2] : "13,14,15,16,19";


  this.setCardNumber = setCardNumber;


  this.setCardType = setCardType;


  this.setLen = setLen;


  this.setRules = setRules;


  this.setCardType(tmpcardtype);
  this.setLen(tmplen);
  this.setRules(tmprules);


  this.checkCardNumber = checkCardNumber;


  this.getCardType = getCardType;


  this.isCardNumber = isCardNumber;



  this.luhnCheck = luhnCheck;

  return this;
}

function getCardType() {
  return this.cardtype;
}

function makeArray(size) {
  this.size = size;
  return this;
}
function setRules(rules) {
  // Create the rules array.
  if (rules.length == 0 || rules == null)
    rules = "0,1,2,3,4,5,6,7,8,9";
  
  var tmprules = rules;
  n = 1;
  while (tmprules.indexOf(",") != -1) {
    tmprules = tmprules.substring(tmprules.indexOf(",") + 1, tmprules.length);
    n++;
  }
  this.rules = new makeArray(n);
  n = 0;
  while (rules.indexOf(",") != -1) {
    var tmpstr = rules.substring(0, rules.indexOf(","));
    this.rules[n] = tmpstr;
    rules = rules.substring(rules.indexOf(",") + 1, rules.length);
    n++;
  }
  this.rules[n] = rules;

  return this;
}

function getCardType() {
  return this.cardtype;
}


function CheckCardNumber(CardTypeIn,CardNumberIN) {

  card = CardTypeIn;
  var retval = eval(card + ".checkCardNumber(\"" + CardNumberIN + "\");");  

  cardname = "";
  if (! retval)
  {
    for (var n = 0; n < Cards.size; n++) {
      if (Cards[n].checkCardNumber(CardNumberIN)) {
        cardname = Cards[n].getCardType();
        break;
      }
    }
    if (cardname.length > 0) {
		errNum++;
		errMsg[errNum]="Card Number is not a valid " + card + " number.";
	
    }
	/* 03.23.2005	#3645	Bharathi bavineni	modified error message
	*/
    else {
      //errMsg[errNum]="This's not a card number.";
	  errMsg[errNum]="The credit card number you entered is invalid. Please double-check the value you entered and try again.";
    }
  }
}
/*************************************************************************\
   boolean checkCardNumber([String cardnumber, int year, int month])
   return true if cardnumber pass the luhncheck and the expiry date is
   valid, else return false.
\*************************************************************************/
function checkCardNumber() {
  var argv = checkCardNumber.arguments;
  var argc = checkCardNumber.arguments.length;
  var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;

  this.setCardNumber(cardnumber);

  if (!this.isCardNumber())
    return false;


  return true;
}

function setCardNumber(cardnumber) {
  this.cardnumber = cardnumber;

  return this;
}

/*************************************************************************\
   CardType setCardType(cardtype)
   return the CardType object.
\*************************************************************************/
function setCardType(cardtype) {
  this.cardtype = cardtype;

  return this;
}

function setLen(len) {
  // Create the len array.
  if (len.length == 0 || len == null)
    len = "13,14,15,16,19";

  var tmplen = len;
  n = 1;
  while (tmplen.indexOf(",") != -1) {
    tmplen = tmplen.substring(tmplen.indexOf(",") + 1, tmplen.length);
    n++;
  }
  this.len = new makeArray(n);
  n = 0;
  while (len.indexOf(",") != -1) {
    var tmpstr = len.substring(0, len.indexOf(","));
    this.len[n] = tmpstr;
    len = len.substring(len.indexOf(",") + 1, len.length);
    n++;
  }
  this.len[n] = len;

  return this;
}
function isCardNumber() {
  var argv = isCardNumber.arguments;
  var argc = isCardNumber.arguments.length;
  var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;

  if (!this.luhnCheck())
    return false;

  for (var n = 0; n < this.len.size; n++)
    if (cardnumber.toString().length == this.len[n]) {
      for (var m = 0; m < this.rules.size; m++) {
        var headdigit = cardnumber.substring(0, this.rules[m].toString().length);
        if (headdigit == this.rules[m])
          return true;
      }
      return false;
    }

  return false;
}

function luhnCheck() {
  var argv = luhnCheck.arguments;
  var argc = luhnCheck.arguments.length;

  var CardNumber = argc > 0 ? argv[0] : this.cardnumber;


  var no_digit = CardNumber.length;
  var oddoeven = no_digit & 1;
  var sum = 0;

  for (var count = 0; count < no_digit; count++) {
    var digit = parseInt(CardNumber.charAt(count));
    if (!((count & 1) ^ oddoeven)) {
      digit *= 2;
      if (digit > 9)
	digit -= 9;
    }
    sum += digit;
  }
  if (sum % 10 == 0)
    return true;
  else
    return false;
}


/* This is a function to format Number to decimal places*/

function formatNumber(number,decimals) 
{  
  if (isNaN(number)) { return 0};  
  if (number=='') { return 0};  
   
  var IsNegative=(parseInt(number)<0); 
  if(IsNegative)pnumber=-number; 

  var snum = new String(number);  
  var sec = snum.split('.');  
  var whole = parseInt(sec[0]);  
  var result = '';  
  if(sec.length > 1){  
    var dec = new String(sec[1]);  
    dec = parseInt(dec)/Math.pow(10,parseInt(dec.length-decimals-1)); 
Math.round(dec); 
dec = parseInt(dec)/10; 

if(IsNegative) 
{ 
  var x = 0-dec; 
      x = Math.round(x); 
  dec = - x; 
} 
else 
{ 
      dec = Math.round(dec); 
} 

/* 
 * If the number was rounded up from 9 to 10, and it was for 1 'decimal' 
 * then we need to add 1 to the 'whole' and set the dec to 0. 
 */ 
if(dec==Math.pow(10, parseInt(decimals)))
{ 
  whole+=1; 
  dec="0"; 
} 

    dec = String(whole) + "." + String(dec);  
    var dot = dec.indexOf('.');  
    if(dot == -1){  
      dec += '.';  
      dot = dec.indexOf('.');  
    } 
var l=parseInt(dot)+parseInt(decimals); 
    while(dec.length <= l) { dec += '0'; }  
    result = dec;  
  } else{  
    var dot;  
    var dec = new String(whole);  
    dec += '.';  
    dot = dec.indexOf('.');  
var l=parseInt(dot)+parseInt(decimals); 
    while(dec.length <= l) { dec += '0'; }  
    result = dec;  
  }  
  if(IsNegative)result="-"+result; 
  return result;  
}  


function valZipCode(ZipCode, Country, fieldName,formField)
{
	if (!errNum)
	{
		if(Country == "USA")
		{
			if(ZipCode.length < 5 || ZipCode.length > 5)
			{
				errNum++;
				errMsg[errNum]=fieldName + " USA Zip code must be 5 digits.";
			}
			valNumeric(ZipCode, "Zip Code");
		}
		if(Country == "Canada")
		{
			if(ZipCode.length < 6)
			{
				errNum++;
				errMsg[errNum]=fieldName + " Canada Zip code must be 6 digits.";
			}
		}
		if(Country != "USA" && Country != "Canada")
		{
			if(ZipCode.length < 4)
			{
				errNum++;
				errMsg[errNum]=fieldName + " can not be less than 4 digits.";
			}
		}
		if (errNum)
		firstError = formField;
	}

	return;
}


//this function checks to see if the zip code entered has 4 to 6 numeris digits
function valZip(Zip,fieldName,formField)
{
	if (!errNum)
	{	
	 valid = "0123456789";
	 hyphencount = 0;
		 
		if (Zip.length !=4 && Zip.length !=5 && Zip.length!=6) 
		{
			errNum++;
			errMsg[errNum]= fieldName + " should be 4, 5 or 6 digits.";
			 
		}
		for (var i=0; i < Zip.length; i++)
	 	{
			temp = "" + Zip.substring(i, i+1);
			//if (temp == "-") hyphencount++;
			if (valid.indexOf(temp) == "-1") 
			{
				errNum++;
				errMsg[errNum]= fieldName +" has invalid characters. Please try again.";
				
			}
			
		}
		if (errNum)
		firstError = formField;
	}
	return;
}


function valZip4(Zip4,fieldName,formField)
{
	if(Zip4.length < 4 && !Zip4.length == 0)
	{
			errNum++;
			errMsg[errNum]=fieldName + " Must be 4 digits.";
		
	}
	return;

}

//this function makes sure that Date of birth is not in future and that the candidate is atleast 18 years old.

function validDOB(DOB,fieldName,formField)
{
	if (!errNum)
	{
		dateOfBirth = new Date(DOB);
		tempBirthYear =(dateOfBirth ).getFullYear();
		tempBirthMonth=(dateOfBirth ).getMonth();
		birthMonth = tempBirthMonth +1;
		birthDate = (dateOfBirth).getDate();
		curdate=new Date();
		year=curdate.getYear();
		tempCurMonth = curdate.getMonth();
		curMonth = tempCurMonth + 1;
		curDate = (curdate).getDate();

			if (dateOfBirth  >=curdate)
			{
				errNum++;
				errMsg[errNum]="Date of Birth cannot be in the future.";
			}
			
			if(( year - tempBirthYear ) < 18)
			{
				errNum++;
				errMsg[errNum]="Candidate must be at least 18 years old.";
			}

			
			if((year - tempBirthYear) == 18)
			{
				if(curMonth < birthMonth)
				{
					errNum++;
					errMsg[errNum]="Candidate must be at least 18 years old.";
				}
				if(curMonth == birthMonth)
				{
					if(curDate < birthDate)
						{
						errNum++;
						errMsg[errNum]="Candidate must be at least 18 years old.";
				}
			}
		}

		if (errNum)
		firstError = formField;
	}
	return;
}

function valNameAdressEntries(NameOrAddress, fieldName, formField)
{
	if (!errNum)
	{
	if(NameOrAddress)
	{
		if (NameOrAddress.search) 
		{
			if ((NameOrAddress.search(/[^\d\s]/) == -1) || (NameOrAddress.search(/\D/) == -1))
				{	
					errNum++;
					errMsg[errNum]=fieldName + " cannot be only numeric";
				}
		}
		if (NameOrAddress.search(/\*/ ) != -1)
				{	
					errNum++;
					errMsg[errNum]= fieldName + " '*' Is not allowed";
				}
	}
		if (errNum)
		firstError = formField;

	}
	return;
}
//phone number function
function valPhoneNumber(PhoneNum, fieldName, formField){
	if (!errNum){
		// tests  for an empty string
		if(PhoneNum.length == 0 ) return;
		// test for length of string	
		if( PhoneNum.length != 12 ){
			errNum++;
			errMsg[errNum]=fieldName + " must be 12 Characters long.";
		}
		else{
			// tests for alpha characters and formating 		
			for( x=0; x<PhoneNum.length; x++ )
				if(Numeric.indexOf(PhoneNum.charAt(x))==-1){
					if(x==3 || x==7){
						if(PhoneNum.charAt(x)!="-"){
							errNum++;
							errMsg[errNum]=fieldName + " must be like: 123-456-7890.";
							break;
						}
					}
					else{
						errNum++;
						errMsg[errNum]=fieldName + " must be like: 123-456-7890.";
						break;
					}
					
				}
				else{
					if(x==3 || x==7){
						if(PhoneNum.charAt(x)!="-"){
							errNum++;
							errMsg[errNum]=fieldName + " must be like: 123-456-7890.";
							break;
						}
					}
				}
		}
		if (errNum)
			firstError = formField;
	}
	return;
}

//determines if a value is a valid transaction number
function valTransNum(TransNum, fieldName, formField){
	if (!errNum){
		if(TransNum.length == 0 ) return;
		if( TransNum.length != 13 ){
			errNum++;
			errMsg[errNum]=fieldName + " must be 13 Characters long.";
			}
		for( x=0; x<TransNum.length; x++ )
			if(Numeric.indexOf(TransNum.charAt(x))==-1){
				if(x==4 || x==8){
					if(TransNum.charAt(x)!="-"){
						errNum++;
						errMsg[errNum]=fieldName + " must be like: 1234-567-8901.";
						break;
					}
				}
				else{
					errNum++;
					errMsg[errNum]=fieldName + " must be like: 1234-567-8901.";
					break;
				}
				
			}
			else{
				if(x==4 || x==8){
					if(TransNum.charAt(x)!="-"){
						errNum++;
						errMsg[errNum]=fieldName + " must be like: 1234-567-8901.";
						break;
					}
				}
			}
		if (errNum)
			firstError = formField;
	}
	return;
}

//determines if the value is a valid Social Security Number
function valSSN(SSN, fieldName, formField){
	if (!errNum){
		//	var SSN=field.value;
		if( SSN.length == 0 ) return;
		if( SSN.length != 9 ){
			errNum++;
			errMsg[errNum]=fieldName + " must be 9 digits long.";
			}
		for( x=0; x<SSN.length; x++ )
			if(Numeric.indexOf(SSN.charAt(x))==-1){
				errNum++;
				errMsg[errNum]=fieldName + " must be numeric only.";
				break;
			}
		if( SSN == "000000000" ){
			errNum++;
			errMsg[errNum]=SSN + " is not a valid SSN.";
			}
		if (errNum)
			firstError = formField;
	}
	return;
}


//determines if the value is a valid CID
// type - pretherapist type
function valCID(CID, fieldName, formField,type){
	if (!errNum){
		if( CID.length == 0 ) return;
		
		// for candidates use valSSN 
		if (type.toUpperCase() == "CANDIDATE")
			valSSN(CID, fieldName, formField);
		// for membership (this is for template) , check 6 digit length
		if( type.toUpperCase() == "MEMBER" && CID.length != 6 ){
			errNum++;
			errMsg[errNum]=fieldName + " must be 6 digits long.";
			}		
		if (errNum)
			firstError = formField;
	}
	return;
}

//determines if the value is a valid date (1 field/date value)
function valDate(Date, fieldName, formField){
	if(!errNum){
		if( Date.length ==0 ) return;
		if( Date.length != 10 ) 
			{
				errNum++;
				errMsg[errNum]=fieldName+" must be like MM/DD/YYYY.";
				firstError = formField;
				return;
			}
		// nnXnnXnnnn where X is a delimiter like / or - or space
		// parse out month, day, year
		i = 0; d = new Array(1); d[i]=0;
		for( x=0; x<Date.length; x++ ){
			ch=Date.charAt(x);
			if( Seperator.indexOf(ch)>=0 ) {i++; d[i]=0;}
			else if( Numeric.indexOf(ch)>=0 ) {d[i]*=10; d[i]+=parseInt(ch);}
			else{
				errNum++;
				errMsg[errNum]=fieldName+" must be like MM/DD/YYYY.";
				firstError = formField;
				return;
			}
		}
		Month=parseInt(d[0]); Day=parseInt(d[1]); Year=parseInt(d[2]);
		// consider leap-year
		maxDay = 31;
		if (Month == 4 || Month == 6 || Month == 9 || Month == 11)
			maxDay = 30;
		else
		if (Month == 2)
		{
			if (Year % 4 > 0)
				maxDay =28;
			else
			if (Year % 100 == 0 && Year % 400 > 0)
				maxDay = 28;
			else
				maxDay = 29;
		}
		// check bounds
		if((Month>=1 && Month<=12) && (Day>=1 && Day<=maxDay) && (Year>1900))
			return;
		errNum++;
		errMsg[errNum]=fieldName+" must be a valid date.";
		errNum++;
		errMsg[errNum]=fieldName+" must be like MM/DD/YYYY.";
	
		if (errNum)
			firstError = formField;
	}
	return;
}

//function to determine if the age is valid
function valAge(mo,yr,age,fieldName,formField){
	if(!errNum){
		if (mo.length==0 || yr.length==0)
			return;
		
		ageDate = new Date();
		aYear = ageDate.getYear();
		aMonth = ageDate.getMonth()+1;
		if (aYear < 1999){
			if(aYear > 99) {
				aYear -= 100; // y2k
				if(aYear < 10){
					aYear = "0" + aYear; // more y2k
					aYear = "20" + aYear;
				}
			}	
			else{
				if(aYear < 10) aYear = "0" + aYear; // more y2k
				if(aYear <= 99) aYear = "19" + aYear;
			}
		}
		
		//year 
		newYr = parseInt(yr);
		if ((newYr+age) > aYear){
			errNum++;
			errMsg[errNum]= fieldName + " must be at least " + age + " years ago.";
		}
		else
			if ((newYr+age) == aYear){
				if (mo > aMonth){
					errNum++;
					errMsg[errNum]= fieldName + " must be at least " + age + " years ago.";
				}
			}
		if(errNum)
			firstError=formField;
	}
	return;
}

//function used to determine if the year is 4 digits, but does not determine if it has a length (valRequired)
function valLongYear(yr,fieldName,formField){
	if(!errNum){
		if (yr.length > 0){
			if (yr.length < 4 || yr.length > 4){
				errNum++;
				errMsg[errNum]= fieldName + " must be a 4 digit year.";
			}
		}
	
		if(errNum)
			firstError = formField;
	}
}

//function used to validate a date field broken up into separate fields
function valMultiFieldDate(fmo,fdy,fyr){
	if (!errNum){
		mo = fmo.value;
		dy = fdy.value;
		yr = fyr.value;
		
		
		//prevent errors with parseInt
		if (mo.charAt(0)=="0"){
			mo=mo.charAt(1);
		}
		if (dy.charAt(0)=="0"){
			dy=dy.charAt(1);
		}
		
		//requires the valNumeric, valRequired, and valNumRange functions
		endDay=0;
		
		//month
		valRequired(mo,'Birth Month',fmo);
		valNumeric(mo,'Birth Month',fmo);
		valNumRange(mo,1,12,'Birth Month',fmo);
		
		//determine the maximum day
		switch (mo) {
			case 4: case 6: case 9: case 11:
				endDay=30;
				break;
			case 2:
				if (yr % 4 > 0)
					endDay =28;
				else
				if (yr % 100 == 0 && yr % 400 > 0)
					endDay = 28;
				else
					endDay = 29;
				break;
			default:
				endDay = 31;
		}
		
		//day
		valRequired(dy,'Birth Day',fdy);
		valNumeric(dy,'Birth Day',fdy);
		valNumRange(dy,1,endDay,'Birth Day',fdy);
		
		//year
		valRequired(yr,'Birth Year',fyr);
		valNumeric(yr,'Birth Year',fyr);
		
	}
}

//function used to validate a date field broken up into separate fields but it is not req
function valMultiFieldDateSpecial(fmo,fdy,fyr){
	if (!errNum){
		mo = fmo.value;
		dy = fdy.value;
		yr = fyr.value;
		
		
		//prevent errors with parseInt
		if (mo.charAt(0)=="0"){
			mo=mo.charAt(1);
		}
		if (dy.charAt(0)=="0"){
			dy=dy.charAt(1);
		}
		
		//requires the valNumeric, valRequired, and valNumRange functions
		endDay=0;
		
		//month
		//valRequired(mo,'Birth Month',fmo);
		valNumeric(mo,'Birth Month',fmo);
		valNumRange(mo,1,12,'Birth Month',fmo);
		
		//determine the maximum day
		switch (mo) {
			case 4: case 6: case 9: case 11:
				endDay=30;
				break;
			case 2:
				if (yr % 4 > 0)
					endDay =28;
				else
				if (yr % 100 == 0 && yr % 400 > 0)
					endDay = 28;
				else
					endDay = 29;
				break;
			default:
				endDay = 31;
		}
		
		//day
		//valRequired(dy,'Birth Day',fdy);
		valNumeric(dy,'Birth Day',fdy);
		valNumRange(dy,1,endDay,'Birth Day',fdy);
		
		//year
		//valRequired(yr,'Birth Year',fyr);
		valNumeric(yr,'Birth Year',fyr);
		
	}
}

//valid license function ??? - not used
function valLicense(License, fieldName){
	// minimum 3 digits long
	// first two digits must be alpha
	// remaining digits must be numeric
//	var License=field.value;
	if( License.length == 0 ) return;
	if( License.length < 4 ){
		errNum++;
		errMsg[errNum]=fieldName + " is too short.";
	}
	License.toUpperCase();
	for( x=0; x<2; x++ )
		if(Alpha.indexOf(License.charAt(x))==-1){
			errNum++;
			errMsg[errNum]=fieldName+" must begin with two letters for state abbreviation.";
			break;
		}
	if(License.charAt(2)=="A") x=3;
	else x=2;
	for(; x<License.length; x++ )
		if(Numeric.indexOf(License.charAt(x))==-1){
			errNum++;
			errMsg[errNum]=fieldName+" must be numeric after the state abbreviation.";
			break;
		}
	return;
}

function valNumeric(num,fieldName,formField)
{	
	
	if(num.length==0)
	{
	 	return;
	}	
	
	for( x=0; x<num.length; x++ )
		if(Numeric.indexOf(num.charAt(x))==-1)
		{
			errNum++;
			errMsg[errNum]=fieldName + " must be numeric only.";
			firstError = formField;
			break;
		}
		return;
}

function valInteger(num,fieldName,formField)
{	
	
	if(num.length==0)
	{
	 	return;
	}	
	
	for( x=0; x<num.length; x++ )
		if(num.charAt(x) != "-" && Numeric.indexOf(num.charAt(x))==-1)
		{
			errNum++;
			errMsg[errNum]=fieldName + " must be inetger only.";
			firstError = formField;
			break;
		}
		return;
}
function valNumRange(num,lo,hi,fieldName,formField){
	if (!errNum){
		num=parseInt(num);
		if((num<lo) || (num>hi)){
			errNum++;
			errMsg[errNum]=fieldName+" must be between "+lo+" and "+hi+".";
		}
		if(errNum)
			firstError=formField;
	}
}

function valRequired(field,fieldName,formField){
	if(!errNum){
		if( field.length==0 ){
			errNum++;
			errMsg[errNum]=fieldName+" is a required field.";
		}
		if (errNum){
			firstError = formField;
		}
	}
	return;
}

function valEmail(field,fieldName,formField){
	if(!errNum){
		if(field.length==0) return;
		// use this mask:  anything@anything.anything
		//   at most one @
		//   at least one . after the @
		//   no spaces
		passedTest=true;
		if(field.indexOf(' ')>=0) passedTest=false;
		AtIdx=field.indexOf('@');
		if(AtIdx==-1)
			passedTest=false;
		else{
			UserName=field.substring(0,AtIdx);
			ServName=field.substring(AtIdx+1,field.length);
			if(
				(UserName.length==0)
				|| (ServName.length==0)
				|| (ServName.indexOf('@')>=0)
				|| (ServName.indexOf('.')==-1)
				)
				passedTest=false;
		}
		if( passedTest ) return;
		errNum++;
		errMsg[errNum]=fieldName+" must be of the form 'username@server.com'"
		
		if(errNum)
			firstError=formField;
	}
	return;
}

function valCreditCard(ccNum,fieldName,formField){
	if(!errNum){
		var creditcard_string="";
		// remove non-numerics
		for( x=0; x<ccNum.length; x++ ){
			var ch=ccNum.charAt(x);
			if( Numeric.indexOf(ch)>=0 ) 
				creditcard_string+=ch;
			else{
				errNum++;
				errMsg[errNum]=fieldName+" must be numeric only.";
				break;
			}
		}
		/* 03.23.2005	#3645	Bharathi bavineni	added new edit check to verify length to be 16 digits
		*/
		if(!errNum && ccNum.length != 16 )
		{
			errNum++;
			errMsg[errNum]=fieldName+" not a valid credit card number.";
		
		}
		if (!errNum){
			// use mod10 test - source modified from cfform
			var doubledigit = creditcard_string.length % 2 == 1 ? false : true;
			var checkdigit = 0;
			var tempdigit;
			for (var i = 0; i < creditcard_string.length; i++)
			{
				tempdigit = eval(creditcard_string.charAt(i))
		
				if (doubledigit)
				{
					tempdigit *= 2;
					checkdigit += (tempdigit % 10);
		
					if ((tempdigit / 10) >= 1.0)
					{
						checkdigit++;
					}
		
					doubledigit = false;
				}
				else
				{
					checkdigit += tempdigit;
					doubledigit = true;
				}
			}	
			if( (checkdigit % 10) != 0 ){
				errNum++;
				errMsg[errNum]=fieldName+" not a valid credit card number.";
			}
		}
		if(errNum)
			firstError=formField;
	}
	return;
}

/* This function tests value entered for money, and allows 0 also */
/* 08.19.2003  #2407  Bharathi bavinnei
new edit function for allowing 0 in money fields*/
function valMoneyOther(num,fieldName,formField){
	count =0;
	if(!errNum){
		//alert(num.length);
		if(num.length==0) return;
		for (x=0; x<num.length; x++)
		{
			if (num.charAt(x) == ".")
			{
				count++;
			}
		}
		
		if (count > 1)
		{
			errNum++;
			errMsg[errNum]=fieldName + " must be like '999.99' or '999'";
		}
		
		for( x=0; x<num.length; x++ )
			if(Numeric.indexOf(num.charAt(x))==-1){
				if (num.charAt(x) != "."){
					errNum++;
					errMsg[errNum]=fieldName + " must be like '999.99' or '999'";
					break;
				}
			}
		if(errNum)
			firstError=formField;
	}
}

function valMoney(num,fieldName,formField){
	count =0;var counter=0;var ValidChars = "123456789";var Char;

	if(!errNum){
		//alert(num.length);
		if(num.length==0) return;
		
		for (x=0; x<num.length; x++)
		{
			if (num.charAt(x) == ".")
			{
				count++;
			}
		}
		
		if (count > 1)
		{
			errNum++;
			errMsg[errNum]=fieldName + " must be like '999.99' or '999'";
		}
		
		


		for( x=0; x<num.length; x++)
			if(Numeric.indexOf(num.charAt(x))==-1){
				if (num.charAt(x) != "."){
					errNum++;
					errMsg[errNum]=fieldName + " must be like '999.99' or '999'";
					break;
				}
			}
	
		for (x=0; x<num.length; x++)
		{
			Char = num.charAt(x); 
      			if (ValidChars.indexOf(Char) != -1) 
         		{
         			counter = 1;
				break
         		}
      		}

		if (counter == 0)
		{
			errNum++;
			errMsg[errNum]=fieldName + " must be like '999.99' or '999'";
		}


		if(errNum)
			firstError=formField;
	}
}

/* This function tests the length of the string submited when the user
clicks the submit buton.  if it is less than 9 char long, it calls the CID check. 
 If it is 13 char long it calls the transnum check */
function valSSNorTrans(compare){
	if(!errNum){
			if(compare.value.length==0){
				return;
			}
			passed=1;
			
			//if (compare.value.length==9){
			  if (compare.value.length <= 9){
				valCID(compare.value,'Customer Identification Number', compare,"");
				return;
			}
			
			if(compare.value.length==13){
				valTransNum(compare.value,'Transaction Number',compare);
				return;
			}
			if(!errNum){
				errNum++;
				errMsg[errNum]= "Transaction Number must be 13 digits";
				firstError=compare;
			}
		}
	return;
}	
	


function valVerifyExpirationDate(field1,field2){
	if(!errNum){
		var CurrentDate= new Date();
		
		Curyear=CurrentDate.getFullYear();
		Curmonth=CurrentDate.getMonth()+1;
		
		//CCmonth=parseInt(field1.value);

		CCYear=parseInt(field2.value);


		if(field1.value.charAt(0) == "0"){
			CCmonth = field1.value.charAt(1)
		}
		else{
			CCmonth = parseInt(field1.value);
		}
		
		if(CCYear == Curyear)
		{
			if (CCmonth < Curmonth)
			{
				errNum++;
				errMsg[errNum]="Credit Card Expiration Date can not be before " + Curmonth + "/" + Curyear;
				firstError=field1;
			}	
		}
		if(CCYear < Curyear)
		{
			errNum++;
			errMsg[errNum]="Credit Card Expiration Date can not be before " + Curmonth + "/" + Curyear;
			firstError=field1;
		
		}
	}
	return;
}


/* this functions validates deceased, and deceaseddate fields*/
function valDeceasedDate(Deceased, DeceasedDate,field1 )
{
	if (!errNum)
	{
		if (Deceased.toUpperCase()=="NO" && DeceasedDate.length > 0 ) 
		{
			errNum++;
			errMsg[errNum]="Cannot enter Date of Death";
			firstError=field1;
		}
		if ( Deceased.length <= 0 && DeceasedDate.length > 0) 
		{
			errNum++;
			errMsg[errNum]= "Deceased is a required field";
			firstError=field1;
		}
		if ( !errNum && DeceasedDate.length > 0) 
		{
			var date1 = new Date(DeceasedDate);
			var date2=new Date();
			
			if (date1 > date2)
			{
				errNum++;
				errMsg[errNum]="Date of Death cannot be in future";
				firstError=field1;
			}
		}
		
		
	}

	return;
}

/* this functions compares deceased date, and dob fields*/
function compareDeceasedDate(DeceasedDate, otherDate,fieldname,field1 )
{
	if (!errNum)
	{
		
		if (DeceasedDate.length > 0 && otherDate.length > 0  ) 
		{
			var date1 = new Date(DeceasedDate);
			var date2=new Date(otherDate);
			
			if (date1 <= date2)
			{
				errNum++;
				errMsg[errNum]="Date of Death cannot be less than "+ fieldname;
				firstError=field1;
			}
		}
		
	}

	return;
}



/* Example Form submit
function formSubmit(form){
	errNum=0; alertString="";
	
	if( !errNum )
		return true;
	for( x=1; x<=errNum; x++ )
		alertString=alertString+"\n"+errMsg[x];
	alert(alertString);
	return false;
}
*/

//-->
