// JavaScript Document

function validate(){
 	 if(document.frmContact.name.value==""){
		 document.getElementById("txtmsg").innerHTML="Please enter your full name.";
		 document.getElementById('n1').style.background='#f9f7bd';
		 document.getElementById('n2').style.background='';
		 document.getElementById('n3').style.background='';
		 document.getElementById('n4').style.background='';
		 	document.frmContact.name.focus();

        return false;
		 }
 	 if(document.frmContact.email.value==""){
		 document.getElementById("txtmsg").innerHTML="Please provide your valid email.";
 		 document.getElementById('n1').style.background='';
		 document.getElementById('n2').style.background='#f9f7bd';
		 document.getElementById('n3').style.background='';
		 document.getElementById('n4').style.background='';
		 	document.frmContact.email.focus();

		 return false;
		 }
 	 if(document.frmContact.orderno.value==""){
		 document.getElementById("txtmsg").innerHTML="Please enter your subject.";
		 document.getElementById('n3').style.background='#f9f7bd';
		 document.getElementById('n2').style.background='';
		 document.getElementById('n1').style.background='';
		 document.getElementById('n4').style.background='';
		 	document.frmContact.orderno.focus();

 		 return false;
		 }
 	 if(document.frmContact.message.value==""){
		 document.getElementById("txtmsg").innerHTML="Cannot submit with empty message.";
		 document.getElementById('n4').style.background='#f9f7bd';
		 document.getElementById('n2').style.background='';
		 document.getElementById('n3').style.background='';
		 document.getElementById('n1').style.background='';
		 	document.frmContact.message.focus();

		 return false;
		 }

 if (echeck(document.frmContact.email.value)==false)
   {
	document.frmContact.email.value="";
	document.frmContact.email.focus();
	 document.getElementById('n1').style.background='';
	 document.getElementById('n2').style.background='#f9f7bd';
	 document.getElementById('n3').style.background='';
	 document.getElementById('n4').style.background='';
	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){
 		   document.getElementById("txtmsg").innerHTML="Invalid E-mail ID.";
 		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
 		   document.getElementById("txtmsg").innerHTML="Invalid E-mail ID.";
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
 		   document.getElementById("txtmsg").innerHTML="Invalid E-mail ID.";
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
 		   document.getElementById("txtmsg").innerHTML="Invalid E-mail ID.";
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
 		   document.getElementById("txtmsg").innerHTML="Invalid E-mail ID.";
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
 		   document.getElementById("txtmsg").innerHTML="Invalid E-mail ID.";
		    return false
		 }

		 if (str.indexOf(" ")!=-1){
 		   document.getElementById("txtmsg").innerHTML="Invalid E-mail ID.";
		    return false
		 }
 		 return true
	}


