// JavaScript Document By Mamoon Rashid 

function CheckForm()
{
	with(document.contact_form)
		{
			if(name.value == "")
			{
				alert("Enter Your Name");
				name.focus();
				return false;
			}
			if ((email.value==null)||(email.value=="")){
				alert("Please Enter your Email ID")
				email.focus()
				return false
			}
			if (echeck(email.value)==false){
				email.value=""
				email.focus()
				return false
			}
			if (telephone.value == "")
			{
				alert("Please Enter your Telephone")
				telephone.focus()
				return false
			}
			if (comment.value == '') 
			{
				alert('Please Enter Your Comment');
			   	comment.focus(); 	
   	   			return false;
			}
		};
}

function bpContactForm(){
	with(document.form)
	{
		if(name.value == "")
		{
			alert("Enter Your Name");
			name.focus();
			return false;
		}
		if (bp_state.value == "")
		{
			alert("Please Enter your State")
			bp_state.focus()
			return false
		}
		if (bp_zip_code.value == "")
		{
			alert("Please Enter your Zip Code")
			bp_zip_code.focus()
			return false
		}
		if ((email.value==null)||(email.value=="")){
			alert("Please Enter your Email ID")
			email.focus()
			return false
		}
		if (echeck(email.value)==false){
			email.value=""
			email.focus()
			return false
		}
		if (bp_telephone.value == "")
		{
			alert("Please Enter your Telephone")
			bp_telephone.focus()
			return false
		}
		if (requested_date.value == "")
		{
			alert("Please Enter your Requested Date")
			requested_date.focus()
			return false
		}
		if (comment.value == '') 
		{
			alert('Please Enter Your Comment');
			comment.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
		 }
				
	}
