// JavaScript Document

	function formValidation(theForm) 
	{
		if (theForm.Email.value == "")
		{
			alert("\"Email\" is a required field.");
			theForm.Email.focus();
			return (false);
		}
		
		if (theForm.Email.value.indexOf("@") == -1 || theForm.Email.value.indexOf(".") == -1)
		{
			alert("The email you entered is not formatted correctly");
			theForm.Email.focus();
			return(false);
		}
		
		if (theForm.EmailVerify.value == "")
		{
			alert("\"Email Verify\" is a required field.");
			theForm.EmailVerify.focus();
			return (false);
		}
		if (theForm.EmailVerify.value.indexOf("@") == -1 || theForm.EmailVerify.value.indexOf(".") == -1)
		{
			alert("The verification email you entered is not formatted correctly");
			theForm.EmailVerify.focus();
			return(false);
		}
		
		if (theForm.Email.value.toUpperCase() != theForm.EmailVerify.value.toUpperCase())
		{
			alert("The verification email you typed does not match!");
			theForm.EmailVerify.focus();
			return (false);
		}
		if (theForm.Password.value == "")
		{
			alert("\"Password\" is a required field.");
			theForm.Password.focus();
			return (false);
		}
		if (theForm.PasswordVerify.value == "")
		{
			alert("\"Password Verify\" is a required field.");
			theForm.PasswordVerify.focus();
			return (false);
		}
		
		
		if (theForm.Password.value.length < 4)
		{
			alert("The \"Password\" field must have more than 3 characters.");
			theForm.Password.focus();
			return(false);
		}
		
		
		if (theForm.Password.value.length > 10)
		{
			alert("The \"Password\" field may not be more than 10 characters.");
			theForm.Password.focus();
			return(false);
		}
		
		
		if (theForm.PasswordVerify.value.length < 4)
		{
			alert("The \"Password Verify\" field must have more than 3 characters.");
			theForm.PasswordVerify.focus();
			return(false);
		}
		
		
		
		if (theForm.PasswordVerify.value.length > 10)
		{
			alert("The \"Password Verify\" field may not be more than 10 characters.");
			theForm.PasswordVerify.focus();
			return(false);
		}
		
		if (theForm.Password.value != theForm.PasswordVerify.value)
		{
			alert("The passwords you entered do not match!");
			theForm.PasswordVerify.focus();
			return(false);
		}
				
	    if (theForm.FirstName.value == "")
		{
			alert("\"First Name\" is a required field.");
			theForm.FirstName.focus();
			return (false);
		}
		
		if (theForm.FirstName.value.length == 1)
		{
			alert("The \"First Name\" field must have more than 1 character.");
			theForm.FirstName.focus();
			return(false);
		}
		
		var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
		
		for (var i = 0; i < theForm.FirstName.value.length; i++) 
      		if (iChars.indexOf(theForm.FirstName.value.charAt(i)) != -1) 
               	{
               		alert ("Your First Name entry contains special characters. \nPlease remove any of the following characters from your First Name. \n @ ! # $ % ^ & * ( ) + = - [ ] \ \\ ' ; , .  /  { } |  \" : < > ?.\n");
                	theForm.FirstName.focus();
					return (false);
        	}
		if (theForm.LastName.value == "")
		{
			alert("\"Last Name\" is a required field.");
			theForm.LastName.focus();
			return (false);
		}
		
		
		
		if (theForm.LastName.value.length == 1)
		{
			alert("The \"Last Name\" field must have more than 1 character.");
			theForm.LastName.focus();
			return(false);
		}
		
		for (var i = 0; i < theForm.LastName.value.length; i++) 
      		if (iChars.indexOf(theForm.LastName.value.charAt(i)) != -1) 
               	{
               		alert ("Your Last Name entry contains special characters. \nPlease remove any of the following characters from your Last Name. \n @ ! # $ % ^ & * ( ) + = - [ ] \ \\ ' ; , .  /  { } |  \" : < > ?.\n");
                	theForm.LastName.focus();
					return (false);
        	}
		
		if (theForm.Address1.value == "")
	{	
		alert("The \"Billing Address\" field is required.");
		theForm.Address1.focus();
		return false;
	}
	
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
		
		for (var i = 0; i < theForm.Address1.value.length; i++) 
      		if (iChars.indexOf(theForm.Address1.value.charAt(i)) != -1) 
               	{
               		alert ("Your Address1 entry contains special characters. \nPlease remove any of the following characters from your Address1. \n @ ! # $ % ^ & * ( ) + = - [ ] \ \\ ' ; , .  /  { } |  \" : < > ?.\n");
                	theForm.Address1.focus();
					return (false);
        	}
			
		for (var i = 0; i < theForm.Address2.value.length; i++) 
      		if (iChars.indexOf(theForm.Address2.value.charAt(i)) != -1) 
               	{
               		alert ("Your Address2 entry contains special characters. \nPlease remove any of the following characters from your Address2. \n @ ! # $ % ^ & * ( ) + = - [ ] \ \\ ' ; , .  /  { } |  \" : < > ?.\n");
                	theForm.Address2.focus();
					return (false);
        	}
		
	if (theForm.City.value == "")
	{	
		alert("The \"City\" field is required.");
		theForm.City.focus();
		return false;
	}
	
	for (var i = 0; i < theForm.City.value.length; i++) 
      		if (iChars.indexOf(theForm.City.value.charAt(i)) != -1) 
               	{
               		alert ("Your City entry contains special characters. \nPlease remove any of the following characters from your City. \n @ ! # $ % ^ & * ( ) + = - [ ] \ \\ ' ; , .  /  { } |  \" : < > ?.\n");
                	theForm.City.focus();
					return (false);
        	}
			
	if (!isAlphabetic(theForm.City.value,true))
	{
		alert("The \"City\" field must be alphabetic.");
		theForm.City.focus();
		return false;
	}
	
	if (theForm.state.selectedIndex == 0 && theForm.Province.value == "")
	{
		alert("You must choose a state or enter a province!");
		theForm.state.focus();
		return false;
	}
	
	if (theForm.state.selectedIndex > 0)
	{
	
		if (theForm.Province.value != "")
		{
			alert("You must choose either state or province!");
			theForm.Province.focus();
			return false;
		}
	
	}
	
	if (theForm.Zip.value == "")
	{
		alert("The \"Postal Code\" field is required!");
		theForm.Zip.focus();
		return false;
	}
	if (theForm.WorkPhone.value == "")
		{
			alert("\"Daytime Phone\" is a required field.");
			theForm.WorkPhone.focus();
			return (false);
		}
		
		if (theForm.WorkPhone.value.length < 10)
		{
			alert("The \"Daytime Phone Number\" field must have at least 10 digits.");
			theForm.WorkPhone.focus();
			return(false);
		}
						
		if (!isNumeric(theForm.WorkPhone.value))
		{
	        alert("The \"Daytime Phone Number\" field must be only numbers.\n\nCorrect: 3335551212\n\nIncorrect : 333-555-1212 or (333) 555-1212");
			theForm.WorkPhone.focus();
			return false;
		}
        
        if (theForm.Phone.value == "")
		{
			alert("\"Evening Phone\" is a required field.");
			theForm.Phone.focus();
			return (false);
		}
		
		if (theForm.Phone.value.length < 10)
		{
			alert("The \"Evening Phone Number\" field must have at least 10 digits.");
			theForm.Phone.focus();
			return(false);
		}
						
		if (!isNumeric(theForm.Phone.value))
		{
	        alert("The \"Evening Phone Number\" field must be only numbers.\n\nCorrect: 3335551212\n\nIncorrect : 333-555-1212 or (333) 555-1212");
			theForm.Phone.focus();
			return false;
		}
	
	/**
	if (theForm.Destination1.selectedIndex < 0)
		{
			alert("\"Select Country 1\" is a required field.");
			theForm.Destination1.focus();
			return (false);
		}
		if (theForm.Destination2.selectedIndex < 0)
		{
			alert("\"Select Country 2\" is a required field.");
			theForm.Destination2.focus();
			return (false);
		}
		if (theForm.Destination3.selectedIndex < 0)
		{
			alert("\"Select Country 3\" is a required field.");
			theForm.Destination3.focus();
			return (false);
		} **/
		
		if (theForm.Terms.checked == false) 
		{
		alert ('Please check the checkbox to agree with the terms and conditions.');
		return false;
		}
		 
	return (true);
}
	
	
	
	
	
	// Check that a string contains only numbers
function isNumeric(string, ignoreWhiteSpace) {
	if (string.search) {
		if ((ignoreWhiteSpace && string.search(/[^\d\s]/) != -1) || (!ignoreWhiteSpace && string.search(/\D/) != -1)) return false;
	}
	return true;
}
// Check that a string contains only letters
function isAlphabetic(string, ignoreWhiteSpace) {
	if (string.search) {
		if ((ignoreWhiteSpace && string.search(/[^a-zA-Z\s]/) != -1) || (!ignoreWhiteSpace && string.search(/[^a-zA-Z]/) != -1)) return false;
	}
	return true;
}		
		
		
		
		
		
			
		
		

        
		
		
		
		
		
		
		
		
// Check that a string contains only numbers
function isNumeric(string, ignoreWhiteSpace) {
	if (string.search) {
		if ((ignoreWhiteSpace && string.search(/[^\d\s]/) != -1) || (!ignoreWhiteSpace && string.search(/\D/) != -1)) return false;
	}
	return true;
}

