// JavaScript Document


function validate()
   {
  if ((document.frmSendInquiry.name.value=="") || (document.frmSendInquiry.name.value.length < 3))
      {
       alert("\nFrom Field is either empty or less than 3 chars.\n\nPlease re-enter your Name.");
       document.frmSendInquiry.name.focus();
       return false;
    }
	
  if ((document.frmSendInquiry.city.value=="") || (document.frmSendInquiry.city.value.length < 3))
      {
       alert("\nFrom Field is either empty or less than 3 chars.\n\nPlease re-enter your City Name.");
       document.frmSendInquiry.city.focus();
       return false;
    }

  if ((document.frmSendInquiry.phone.value=="") || (document.frmSendInquiry.phone.value.length >10))
      {
       alert("\nFrom Field is either empty or less than 7 chars.\n\nPlease re-enter your Phone Number.");
       document.frmSendInquiry.phone.focus();
       return false;
    }
 var var10 = document.frmSendInquiry.phone.value;
	if(var10.value != "")
	{
	var i= doValidateNumber(var10,'phone');
	if(i == 1) return false;
	} 
	
	function doValidateNumber(vart,vat)
				{
					var valid = "0123456789/"
					var ok = "yes";
					var temp;
					var i;
					for(i=0;i<vart.length;i++) 
						{
							temp = "" + vart.substring(i, i+1);							
							if (valid.indexOf(temp) == "-1") 
							{
							ok = "no";
							}
						}
						if (ok == "no")
						{
							alert(vat + " Invalid! Only numbers are accepted!");
							document.frmSendInquiry.phone.focus();
							return 1;
						}
						return 2;
				} 
	     
	
if (document.frmSendInquiry.email.value=="")
		{
			alert("Please enter Email");
			document.frmSendInquiry.email.focus();
			return false;
		}
		var str = document.frmSendInquiry.email.value
		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
		 }
  if ((document.frmSendInquiry.inquirymessage.value=="") || (document.frmSendInquiry.inquirymessage.value.length < 10))
      {
       alert("\nThe Inquiry Message is either empty or less than 10 chars.\n\nPlease re-enter your Inquiry Message.");
       document.frmSendInquiry.inquirymessage.focus();
       return false;
    }
  if ((document.frmSendInquiry.origincity.value=="") || (document.frmSendInquiry.origincity.value.length < 3))
      {
       alert("\nFrom Field is either empty or less than 3 chars.\n\nPlease re-enter your Origin Details City Name.");
       document.frmSendInquiry.origincity.focus();
       return false;
    }
  if ((document.frmSendInquiry.destinationcity.value=="") || (document.frmSendInquiry.destinationcity.value.length < 3))
      {
       alert("\nFrom Field is either empty or less than 3 chars.\n\nPlease re-enter your Destination City Name.");
       document.frmSendInquiry.destinationcity.focus();
       return false;
    }
    
     
    return true;
 }

