// JavaScript Document
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try	{
	xmlHttp=new XMLHttpRequest();
		}
	catch (e){
	
			try{
			xmlHttp=new ActiveXObject('Msxml2.XMLHTTP');
			}
			catch(e){
			xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');
			}
	}
	
	return xmlHttp;
}

var xmlHttp;


function sendEmail(a,b,c,d){
	var cname = document.getElementById(a).value;
	var cemail = document.getElementById(b).value;
	var cno = document.getElementById(c).value;
	var cmsg = document.getElementById(d).value;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

	if(cname==''){
	document.getElementById('errors').innerHTML="Fill your name";
	document.getElementById('contactName').style.borderColor="red";
	document.getElementById('contactEmail').style.borderColor="#cccccc";
	document.getElementById('contactNo').style.borderColor="#cccccc";
	document.getElementById('contactMassege').style.borderColor="#cccccc";
	document.getElementById(a).focus();
	return false;	
	}
	if(cemail==''){
	document.getElementById('errors').innerHTML="Fill your email-Id";
	document.getElementById('contactEmail').style.borderColor="red";
	document.getElementById('contactName').style.borderColor="#cccccc";
	document.getElementById('contactNo').style.borderColor="#cccccc";
	document.getElementById('contactMassege').style.borderColor="#cccccc";
	document.getElementById(b).focus();
	return false;	
	} 
	if(reg.test(cemail) == false) {
	document.getElementById('errors').innerHTML="Fill right email-Id";
	document.getElementById('contactEmail').style.borderColor="red";
	document.getElementById('contactName').style.borderColor="#cccccc";
	document.getElementById('contactNo').style.borderColor="#cccccc";
	document.getElementById('contactMassege').style.borderColor="#cccccc";
	document.getElementById(b).focus();
	return false;
	}
	if(cno==''){
	document.getElementById('errors').innerHTML="Fill contact no.";
	document.getElementById('contactNo').style.borderColor="red";
	document.getElementById('contactName').style.borderColor="#cccccc";
	document.getElementById('contactEmail').style.borderColor="#cccccc";
	document.getElementById('contactMassege').style.borderColor="#cccccc";
	document.getElementById(c).focus();
	return false;		
	}
	if(cmsg==''){
	document.getElementById('errors').innerHTML="Fill your massege";
	document.getElementById('contactMassege').style.borderColor="red";
	document.getElementById('contactNo').style.borderColor="#cccccc";
	document.getElementById('contactName').style.borderColor="#cccccc";
	document.getElementById('contactEmail').style.borderColor="#cccccc";
	document.getElementById(d).focus();
	return false;		
	} else {
	var url = "name="+cname+"&email="+encodeURIComponent(cemail)+"&no="+cno+"&msg="+encodeURIComponent(cmsg);	
	}

   var strURL="ajax.php?id=1&"+url;
   var xmlHttp = GetXmlHttpObject();
 
	xmlHttp.onreadystatechange=function(){ 
	 if (xmlHttp.readyState == 1 || xmlHttp.readyState == 2 || xmlHttp.readyState == 3){
	 document.getElementById("errors").innerHTML="<div style='text-decoration:blink;'><img src='http://www.metrixweb.net/noida/ic/loading.gif'/> Please wait ....</div>";
	}
	if (xmlHttp.readyState==4){

		 if (xmlHttp.status == 200){		
		 document.getElementById("errors").innerHTML=xmlHttp.responseText;
		 document.getElementById(a).value='';
		 document.getElementById(b).value='';	
		 document.getElementById(c).value='';
		 document.getElementById(d).value='';			
		 } else {
   	  	 alert("There was a problem while using XMLHTTP:\n" + xmlHttp.statusText);
		 }
	}
	}
   xmlHttp.open("GET", strURL, true);
   xmlHttp.send(null);
   
}

function sendCall(a,b){
	if(document.getElementById(a).value==''){
	document.getElementById('errors1').innerHTML="Fill your name.";
	document.getElementById('contactName1').style.borderColor="red";
	document.getElementById('contactNo1').style.borderColor="#cccccc";
	document.getElementById(a).focus();
	return false;	
	}
	if(document.getElementById(b).value==''){
	document.getElementById('errors1').innerHTML="Fill your mobile no.";
	document.getElementById('contactName1').style.borderColor="#cccccc";
	document.getElementById('contactNo1').style.borderColor="red";
	document.getElementById(b).focus();
	return false;	
	} else {
	var url = "cno="+document.getElementById(b).value;	
	}

   var strURL="ajax.php?id=2&"+url;
   var xmlHttp = GetXmlHttpObject();
   
  	xmlHttp.onreadystatechange=function(){ 
	 if (xmlHttp.readyState == 1 || xmlHttp.readyState == 2 || xmlHttp.readyState == 3){
	 document.getElementById("errors1").innerHTML="<div style='text-decoration:blink;'><img src='http://www.metrixweb.net/noida/ic/loading.gif'/> Please wait to connect the call....</div>";
	}

	if (xmlHttp.readyState==4){

		 if (xmlHttp.status == 200){		
		 document.getElementById("errors1").innerHTML=xmlHttp.responseText;
		 document.getElementById(a).value='';
		 document.getElementById(b).value='';			
		 } else {
   	  	 alert("There was a problem while using XMLHTTP:\n" + xmlHttp.statusText);
		 }
	}
	}
   xmlHttp.open("GET", strURL, true);
   xmlHttp.send(null);
   
}

function sendSms(a,b){
	if(document.getElementById(a).value==''){
	document.getElementById('errors2').innerHTML="Fill your mobile no.";
	document.getElementById('contactNo2').style.borderColor="red";
	document.getElementById('contactMassege2').style.borderColor="#cccccc";
	document.getElementById(a).focus();
	return false;	
	} else if(document.getElementById(b).value==''){
	document.getElementById('errors2').innerHTML="Fill your msg";
	document.getElementById('contactMassege2').style.borderColor="red";
	document.getElementById('contactNo2').style.borderColor="#cccccc";
	document.getElementById(b).focus();
	return false;	
	}else {
	var url = "cmno="+document.getElementById(a).value+"&smsg="+document.getElementById(b).value;	
	}
   var strURL="ajax.php?id=3&"+url;
   var xmlHttp = GetXmlHttpObject();
   
   	xmlHttp.onreadystatechange=function(){ 
	 if (xmlHttp.readyState == 1 || xmlHttp.readyState == 2 || xmlHttp.readyState == 3){
	 document.getElementById("errors2").innerHTML="<div style='text-decoration:blink;'><img src='http://www.metrixweb.net/noida/ic/loading.gif'/> Please wait to sent the sms....</div>";
	}
		if (xmlHttp.readyState==4){

		 if (xmlHttp.status == 200){		
		 document.getElementById("errors2").innerHTML=xmlHttp.responseText;	
		 document.getElementById(a).value='';
		 document.getElementById(b).value='';	
		 } else {
   	  	 alert("There was a problem while using XMLHTTP:\n" + xmlHttp.statusText);
		 }
	}
	}
   xmlHttp.open("GET", strURL, true);
   xmlHttp.send(null);
   
}
function showTab(id0,id,id1,id2,S,t,t1,t2){
	document.getElementById(id0).style.display="inline";
	document.getElementById(id).style.display="none";
	document.getElementById(id1).style.display="none";
	document.getElementById(id2).style.display="none";
	document.getElementById(S).className="tab_now";
	document.getElementById(t).className="tab";
	document.getElementById(t1).className="tab";
	document.getElementById(t2).className="tab";
	document.getElementById('errors').innerHTML="";
	document.getElementById('errors1').innerHTML="";
	document.getElementById('errors2').innerHTML="";
	document.getElementById('contactName').style.borderColor="#cccccc";
	document.getElementById('contactEmail').style.borderColor="#cccccc";
	document.getElementById('contactNo').style.borderColor="#cccccc";
	document.getElementById('contactName1').style.borderColor="#cccccc";
	document.getElementById('contactNo2').style.borderColor="#cccccc";
	document.getElementById('contactMassege').style.borderColor="#cccccc";
	document.getElementById('contactMassege2').style.borderColor="#cccccc";
}
function restrictToNumbers(myfield, e) {
	var key;
	var keychar;
	if (window.event) {
		key = window.event.keyCode;
	} else if (e) {
		key = e.which;
	} else {
		return true;
	}
	keychar = String.fromCharCode(key);
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) {
		return true;
	} else if ((("0123456789").indexOf(keychar) > -1)) {
		return true;
	} else {
		return false;
	}
}
