var divD = "";
var divE = "";
var divT = "";

function get(id) { 
	try { 
		var a = document.getElementById(id); 
	} catch(e) { 
		alert("Erro encontrado: "+e); 		
	} 
	return 	a;
}

function $(id) { 
	try { 
		var a = document.getElementById(id); 
	} catch(e) { 
		alert("Erro encontrado: "+e); 		
	} 
	return 	a;
}
function rolaE(id) {
	var obj = $('div_imgs_'+id);
	var left = obj.style.left;
	left = parseInt(left.replace("px",""));
	if(left!=0)	
	{
		valor = left;
		valor = valor + 4;
		
		obj.style.left = valor+"px";
	} else {
		clearInterval(divE);
	}
}
function rolaD(id) {
	var obj = $('div_imgs_'+id);
	var num = ($('num_imgs_'+id).value)-3;
	var left = obj.style.left;
	left = left.replace("px","");
	
	var aux = (num * 58);
	
	if(num<=4)
		aux += - 4;
	var auxLeft = left.replace('-',"");

	if(aux>auxLeft)
	{		
		valor = left-4;
		obj.style.left = valor+"px";
	} else {
		clearInterval(divD);
	}
}

function rolaDivD(id, init) {
	if(init=="start")	{
		divD = setInterval("rolaD("+id+")",50);	

	} else {
		clearInterval(divD);
	}
}
function rolaDivE(id,  init) {
	if(init=="start")	{
		divE = setInterval("rolaE("+id+")",50);	
	} else {
		clearInterval(divE);
	}
}
function abreGaleria() {
	
}
function getRequest ()
{
    var xmlhttp = null;
    
    try
    {
        xmlhttp = new XMLHttpRequest();
    }
    catch(ee)
    {
        try
        {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            try
            {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(E)
            {
                xmlhttp = false;
            }
        }
    }
    
    return xmlhttp;
}
function abrePg(pagina ,tabela, where, local)
{	
	var url = "";
	if(!pagina)
		url = "";
	else
		url = "&"+pagina;
		
    var pagina = new Ajax();
	pagina.setLoader($("loader_img"));
	pagina.loadContent("galeria.php?tabela="+tabela+"&where="+where+"&local="+local+url,$(local));
}
function abrirImagem(src) {
    var a_false = document.createElement("A");
    a_false.rel = "lightbox";
    a_false.href = src;
    //chamando a funçao do lightbox responsável pelo início das açoes
    myLightbox.start(a_false);
    //anulando o link
    a_false = null;
}
function abreFotos(codigo, nome) {
	var chave = Math.round(Math.random()*2000);
	var obj = document.getElementById("fotosResort");	
	var swf = "<div id=\"flash"+chave+"\" style=\"background:#FFFFFF;\"></div>";
	obj.innerHTML = swf;	
	var fo = new FlashObject("swf/galeria.swf?dir=tb_estrutura&codigo="+codigo+"&titulo="+nome+"&subtitulo=Resort", "770", "480", "235", "#333333", true);
	fo.addParam("scale", "noscale");
	fo.addParam("wmode", "transparent");
	fo.addParam("wmode", "opaque");
	fo.write("flash"+chave);
}
function checkPromo() {
 with(document.contato) {
   if(nome.value.length < 5 || nome.value==""){
	   alert("Preencha Corretamente seu Nome");
	   nome.focus();
	   return false;
   }
   if(cidade.value==""){
	   alert("Digite sua cidade!");
	   cidade.focus();
	   return false;
   }
   if(estado.value==""){
	   alert("Digite seu Estado!");
	   estado.focus();
	   return false;
   }
   if(telefone.value==""){
	   alert("Digite seu Telefone!");
	   telefone.focus();
	   return false;
   }
   if(email.value=="") {   
	   alert('Digite seu E-mail!');
	   email.focus();
	   return false;
   }
   if(email.value!="") {   
	   if (email.value.indexOf('@') < 1) {
		   alert('O seu endereço de e-mail não é válido.');
		   email.focus();
		   return false;
	   }
   }
	
 }		
}
function descer(id) {
	var obj = $(id);
	var top = obj.style.top;
	top = parseInt(top.replace("px",""));
	
	if(top<0) {
		valor = top;
		valor = valor + 4;
	
		obj.style.top = valor+"px";
	} else {
		clearInterval(divT);	
	}
	
}
function subir(id) {
	var obj = $(id);
	var top = obj.style.top;
	top = parseInt(top.replace("px",""));
	
	var num = ($("num_acont").value) - 4;
	var aux = num * -35;

	if(top>aux) {
		valor = top;
		valor = valor - 4;
		obj.style.top = valor+"px";
	} else {
		clearInterval(divT);
	}
}

function sobeDiv(id, init) {
	if(init=="start")	{
		divT = setInterval("subir('"+id+"')",50);	

	} else {
		clearInterval(divT);
	}
}
function desceDiv(id,  init) {
	if(init=="start")	{
		divT = setInterval("descer('"+id+"')",50);	
	} else {
		clearInterval(divT);
	}
}
