var xmlHttp0800;
var div0800;
var funcaoretry0800;
function GetXmlHttpObject0800()
{
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}
function ligar0800(pref,suf,btfechar)
{
		//alert("p:"+pref+" s:"+suf);
		//alert("d1");
		var p = document.getElementById(pref).value;
		var n = document.getElementById(suf).value;
	   // alert("d2");
		
		document.getElementById(div0800).innerHTML = "<table bgcolor=\"#999999\" cellspacing=1 cellpadding=10 align=center><tr><td bgcolor=\"#EEEEEE\"><img src=\"/images/loading-gif-animation.gif\"> <span style=\"font-size:13px;font-weight:bold;\">Processando ligação...</span></td></tr></table>";
		
		//alert("d3");
		xmlHttp0800=GetXmlHttpObject0800();
		xmlHttp0800.onreadystatechange=stateChanged0800;
		//alert("d4");
		var url = "/callback0800.php?op=call&prefixo="+p+"&numero="+n+"&cmp_pref="+pref+"&cmp_num="+suf+"&btfechar="+btfechar;
		xmlHttp0800.open("GET",url,true);
		//alert("d5");
		xmlHttp0800.send(null);
		var lt = setTimeout("ligacao0800checartimeout()",50000);
		//alert("d6");
}
function ligacao0800checartimeout()
{
	if (xmlHttp0800)
		if (xmlHttp0800.readyState!=4 && xmlHttp0800.readyState!="complete") ligacao0800timeout();
}
function ligacao0800timeout()
{
		xmlHttp0800.abort();
		xmlHttp0800=null;
		document.getElementById(div0800).innerHTML = "<table bgcolor=\"#999999\" cellspacing=1 cellpadding=10><tr><td bgcolor=\"#EEEEEE\"><table border=0><tr><td valign=top><img src=\"images/x_vermelho.gif\"></td><td align=center valign=top><span style=\"font-size:13px;font-weight:bold;\">Sua chamada não pode ser completada: rede ocupada<br><input type=button value=\"Tentar novamente\" onClick=\""+funcaoretry0800+";\" style=\"font-size:12px;font-weight:bold;width:120px;margin-top:5px;\"></span></td></tr></table></td></tr></table>";
}
function ligacao0800celular()
{
		//alert("Servico desabilitado para celular");
		//document.getElementById('telcidade').innerHTML = "<table bgcolor=\"#999999\" cellspacing=1 cellpadding=10><tr><td bgcolor=\"#EEEEEE\"><table border=0><tr><td valign=top><img src=\"images/x_vermelho.gif\"></td><td align=center valign=top><span style=\"font-size:13px;font-weight:bold;\"> Para utilizar o 0800 informe um telefone fixo.<br><input type=button value=\"Tentar novamente\" onClick=\"escreveTelCidade();\" style=\"font-size:12px;font-weight:bold;width:120px;margin-top:5px;\"></span></td></tr></table></td></tr></table>";
}
function ligacao0800ok()
{
		document.getElementById(div0800).innerHTML = "<table bgcolor=\"#999999\" cellspacing=1 cellpadding=10><tr><td bgcolor=\"#EEEEEE\"><img src=\"/images/v_verde.gif\"> <span style=\"font-size:13px;font-weight:bold;\">Ligação concretizada!</span></td></tr></table>";

}
function fechar0800()
{
		//alert("--"+div0800); 
		document.getElementById(div0800).style.visibility="hidden";
		document.getElementById(div0800).style.display="block";
		document.getElementById('telefones').style.visibility="hidden";
		document.getElementById('telefones').style.display="block";
				
		div0800='';
}
function stateChanged0800()
{
	//alert(xmlHttp.readyState);
	
	if (xmlHttp0800.readyState==4 || xmlHttp0800.readyState=="complete")
	{
//		document.getElementById("exibe_cidade").innerHTML=xmlHttp.responseText
		document.getElementById(div0800).innerHTML = xmlHttp0800.responseText;
		xmlHttp0800=null;		
	}
	
} 