function horizontal() {
 
   var navItems = document.getElementById("menu_dropdown").getElementsByTagName("li");
    
   for (var i=0; i< navItems.length; i++) {
      if(navItems[i].className == "submenu")
      {
         if(navItems[i].getElementsByTagName('ul')[0] != null)
         {
            navItems[i].onmouseover=function() {this.getElementsByTagName('ul')[0].style.display="block";this.style.backgroundColor = "#f9f9f9";}
            navItems[i].onmouseout=function() {this.getElementsByTagName('ul')[0].style.display="none";this.style.backgroundColor = "#FFFFFF";}
         }
      }
   }
 
}

function openAjax(){
	var Ajax;
	try{
		Ajax = new XMLHttpRequest();
	}catch(ee){
		try{
			Ajax = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				Ajax = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				Ajax = false;
			}
		}
	}
	return Ajax;
}

function trocaCor(objeto)
{
	nNos = document.getElementById('legenda-link').getElementsByTagName('a').length;

	objeto.style.color="#FF0000";
	for (i=0;i<nNos;i++){
		if (document.getElementById('legenda-link').getElementsByTagName('a')[i] != objeto){
			document.getElementById('legenda-link').getElementsByTagName('a')[i].style.color="#000000";
		}
	}

}

function carregaFotosDestinos(id_destino, nome_arquivo)
{
	if(document.getElementById){
       
        var exibeResultado = document.getElementById("foto-destino");

		var dataArray = new Array();
		
		dataArray.push("funcao=" + "foto_produto");
		dataArray = dataArray.join("&");
		var Ajax = openAjax();

		Ajax.open("POST", "funcoes_produtos.php", true);
		
		Ajax.onreadystatechange = function()
		{
			if(Ajax.readyState == 1){
				exibeResultado.src = "http://www.resorthotelturismo.com.br/imgs/carregando_foto.gif";
			}
			
			if(Ajax.readyState == 4){
				//if(Ajax.status == 200){
					var resultado = Ajax.responseText;
					resultado = "http://www.resorthotelturismo.com.br/imgs/foto_destino/" + id_destino + "/" + nome_arquivo +".jpg";
					exibeResultado.src = resultado;
				//}
			}
		}
		Ajax.send(dataArray);
	}
}

function carregaFotosHoteis(id_pagina_hotel, nome_arquivo)
{
	if(document.getElementById){
       
        var exibeResultado = document.getElementById("foto-destino");

		var dataArray = new Array();
		
		dataArray.push("funcao=" + "foto_produto");
		dataArray = dataArray.join("&");
		var Ajax = openAjax();

		Ajax.open("POST", "funcoes_produtos.php", true);
		
		Ajax.onreadystatechange = function()
		{
			if(Ajax.readyState == 1){
				exibeResultado.src = "http://www.resorthotelturismo.com.br/imgs/carregando_foto.gif";
			}
			
			if(Ajax.readyState == 4){
				//if(Ajax.status == 200){
					var resultado = Ajax.responseText;
					resultado = "http://www.resorthotelturismo.com.br/imgs/foto_hotel/" + id_pagina_hotel + "/" + nome_arquivo +".jpg";
					exibeResultado.src = resultado;
				//}
			}
		}
		Ajax.send(dataArray);
	}
}

function abre_link(link_produto)
{
	if(link_produto != 'nda')
   		window.open(link_produto,'_self');
}

function abre_roteiro(id_roteiro)
{
	if(id_roteiro != 'nda')
   		window.open('resort_roteiro.php?roteiro='+id_roteiro,'_self');
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function mostra_div(nome)
{
	if(navigator.appName == "Microsoft Internet Explorer")	
		document.getElementById(nome).style.display="block";
	else
		document.getElementById(nome).style.display="table-row";
}

function esconde_div(nome)
{
	document.getElementById(nome).style.display="none";
}

function getScrollY()
{
	var scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' )
		scrOfY = window.pageYOffset;
	else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
		scrOfY = document.body.scrollTop;
	else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
		scrOfY = document.documentElement.scrollTop;
	return scrOfY;
}

function sair_flutuante(elemento)
{
	idElemento = document.getElementById(elemento);
	idElementoPai = idElemento.parentNode;
	idElementoPai.removeChild(idElemento);
}

function flutuante(pg,elemento,width,height)
{
	if(document.getElementById(elemento)){
		var scrollTop = getScrollY();
		banner = document.getElementById(elemento);
		banner.style.top = (scrollTop + 80) + 'px';
	}
	else
	{
		var banner = document.createElement('div');
		banner.setAttribute('id',elemento);
		banner.innerHTML  = '<div id="fechar" ><a href="javascript:void(0);" onClick="javascript:sair_flutuante(\'' + elemento + '\')">fechar X</a></div><iframe scrolling="no" frameborder="0" src="' + pg + '" style="padding:0px; margin:0px; width:' + width + 'px; height:' + height + 'px;" name="area' + elemento + '" ></iframe>';
		
		
		var scrollTop = getScrollY();
		if(elemento == 'orcamento')
			banner.style.top = (scrollTop + 80) + 'px';
		else
			banner.style.top = (scrollTop + 80) + 'px';

		document.body.appendChild(banner);
		
		if(elemento == "orcamento")
			areaorcamento.window.location = pg;
		else
			areaamigo.window.location = pg;

	}
}

function addFav(titulo)
{
	var url = document.location;
    	
	if (window.sidebar) window.sidebar.addPanel(titulo, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',titulo);
        mbm.click();
    }
    else if (document.all)
			window.external.AddFavorite(url,titulo);
}






function orcamento(pg,elemento,width,height)
{
		var saida = document.getElementById("texto");
		var banner = document.createElement('div');
				
		banner.innerHTML  = '<iframe scrolling="auto" frameborder="0" src="' + pg + '" style="width:' + width + '; height:' + height + ';" ></iframe>';
		
		saida.appendChild(banner);
}
/*function orcamento(hotel){
   	var saida = document.getElementById("texto");
   	var nova = document.createElement('div');
   	nova.innerHTML = '<div id="fechar" ><a href="javascript:void(0);" onClick="javascript:sair_flutuante(\'' + elemento + '\')">fechar X</a></div><img src="' + pg + '" border="0" alt="Promoção relâmpago!" />';
   	saida.appendChild(nova);
   
   
   
   //saida.scrollTop = 100000; // rolagem da pagina automática.
	//parent.frameEnvio.document.formAjax.msg.focus();
	//window.self.focus();
	//requisicaoHTTP("GET","apagar.php?m="+msg,true);
}*/
