//CRIA A VARIÁVEL RETORNO
var retorno;
function CarregaArquivo(url,valor)
{
    retorno = null;
	//CRIA O OBJETO HttpRequest PARA O RESPECTIVO NAVEGADOR
	//Mozilla Fire Fox / Safari ...
	//
    if (window.XMLHttpRequest) {
        retorno = new XMLHttpRequest();
		//SETA A FUNÇÃO QUE SERÁ CHAMADA QUANDO O AJAX DER UM RETORNO
        retorno.onreadystatechange = processReqChange;
		 //ABRE A REQUISIÇÃO AJAX, PASSANDO O MÉTODO DE ACESSO, URL E O PARÂMETRO
        retorno.open("GET", url+'?segmentos='+valor, true);
		//INICIA O TRANSPORTA DOS OBJETOS NA REQUISIÇÃO
        retorno.send(null);
    } else if (window.ActiveXObject) {
		//
		//IE
		//
        retorno = new ActiveXObject("Microsoft.XMLHTTP");
        if (retorno) {
			//SETA A FUNÇÃO QUE SERÁ CHAMADA QUANDO O AJAX DER  UM RETORNO
            retorno.onreadystatechange = processReqChange;
		    //ABRE A REQUISIÇÃO AJAX, PASSANDO O MÉTODO DE ACESSO, URL E O PARÂMETRO
            retorno.open("GET", url+'?segmentos='+valor, true);
			//INICIA O TRANSPORTA DOS OBJETOS NA REQUISIÇÃO
            retorno.send();
        }
    }
}
//FUNÇÃO QUE TRATA O RETORNO DO AJAX
function processReqChange()
{
	//CASO O STATUS DO AJAX SEJA OK, CHAMA A FUNÇÃO mudar()
	//A LISTA COMPLETA DOS VALORES readyState É A SEGUINTE:
	//0 (uninitialized) 
	//1 (a carregar) 
	//2 (carregado) 
	//3 (interactivo) 
	//4 (completo) 
    if (retorno.readyState == 4)
	{
		if(retorno.status == 200) 
			{
				//PROCURA PELA DIV MOSTRACOMBO E INSERE O OBJETO
				document.getElementById('pesquisarEstados').innerHTML = retorno.responseText;
			} 
				else 
				{
					//MOSTRA UM ALERTA AO OBTER UM RETORNO DE OK.
					alert("Houve um problema ao obter os dados:\n" + retorno.statusText);
				}
   }
}

//FUNÇÃO MUDAR, QUE CHAMA AS INFORMAÇÕES PASSADAS NO PARÂMETRO E CARREGA O ARQUIVO EXTERNO
function mudar(valor)
{
	//CARREGA O ARQUIVO EXTERNO DO AJAX
    CarregaArquivo("mostra_roteiros.php",valor);
}
function mudar_busca(valor)
{
	//CARREGA O ARQUIVO EXTERNO DO AJAX
    CarregaArquivo("mostra_roteiros_busca.php",valor);
}

function correctPNG()
   {
   for(var i=0; i<document.images.length; i++)
      {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText
         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
         img.outerHTML = strNewHTML
         i = i-1
         }
      }
   }
window.attachEvent("onload", correctPNG);

function mostrar(id){
	var mostrar = document.getElementById(id);
	if (mostrar.style.display != "none")
	{		
	mostrar.style.display = "block";
	}
}

function mostrar1(id){
	var mostrar = document.getElementById(id);
	if (mostrar.style.display != "5435")
	{		
	mostrar.style.display = "none";
	}
}

function apagavalue(){

document.newsletter.email.value = "";
}
function escrevevalue(){

document.newsletter.email.value = "Digite seu e-mail";
}
function enviadados(){

document.newsletter.submit();

}

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
var pageTracker = _gat._getTracker("UA-8920543-1");
pageTracker._trackPageview();
} 
catch(err)
{
}

function abrir(URL){
	window.open
	(URL,'popup', 'width=690 , height=450, top=99, left=99, scrollbars = yes, status=no, toolbar=no, location = no, directories=no, menubar=no, resizable=no, fullscreen=no');}
function abrirflash(URL){
	window.open
	(URL,'popup', 'width=685 , height=800, top=0, left=99, scrollbars = yes, status=no, toolbar=no, location = no, directories=no, menubar=no, resizable=no, fullscreen=no');}


function carregaDados()
{
	document.body.style.display = "block";	
}
function pegaURL()
{
	return url;
}

function abreconheca1(){
window.open('conheca/montando.html', 'LoginCliente', 'status=no,width=600,height=400,top=200,left=250');
}
function abreconheca2(){
window.open('conheca/disponiveis.html', 'LoginCliente', 'status=no,width=600,height=400,top=200,left=250');
}

function gerarEstados(e) {
if (e.selectedIndex != '') {
var segmentos = e.value;
document.location=('?segmentos=' + segmentos + '&tipo=' + e.id);
}
}

function visualizacao()
{
	document.getElementById('hotel_internacional').style.display = 'none';
	if(document.getElementById('tipo_segmento').value == null)
	{
		return false;	
	}
	else if(document.getElementById('tipo_segmento').value == "segmentosI")
	{
	document.getElementById('select_nacionais').style.display = "none";
	document.getElementById('select_internacionais').style.display = "block";
	document.getElementById('select_nacionais_aba').style.display = "none";
	document.getElementById('select_internacionais_aba').style.display = "block";
	
	}
	else
	{
	document.getElementById('select_nacionais').style.display = "block";
	document.getElementById('select_internacionais').style.display = "none";	
	}
	
}
