function makePOSTRequest(url, parameters, spaname) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            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;
      }
      
      http_request.onreadystatechange =  function (){ 
	  if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            
			result = http_request.responseText;
            
			document.getElementById(spaname).innerHTML = result;
			
         } else {
            alert('There was a problem with the request.');
         }
      }  
	  };
	  
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
	  
	 
	  
   }

function sendContact() {
error = false;
var name=document.getElementById("name");
var emailID=document.getElementById("email");
var phone=document.getElementById("phone");
var comments=document.getElementById("comments");
	//alert(emailID.value);
if (document.getElementById("name").value=="")
	{
		document.getElementById("FormMsg").innerHTML = "Enter name";
		name.focus()
		error = true;
			
	}
	else if ((emailID.value==null)||(emailID.value=="")){
		//alert("Please Enter your Email ID")
		document.getElementById("FormMsg").innerHTML = "Enter email address";
		emailID.focus()
		error = true;
	}
	else if (echeck(emailID.value)==false){
			emailID.value=""
			emailID.focus()
			error = true;
		}
	else if (phone.value=="")
	{
		document.getElementById("FormMsg").innerHTML = "Enter phone";
		phone.focus()
		error = true;
	}
	
	else if (comments.value=="")
	{
		document.getElementById("FormMsg").innerHTML = "Enter comments";
		comments.focus()
		error = true;
	}
	
	

	if (error != true)  	  
	  {
	
         var poststr = "name=" + encodeURI( document.getElementById("name").value ) +
				   "&email=" + encodeURI( document.getElementById("email").value )+
				   "&phone=" + encodeURI( document.getElementById("phone").value )+
					"&comments=" + encodeURI( document.getElementById("comments").value );        	
	
	document.getElementById("FormMsg").innerHTML = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td valign=\"middle\">Sending your Inquiry</td></tr></table>";
	
					
	makePOSTRequest('/_contactsend.php', poststr, 'FormMsg');  
	
	name.value="";
	emailID.value="";
	phone.value="";
	comments.value="";	
	
	}
}
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					
	}
