// JavaScript Document

	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
		}
		return true					
	}

	function validate()
	{
		if(document.frm.trainValue.value=="99")
		{
			alert("Train Name Can't be blank");
			document.frm.trainValue.focus()
			return false;
		}
		if((document.frm.date.value=="99") || (document.frm.date.value==""))
		{
			alert("Please Select Journey Date");
			document.frm.date.focus();
			return false;
		}
		if(document.frm.adult.value==0)
		{
			alert("Please choose no of adults");
			document.frm.adult.focus()
			return false;
		}
		return true;
	}
	
	function valid()
	{
		if(document.frm.trainValue.value=="")
		{
			alert("Please select Trian Name");
			document.frm.trainValue.focus();
			return false;
		}
		if((document.frm.date.value=="99") || document.frm.date.value=="")
		{
			alert("Please select Date");
			document.frm.date.focus();
			return false;
		}
		if(document.frm.adult.value=="")
		{
			alert("Please enter no of people");
			document.frm.adult.focus();
			return false;
		}
		if(document.frm.fname.value=="")
		{
			alert("Name Can't be blank");
			document.frm.fname.focus();
			return false;
		}
		if(document.frm.email.value=="")
		{
			alert("Email ID Can't be blank");
			document.frm.email.focus();
			return false;
		}
		if (echeck(document.frm.email.value)==false){
			document.frm.email.value=""
			document.frm.email.focus()
			return false
		}
		if(document.frm.country.value=="")
		{
			alert("Please select your country name");
			document.frm.country.focus();
			return false;
		}
		if(document.frm.phone.value=="")
		{
			alert("Phone no can't be blank");
			document.frm.phone.focus();
			return false;
		}
		if(document.frm.captcha.value=="")
		{
			alert("please write image code");
			document.frm.captcha.focus();
			return false;
		}
		return true;
	}
	
	function homevalid()
	{
		if(document.frm.name.value=="")
		{
			alert("Name Can't be blank");
			document.frm.name.focus();
			return false;
		}
		if(document.frm.email.value=="")
		{
			alert("Email ID Can't be blank");
			document.frm.email.focus();
			return false;
		}
		if(document.frm.phone.value=="")
		{
			alert("Phone no Can't be blank");
			document.frm.phone.focus();
			return false;
		}
		if(document.frm.country.value=="")
		{
			alert("Select your country name");
			document.frm.country.focus();
			return false;
		}
		if(document.frm.query.value=="")
		{
			alert("Please right your query");
			document.frm.query.focus();
			return false;
		}
		return true;
	}
	
	function submitform()
	{
		document.forms["form1"].submit();
	}
	
	function submitfrms()
	{
		document.forms["frms"].submit();
	}
