<!--
function onError(error_message)
    {
	alert(error_message);
       	return false;	
    }

function checkInteger(object_value)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is an integer defined as
    //   having an optional leading + or -.
    //   otherwise containing only the characters 0-9.
	var decimal_format = ".";
	var check_char;

    //The first character can be + -  blank or a digit.
	check_char = object_value.indexOf(decimal_format)
    //Was it a decimal?
    if (check_char < 1)
	return checkNumber(object_value);
    else
	return false;
    }

function checkNumber(object_value)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is a number defined as
    //   having an optional leading + or -.
    //   having at most 1 decimal point.
    //   otherwise containing only the characters 0-9.
	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;

    //The first character can be + - .  blank or a digit.
	check_char = start_format.indexOf(object_value.charAt(0))
    //Was it a decimal?
	if (check_char == 1)
	    decimal = true;
	else if (check_char < 1)
		return false;
        
	//Remaining characters can be only . or a digit, but only one decimal.
	for (var i = 1; i < object_value.length; i++)
	{
		check_char = number_format.indexOf(object_value.charAt(i))
		if (check_char < 0)
			return false;
		else if (check_char == 1)
		{
			if (decimal)		// Second decimal.
				return false;
			else
				decimal = true;
		}
		else if (check_char == 0)
		{
			if (decimal || digits)	
				trailing_blank = true;
        // ignore leading blanks

		}
	        else if (trailing_blank)
			return false;
		else
			digits = true;
	}	
    //All tests passed, so...
    return true
    }

function checkRequired(obj, obj_type)
    {
    if (obj_type == "TEXT" || obj_type == "PASSWORD")
	{
    	if (obj.value.length == 0) 
      		return false;
    	else 
      		return true;
    	}
    else if (obj_type == "SELECT")
	{
        for (i=0; i < obj.length; i++)
	    	{
		if (obj.options[i].selected)
			return true;
		}

       	return false;	
	}
    else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX")
	{
		if (obj.checked)
			return true;
		else
       		return false;	
	}
    else if (obj_type == "RADIO" || obj_type == "CHECKBOX")
	{
        for (i=0; i < obj.length; i++)
	    	{
		if (obj[i].checked)
			return true;
		}
       	return false;	
	}
	}

function checkDate(object_value)
    {
    //Returns true if value is a date format or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is a date in the mm/dd/yyyy format
	isplit = object_value.indexOf('/');

	if (isplit == -1 || isplit == object_value.length)
		return false;

    sMonth = object_value.substring(0, isplit);
	isplit = object_value.indexOf('/', isplit + 1);

	if (isplit == -1 || (isplit + 1 ) == object_value.length)
		return false;

    sDay = object_value.substring((sMonth.length + 1), isplit);

	sYear = object_value.substring(isplit + 1);

	if (!checkInteger(sMonth)) //check month
		return false;
	else
	if (!numberRange(sMonth, 1, 12)) //check month
		return false;
	else
	if (!checkInteger(sYear)) //check year
		return false;
	else
	if (!numberRange(sYear, 0, 9999)) //check year
		return false;
	else
	if (!checkInteger(sDay)) //check day
		return false;
	else
	if (!checkDay(sYear, sMonth, sDay)) // check day
		return false;
	else
		return true;
    }

function checkZip(obj_value)
	{
	if (obj_value.length == 0)
		return true;
	// Valid zipcodes are either 5 digits or 5+4.  If 5+4,
	// allow for hyphen or not.	
    if (obj_value.length != 5 && obj_value.length != 9 &&
		obj_value.length !=10)
		return false;
		
	if (obj_value.length == 5 || obj_value.length == 9)
		{
	    if (!checkInteger(obj_value))
			return false;
		else
			return true;
		}	

	if (obj_value.length == 10)
		{
		if (obj_value.charAt(5) != "-" && obj_value.charAt(5) != " ")
	       	return false;
			
	    if (!checkInteger(obj_value.substring(0,4)))
			return false;
		
	    if (!checkInteger(obj_value.substring(6,9)))
			return false;
		}
	return true;		
	}
	
function checkDay(checkYear, checkMonth, checkDay)
    {

	maxDay = 31;

	if (checkMonth == 4 || checkMonth == 6 ||
			checkMonth == 9 || checkMonth == 11)
		maxDay = 30;
	else
	if (checkMonth == 2)
	{
		if (checkYear % 4 > 0)
			maxDay =28;
		else
		if (checkYear % 100 == 0 && checkYear % 400 > 0)
			maxDay = 28;
		else
			maxDay = 29;
	}

	return numberRange(checkDay, 1, maxDay); //check day
    }

function numberRange(object_value, min_value, max_value)
    {
    // check minimum
    if (min_value != null)
	{
        if (object_value < min_value)
		{
		return false;
		}
	}

    // check maximum
    if (max_value != null)
	{
	if (object_value > max_value)
		return false;
	}
	
    //All tests passed, so...
    return true;
    }

function checkRange(obj, min_value, max_value)
    {
    //if value is in range then return true else return false
    if (obj.value.length == 0)
        return true;

    if (!checkNumber(obj.value))
	{
	return false;
	}
    else
	{
		if (!numberRange((eval(obj.value)), min_value, max_value))
		{
			onError("This field requires a value between " + min_value + " and " + max_value + ".");
			obj.focus();
			return false;
		}
	}
	
    //All tests passed, so...
    return true;
    }

function checkPhone(object_value)
    {
	var startChar = 0;
	var endChar = 0;  
	var useParens = false;
	var useAreaCode = true;
	
    if (object_value.length == 0)
        return true;
	
    if (object_value.length > 14)
        return false;

	if (object_value.length == 8)
		useAreaCode = false;
		
	if (object_value.charAt(0) == "(")
		useParens = true;

	if (useAreaCode)
		{
			// check if first 3 characters represent a valid area code
			if (useParens)
			{
				startChar = 1;
				endChar = 4;
			} else {
				startChar = 0;
				endChar = 3;
			}
		} else {
			startChar = 0;
			endChar = 3;
		}		

    if (!checkNumber(object_value.substring(startChar,endChar)))
		return false;
	else
	if (!numberRange((eval(object_value.substring(startChar,endChar))), 100, 1000))
		return false;

	// check if area code/exchange separator is either a'-' or ' '
	if (useParens)
		{
			startChar = 5;
			endChar = 9;
		} else {
			startChar = 3;
			endChar = 7;
		}
	
	if (object_value.charAt(startChar) != "-" && object_value.charAt(startChar) != " ")
   	   	return false;

	if (useAreaCode)
		{	
			startChar += 1;

			// check if  characters 5 - 7 represent a valid exchange
 		  	if (!checkNumber(object_value.substring(startChar,endChar)))
				return false;
			else
			if (!numberRange((eval(object_value.substring(startChar,endChar))), 100, 1000))
				return false;
	
			// check if exchange/number separator is either a'-' or ' '
			if (object_value.charAt(endChar) != "-" && object_value.charAt(endChar) != " ")
    		    return false;

			startChar += 4;
			endChar += 5;
		
		} else {
			startChar = 4;
			endChar = 9;
		}
		
	// make sure last four digits are a valid integer
	if (object_value.charAt(startChar) == "-" || object_value.charAt(startChar) == "+")
   		return false;
	else
		{
		return (checkInteger(object_value.substring(startChar,endChar)));
		}
    }
		
function checkIntField(obj)
    {
    if  (!checkInteger(obj.value))
        {
        	onError("Enter a valid numeric value in this field without a dollar sign or commas.");
			obj.focus();
			return false;
        }
    return true;
    }

function checkRealField(obj)
    {
    if  (!checkNumber(obj.value))
		{
        	onError("Enter a valid numeric value in this field without a dollar sign or commas.");
			obj.focus();
			return false;
		}
    return true;
    }
	
function checkDateField(obj)
    {
    if  (!checkDate(obj.value))
        {
        	onError("Enter a valid date value in this field in MM/DD/YYYY format.");
			obj.focus();
			return false;
        }
    return true;
    }

function checkPhoneField(obj)
    {
    if  (!checkPhone(obj.value))
        {
        	onError("Enter a valid phone no. value in this field.  For example, 555-1212, 615-555-1212 or (615)-555-1212.");
			obj.focus();
			return false;
        }
    return true;
    }

function checkZipField(obj)
    {
    if  (!checkZip(obj.value))
        {
        	onError("Enter a valid 5 or 9 digit zipcode value in this field.  For example, 12345 or 12345-6789.");
			obj.focus();
			return false;
        }
    return true;
    }
	
function checkRequiredField(obj, obj_type)
    {
    if  (!checkRequired(obj, obj_type))
        {
			onError("An entry is required in this field.");
			obj.focus();
			return false;
        }
    return true;
    }

function checkEmailField(obj)
	{
		var EmailOk  = true;
		var AtSym    = obj.value.indexOf('@');
		var Period   = obj.value.lastIndexOf('.');
		var Space    = obj.value.indexOf(' ');
		var Length   = obj.value.length - 1;   // Array is from 0 to length-1
	
		if (obj.value.length == 0)
			return true;
		
		if ((AtSym < 1) ||                     // '@' cannot be in first position
  		  (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
  		  (Period == Length ) ||             // Must be atleast one valid char after '.'
  		  (Space  != -1))                    // No empty spaces permitted
  		 {  
    		  EmailOk = false;
    		  alert("Enter a valid e-mail address with an @ symbol in this field.  For example, johndoe@msn.com.");
      		  obj.focus();
  		 }	return EmailOk
	}

//#######################################################################
function checkExpiryDate(CCMonth, CCYear){
//#######################################################################
		var now = new Date();
	
		/* getMonth returns month as 0-11 - this adds 1 */
		var m = now.getMonth() + 1;						
	
		/* months 1-9 stored as a single digit - this adds the leading zero */
		var thisMonth = (m < 10) ? '0' + m : m;			
	
		var yy = now.getYear();					
	
		// year is sometimes stored as 2 digits 
		//  this adds the 20 if year length is 2 digits 
		var thisYear = (yy.length == 2) ? yy + 2000 : yy;
	
		if (CCYear < thisYear)
			{
			alert("Your credit card has expired and cannot be used.  Please check your date entries or use another card.")
			return false;
			}
	
		if (CCYear == thisYear && CCMonth < thisMonth)
			{
			alert("Your credit card has expired and cannot be used.  Please check your date entries or use another card.")
			return false;
			}

		return true;
	}

// #####################################
function checkCC(CC_NUMBER, formCC_TYPE)
// #####################################
		{
		var DebugOn = false;
	// CCN_digits is where we store just the digits from the Card Number
		var CCN_digits = "";
	// ------------------------------------------------------------------------------------------------------
	// remove everything but the digits from the entered Card Number
	// ------------------------------------------------------------------------------------------------------
		for (var i = 0; i < CC_NUMBER.length; i++)
			{
			if (jsVersion > 1.1)
				{
				if ((!isNaN(CC_NUMBER.charAt(i))) && (CC_NUMBER.charAt(i) != " "))
					CCN_digits = CCN_digits + CC_NUMBER.charAt(i);
				}
			else
				{
				if ((CC_NUMBER.charAt(i) == "0") || (CC_NUMBER.charAt(i) == "1") || (CC_NUMBER.charAt(i) == "2") || (CC_NUMBER.charAt(i) == "3") || (CC_NUMBER.charAt(i) == "4") || (CC_NUMBER.charAt(i) == "5") || (CC_NUMBER.charAt(i) == "6") || (CC_NUMBER.charAt(i) == "7") || (CC_NUMBER.charAt(i) == "8") || (CC_NUMBER.charAt(i) == "9"))
					CCN_digits = CCN_digits + CC_NUMBER.charAt(i);
				}
			}
	// *** debug -----------------------------------------------------------------------
	// alert ("CCN_digits.length = " + CCN_digits.length + " CCN_digits = " + CCN_digits);
	// *** debug -----------------------------------------------------------------------
	
	// ------------------------------------------------------------------------------------------------------
	// validcard is the true/false indicator for a valid card - it is returned to the caller
	// ------------------------------------------------------------------------------------------------------
		var validcard = false;
	
	// ------------------------------------------------------------------------------------------------------
	// msgind is used to communicate the type of alert to post in case of a problem
	//	1=invalid prefix (prefix does not match card type)
	//	2=invalid number of digits in card number for the card type selected
	// ------------------------------------------------------------------------------------------------------
		var msgind = 0;
	
	// ------------------------------------------------------------------------------------------------------
	// Check the card for having a valid prefix and number of digits (length) for the card type.
	// Note - the if, else if construct was used here because switch/case is not supported by JavaScript 1.0
	// ------------------------------------------------------------------------------------------------------
	//							AMEX		DISCOVER		MASTERCARD		VISA
	// ------------------------------------------------------------------------------------------------------
	//		VALID LENGTHS		 15				  16			16			13/16
	// ------------------------------------------------------------------------------------------------------
	//		VALID PREFIXES	 34				6011			51			  4
	//							 37								52
	//							 								53
	//							 								54
	//							 								55
	// ------------------------------------------------------------------------------------------------------
		if (formCC_TYPE == "American Express")
			if (CCN_digits.length == 15)
				if ((CCN_digits.substring (0, 2) == "34") || (CCN_digits.substring (0, 2) == "37"))
					validcard = true;
				else
					msgind = 1;
			else	
				msgind = 2;
		else if (formCC_TYPE == "Discover")
			if (CCN_digits.length == 16)
				if (CCN_digits.substring (0, 4) == "6011")
					validcard = true;
				else
					msgind = 1;
			else	
				msgind = 2;
		else if (formCC_TYPE == "Master Card")
			if (CCN_digits.length == 16)
				if ((CCN_digits.substring (0, 2) >= "51") && (CCN_digits.substring (0, 2) <= "55"))
					validcard = true;
				else
					msgind = 1;
			else	
				msgind = 2;
		else if (formCC_TYPE == "Visa")
			if ((CCN_digits.length == 16)  || (CCN_digits.length ==13))
				if (CCN_digits.substring (0, 1) == "4")
					validcard = true;
				else
					msgind = 1;
			else	
				msgind = 2;
		else
	// ------------------------------------------------------------------------------------------------------
	// this should be impossible to reach as long as all valid card types are in the list above....
	// ------------------------------------------------------------------------------------------------------
			alert ("Sorry, "+ formCC_TYPE + " is not currently being accepted - please contact us by phone or email.");
		if (!validcard)
			{
			if (msgind == 1)
	// ------------------------------------------------------------------------------------------------------
	//			Invalid prefix
	// ------------------------------------------------------------------------------------------------------
				alert ("The Credit Card Number you entered is not a valid " + formCC_TYPE + " number.  Please reenter it without any spaces between numbers.");
	
			else if (msgind == 2)
	// ------------------------------------------------------------------------------------------------------
	//			Invalid number of digits (length)
	// ------------------------------------------------------------------------------------------------------
				alert ("The Credit Card Number you entered is not a valid " + formCC_TYPE + " number.  Please reenter it without any spaces between numbers.");
			}
	
		if (!validcard)
			return (validcard);

		var CheckSum = 0;
	// for loop
		for (var x = 1; x <= CCN_digits.length; x++)
			{
	// BUG-FIX 1999.12.21
	//		var CurrentDigit = CCN_digits.charAt(CC_NUMBER.length - x); CHANGED TO:
			var CurrentDigit = CCN_digits.charAt(CCN_digits.length - x);
	// BUG-FIX THANKS TO Curt Cloninger
	// x is subtracted from the length of the CCN to point at the digits from RIGHT to LEFT
			if (x % 2 == 0)
				{
	// even position in credit card number (2nd, 4th, etc. from RIGHT of Credit Card Number)
				var WorkDigit = CurrentDigit * 2;	
				if (WorkDigit > 9)
					{ 
					CheckSum = CheckSum + (1 - 0);
					CheckSum = CheckSum + (WorkDigit % 10 - 0);
					if (DebugOn)
						{
						alert ("CurrentDigit = " + CurrentDigit + " even position - WorkDigit=" + WorkDigit + " > 9 - Checksum = Checksum + WorkDigit mod10 + 1 = " + CheckSum);
						}
					}
				else
					{
					CheckSum = CheckSum + (WorkDigit - 0);
					if (DebugOn)
						{
						alert ("CurrentDigit = " + CurrentDigit + " even position - WorkDigit = " + WorkDigit + " NOT > 9 - Checksum = Checksum + WorkDigit = " + CheckSum);
						}
					}	
				}
			else
				{
	// odd position in credit card number (1st, 3rd, etc. from RIGHT of Credit Card Number)
				CheckSum = CheckSum + (CurrentDigit - 0);
				if (DebugOn)
					{
					alert ("CurrentDigit = " + CurrentDigit + " odd position " + "Checksum = Checksum + CurrentDigit = " + CheckSum);
					}
				}
			}
	// end for loop
	
		if (CheckSum % 10) 
			{ 
			validcard = false; 
			alert ("The Credit Card Number you entered is not a valid " + formCC_TYPE + " number.  Please reenter it without any spaces between numbers.");
			} 
		
		return (validcard); 
	}
	
// -->