  function verViaSatelite(satEnd, cidade,estado) {
	 
	window.open("localizacaoSatelite.php?endereco="+satEnd+"&cidade="+cidade+"&estado="+estado,"_blank", "location=NO, width="+screen.width+", height="+screen.height);
  }
  function abrirJanela(url, name) {
	window.open(url, name, 'scrollbars=no,resizable=no,width=550,height=400');
  }
  function abreJanelaFotos(caminho, nome) {
    window.open(caminho,nome,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=800,height=400,left=0,top=0');
  }

  function abreJanelaCliente(caminho, nome) {
    window.open(caminho,nome,'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=680,height=500,left=0,top=0');
  }

  function abreJanelaContrato(caminho, nome) {
    window.open(caminho,nome,'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=600,height=340,left=0,top=0');
  }

	function abrirJanela_TamanhoDefinido(url, name, altura, largura, topo, esquerda) {
		window.open(url, name, 'scrollbars=no,resizable=no,height='+altura+',width='+largura+'top='+topo+',left='+esquerda);
	}

// apartir daqui

var num = 0;
function carregarCidade(num)
{
  this.num = num;
  if(num == 3) {
	   location.href = "index.php?pag=40";  
  }
  http.open("GET", "includes/busca_simples.php?opcao="+num+"&comando=consultarCidade", true);
  http.onreadystatechange = handleHttpResponseCid;
  http.send(null);
}

function handleHttpResponseCid()
{
  campo_select = document.formBusca.cidade;
  if (http.readyState == 4) {
    campo_select.options.length = 0;
    results = http.responseText.split(",");
    for( i = 0; i < results.length; i++ )
    { 
      string = results[i].split( "|" );
      campo_select.options[i] = new Option( string[0], string[1] );
    }
	 carregarBairro(num);
  }
}
function carregarBairro(num)
{ 
  http.open("GET", "includes/busca_simples.php?opcao="+num+"&comando=consultarBairro", true);
  http.onreadystatechange = handleHttpResponseBair;
  http.send(null);
}
function carregarTipos(num)
{ 
  http.open("GET", "includes/busca_simples.php?opcao="+num+"&comando=consultarTipo", true);
  http.onreadystatechange = handleHttpResponseTip;
  http.send(null);
}
function carregarBairroCid(num,cid)
{ 
  http.open("GET", "includes/busca_simples.php?opcao="+num+"&comando=consultarBairro&cidade="+cid, true);
  http.onreadystatechange = handleHttpResponseBair;
  http.send(null);
}

function handleHttpResponseBair()
{
  if (http.readyState == 4) {
    campo_text = http.responseText;
	 document.getElementById('bairro').innerHTML = campo_text;
	 carregarTipos(num)
  }
}
function handleHttpResponseTip()
{
  campo_select = document.frmBusca.tipo;
  if (http.readyState == 4) {
    campo_select.options.length = 0;
    results = http.responseText.split(",");
    for( i = 0; i < results.length; i++ )
    { 
      string = results[i].split( "|" );
      campo_select.options[i] = new Option( string[0], string[1] );
    }
  }
}
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var http = getHTTPObject();
function formataValorMonetario(campooriginal,decimais)
{
 var posicaoPontoDecimal;
 var campo = '';
 var resultado = '';
 var pos,sep,dec;

 //Retira possiveis separadores de milhar
 for (pos=0; pos < campooriginal.value.length; pos ++)
 {
  if (campooriginal.value.charAt(pos)!='.')
	campo = campo + campooriginal.value.charAt(pos);
 }     

 //Formata valor monetário com decimais
 posicaoPontoDecimal = campo.indexOf(',');
 if (posicaoPontoDecimal != -1)
 {
  sep = 0;
  for (pos=posicaoPontoDecimal-1;pos >= 0;pos--)
  {
	sep ++;
	if (sep > 3)
	{
		resultado = '.' + resultado;
		sep = 1;
	}

	resultado = campo.charAt(pos) + resultado;   
  }

  // Trata parte decimal
  if (parseInt(decimais) > 0 )
  {
	 resultado = resultado + ',';
  
	 pos=posicaoPontoDecimal+1;
	 for (dec = 1;dec <= parseInt(decimais); dec++)
	 {
		if (pos < campo.length)
		{
		  resultado = resultado + campo.charAt(pos);
		  pos++;
		}
		else
		  resultado = resultado + '0';   
	 }

  } // trata decimais
}
// Trata valor monetário sem decimais
else
{
  sep = 0;
  for (pos=campo.length-1;pos >= 0;pos--)
  {
	sep ++;
	if (sep > 3)
	{
		resultado = '.' + resultado;
		sep = 1;
	}
	resultado = campo.charAt(pos) + resultado;   
  }
  // Trata parte decimal
  if (parseInt(decimais) > 0 )
  {
	 resultado = resultado + ',';
	 for (dec = 1;dec <= parseInt(decimais); dec++)
	 {
		  resultado = resultado + '0';   
	 }
  } // trata decimais
}
campooriginal.value = resultado;
}
function validaNumeros(campo, event)
{
  var BACKSPACE= 8;
  var key;
  var tecla;
	
  CheckTAB=true;
  if (navigator.appName.indexOf("Netscape")!= -1) 
	tecla= event.which;
  else
	tecla= event.keyCode;
	 
  key = String.fromCharCode( tecla);
	
  if (tecla == 13) return false;
	 
  if (tecla == BACKSPACE) return true;
	 
  return (numerico(key));
} // fim da funcao validaTecla 
function numerico(caractere)
{
  var strValidos = "0123456789"
  if (strValidos.indexOf(caractere) == -1) return false;
  return true;
}
function carregar() {
  //carregarCidade(1);
  //carregarCaracsAv(1,2); 
}
function carregar2(opc) {
  if(opc != 0){
	  tip = document.getElementById('opcao').value;
	  if(opc == 1) {
	  carregarCaracsAv(1,tip);
	  }else if(opc == 2) {
	  carregarCaracsAv(2,tip);
	  }else{
		  document.getElementById('caracsAv').innerHTML = '';
	  }
  }
}
function carregarDados()
{
  http.open("GET", "noticia_acesso.php?comando=buscarTodos", true);
  http.onreadystatechange = handleHttpResponseDefault;
  http.send(null);
}

function handleHttpResponseDefault() {
  //campo_select = document.formBusca.cidade;
  if (http.readyState == 4) {
	 campo_text = http.responseText;
	 //document.getElementById('noticia').innerHTML = campo_text; 
  }
}
function buscarNot(cod) { 
  http.open("GET", "noticia_acesso.php?comando=buscarNoticia&codigo="+cod, true);
  http.onreadystatechange = handleHttpResponseDefault;
  http.send(null);
}

function enviarNews(email,nome,tipo) {
  http.open("GET", "includes/newsletter_dao.php?comando=enviar&nome="+nome+"&email="+email+"&tipo="+tipo, true);
  http.onreadystatechange = handleHttpResponseNws;
  http.send(null);
}

function retirarNews(email,nome,tipo) {
  http.open("GET", "includes/newsletter_dao.php?comando=retirar&nome="+nome+"&email="+email+"&tipo="+tipo, true);
  http.onreadystatechange = handleHttpResponseNws;
  http.send(null);
}

function buscarNoticia(cod) { 
  http.open("GET", "noticia_acesso.php?comando=buscarNoticia&status=1&codigo="+cod, true);
  http.onreadystatechange = handleHttpResponseDefault;
  http.send(null);
}

function carregarNoticias(dat)
{ 
  http.open("GET", "noticia_acesso.php?comando=carregarNoticias&data="+dat, true);
  http.onreadystatechange = handleHttpResponseDefault;
  http.send(null);
}
function carregarNoticiasExp(param) {
  http.open("GET", "noticia_acesso.php?comando=carregarNoticias&parametro="+param, true);
  http.onreadystatechange = handleHttpResponseDefault;
  http.send(null);
}

function handleHttpResponseNws()
{
  if (http.readyState == 4) {
     campo_text = http.responseText;
	  alert(campo_text);
	  location.href = "index.php";
  }
}
function carregarBanner(pag)
{
var tempo = 0;
  http.open("GET", "banner.php?pag="+pag, true);
  http.onreadystatechange = handleHttpResponseBanner;
  http.send(null);
  tempo = 27000;
  setTimeout("carregarBanner()",tempo);
}
function handleHttpResponseBanner()
{
  if (http.readyState == 4) {
     campo_text = http.responseText;
	  //alert(campo_text);
	  document.getElementById('banner').innerHTML = campo_text;
  }
}
