function form_validate(theForm)
{
if (theForm.fromvisitor.value == "")
  {
    alert("Please enter a value for the \"Name required.\" field.");
    theForm.fromvisitor.focus();
    return (false);
  }

  if (theForm.fromvisitor.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Name required.\" field.");
    theForm.fromvisitor.focus();
    return (false);
  }

  
  
if (theForm.vistoremail.value == "")
  {
    alert("Please enter a value for the \"E-mail address required.\" field.");
    theForm.vistoremail.focus();
    return (false);
  }

  if (theForm.vistoremail.value.length < 4)
  {
    alert("Please enter at least 4 characters in the \"E-mail adress required.\" field.");
    theForm.vistoremail.focus();
    return (false);
  }

  if (theForm.vistoremail.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"E-mail adress required.\" field.");
    theForm.vistoremail.focus();
    return (false);
  }
  
  if (echeck(theForm.vistoremail.value)==false){
  theForm.vistoremail.value=""
		theForm.vistoremail.focus()
		return (false);
  }
  
  if (theForm.mess.value.length < 10)
  {
    alert("Please enter at most 10 characters in the \"Message\" field.");
    theForm.mess.focus();
    return (false);
  }
  
  if (validate_user_text(theForm.mess.value)==false)
  {
    alert("The form cannot be submitted with illegal Characters");
    theForm.mess.focus();
    return (false);
  }
  
  
  
  if (theForm.edit_user_pass2.value == "")
  {
    alert("Code cannot be blank");
    theForm.edit_user_pass2.focus();
    return (false);
  }
  
  if (BothFieldsIdenticalCaseSensitive(theForm.edit_user_pass.value, theForm.edit_user_pass2.value)==false)
  {  
  theForm.edit_user_pass2.value=""
		theForm.edit_user_pass2.focus()
		return (false);
  } 
  
  
 } 
 
  
  

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("Invalid E-mail ID")
		   return (false);
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return (false);
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return (false);
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return (false);
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return (false);
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return (false);
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return (false);
		 }					
	}
	
	function BothFieldsIdenticalCaseSensitive(str1, str2) {
var one = str1;
var another = str2;
if(one != another) { 
alert("Oops, both codes must be identical.");
return (false);
}
}

var swear_words_arr=new Array("<a href=\"http://", "http", "<a href=", "</a>", "<",">","[","]","{","}","tits","fuck","fucking","fucks",".com",".net","urL");
var swear_alert_arr=new Array;
var swear_alert_count=0;
function reset_alert_count()
{
 swear_alert_count=0;
}
function validate_user_text()
{
 reset_alert_count();
 var compare_text=document.theForm.mess.value;
 for(var i=0; i<swear_words_arr.length; i++)
 {
  for(var j=0; j<(compare_text.length); j++)
  {
   if(swear_words_arr[i]==compare_text.substring(j,(j+swear_words_arr[i].length)).toLowerCase())
   {
    swear_alert_arr[swear_alert_count]=compare_text.substring(j,(j+swear_words_arr[i].length));
    swear_alert_count++;
   }
  }
 }
 var alert_text="";
 for(var k=1; k<=swear_alert_count; k++)
 {
  alert_text+="\n" + "(" + k + ")  " + swear_alert_arr[k-1];
 }
 if(swear_alert_count>0)
 {
  alert("The form cannot be submitted with illegal Characters");
  return false;
 }
 
}