function ComboIata_Change(cboIata,txtCidade)
{
if( cboIata.value == 'out' )
{
txtCidade.value = "" ;
txtCidade.style.visibility = "visible" ;
txtCidade.style.width = "100px" ;
cboIata.style.visibility = "hidden" ;
cboIata.style.width = 0 ;
}
else
txtCidade.value = cboIata.value ;
}
function pesquisaavancada()
{
buscahoteis_home.action = '/VxlHotel20/BuscaAvancada.aspx' ;
buscahoteis_home.submit() ;
}
function InitDataAereos(campo, dias)
{
DataHoje = new Date() ;
dia = DataHoje.getDate() ;
mes = DataHoje.getMonth() ;
if(mes>=11 && dia > 22) { dia=1; mes=12;}//Workaround do bug em 'AddDias' (FABIO)
ano = DataHoje.getFullYear() ;
if( dia < 10 ) {   dia = '0' + dia ; } if( mes < 10 ) {   mes = '0' + mes ; } AddDias(dia + "/" + mes + "/" + ano,campo, dias) ; }function FormataData_Hoteis(objCampo){ intKeyCode = event.keyCode ; if( (intKeyCode < 47) || (intKeyCode > 57) )
{
psValidChars = objCampo.value ;
event.cancelBubble = true ;
event.returnValue = ((psValidChars.indexOf(String.fromCharCode(event.keyCode)) >= 0) || (event.keyCode == 13)) ;
if (event.returnValue == false)
{
return event.returnValue ;
}
}
else
{
var strValor = objCampo.value ;
var intLengthValor = parseInt(strValor.length) ;
if((intLengthValor == 2) && (intKeyCode!=47))
{
objCampo.value = strValor + "/" ;
}
if((intLengthValor == 1) && (intKeyCode==47))
{
objCampo.value = "0" + strValor ;
}
if((intLengthValor == 4) && (intKeyCode==47))
{
objCampo.value = strValor.substring(0,3) + '0' + strValor.substring(2,1) ;
}
if((intLengthValor == 5) && (intKeyCode!=47))
{
objCampo.value = strValor + "/" ;
}
}
return true ;
}
function InitDataIda()
{
DataHoje = new Date() ;
dia = DataHoje.getDate() ;
mes = DataHoje.getMonth() ;
ano = DataHoje.getFullYear() ;
if( dia < 10 )          dia = '0' + dia ;     if( mes < 10 )          mes = '0' + mes ;     AddDias(dia + "/" + mes + "/" + ano,document.buscaaereos_home.DataIda,3) ; } function verificaDatasHome(dtInicial, dtFinal){  var dtini = dtInicial;  var dtfim = dtFinal;  datInicio = new Date(dtini.substring(6,10), dtini.substring(3,5), dtini.substring(0,2));  datInicio.setMonth(datInicio.getMonth() - 1);  datFim = new Date(dtfim.substring(6,10), dtfim.substring(3,5), dtfim.substring(0,2));  datFim.setMonth(datFim.getMonth() - 1);  if(datInicio < datFim)  {    return true;  }   else   {    document.buscahoteis_home.checkout.focus();    return false;  } }function isDate(dt){    var vlr = new String(dt.value);     if(isNaN(parseInt(dt.value))) {   alert('data inválida');   return false ; } else {   if(vlr.length==0)   {     alert('Campo em branco');     dt.focus();     return false ;   }    if(vlr.substr(3,2)>12 || vlr.substr(3,2)<1)   {     alert('data inválida');      dt.focus();     return false ;   }   else   {     if(vlr.substr(3,2)==2)     {       if(vlr.substr(0,2)>29 || (vlr.substr(0,2)==29 && vlr.substr(6,4)%4!=0))
{
alert('Data inválida');
dt.focus();
return false ;
}
}
else
{
if(vlr.substr(0,2)>31)
{
alert('Data inválida');
dt.focus();
return false ;
}
}
}
}
return true ;
}
function InitDataHoteis(campo, dias)
{
DataHoje = new Date() ;
dia = DataHoje.getDate() ;
mes = DataHoje.getMonth() ;
ano = DataHoje.getFullYear() ;
if(mes>=11 && dia > 22) { dia=1; mes=12; }//Workaround do bug em 'AddDias' (FABIO)
if( dia < 10 ) {   dia = '0' + dia ; } if( mes < 10 ) {   mes = '0' + mes ; } AddDias(dia + "/" + mes + "/" + ano,campo, dias) ; }function FormataData_Hoteis(objCampo){ intKeyCode = event.keyCode ; if( (intKeyCode < 47) || (intKeyCode > 57) )
{
psValidChars = objCampo.value ;
event.cancelBubble = true ;
event.returnValue = ((psValidChars.indexOf(String.fromCharCode(event.keyCode)) >= 0) || (event.keyCode == 13)) ;
if (event.returnValue == false)
{
return event.returnValue ;
}
}
else
{
var strValor = objCampo.value ;
var intLengthValor = parseInt(strValor.length) ;
if((intLengthValor == 2) && (intKeyCode!=47))
{
objCampo.value = strValor + "/" ;
}
if((intLengthValor == 1) && (intKeyCode==47))
{
objCampo.value = "0" + strValor ;
}
if((intLengthValor == 4) && (intKeyCode==47))
{
objCampo.value = strValor.substring(0,3) + '0' + strValor.substring(2,1) ;
}
if((intLengthValor == 5) && (intKeyCode!=47))
{
objCampo.value = strValor + "/" ;
}
}
return true ;
}
function LimpaCombos()
{
buscahoteis_home.quarto1a.value = "1";
buscahoteis_home.quarto1b.value = "0";
buscahoteis_home.quarto2a.value = "0";
buscahoteis_home.quarto2b.value = "0";
buscahoteis_home.quarto3a.value = "0";
buscahoteis_home.quarto3b.value = "0";
buscahoteis_home.quarto4a.value = "0";
buscahoteis_home.quarto4b.value = "0";
}
function EscondeCombos(valor)
{
if (valor==0)
{
LimpaCombos();
buscahoteis_home.quarto1a.style.visibility = "hidden";
buscahoteis_home.quarto1b.style.visibility = "hidden";
buscahoteis_home.quarto2a.style.visibility = "hidden";
buscahoteis_home.quarto2b.style.visibility = "hidden";
buscahoteis_home.quarto3a.style.visibility = "hidden";
buscahoteis_home.quarto3b.style.visibility = "hidden";
buscahoteis_home.quarto4a.style.visibility = "hidden";
buscahoteis_home.quarto4b.style.visibility = "hidden";
}
if (valor==1)
{
LimpaCombos();
buscahoteis_home.quarto1a.style.visibility = "visible";
buscahoteis_home.quarto1b.style.visibility = "visible";
buscahoteis_home.quarto2a.style.visibility = "hidden";
buscahoteis_home.quarto2b.style.visibility = "hidden";
buscahoteis_home.quarto3a.style.visibility = "hidden";
buscahoteis_home.quarto3b.style.visibility = "hidden";
buscahoteis_home.quarto4a.style.visibility = "hidden";
buscahoteis_home.quarto4b.style.visibility = "hidden";
}
if (valor==2)
{
LimpaCombos();
buscahoteis_home.quarto1a.style.visibility = "visible";
buscahoteis_home.quarto1b.style.visibility = "visible";
buscahoteis_home.quarto2a.style.visibility = "visible";
buscahoteis_home.quarto2b.style.visibility = "visible";
buscahoteis_home.quarto3a.style.visibility = "hidden";
buscahoteis_home.quarto3b.style.visibility = "hidden";
buscahoteis_home.quarto4a.style.visibility = "hidden";
buscahoteis_home.quarto4b.style.visibility = "hidden";
}
if (valor==3)
{
LimpaCombos();
buscahoteis_home.quarto1a.style.visibility = "visible";
buscahoteis_home.quarto1b.style.visibility = "visible";
buscahoteis_home.quarto2a.style.visibility = "visible";
buscahoteis_home.quarto2b.style.visibility = "visible";
buscahoteis_home.quarto3a.style.visibility = "visible";
buscahoteis_home.quarto3b.style.visibility = "visible";
buscahoteis_home.quarto4a.style.visibility = "hidden";
buscahoteis_home.quarto4b.style.visibility = "hidden";
}
if (valor==4)
{
LimpaCombos();
buscahoteis_home.quarto1a.style.visibility = "visible";
buscahoteis_home.quarto1b.style.visibility = "visible";
buscahoteis_home.quarto2a.style.visibility = "visible";
buscahoteis_home.quarto2b.style.visibility = "visible";
buscahoteis_home.quarto3a.style.visibility = "visible";
buscahoteis_home.quarto3b.style.visibility = "visible";
buscahoteis_home.quarto4a.style.visibility = "visible";
buscahoteis_home.quarto4b.style.visibility = "visible";
}
}
function pesquisahomehoteis()
{
with(document.buscahoteis_home)
{
if(cidade.value=='')
{
alert('Preencha o campo localidade');
return;
}
if(checkin.value=='')
{
alert('Preencha o campo checkin');
return;
}
if (!(isDate(document.buscahoteis_home.checkin)))
return ;
if(document.buscahoteis_home.checkout.value=='')
{
alert('Preencha o campo checkout');
return;
}
if (!(isDate(document.buscahoteis_home.checkout)))
return ;
if (!(verificaDatasHome(checkin.value, checkout.value)))
{
alert('A data de checkin deve ser menor que a de checkout!');
return ;
}
submit();
}
}
function SetaEnableVoltaOnLine()
{
with(document.buscaaereos_home)
{
DataVolta.disabled = radNacSoIda.checked ;
}
}
function verificaporciamaritima()
{
valorDestino = document.BuscaCruzeiros.destino.value ;
valorCiaMaritima = document.BuscaCruzeiros.select.value ;
if (valorDestino=='' && valorCiaMaritima=='')
{
window.alert('Selecione um destino ou uma cia. marítima para pesquisar.');
return;
}
if (valorDestino!='' && valorCiaMaritima!='')
{
window.alert('Selecione um destino ou uma cia. marítima para pesquisar.');
return;
}
// Busca por Destino
if(valorDestino!='')
{
document.BuscaCruzeiros.submit();
}
// Busca por Cia Maritima
if(valorCiaMaritima!='')
{
window.location.href= (valorCiaMaritima)
}
}
function verificapesq()
{
var valorDestino=document.BuscaPacotes.destino.value;
var valorTipoViagem=document.BuscaPacotes.modalidadeexc.value;
if (valorDestino==0 && valorTipoViagem =='')
{
window.alert('Selecione um destino ou um tipo de viagem.');
return ;
}
if (valorDestino!=0 && valorTipoViagem !='')
{
window.alert('Selecione um destino ou um tipo de viagem.');
return ;
}
// Busca por Destino
if(valorDestino!=0)
{
document.BuscaPacotes.submit();
}
// Busca por tipo de viagem
if(valorTipoViagem!='')
{
document.BuscaPacotes.action='/excursoes/pesqwrdRes.asp';
document.BuscaPacotes.submit();
}
}
function TrocaPesquisa(NomeDiv)
{
if (NomeDiv=='Pacotes')
{
divgeral.style.height="207";
pacotes.style.visibility = "visible";
aereos.style.visibility = "hidden";
cruzeiros.style.visibility = "hidden";
hoteis.style.visibility = "hidden";
BuscaPacotes.a[3].checked = "true";
EscondeCombos('0');
}
if (NomeDiv=='Aereos')
{
divgeral.style.height="475";
pacotes.style.visibility = "hidden";
aereos.style.visibility = "visible";
cruzeiros.style.visibility = "hidden";
hoteis.style.visibility = "hidden";
buscaaereos_home.a[0].checked = "true";
EscondeCombos('0');
}
if (NomeDiv=='Cruzeiros')
{
divgeral.style.height="208";
pacotes.style.visibility = "hidden";
aereos.style.visibility = "hidden";
cruzeiros.style.visibility = "visible";
hoteis.style.visibility = "hidden";
BuscaCruzeiros.a[2].checked = "true";
EscondeCombos('0');
}
if (NomeDiv=='Hoteis')
{
divgeral.style.height="290";
pacotes.style.visibility = "hidden";
aereos.style.visibility = "hidden";
cruzeiros.style.visibility = "hidden";
hoteis.style.visibility = "visible";
buscahoteis_home.a[1].checked = "true";
buscahoteis_home.nquartos[0].selected = "true";
EscondeCombos('1');
}
}
function pesquisahomevoos()
{
if( document.buscaaereos_home.Origem.value=='')
{
alert('Selecione a Origem.');
return;
}
if(document.buscaaereos_home.radNacIdaVolta.checked)
{
if(document.buscaaereos_home.DataVolta.value=='dd/mm/aaaa' || document.buscaaereos_home.DataVolta.value == '')
{
alert('Selecione a data de volta.');
return;
}
if (!(isDate(document.buscaaereos_home.DataVolta)))
{
return;
}
}
if(document.buscaaereos_home.DataIda.value=='dd/mm/aaaa')
{
alert('Selecione a data de ida.');
return;
}
if (!(isDate(document.buscaaereos_home.DataIda)))
{
return;
}
if(document.buscaaereos_home.Destino.value=='')
{
alert('Selecione o Destino.');
return;
}
if(document.buscaaereos_home.DataVolta.value=='dd/mm/aaaa')
{
document.buscaaereos_home.DataVolta.value='';
}
document.buscaaereos_home.submit();
}
function SetaData(objCampo, Valor)
{
if ( (objCampo.value=='' && Valor=='dd/mm/aaaa') || (objCampo.value=='dd/mm/aaaa' && Valor==''))
objCampo.value=Valor;
}
function FormataData_New(objCampo)
{
intKeyCode = event.keyCode ;
if((intKeyCode.keyCode < 48) || (intKeyCode.keyCode > 57))
{
return false;
}
else
{
strValor = objCampo.value;
intLengthValor = parseInt(strValor.length);
if((intLengthValor == 2) && (intKeyCode!=47))
{
objCampo.value = strValor + "/";
}
if((intLengthValor == 1) && (intKeyCode==47))
{
objCampo.value = "0" + strValor;
}
if((intLengthValor == 4) && (intKeyCode==47))
{
objCampo.value = strValor.substring(0,3) + '0' + strValor.substring(2,1);
}
if((intLengthValor == 5) && (intKeyCode!=47))
{
objCampo.value = strValor + "/";
}
}
return true;
}
//Div do botão "Classificação de idades - motor online
function MostraClassificIdades()
{
botao = document.getElementById("botaoClassificaIdades");
obj = document.getElementById("divClassificIdades");
obj.style.visibility = "visible";
//var pos = findPosition(botao);
//obj.style.top =pos[1] - 15;
//obj.style.left = pos[0] + 30;
//obj.style.top = obj.style.top + 370;
//obj.style.left = obj.style.left + 142;
}
function EscondeClassificIdades()
{
obj = document.getElementById("divClassificIdades");
obj.style.visibility = "hidden"
}
function findPosition( obj ) {
if( obj.offsetParent ) {
for( var posX = 0, posY = 0; obj.offsetParent; obj = obj.offsetParent )
{
posX += obj.offsetLeft; posY += obj.offsetTop;
}
return [ posX, posY ];
}
else
{
return [ obj.x, obj.y ];
}
}
//FIM - Div do botão "Classificação de idades - motor online
var popupListAero;//Selecao de aeroportos - Inicio
function OpenListaAeroportos(id,txt,somenteNacional){
var DataIda = "0" ;
var URL;
if (somenteNacional == '1')
URL = '/Aereo/ListaAeroportos.aspx?id=' + id + '&txt=' + txt + '&pais=Brazil&SomentePais=1'
else
URL = '/Aereo/ListaAeroportos.aspx?id=' + id + '&txt=' + txt + '&SomentePais=0'
popupListAero = window.open(URL,
'popupListAero',
'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=557,height=480');
}
function SetListaAeroportos(id,txt,newIata,nomeCidade){
var TextControl ;
//TextControl = document.buscaaereos_home.elements[txt];
TextControl = document.getElementById(txt)
popupListAero.close();
TextControl.value=newIata; //Coloca IATA no textBox - o valor que é usado realmente
}
/*
function RedimencionaWin()
{
        var larguratabela = 755 ;
        var espacosobra = 0;
        var esquerda = 0 ;
        var largura = 0 ;
        var larguratela = document.body.offsetWidth ;
        var DivAereos = document.getElementById('aereos').offsetWidth ;
        var DivPacotes = document.getElementById('pacotes').offsetWidth ;
        var DivHoteis = document.getElementById('hoteis').offsetWidth ;
        var DivCruzeiros = document.getElementById('cruzeiros').offsetWidth ;
        var DivAereos = 266 ;
        var DivPacotes = 266 ;
        var DivHoteis = 266 ;
        var DivCruzeiros = 266 ;
        espacosobra = larguratela - larguratabela ;
        if (espacosobra < 0)
        espacosobra = 0 ;
        else
        espacosobra = (espacosobra / 2)  - 8 ;
        largura = larguratabela - DivAereos ;
        esquerda = largura +  espacosobra ;
        document.getElementById('aereos').style.left = esquerda + 'px' ;
        largura = larguratabela - DivPacotes ;
        esquerda = largura  + espacosobra ;
        document.getElementById('pacotes').style.left = esquerda + 'px' ;
        largura = larguratabela - DivCruzeiros ;
        esquerda = largura  + espacosobra ;
        document.getElementById('cruzeiros').style.left = esquerda + 'px' ;
        largura = larguratabela - DivHoteis ;
        esquerda = largura  + espacosobra;
        document.getElementById('hoteis').style.left = esquerda + 'px' ;
}
RedimencionaWin();
*/

var data = new Date();
var dia = data.getDate();
var mes = data.getMonth();
var ano = Number(data.getFullYear());
    
if (Number(dia) < 10)
    dia = "0" + dia;
if (Number(mes) < 10)
    mes = "0" + String(Number(mes) + 1);
if (ano < 2000)
    ano = 1900 + ano

var CalS = mes + '/' + dia + '/' + ano;

//Volta
if ( dia == '29' && mes == '2' )
    dia = '28';
ano = ano + 1;
var CalE = mes + '/' + dia + '/' + ano;

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function HabilitaIdaVolta()
{
    with(document.frmMotor)
    {
        DataVolta.disabled = radNacSoIda.checked ;
    }
}
function SetaDataVolta(campoIda,campoVolta)
{
	return ;
	if( (campoVolta.value == 'dd/mm/aaaa' || campoVolta.value.length == 0 ) && campoIda.value.length == 10 )
	{
		DataIda = GetData(campoIda.value) ;
					
		if( DataIda )							
		{
			DataIda = DataIda + 1 ;
			campoVolta.value =  DataIda.getDate() + "/" + (DataIda.getMonth() + 1 ) + "/" + DataIda.getYear() ;
		}
	}
}
function PesquisaAereoHome()
{
	if( document.getElementById("Origem").value=='')
    {
        alert('Selecione a Origem.');
        return;
    }
    if(document.getElementById("Destino").value=='')
    {
        alert('Selecione o Destino.');
        return;
    }
    if(document.getElementById("DataIda").value=='dd/mm/aaaa')
    {
        alert('Selecione a data de ida.');
        return;
    }
    if (!(isDate(document.getElementById("DataIda"))))
    {
        return;
    }
    if(document.getElementById("radNacIdaVolta").checked)
    {
        if(document.getElementById("DataVolta").value=='dd/mm/aaaa' || document.getElementById("DataVolta").value == '')
        {
            alert('Selecione a data de volta.');
            return;
        }
        if (!(isDate(document.getElementById("DataVolta"))))
        {
            return;
        }
    }
	if(document.getElementById("DataVolta").value=='dd/mm/aaaa')
    {
        document.getElementById("DataVolta").value='';
    }
	
	
	strParam =  '?Origem=' + document.getElementById('Origem').value;
	strParam += '&Destino=' + document.getElementById('Destino').value;
	strParam += '&Data=' + document.getElementById('DataIda').value;
	strParam += '&Hora=' + document.getElementById('HorarioIda').value;
	if(document.getElementById('radNacIdaVolta').checked)
	{
		strParam += '&Origem=' + document.getElementById('Destino').value;
		strParam += '&Destino=' + document.getElementById('Origem').value;
		strParam += '&Data=' + document.getElementById('DataVolta').value;
		strParam += '&Hora=' + document.getElementById('HorarioVolta').value;
	}

	strParam += '&NumADT=' + document.getElementById('NumAdt').value;
	strParam += '&NumCHD=' + document.getElementById('NumChd').value;
	strParam += '&NumINF=' + document.getElementById('NumInf').value;

	if ( document.getElementById('chkSomenteDireto').checked )
		strParam += '&SomenteDireto=1';
	else
		strParam += '&SomenteDireto=0';
	
	strParam += '&Cia=' + document.getElementById('ddlNacCia').value;
	strParam += '&Cabine=' + document.getElementById('ddlNacClasse').value;


	var objForm = document.forms[0];
	objForm.method = 'post';
/*	alert('http://www.submarinoviagens.com.br/Viagens/Produtos/Aereo/BuscaIatas.aspx?'+ strParam + '&utm_source=PontoTur&utm_medium=MotorHome&utm_campaign=PassagensAereas');*/
    objForm.action = 'http://www.submarinoviagens.com.br/Viagens/Produtos/Aereo/BuscaIatas.aspx'+ strParam + '&utm_source=PontoTur&utm_medium=MotorProdutos&utm_campaign=Passagens';
    objForm.submit();


}

