

function iLLegalChar(strInput)
{
	if (!strInput) return false;
	var specialChars= "~!@#$%^*+=[]{}|;<>?\"";
	for (var i = 0; i < strInput.length; i++)
	{ 
		if (specialChars.indexOf(strInput.charAt(i)) > -1)
		return false;
	}
	return true;
}

function CreateObject()
{
 var http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
return http_request;
}

function fSubmit()
{
	
 var NameVal=document.getElementById("nameVal").value;
 var aCompany=document.getElementById("aCompany").value;
 var email=document.getElementById("email").value;
 var phone=document.getElementById("phone").value;
 var intrest=document.getElementById("intrest").value;
 var findus=document.getElementById("findus").value;
 var comments=document.getElementById("comments").value;
 var strCAPTCHA=document.getElementById("strCAPTCHA").value;
 var subs=document.getElementById("subs").value;
 if(NameVal==""){alert("please enter your Name.");document.getElementById("nameVal").focus();}else if(email==""){alert("Please enter your Email.");document.getElementById("email").focus();}else if(!echeck(email)){alert("please enter valid Email.");document.getElementById("email").focus();}else if(phone==""){alert("please enter your Phone.");document.getElementById("phone").focus();}else if(!isInteger(phone)){alert("please enter Valid Phone Number.");document.getElementById("phone").focus();}else if(comments==""){alert("please enter your Comments.");document.getElementById("comments").focus();}else if(strCAPTCHA==""){alert("please enter Capcha Code.");document.getElementById("strCAPTCHA").focus();}else{
document.getElementById("appForm").innerHTML="<div align='center'><br><br><br<img src='images/loding.gif'></div>"
 var url = "ajaxSubmit.asp";  
 var parameters = "NameVal="+encodeURI(NameVal)+"&aCompany="+encodeURI(aCompany)+"&email="+encodeURI(email)+"&phone="+encodeURI(phone)+"&intrest="+encodeURI(intrest)+"&findus="+encodeURI(findus)+"&comments="+encodeURI(comments)+"&strCAPTCHA="+encodeURI(strCAPTCHA)+"&subs="+encodeURI(subs); 
//alert(parameters)
 var xmlHttp=new CreateObject();
 xmlHttp.open("POST", url, true);  
 //Send the proper header information along with the request  
 xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");  
 xmlHttp.setRequestHeader("Content-length", parameters .length);  
 xmlHttp.setRequestHeader("Connection", "close");  
 xmlHttp.onreadystatechange = function() {//Handler function for call back on state change.  
     if(xmlHttp.readyState == 4) { 
document.getElementById("appForm").innerHTML="<div align='center' >"+xmlHttp.responseText+"</div>";
     }  
 }  
 xmlHttp.send(parameters); 
 }
}

//*************************** Insert Keywords into dictionary **********
var digits = "0123456789-+";
function isInteger(s)
{   var i;

    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
       if(digits.indexOf(c)<0)
	   {
	   return false
	   exit();
	   }
    }
    return true;
}
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					
	}
