<!--

// returns input parameter stripped of all characters but base 10 digits
function filterForNumeric( inputString ) {var output = new String;	
	for (counter = 0; counter < inputString.length; counter++){ if ( isDigit(inputString.charAt(counter)) ){output += inputString.charAt(counter);}
	}		
	return output;
}

// returns true if the input contains only base 10 digits
function verifyNumeric( inputString ) {if (inputString == "") return false;
	for (counter = 0; counter < inputString.length; counter++){if ( !isDigit(inputString.charAt(counter)) ) return false;
	}		
	return true;
}

//returns true if character is a base 10 digit
function isDigit( inputChar ) {if (inputChar.length == 1 && inputChar.charCodeAt(0) >= 48 && inputChar.charCodeAt(0) <= 57) return true;
	else return false;
}

// returns true if character is a letter
function isLetter ( inputChar ) {if ( inputChar.length == 1 && ((inputChar.charCodeAt(0) >= 65 && inputChar.charCodeAt(0) <= 90) || (inputChar.charCodeAt(0) >= 97 && inputChar.charCodeAt(0) <= 122)) ) return true;
	else return false;
}

// returns true if input is a valid 5 or 9 digit US Zip code
function isUSZip(inputString) {
	if (inputString.length != 5 && inputString.length != 9 && inputString.length != 10) return false;
	if ( !verifyNumeric(inputString.substring(0, 4)) ) return false;
	if ( (inputString.length == 9 || inputString.length == 10) &&
	!verifyNumeric(inputString.substring(inputString.length-4, inputString.length-1)) ) return false;
	if (inputString.length == 10 && inputString.charCodeAt(5) != 45) return false;
	return true;
}

function isEmail(Email) {if (Email.length < 5) return false;
	else if (Email.indexOf("@") < 1) return false;
	else if ((Email.indexOf(".", Email.indexOf("@")) - Email.indexOf("@")) < 2) return false;
	return true;
}

function isPhone(Phone) {
    if (Phone.length != 12) return false; {
	var strPhone = orderform.Phone.value; for ( i=0; i <= strPhone.length; i++ )
	  {
        if ( i != 3 && i != 7) {
			if ( isNaN(strPhone.charAt(i)) ){return false;}
		}
		else {if ( strPhone.charAt(i) != "-" ){return false;}
        }
      }
    }
	return true;
}

function CheckForm(orderform) {
	
if (orderform.sjname.value == "") {alert("Sorry, but it doesn't look like you filled out the Full Name field.\nPlease fill out the Full Name field."); orderform.sjname.select(); return false; }
		
if (orderform.Streetaddress.value == "") {alert("Sorry, but it doesn't look like you filled out the Street Address field.\nPlease fill out the Address field."); orderform.Streetaddress.select(); return false; }
		
if (orderform.City.value == ""){alert("Sorry, but it doesn't look like you filled out the City field.\nPlease fill out the City field."); orderform.City.select(); return false; }
	
if (orderform.State.value == ""){alert("Sorry, but it doesn't look like you filled out the State field.\nPlease fill out the State field."); orderform.State.focus(); return false; }
			
if (orderform.Email.value == ""){alert("Sorry, but it doesn't look like you filled out the Email field.\nPlease fill out the Email field."); orderform.Email.select(); return false; }
	
if (!isUSZip(orderform.Zipcode.value)){alert("Sorry, but it doesn't look like you filled out the Zip Code field correctly.\nPlease check the Zipcode and make sure the number of characters is 5 or 9."); orderform.Zipcode.select(); return false; }

if ((filterForNumeric(orderform.Zipcode.value).length != 5 && filterForNumeric(orderform.Zipcode.value).length != 9)){alert("Sorry, but it doesn't look like you filled out the Zip Code field correctly.\nPlease check the Zipcode and make sure there are no non-numeric characters."); orderform.Zipcode.select(); return false; }
		
if (!isEmail(orderform.Email.value)){alert("Sorry, but the Email address you entered does not appear to be valid.\nPlease revise the Email Address."); orderform.Email.select(); return false; }
	
if (orderform.Phone.value == ""){alert("Sorry, but it doesn't look like you filled out the Phone Number field.\nPlease fill out the Phone Number field."); orderform.Phone.select(); return false; }
	
if (!isPhone(orderform.Phone.value)){alert("Sorry, but the Phone Number you entered does not appear to be valid.\nEither one or more characters are not numbers or dashes, you did not use\ndashes to separate the numbers (for example, 123-456-7890), or the\nPhone Number is not the correct length (10 numbers and two dashes)\nPlease revise the Phone Number."); orderform.Phone.select(); return false; }

return true;
}
// end -->