/* Z START */
function EVENTO(var2){
if (var2 == 1) {
document.all.LEVENTO1.style.display='block';
document.all.LEVENTO2.style.display='none';
}
else if(var2 == 2) {
document.all.LEVENTO1.style.display='none';	
document.all.LEVENTO2.style.display='block';
	}
}

function VerificaResolucao() {

try {
	var resolution = screen.width;
	var leftCalendario
	if (resolution == 800){
		leftCalendario = 369;
	}

	if (resolution == 1024){
		leftCalendario = 481;
	}

	if (resolution == 1152){
		leftCalendario = 545;
	}

	if (resolution == 1280){
		leftCalendario = 440;
	}
	document.all.pop1.style.left=leftCalendario
	document.all.pop2.style.left=leftCalendario
	document.all.pop3.style.left=leftCalendario
	document.all.pop4.style.left=leftCalendario
} catch(e) {}

}

function RESERVA(var1){
if (var1 == 1) {
document.all.LRESERVA01.style.display='block';
document.all.LRESERVA02.style.display='none';
}
else if(var1 == 2) {
document.all.LRESERVA01.style.display='none';	
document.all.LRESERVA02.style.display='block';
	}
}

function hl_menu(menu){
	for (i=1;i<=7;i++){
		$('menu_'+i).style.background = '#343A56';
	}
	if(menu != 'off'){
		$('menu_'+menu).style.background = '#555d7c';
	}	
}

function selecionaHotel(numHotel){				
	if (numHotel !='')
	{
		endereco = "../hoteis_e_resorts/conceito.asp?secao=hoteis_e_resorts&pagina=conceito&numhotel=" + numHotel;		
		window.location.href= endereco;
	}		
}
	
	
function selecionaCidade(numCidade){				
	if (numCidade !='')
	{
		endereco = "../hoteis_e_resorts/lista_hotel.asp?secao=nossos_hoteis&pagina=listagem&filtro=cidade&numcidade=" + numCidade;		
		window.location.href= endereco;
	}		
}
	
function localizacaoClick(){
	if (document.all.cidade.value != ''){
		if (document.all.cidade.value ==0){
			document.location='../hoteis_e_resorts/lista_hotel.asp?secao=nossos_hoteis&pagina=listagem';
		}
		else{
			document.location='../hoteis_e_resorts/lista_hotel.asp?secao=nossos_hoteis&pagina=listagem&filtro=cidade&numcidade='+document.all.cidade.value;
		}
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function CarregaCombo(id)
{
	if(pagina == 'enderecos_e_telefones'){
		document.all.exibe_hotel.innerHTML = '<span class="TextoCinzaEscuro">Carregando...</span>';
		cp.call('../_cpaint/RetornaSelectHotel.asp', 'RetornaTabelaHotel', Retorna, id);
	}else{		
		document.all.exibe_promocao.innerHTML = '<span class="TextoCinzaEscuro">Carregando...</span>';
		cp.call('../_cpaint/RetornaSelectHotelPromocao.asp', 'RetornaPromocao', Retorna, id);
	}
}

function Retorna(result) 
{
	if(pagina == 'enderecos_e_telefones'){
		document.all.exibe_hotel.innerHTML = unescape(result.replace(/\+/g,  " "));
	}else{		
		document.all.exibe_promocao.innerHTML = unescape(result.replace(/\+/g,  " "));
	}	
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function abreHoteis(){
	document.getElementById('TodosHoteis').style.display = 'block';
	document.getElementById('btnMais').style.display = 'none';
	document.getElementById('btnMenos').style.display = 'block';
}

function fechaHoteis()
{
	document.getElementById('TodosHoteis').style.display = 'none';
	document.getElementById('btnMais').style.display = 'block';
	document.getElementById('btnMenos').style.display = 'none';
}

function ValidaSubmite(form)
{
	if (Validacao(form))
	{
		//alert('entro');
		//cadastro
		if (document.all.cmbTipoMontagem.value)
		{
			//alert('entro if');
			document.all.hddTipoMontagem.value = document.all.cmbTipoMontagem.value;
			document.all.hddNumeroParticipantes.value = document.all.txtNumeroParticipantes.value;
			
			//alert(document.all.hddTipoMontagem.value);
			//alert(document.all.hddNumeroParticipantes.value);
		}
		else
		{
			//alert('entro else');
			var TotalComplemento = document.all.cmbTipoMontagem.length;
			var xcmbTipoMontagem = '';
			var xtxtNumeroParticipantes = '';
			for (var i = 0; i < TotalComplemento; i++)
			{
				if (!document.all.cmbTipoMontagem[i].value==''&&!document.all.txtNumeroParticipantes[i].value=='')
				{
				
					xcmbTipoMontagem += document.all.cmbTipoMontagem[i].value + '|';
					xtxtNumeroParticipantes += document.all.txtNumeroParticipantes[i].value + '|';

				}
			}
						
			document.all.hddTipoMontagem.value = xcmbTipoMontagem;
			document.all.hddNumeroParticipantes.value = xtxtNumeroParticipantes;			
			
		}
		
		var QuantidadeHoteis = document.all.outros_hoteis.length;
		var strOutrosHoteis = '';
		for (var i = 0; i < QuantidadeHoteis;i++ )
		{
			if(document.all.outros_hoteis[i].checked)
			{				
				strOutrosHoteis += document.all.outros_hoteis[i].value + '|';
			}
		}		
		document.all.hddOutrosHoteis.value = strOutrosHoteis;
				
		if (document.all.txtEmpresa.value.length > 0)
		{
			if (isNaN(document.all.txtCNPJ.value) || isEmpty(document.all.txtCNPJ.value))
			{
				alert('O campo CNPJ deve conter um número.');
				document.all.txtCNPJ.focus();
				return false;
			}
			if (document.all.txtCNPJ.value.length < 14)
			{
				alert('Por favor,\nPreencha o CNPJ da sua empresa com 14 caracteres.');
				document.all.txtCNPJ.focus();
				return false;
			}
		}
		
		return true;
	} 
	return false;		
}

/* Z END */
function formatar(src, mask) 
{
  var i = src.value.length;
  var saida = mask.substring(0,1);
  var texto = mask.substring(i)
if (texto.substring(0,1) != saida) 
  {
	src.value += texto.substring(0,1);
  }
}

// Permite apenas número no campo
// onKeyPress="return checkIt(event)"
function checkIt(evt) {
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode

	if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 44 ) {
		alert ("Por favor\nUtilize apenas números")
		return false
	}
	return true
}

var show = 'S';
var hide = 'H';

function showHide(theID, action) {
	var obj = document.all.item(theID);
	var strDsp;
	if (action)
		strDsp = (action == show ? 'block' : 'none');
	else
		strDsp = (document.getElementById(theID).style.display == 'block' ? 'none' : 'block');
	if (obj.length) {
		for (var i=0; i<obj.length; i++)
			obj[i].style.display = strDsp;
	} else 
		obj.style.display = strDsp;
	
	return ( (strDsp == 'block') ? true : false);
}

function abreMapaG(theID, action) {
	document.all.google_maps.style.display = 'block';
	document.all.mapa_antigo.style.display = 'none';
}

function abreMapaA(theID, action) {
	document.all.mapa_antigo.style.display = 'block';
	document.all.google_maps.style.display = 'none';
}

function abreJANELA(url,parametro) {
   JANELA = window.open(url,'JANELA',parametro);
}

function ResizeColunas()
	{
		var intConteudo = document.all.tblConteudo.scrollHeight;
		
		//alert(intConteudo);

		document.all.tdDireita.height = intConteudo;	
		document.all.tdEsquerda.height = intConteudo;	
	}

function popdate(obj,div,tam,ddd)
{
   if (ddd) 
   {
       day = ""
       mmonth = ""
       ano = ""
       c = 1
       char = ""
       for (s=0;s<parseInt(ddd.length);s++)
       {
           char = ddd.substr(s,1)
           if (char == "/") 
           {
               c++; 
               s++; 
               char = ddd.substr(s,1);
           }
           if (c==1) day    += char
           if (c==2) mmonth += char
           if (c==3) ano    += char
       }
       //ddd = mmonth + "/" + day + "/" + ano
	   ddd = ano + "/" + mmonth + "/"  + day   
   }
 
   if(!ddd) {today = new Date()} else {today = new Date(ddd)}
   date_Form = eval (obj)
   if (date_Form.value == "") { date_Form = new Date()} else {date_Form = new Date(date_Form.value)}
 
   ano = today.getFullYear();
   mmonth = today.getMonth ();
   day = today.toString ().substr (8,2)
 
   umonth = new Array ("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre")
   days_Feb = (!(ano % 4) ? 29 : 28)
   days = new Array (31, days_Feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)

   if ((mmonth < 0) || (mmonth > 11))  alert(mmonth)
   if ((mmonth - 1) == -1) {month_prior = 11; year_prior = ano - 1} else {month_prior = mmonth - 1; year_prior = ano}
   if ((mmonth + 1) == 12) {month_next  = 0;  year_next  = ano + 1} else {month_next  = mmonth + 1; year_next  = ano}
   txt  = "<table bgcolor='#336699' style='border:solid #336699; border-width:2' cellspacing='0' cellpadding='3' border='0' width='195' height='"+tam*1.1 +"'>"
   txt += "<tr bgcolor='#FFFFFF'><td colspan='7' align='center'><table border='0' cellpadding='0' width='100%' bgcolor='#FFFFFF'><tr>"
   txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+((mmonth+1).toString() +"/01/"+(ano-1).toString())+"') class='Cabecalho_Calendario' title='Año Anterior'><<</a></td>"
   txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+( "01/" + (month_prior+1).toString() + "/" + year_prior.toString())+"') class='Cabecalho_Calendario' title='Mes Anterior'><</a></td>"
   txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+( "01/" + (month_next+1).toString()  + "/" + year_next.toString())+"') class='Cabecalho_Calendario' title='Mes Siguiente'>></a></td>"
   txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+((mmonth+1).toString() +"/01/"+(ano+1).toString())+"') class='Cabecalho_Calendario' title='Ano Siguiente'>>></a></td>"
   txt += "<td width=20% align=right><a href=javascript:force_close('"+div+"') class='Cabecalho_Calendario' title='Cerrar'><b>X</b></a></td></tr></table></td></tr>"
   txt += "<tr><td colspan='7' align='right' bgcolor='#003366' class='mes1'><a href=javascript:pop_year('"+obj+"','"+div+"','"+tam+"','" + (mmonth+1) + "') class='mes1'>" + ano.toString() + "</a>"
   txt += " <a href=javascript:pop_month('"+obj+"','"+div+"','"+tam+"','" + ano + "') class='mes1'>" + umonth[mmonth] + "</a> <div id='popd' style='position:absolute'></div></td></tr>"
   txt += "<tr bgcolor='#336699' style='font-size: 10px;'><td width='14%' class='dia' align=center><b>Dom</b></td><td width='14%' class='dia' align=center><b>Lun</b></td><td width='14%' class='dia' align=center><b>Mar</b></td><td width='14%' class='dia' align=center><b>Mie</b></td><td width='14%' class='dia' align=center><b>Jue</b></td><td width='14%' class='dia' align=center><b>Vie<b></td><td width='14%' class='dia' align=center><b>Sab</b></td></tr>"
   today1 = new Date((mmonth+1).toString() +"/01/"+ano.toString());
   diainicio = today1.getDay () + 1;
   week = d = 1
   start = false;

   for (n=1;n<= 42;n++) 
   {
       if (week == 1)  txt += "<tr bgcolor='#336699' align=center>"
       if (week==diainicio) {start = true}
       if (d > days[mmonth]) {start=false}
       if (start) 
       {
           dat = new Date((mmonth+1).toString() + "/" + d + "/" + ano.toString())
           day_dat   = dat.toString().substr(0,10)
           day_today  = date_Form.toString().substr(0,10)
           year_dat  = dat.getFullYear ()
           year_today = date_Form.getFullYear ()
           colorcell = ((day_dat == day_today) && (year_dat == year_today) ? " bgcolor='#FFCC00' " : "" )
					 mesp = mmonth+1;
					 if (mesp<10){
					 mes_sh = '0' + mesp
					 }else{
					 mes_sh = mesp
					 }
					 
					 if(d<10){
					 	d = '0' + d;
					 }
					 
           txt += "<td"+colorcell+" align=center><a href=javascript:block('"+ d + "/" + (mes_sh).toString() + "/" + ano.toString() +"','"+ obj +"','" + div +"') class='data'>"+ d.toString() + "</a></td>"
           d ++ 
       } 
       else 
       { 
           txt += "<td class='data' align=center> </td>"
       }
       week ++
       if (week == 8) 
       { 
           week = 1; txt += "</tr>"} 
       }
       txt += "</table>"
       div2 = eval (div)
       div2.innerHTML = txt 
	   
}
 
// função para exibir a janela com os meses
function pop_month(obj, div, tam, ano)
{
 txt  = "<table bgcolor='#336699' border='0' width=80>"
 for (n = 0; n < 12; n++) { txt += "<tr><td align=center><font size=1 face=verdana color=#FFFFF><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+("01/" + (n+1).toString() + "/" + ano.toString())+"') style='color:#ffffff; text-decoration:none;'>" + umonth[n] +"</a></td></tr>" }
 txt += "</table>"
 popd.innerHTML = txt
}

// função para exibir a janela com os anos
function pop_year(obj, div, tam, umonth)
{
 txt  = "<table bgcolor='#336699' border='0' width=160>"
 l = 1
 for (n=1991; n<2012; n++)
 {  if (l == 1) txt += "<tr>"
    txt += "<td align=center><font size=1 face=verdana color=#FFFFF><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+(umonth.toString () +"/01/" + n) +"') style='color:#ffffff; text-decoration:none;'>" + n + "</a></font></td>"
    l++
    if (l == 4) 
       {txt += "</tr>"; l = 1 } 
 }
 txt += "</tr></table>"
 popd.innerHTML = txt 
}

// função para fechar o calendário
function force_close(div) 
   { //div2 = eval (div); div2.innerHTML = ''
	   new Effect.SlideUp(div)
   }
   
// função para fechar o calendário e setar a data no campo de data associado
function block(data, obj, div)
{ 
   force_close (div)
   obj2 = eval(obj)
   obj2.value = data 
   
}

function evento_select(hotel){
	if ($('evento_link') != undefined)
	{
		$('evento_link').href = 'faca_seu_evento.asp?secao=eventos&pagina=faca_seu_evento&evento_hotel='+hotel;
	}
	$('evento_pic').src = '../_img/eventos_fotos/'+hotel+'.jpg';
}
