
/////////////////////////////////////

 var http_request = false;
   function makePOSTRequest(url, parameters) {
	 
      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 = alertContents;
      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 alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
			       //alert(http_request.responseText);
            result = http_request.responseText;
		    document.getElementById('myspans').innerHTML =result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function get(obj) {
	   
	  var poststr="";
	  var textfields;
	 
	 
	   if(document.f_cat.company.value!="")
		{
			l= "company='"+ escape(encodeURI(document.f_cat.company.value)) +"'&";
	        poststr= poststr + l; 
		} 
		
	n= "fname="+ escape(encodeURI(document.f_cat.fname.value)) +"&lname="+ escape(encodeURI(document.f_cat.lname.value)) +"&tel="+ escape(encodeURI(document.f_cat.tel.value)) +"&email="+ escape(encodeURI(document.f_cat.email.value)) +"&address="+ escape(encodeURI(document.f_cat.address.value)) +"&posts="+ obj +"&";	
	poststr= poststr + n;
	
		
document.f_cat.fname.value="";
document.f_cat.lname.value="";
document.f_cat.email.value="";
document.f_cat.tel.value="";
document.f_cat.address.value="";
document.f_cat.company.value="";

document.getElementById("myInput_1").innerHTML="";
document.getElementById("myinput").innerHTML="";
document.getElementById("myspans").innerHTML="";

	      makePOSTRequest('ns_w_ajax.php', poststr);

   }

function emails(emailID)
{

if ((emailID==null)||(emailID=="")){
			document.getElementById("myInput_1").innerHTML="<font color='#ff0000'><b>- Please enter valid email-id</font></b>";	  
			//emailID.focus();
		 return false;
	}
if (echeck(emailID)==false){
		
		//emailID.focus();
		return false;
	}
}

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){
		   document.getElementById("myInput_1").innerHTML="<font color='#ff0000'><b>- Invalid E-mail ID</font></b>";
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   document.getElementById("myInput_1").innerHTML="<font color='#ff0000'><b>- Invalid E-mail ID</font></b>";
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    document.getElementById("myInput_1").innerHTML="<font color='#ff0000'><b>- Invalid E-mail ID</font></b>";
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    document.getElementById("myInput_1").innerHTML="<font color='#ff0000'><b>- Invalid E-mail ID</font></b>";
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    document.getElementById("myInput_1").innerHTML="<font color='#ff0000'><b>- Invalid E-mail ID</font></b>";
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    document.getElementById("myInput_1").innerHTML="<font color='#ff0000'><b>- Invalid E-mail ID</font></b>";
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    document.getElementById("myInput_1").innerHTML="<font color='#ff0000'><b>- Invalid E-mail ID</font></b>";
		    return false;
		 }

 						
	}


		 

		  

