function echeck(str) {
  var at="@"
  var dot="."
  var lat=str.indexOf(at)
  var lstr=str.length
  var ldot=str.indexOf(dot)
  if (str.indexOf(at)==-1){
     alert("Please enter a valid e-mail")
     return false
  }
  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
     alert("Please enter a valid e-mail")
     return false
  }
  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
      alert("Please enter a valid e-mail")
      return false
  }
   if (str.indexOf(at,(lat+1))!=-1){
      alert("Please enter a valid e-mail")
      return false
   }
   if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
      alert("Please enter a valid e-mail")
      return false
   }
   if (str.indexOf(dot,(lat+2))==-1){
      alert("Please enter a valid e-mail")
      return false
   }
   if (str.indexOf(" ")!=-1){
      alert("Please enter a valid e-mail")
      return false
   }
   return true          
}





function ValidateForm ( )
{


	//special characters that we won't allow
	 var iChars = "#%^*+=[]{}|<>";	




    valid = true;

    if ( document.CForm.Name.value == "" )
    {
        alert ( "Please enter your name." );
        valid = false;
    }
    
    if ( document.CForm.Phone.value == "" )
    {
        alert ( "Please enter your telephone number." );
        valid = false;
    }

	 if ( document.CForm.State.value == "" )
    {
        alert ( "Please enter your state." );
        valid = false;
    }


if ( document.CForm.Website.value == "" )
    {
        alert ( "Please enter your website address." );
        valid = false;
    }

		
	for (var i = 0; i < document.CForm.Name.value.length; i++) {
	  	if (iChars.indexOf(document.CForm.Name.value.charAt(i)) != -1) {
	  	alert ("Your name has special characters. \nThese are not allowed.\n Please remove them and try again.");
	  	return false;
	  	}
	  }
	  
	  if ( document.CForm.Company.value == "" )
    {
        alert ( "Please enter your company name." );
        valid = false;
    }
	
		
	for (var i = 0; i < document.CForm.Company.value.length; i++) {
	  	if (iChars.indexOf(document.CForm.Company.value.charAt(i)) != -1) {
	  	alert ("Your name has special characters. \nThese are not allowed.\n Please remove them and try again.");
	  	return false;
	  	}
	  }


for (var i = 0; i < document.CForm.Website.value.length; i++) {
	  	if (iChars.indexOf(document.CForm.Website.value.charAt(i)) != -1) {
	  	alert ("Your website has special characters. \nThese are not allowed.\n Please remove them and try again.");
	  	return false;
	  	}
	  }
for (var i = 0; i < document.CForm.Title.value.length; i++) {
	  	if (iChars.indexOf(document.CForm.Title.value.charAt(i)) != -1) {
	  	alert ("Your position has special characters. \nThese are not allowed.\n Please remove them and try again.");
	  	return false;
	  	}
	  }

   


	
	for (var i = 0; i < document.CForm.Address1.value.length; i++) {
	  	if (iChars.indexOf(document.CForm.Address1.value.charAt(i)) != -1) {
	  	alert ("The first line of your address has special characters. \nThese are not allowed.\n Please remove them and try again.");
	  	return false;
	  	}
	  }



	
	for (var i = 0; i < document.CForm.Address2.value.length; i++) {
	  	if (iChars.indexOf(document.CForm.Address2.value.charAt(i)) != -1) {
	  	alert ("The second line of your address has special characters. \nThese are not allowed.\n Please remove them and try again.");
	  	return false;
	  	}
	  }




	
	for (var i = 0; i < document.CForm.City.value.length; i++) {
	  	if (iChars.indexOf(document.CForm.City.value.charAt(i)) != -1) {
	  	alert ("Your city has special characters. \nThese are not allowed.\n Please remove them and try again.");
	  	return false;
	  	}
	  }


     
  

	for (var i = 0; i < document.CForm.State.value.length; i++) {
	  	if (iChars.indexOf(document.CForm.State.value.charAt(i)) != -1) {
	  	alert ("Your state has special characters. \nThese are not allowed.\n Please remove them and try again.");
	  	return false;
	  	}
	  }


	for (var i = 0; i < document.CForm.Zip.value.length; i++) {
	  	if (iChars.indexOf(document.CForm.Zip.value.charAt(i)) != -1) {
	  	alert ("Your zip code has special characters. \nThese are not allowed.\n Please remove them and try again.");
	  	return false;
	  	}
	  }
	  
	  
	  for (var i = 0; i < document.CForm.Phone.value.length; i++) {
	  	if (iChars.indexOf(document.CForm.Phone.value.charAt(i)) != -1) {
	  	alert ("Your phone number has special characters. \nThese are not allowed.\n Please remove them and try again.");
	  	return false;
	  	}
	  }


var emailID=document.CForm.Email;
  
  if ((emailID.value==null)||(emailID.value=="")){
    alert("Please enter your e-mail address")
    emailID.focus()
    return false
  }
  if (echeck(emailID.value)==false){
    emailID.value=""
    emailID.focus()
    return false
  }






for (var i = 0; i < document.CForm.Message.value.length; i++) {
	  	if (iChars.indexOf(document.CForm.Message.value.charAt(i)) != -1) {
	  	alert ("Your comment has special characters. \nThese are not allowed.\n Please remove them and try again.");
	  	return false;
	  	}
	  }

for (var i = 0; i < document.CForm.Market.value.length; i++) {
	  	if (iChars.indexOf(document.CForm.Market.value.charAt(i)) != -1) {
	  	alert ("The way your heard about us has special characters. \nThese are not allowed.\n Please remove them and try again.");
	  	return false;
	  	}
	  }


    return valid;
}
