// JavaScript Document

function check(){

	if(document.getElementById("txt_subject").value==""){
		alert("Subject Can't be Blank");
		document.getElementById("txt_subject").focus();
		return false;
	}
	if(document.getElementById("txt_name").value==""){
		
		alert("Name Can't be Blank");
		document.getElementById("txt_name").focus();
		return false;
	}
	if(document.getElementById("txt_email").value==""){
		
		alert("Email Can't be Blank");
		document.getElementById("txt_email").focus();
		return false;
	}
	if(echeck(document.getElementById("txt_email").value)==false){
		return false;
	}
	if(document.getElementById("txt_quries").value==""){
		
		alert("Queries Can't be Blank");
		document.getElementById("txt_quries").focus();
		return false;
	}
	
return true;
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var msg= "Invalid E-mail ID \t e.g. james@domain.com";
		if (str.indexOf(at)==-1){
		   alert(msg)
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert(msg)
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert(msg)
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert(msg)
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert(msg)
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert(msg)
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert(msg)
		    return false
		 }

 		 return true					
	}
function form_submit(){
	
	if(check()==true){
		
		document.getElementById('frm').submit();
		
		}
	
	}


