
function ValidateEmail(theinput){
 var s=theinput;
 if(s.search)
  return (s.search(new RegExp("^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}$","gi"))>=0);
 if(s.indexOf)
 {
  at_character=s.indexOf('@');
  if(at_character<=0 || at_character+4>s.length)
   return false;
 }
 if(s.length<6)
  return false;
 else
  return true;
}
 
/************************************************
 bool ValidateName(string input)
 Return true or false
 if the email is valid or not.
**************************************************/
function ValidateName(theinput){
 var s=theinput;
 if(s.search)
  return (s.search(new RegExp("^[^&'^`]+$","gi"))>=0);
 if(s.length<3)
  return false;
 else
  return true;
}
 
/************************************************
 bool ValidatePhone(string input)
 Return true or false
 if the phone number is valid or not.
 acepts - and + symbols
**************************************************/
function ValidatePhone(theinput){
 var s=theinput;
 if(s.search)
  return (s.search(new RegExp("[-+0-9]+","gi"))>=0);
 if(s.length<5)
  return false;
 else
  return true;
}
 

	
	
function CheckFormCatalog(){
	
	var error="";

		
		if(document.contactForm.Contact_Contact_Name.value == "")
		error+="Name\n";
		
			if(document.contactForm.Contact_Postal_Company.value == "")
		error+="Business Name\n";
		
			if(document.contactForm.Contact_Postal_Street_Line1.value == "")
		error+="Address\n";
		
			if(document.contactForm.Contact_Postal_City.value == "")
		error+="City\n";
			if(document.contactForm.Contact_Postal_StateProv.value == "")
		error+="State\n";
			if(!ValidatePhone(document.contactForm.Contact_Postal_PostalCode.value))
		error+="Zip\n";
			if(!ValidatePhone(document.contactForm.Contact_Contact_PhoneNumber.value))
		error+="Phone\n";
			if(!ValidateEmail(document.contactForm.Contact_Contact_EMailAddress.value))
		error+="Email\n";
		
		if((!document.contactForm.indoor.checked)  && (!document.contactForm.outdoor.checked))
		error+="Grow indoor or outdoor\n";
		
		if(document.contactForm.sqfeet.value == "")
		error+="Square Feet\n";
		if(document.contactForm.cropsgrown.value == "")
		error+="Crops Grown\n";
			if(document.contactForm.interestedin.value == "")
		error+="Crops Interested In Growing\n";
		
		if((!document.contactForm.sellto[0].checked) && (!document.contactForm.sellto[1].checked) && (!document.contactForm.sellto[2].checked) && (!document.contactForm.sellto[3].checked))
		error+="Who You Sell To\n";
		
		if(document.contactForm.ownername.value == "")
		error+="Name of Owner\n";
		
		if(document.contactForm.growername.value == "")
		error+="Name of Grower\n";
		
		if((!document.contactForm.communicate[0].checked) && (!document.contactForm.communicate[1].checked) && (!document.contactForm.communicate[2].checked) && (!document.contactForm.communicate[3].checked))
		error+="Best Way to Communicate With You\n";
		
		
	
		
	if(error!="")
		alert("Error! Please check:\n"+error);
	else
		document.contactForm.submit();
	
	return;
}
	
	function CheckFormContact(){
	
	var error="";

		
		if(document.contactForm.Contact_Contact_Name.value == "")
		error+="Name\n";
		
			if(document.contactForm.Contact_Postal_Company.value == "")
		error+="Business Name\n";
		
			if(document.contactForm.Contact_Postal_Street_Line1.value == "")
		error+="Address\n";
		
			if(document.contactForm.Contact_Postal_City.value == "")
		error+="City\n";
			if(document.contactForm.Contact_Postal_StateProv.value == "")
		error+="State\n";
					if(!ValidatePhone(document.contactForm.Contact_Postal_PostalCode.value))
		error+="Zip\n";
			if(!ValidatePhone(document.contactForm.Contact_Contact_PhoneNumber.value))
		error+="Phone\n";
			if(!ValidateEmail(document.contactForm.Contact_Contact_EMailAddress.value))
			if(!ValidateEmail(document.contactForm.Contact_Contact_EMailAddress.value))
		error+="Email\n";
		
		
	if(error!="")
		alert("Error! Please check:\n"+error);
	else
		document.contactForm.submit();
	
	return;
}