
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 || 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("SInvalid 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;
			/*var text="excellent"
text.substring(0,4) //returns "exce"
text.substring(2,4) //returns "ce"*/
		 }

		 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;
		 }

 		return true;				
	}    

function ValidateForm(){
	if(document.checkk.name.value==""){
		alert("Please enter your name");
		document.checkk.name.focus();
		return;
	}
	var emailID=document.checkk.mail;
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID");
		emailID.focus();
		return ;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return ;
	}
	else
	document.checkk.submit();
}

function ValidateGuest(){
	 					if(document.guest.name.value=="")
						{
						window.alert ("Please add a First name")
						guest.name.focus();
						return false
						}
						else
						if(!isNaN(document.guest.name.value))
						{
						window.alert ("Please Add a First name")
						guest.name.focus();
						return false
						}
						else
						if(document.guest.family.value=="")
						{
						window.alert ("Please Add a Last name")
						guest.family.focus();
						return false
						}
						if(!isNaN(document.guest.family.value))
						{
						window.alert ("Please Add a Last name")
						guest.family.focus();
						return false
						}
						else
						if (document.guest.title.value=="")
						{
						window.alert ("Please add Subject")
						guest.title.focus();
						return false
						}
						else
						if(document.guest.message.value=="")
						{
						window.alert ("Please add message")
						guest.message.focus();
						return false
						}
						else
						ValidateFormguest();
						
}
function ValidateFormguest(){

	var emailID=document.guest.mail;
	
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID");
		emailID.focus();
		return ;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return ;
	}
	else{
	document.guest.test.value="1";
	document.guest.submit();}
	
}	
	
