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 ss(){
document.getElementById('merrors').innerHTML="";
document.getElementById('mobile_no').style.borderColor="#cccccc";
document.getElementById('mobile_no').focus();
}

function mainCall(){
	if(document.getElementById('mobile_no').value==''){
	document.getElementById('merrors').innerHTML=" <a href='javascript:void(0);' onclick='ss();'>X</a>";
	document.getElementById('mobile_no').style.borderColor="red";
	document.getElementById('mobile_no').focus();
	return false;	
	} else {
	var url = "mainno="+document.getElementById('mobile_no').value;	
	}

   var strURL="ajax.php?id=4&"+url;
   var xmlHttp = GetXmlHttpObject();
  	xmlHttp.onreadystatechange=function(){ 
	 if (xmlHttp.readyState == 1 || xmlHttp.readyState == 2 || xmlHttp.readyState == 3){
	 document.getElementById("retval").innerHTML="<div style='text-decoration:blink;'>Connecting Please Wait....</div>";
	}

	if (xmlHttp.readyState==4){

		 if (xmlHttp.status == 200){	
		 document.getElementById("retval").innerHTML='<div id="retval">Your Mobile : <input type="text" name="mobile_no" id="mobile_no" value="" maxlength="10" onkeypress="return restrictToNumbers(this, event)" size="9"> <font id="merrors"></font>  <input type="button" value="Call" onclick="return mainCall();"></div>';
		 document.getElementById(a).value='';		
		 } else {
   	  	 alert("There was a problem while using XMLHTTP:\n" + xmlHttp.statusText);
		 }
	}
	}
   xmlHttp.open("GET", strURL, true);
   xmlHttp.send(null);
   
}


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;
	}
}
