//FUNÇÃO PARA GERAÇÃO DO MENU PRINCIPAL
function trocaCor(objeto)
{
	nNos = document.getElementById('legenda-link').getElementsByTagName('a').length;

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

}

window.onload=montre;
function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=6; i++) {
		if (document.getElementById('smenu'+i)){
			document.getElementById('smenu'+i).style.display='none';
		}
	}

	if (d){
		d.style.display='block';
		d.style.visibility='visible';
	}

}
//////////////////////////////////////////////

function mostraLista(){
	document.getElementById("listaR").style.display="block";
}	

function fechaLista(){
	document.getElementById("listaR").style.display="none";
}

function mostraDestino(){
	document.getElementById("opcoesDestino").style.display="block";
}	

function fechaDestino(){
	document.getElementById("opcoesDestino").style.display="none";
}

function mostraResort(id){
	document.getElementById(id).style.display="block";
}	

function fechaResort(id){
	document.getElementById(id).style.display="none";
}

///////////////////////////////////////////////////
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 carregaFotosResort(legenda, nome_arquivo, cod_produto, cod_sub_menu)
{
	if(document.getElementById){
       
        var exibeResultado = document.getElementById("foto-player-resort");
		var exibeLegenda = document.getElementById("texto-legenda");

		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.litoralverde.com.br/layout/produtos/carregando_foto.gif";
			}

			if(Ajax.readyState == 4){
				if(Ajax.status == 200){
					var resultado = Ajax.responseText;
					resultado = "http://www.litoralverde.com.br/imagens/resorts/" + cod_produto + "/" + cod_sub_menu + "/foto" + nome_arquivo +".jpg";
					exibeResultado.src = resultado;
					exibeLegenda.innerHTML = legenda;
					
				}else{
					alert("erro");
					exibeResultado.innerHTML = "Erro: .";

				}
			}
		}
		Ajax.send(dataArray);
	}
}

function carregaFotosDestino(legenda, nome_arquivo, cod_destino, cod_sub_menu)
{
	if(document.getElementById){
       
        var exibeResultado = document.getElementById("foto-player-resort");
		var exibeLegenda = document.getElementById("texto-legenda");

		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.litoralverde.com.br/layout/produtos/carregando_foto.gif";
			}

			if(Ajax.readyState == 4){
				if(Ajax.status == 200){
					var resultado = Ajax.responseText;
					resultado = "http://www.litoralverde.com.br/imagens/destinos/" + cod_destino + "/" + cod_sub_menu + "/foto" + nome_arquivo +".jpg";
					exibeResultado.src = resultado;
					exibeLegenda.innerHTML = legenda;
					
				}else{
					alert("erro");
					exibeResultado.innerHTML = "Erro: .";

				}
			}
		}
		Ajax.send(dataArray);
	}
}


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

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


}
///////////////////////////////////////////
var popUpWin=0;
function popUpWindow_scroll(URLStr, left, top, width, height){
	if(popUpWin){
		if(!popUpWin.closed){
			popUpWin.close();
		}
	}
    popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}



var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height){
	if(popUpWin){
		if(!popUpWin.closed){
			popUpWin.close();
		}
	}
	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}



//////////////////////////////////////////////////
function adicionar_favoritos(){
	var browsName = navigator.appName;
	var url=document.location
    var site=document.title
    if (browsName == 'Microsoft Internet Explorer'){
		if (document.all){
			window.external.AddFavorite(url,site);
		}
	}else if (browsName == 'Netscape'){
		alert ('Pressione CTRL + D para adicionar esta página a seus Favoritos');
	}
}
///////////////////////////////////////////////////////
function scrollit(speed) {
var m1  = "Fuja das excursões.  ";
var m2  = "Viaje com estilo.  ";
var m3  = "Viaje com a Litoral Verde.";
var msg=m1+m2+m3;
var out = " ";
var c   = 1;
if (speed > 100) {
speed--;
cmd="scrollit("+speed+")";
timerTwo=window.setTimeout(cmd,100);
}
else if (speed <= 100 && speed > 0) {
for (c=0 ; c < speed ; c++) {
out+=" ";
}
out+=msg;
speed--;
window.status=out;
cmd="scrollit("+speed+")";
timerTwo=window.setTimeout(cmd,100);
}
else if (speed <= 0) {
if (-speed < msg.length) {
out+=msg.substring(-speed,msg.length);
speed--;
window.status=out;
cmd="scrollit("+speed+")";
timerTwo=window.setTimeout(cmd,100);
}
else {
window.status=" ";
timerTwo=window.setTimeout("scrollit(100)",75);
      }
   }
}
////////////////////////////////////////////////
function abre_produto(link_produto,cod_idioma)
{
    window.open(link_produto+'.php?cod_idioma='+cod_idioma,'_self')
}

function abre_destino(link_destino,cod_idioma)
{
    //window.open('destino-'+link_destino+'.php?cod_idioma='+cod_idioma,'_self')
	window.open(link_destino+'?cod_idioma='+cod_idioma,'_self');
}
