
 var dot = ".";
 var phone = "" ; 
 var phone1 = "" ; 
 var phone2 = "" ; 
 var phone3 = "" ; 
 
function calling_agent_go(){
	

// in_to_table  = 'Calling'+ dot + " " +phone   ; 
 if( dot.length  <= 3){
	dot = dot + "." ; 
	
 }else{
	 dot = ".";
 }
 document.getElementById("calling_agent1").innerHTML = 'Calling'+ dot;
 document.getElementById("calling_agent2").innerHTML = phone1 + "-" + phone2 +"-" + phone3;
	// alert(dot);
	setTimeout("calling_agent_go();",1000);

}


function call_agent()
{ 
xmlHttp=GetXmlHttpObject41()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
 	phone = document.getElementById("phone1").value;
	phone = phone +  document.getElementById("phone2").value;
	phone = phone + document.getElementById("phone3").value;
 	phone1 = document.getElementById("phone1").value;
	phone2 = document.getElementById("phone2").value;
	phone3 = document.getElementById("phone3").value;
	if(validateSignedInt(phone) == "1" && phone.length  == 10){
		var urlcaling="";
	//	urlcaling= "http://control.phone.com/voip/call/me/5334abde24b66900ba3ecc4713403c98?action=call&number=" + phone + "&private=on" ;
		urlcaling = "/lib/caller.php?phone=" + phone ;
		
		//alert(url);
		xmlHttp.onreadystatechange=stateChanged41 
		xmlHttp.open("GET",urlcaling,true)
		xmlHttp.send(null)
	}else{
		
	}
}
function stateChanged41() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 	calling_agent_go();
 } 
}
function GetXmlHttpObject41()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}



 function validateSignedInt(info)
   {
      var s = info;
      switch(isSignedInteger(s))
      {
         case true:
            return("1");
            break;
         case false:
            return("0");
      }
   }

   function isEmpty(s)
   {
      return ((s == null) || (s.length == 0))
   }
   function isDigit (c)
   {
      return ((c >= "0") && (c <= "9"))
   }
   function isInteger (s)
   {
      var i;

      if (isEmpty(s))
      if (isInteger.arguments.length == 1) return 0;
      else return (isInteger.arguments[1] == true);

      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);

         if (!isDigit(c)) return false;
      }

      return true;
   }
   function isSignedInteger (s){ 
   
   if (isEmpty(s))
      if (isSignedInteger.arguments.length == 1) return false;
      else return (isSignedInteger.arguments[1] == true);

      else {
         var startPos = 0;
         var secondArg = false;

         if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

         // skip leading + or -
         if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
            startPos = 1;
         return (isInteger(s.substring(startPos, s.length), secondArg))
      }
   }
