function validate_email(theControl)
{
	
	if ( theControl.value == "" | theControl.value.length <= 0 )
	{

   alert("I'm sorry. This email address must be filled in correct to send the form to our server. Please"
   +" check the prefix and '@' sign.");
   theControl.focus()
		return false;
	}
	
	var reEmail = /^.+\@.+\..+$/
	var holderValue;
	var thisValue = theControl.value;
	
	// Check for e-mail addresses from ISPs and other sources that have been consistently
	// entered incorrectly.  If detected, correct the situation.
	if
		(
			(thisValue.substring(thisValue.length - 4, thisValue.length).toLowerCase()) == '@aol' ||
			(thisValue.substring(thisValue.length - 4, thisValue.length).toLowerCase()) == '@msn' ||
			(thisValue.substring(thisValue.length - 6, thisValue.length).toLowerCase()) == '@yahoo' ||
			(thisValue.substring(thisValue.length - 6, thisValue.length).toLowerCase()) == '@lycos' ||
			(thisValue.substring(thisValue.length - 7, thisValue.length).toLowerCase()) == '@excite' ||
			(thisValue.substring(thisValue.length - 10, thisValue.length).toLowerCase()) == '@altavista' ||
			(thisValue.substring(thisValue.length - 11, thisValue.length).toLowerCase()) == '@compuserve' ||
			(thisValue.substring(thisValue.length - 8, thisValue.length).toLowerCase()) == '@prodigy' ||
			(thisValue.substring(thisValue.length - 8, thisValue.length).toLowerCase()) == '@hotmail' ||
			(thisValue.substring(thisValue.length - 9, thisValue.length).toLowerCase()) == '@netscape'
		)
		{
			holderValue = thisValue.concat('.com');
			thisValue = holderValue;
			theControl.value = thisValue;
		}
	if
		(
			(thisValue.substring(thisValue.length - 5, thisValue.length).toLowerCase()) == '@home'
		)
		{
			holderValue = thisValue.concat('.net');
			thisValue = holderValue;
			theControl.value = thisValue;
		}
		
	// Now check the actual value of the e-mail address for validity.
	var flagFirstCheck = (theControl.value.length < 6) ||
		(thisValue.indexOf('@') == -1) || 
		(thisValue.indexOf('.') == -1) || 
		(thisValue.indexOf('@',(thisValue.indexOf('@')+1)) != -1) ||
		((thisValue.indexOf('.')+1) == thisValue.length) || 
		((thisValue.indexOf('@')+1) == thisValue.length)
	var flagSecondCheck = reEmail.test(thisValue)
	if ( flagFirstCheck || !flagSecondCheck)
	{

   alert("I'm sorry. This email address seems to be incorrect. Please check the prefix and '@' sign.");
   theControl.focus()

		return false;
	} 
	else {

		return true;
	}
}


function stripNonNumbers (InString)  {
	OutString="";
	for (Count=0; Count < InString.length; Count++)  {
		TempChar=InString.substring (Count, Count+1);
		Strip = false;
		CharString="0123456789";
		for (Countx = 0; Countx < CharString.length; Countx++) {
			StripThis = CharString.substring(Countx, Countx+1)
			if (TempChar == StripThis) {
				Strip = true;
				break;
			}
		}
		if (Strip)
			OutString=OutString+TempChar;
	}
	return (OutString);
}

// Check that a phone number has the correct number of digits
function validate_phone(theField, prompt) {
	inStr = stripNonNumbers(theField.value);
	inLen = inStr.length;

	//If this is a ten digit number XXXYYYZZZZ
	if(inLen == 10) {

		for(var i=0; i<inLen; i++) {
			var ch = inStr.substring(i,i+1)
			if (ch < "0" | "9" < ch)
				return false;
		}

		var fixedNumber = "(" + inStr.substring(0,3)
						+ ") "
						+ inStr.substring(3,6)
						+ "-"
						+ inStr.substring(6,10) ;

		theField.value = fixedNumber;

		// alert("Reformatted the Phone field to '" + fixedNumber + "'.");

		return true;
	}

	// Is this is a twelve digit number WWXXXYYYZZZZ
	if (inLen == 12) {

		// check country code
		for (var i = 0; i < 2; i++) {
			var ch = inStr.substring(i,i+1)
			if (ch < "0" || "9" < ch)
				return false;
		}

		// check area code
		for (var i = 2; i < 5; i++) {
			var ch = inStr.substring(i,i+1)
			if (ch < "0" || "9" < ch)
			return false;
		}

		// check prefix
		for (var i = 5; i < 8; i++) {
			var ch = inStr.substring(i,i+1)
			if (ch < "0" || "9" < ch)
				return false;
		}

		// check body
		for (var i = 8; i < 12; i++) {
			var ch = inStr.substring(i,i+1)
			if (ch < "0" || "9" < ch)
				return false;
		}

		var fixedNumber = "(" + inStr.substring(0,2)
						+ ") "
						+ inStr.substring(2,5)
						+ "-"
						+ inStr.substring(5,8)
						+ "-"
						+ inStr.substring(8,12) ;

		theField.value = fixedNumber;

		// alert("Reformatted the Phone field to '" + fixedNumber + "'.");

		return true;
	}

	alert("The " + prompt + " field is a required field, and it must be formatted (nnnxxxyyyy) properly.");
	theField.focus();

	return false;
}

function validate_number(control, prompt, isDecimal) {

        inStr = stripNonNumbers(control.value, isDecimal);
        inLen = inStr.length;

        if ( inStr == "" || inLen <= 0 )
        {

        alert("The " + prompt + " field is a required field, and it must be filled in properly before your form can be sent to our server.")
        control.focus()
        return false;

        }

  return true;
}

function FValidateControl(control, prompt) {
	if (control.value=="") {
		alert("The " + prompt + " field is a required field, and it must be filled in before your form can be sent to our server.")
		control.focus()
		return false
	}
	return true
}