// JavaScript Document

// validate the contact us form before submitting it
function ValidateForm(frm) {
	// contactform
	// name and id must be the same for each input
	//validate for empty fileds and reurn to the empty field without submitting the form
	// only validate REQUIRED FIELDS
//	<input name="realname" 
//	input name="telephone"
//	<input name="address1" 
//	<input name="address2"
//	<input name="towncity"
//	<input name="countystate"
//	<input name="postzipcode" 
//	<input name="country" 
//	<input name="email" 
//	<textarea name="comments"   10 inputs
	//check for links being added
// check email address first !
 if (!frm.email.value)	{
	 
		alert ("Please enter a value for the EMAIL field");
	 	frm.email.focus();
	  	frm.email.select();
		return false;
	
	 } else {
		 	 if (!check_link(frm.email.value)){ 
				 frm.email.focus();
				frm.email.select();
			 return false;}

					if (frm.email.value.indexOf("@") > 0) // check for @ character 
					{				
					} else {
							alert ("Please enter a VALID Email address in the EMAIL field");
									frm.email.focus();
									frm.email.select();
						return false;
					}
	
	}

if (!frm.realname.value)	{
		alert ("Please enter a value for the NAME field");
	 	frm.realname.focus();
	  	frm.realname.select();
		return false;
	 }			
			if (!check_link(frm.realname.value)){ 
				 frm.realname.focus();
				frm.realname.select();
			 return false;}
 
	 if (!frm.telephone.value)	{
		alert ("Please enter a value for the TELEPHONE field");
	 	frm.telephone.focus();
	  	frm.telephone.select();
		return false;
	 }
	 			if (!check_link(frm.telephone.value)){ 
				 frm.telephone.focus();
				frm.telephone.select();
			 return false;}

	 
	 if (!frm.address1.value)	{
		alert ("Please enter a value for the ADDRESS 1 field");
	 	frm.address1.focus();
	  	frm.address1.select();
		return false;
	 }
	 	 			
					if (!check_link(frm.address1.value)){ 
				 frm.address1.focus();
				frm.address1.select();
			 return false;}

	 
	 if (!frm.address2.value)	{
		alert ("Please enter a value for the ADDRESS 2 field");
	 	frm.address2.focus();
	  	frm.address2.select();
		return false;
	 }
	 					if (!check_link(frm.address1.value)){ 
				 frm.address1.focus();
				frm.address1.select();
			 return false;}

	 
	 if (!frm.towncity.value)	{
		alert ("Please enter a value for the TOWN / CITY field");
	 	frm.towncity.focus();
	  	frm.towncity.select();
		return false;
	 }
	 
	 					if (!check_link(frm.address1.value)){ 
				 frm.address1.focus();
				frm.address1.select();
			 return false;}

	 if (!frm.countystate.value)	{
		alert ("Please enter a value for the COUNTY / STATE field");
	 	frm.countystate.focus();
	  	frm.countystate.select();
		return false;
	 }
	 					if (!check_link(frm.address1.value)){ 
				 frm.address1.focus();
				frm.address1.select();
			 return false;}

	 
	 if (!frm.postzipcode.value)	{
		alert ("Please enter a value for the POST / ZIP CODE field");
	 	frm.postzipcode.focus();
	  	frm.postzipcode.select();
		return false;
	 }
	 					if (!check_link(frm.address1.value)){ 
				 frm.address1.focus();
				frm.address1.select();
			 return false;}

	 if (!frm.country.value)	{
		alert ("Please enter a value for the COUNTRY field");
	 	frm.country.focus();
	  	frm.country.select();
		return false;
	 }
		
						if (!check_link(frm.country.value)){ 
				 frm.country.focus();
				frm.country.select();
			 return false;}

	if (!frm.comments.value)	{
		alert ("Please enter a value for the COMMENTS field");
	 	frm.comments.focus();
	  	frm.comments.select();
		return false;
	 }
						if (!check_link(frm.comments.value)){ 
				 frm.comments.focus();
				frm.comments.select();
			 return false;}

		 // submit=true calls the formmail script
return true;	
}

function check_link(fld) {
//chekd to see if spammers have put in links!!!	
//alert("FLD=" + fld + " Index OF=" + fld.indexOf("http") );
	if (fld.indexOf("http") >= 0){
		alert("You are not allowed to post links on this page");	
			return false;
		} else{
			return true;
			}
}//fn