﻿function contactquery()
{
   var val
   if (document.form1.fname.value==""){alert("Enter Your Name."); document.form1.fname.focus();}
   else if (document.form1.fname.value.length>30){alert("First Name can be maximum of 30 characters."); document.form1.fname.focus();}
   else if (document.form1.email.value==""){alert("Enter E-Mail Address."); document.form1.email.focus();}
   else if (document.form1.country.value==""){alert("Enter Country Name."); document.form1.country.focus();}
   else	if (checkmail(document.form1.email.value))
   {
       val=document.form1.fname.value
       val=val+'.;'+document.form1.email.value;
       val=val+'.;'+document.form1.country.value;
       val=val+'.;'+document.form1.phone.value;
   
      if(document.getElementById('message')=="[object]")
        val=val+'.;'+document.form1.message.value+'.;';       
      else
         val=val+'.;'
       centerWindowX('submit.asp?val='+val+'&mode=contactquery'); 
	   document.form1.reset();
   }
}
function centerWindowX(fname) {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;
    var xOffset = (xMax - 490)/2, yOffset = (yMax - 190)/2;	
    MM_openBrWindow(fname,'info','width=400,height=150,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
}

function MM_openBrWindow(theURL,winName,features) { 
     window.open(theURL,winName,features);}
     
function checkmail(str){
   		var at="@"        
		var dot="."
		var temp;
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var invalidchar=" \"([{}])!#$%^&*';:,/\\?|+`~<>=~"
		if (str.indexOf(at)==-1){
			alert("Please Enter a valid Email ID.")
		   	return false }
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr-1){
		   alert("Please Enter a valid Email ID.")
		   return false	}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1){
		    alert("Please Enter a valid Email ID.")
		    return false }
		if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please Enter a valid Email ID.")
		    return false }
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please Enter a valid Email ID.")
		    return false }
		if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please Enter a valid Email ID.")
		    return false }		
		for (i=0; i<(invalidchar.length-1); i++){
		      temp=invalidchar.substring(i,i+1);		      
		      if (str.indexOf(temp)!=-1){
		         alert("Please Enter a valid Email ID.")
		         return false} 
	 	}		 		
return true; }  

