    var tablaDatosPantalla= new Array();
    var constPAIS=0;
    var constCIUDAD=1;
    var constDIALLEGADA=2;
    var constMESLLEGADA=3;
    var constANYOLLEGADA=4;
    var constNOCHES=5;
    var constHUESPED=6;
    var constMONEDA=7;
    var constORDEN=8;
    var constHOSTAL=9;
    var constBED=10;
    var constAPARTAMENTO=11;
    var constHOTEL1=12;
    var constHOTEL2=13;
    var constHOTEL3=14;
    var constHOTEL4=15;
    var constHOTEL5=16;
    var constTODOSHOTEL=17;
    var constCOMPARTIDA=18;
    var constCOMPARTIDABANYO=19;
    var constCOMPARTIDADOBLE=20;
    var constCONBANYO=21;
    var constPRIVADA=22;
    var constTODOSHABITACION=23;
    var constNOMBRE=24;
    var wAuxIdCiudad;
    var wDestino="simple";
    var BuscaPor = "destino";

function guardar(idPantalla) 
{
    mySelect=document.getElementById("form"+idPantalla).idPais;
    tablaDatosPantalla[constPAIS]=mySelect.selectedIndex;

    //mySelect=document.getElementById("idCiudad"+idPantalla);
    mySelect=document.getElementById("form"+idPantalla).idCiudad;

    tablaDatosPantalla[constCIUDAD]=mySelect.selectedIndex;
	
    if (idPantalla=="01" || idPantalla=="02") 
    {
        mySelect=document.getElementById("Dia"+idPantalla);
        tablaDatosPantalla[constDIALLEGADA]=mySelect.selectedIndex;

        mySelect=document.getElementById("Mes"+idPantalla);
        tablaDatosPantalla[constMESLLEGADA]=mySelect.selectedIndex;

        mySelect=document.getElementById("Any"+idPantalla);
        tablaDatosPantalla[constANYOLLEGADA]=mySelect.selectedIndex;


        mySelect=document.getElementById("idNoches"+idPantalla);
        tablaDatosPantalla[constNOCHES]=mySelect.selectedIndex;


        mySelect=document.getElementById("idHuesped"+idPantalla);
        tablaDatosPantalla[constHUESPED]=mySelect.selectedIndex;

        mySelect=document.getElementById("form"+idPantalla).idMoneda;
        tablaDatosPantalla[constMONEDA]=mySelect.selectedIndex;
    }

    if (idPantalla=="02" || idPantalla=="04") 
    {
        mySelect=document.getElementById("idOrden"+idPantalla);
        tablaDatosPantalla[constORDEN]=mySelect.selectedIndex;

        mySelect=document.getElementById("hostal"+idPantalla);
        tablaDatosPantalla[constHOSTAL]=mySelect.checked;

        mySelect=document.getElementById("bed"+idPantalla);
        tablaDatosPantalla[constBED]=mySelect.checked;	

        mySelect=document.getElementById("apartamento"+idPantalla);
        tablaDatosPantalla[constAPARTAMENTO]=mySelect.checked;

        mySelect=document.getElementById("hotel1"+idPantalla);
        tablaDatosPantalla[constHOTEL1]=mySelect.checked;

        mySelect=document.getElementById("hotel2"+idPantalla);
        tablaDatosPantalla[constHOTEL2]=mySelect.checked;

        mySelect=document.getElementById("hotel3"+idPantalla);
        tablaDatosPantalla[constHOTEL3]=mySelect.checked;

        mySelect=document.getElementById("hotel4"+idPantalla);
        tablaDatosPantalla[constHOTEL4]=mySelect.checked;

        mySelect=document.getElementById("hotel5"+idPantalla);
        tablaDatosPantalla[constHOTEL5]=mySelect.checked;

        mySelect=document.getElementById("todosHotel"+idPantalla);
        tablaDatosPantalla[constTODOSHOTEL]=mySelect.checked;		
    }

    if (idPantalla=="02") 
    {
        mySelect=document.getElementById("compartida"+idPantalla);
        tablaDatosPantalla[constCOMPARTIDA]=mySelect.checked;

        mySelect=document.getElementById("compartidaBanyo"+idPantalla);
        tablaDatosPantalla[constCOMPARTIDABANYO]=mySelect.checked;

        mySelect=document.getElementById("compartidaDoble"+idPantalla);
        tablaDatosPantalla[constCOMPARTIDADOBLE]=mySelect.checked;

        mySelect=document.getElementById("privadaBanyo"+idPantalla);
        tablaDatosPantalla[constCONBANYO]=mySelect.checked;

        mySelect=document.getElementById("privada"+idPantalla);
        tablaDatosPantalla[constPRIVADA]=mySelect.checked;

        mySelect=document.getElementById("todosHabitacion"+idPantalla);
        tablaDatosPantalla[constTODOSHABITACION]=mySelect.checked;		
    }

    if (idPantalla=="03" || idPantalla=="04") 
    {
        mySelect=document.getElementById("idNombre"+idPantalla);
        tablaDatosPantalla[constNOMBRE]=mySelect.value;				
    }              
}


function incorporar(idPantalla) 
{
    mySelect=document.getElementById("form"+idPantalla).idPais;
    mySelect.selectedIndex=tablaDatosPantalla[constPAIS];

    //mySelect=document.getElementById("idCiudad"+idPantalla);
    mySelect=document.getElementById("form"+idPantalla).idCiudad;
    mySelect.selectedIndex=tablaDatosPantalla[constCIUDAD];
	
    if(mySelect.selectedIndex==-1)
    {
        mySelect.disabled=true;
    }

    if (idPantalla=="01" || idPantalla=="02") 
    {
        mySelect=document.getElementById("Dia"+idPantalla);
        mySelect.selectedIndex=tablaDatosPantalla[constDIALLEGADA];

        mySelect=document.getElementById("Mes"+idPantalla);
        mySelect.selectedIndex=tablaDatosPantalla[constMESLLEGADA];

        mySelect=document.getElementById("Any"+idPantalla);
        mySelect.selectedIndex=tablaDatosPantalla[constANYOLLEGADA];

        mySelect=document.getElementById("idNoches"+idPantalla);
        mySelect.selectedIndex=tablaDatosPantalla[constNOCHES];

        mySelect=document.getElementById("idHuesped"+idPantalla);
        mySelect.selectedIndex=tablaDatosPantalla[constHUESPED];

        mySelect=document.getElementById("form"+idPantalla).idMoneda;
        mySelect.selectedIndex=tablaDatosPantalla[constMONEDA];
    }

    if (idPantalla=="02" || idPantalla=="04") 
    {
        mySelect=document.getElementById("idOrden"+idPantalla);
        mySelect.selectedIndex=tablaDatosPantalla[constORDEN];

        mySelect=document.getElementById("hostal"+idPantalla);
        mySelect.checked=tablaDatosPantalla[constHOSTAL];

        mySelect=document.getElementById("bed"+idPantalla);
        mySelect.checked=tablaDatosPantalla[constBED];

        mySelect=document.getElementById("apartamento"+idPantalla);
        mySelect.checked=tablaDatosPantalla[constAPARTAMENTO];

        mySelect=document.getElementById("hotel1"+idPantalla);
        mySelect.checked=tablaDatosPantalla[constHOTEL1];

        mySelect=document.getElementById("hotel2"+idPantalla);
        mySelect.checked=tablaDatosPantalla[constHOTEL2];

        mySelect=document.getElementById("hotel3"+idPantalla);
        mySelect.checked=tablaDatosPantalla[constHOTEL3];

        mySelect=document.getElementById("hotel4"+idPantalla);
        mySelect.checked=tablaDatosPantalla[constHOTEL4];

        mySelect=document.getElementById("hotel5"+idPantalla);
        mySelect.checked=tablaDatosPantalla[constHOTEL5];

        mySelect=document.getElementById("todosHotel"+idPantalla);
        mySelect.checked=tablaDatosPantalla[constTODOSHOTEL];	
    }

    if (idPantalla=="02") 
    {
        mySelect=document.getElementById("compartida"+idPantalla);
        mySelect.checked=tablaDatosPantalla[constCOMPARTIDA];

        mySelect=document.getElementById("compartidaBanyo"+idPantalla);
        mySelect.checked=tablaDatosPantalla[constCOMPARTIDABANYO];

        mySelect=document.getElementById("compartidaDoble"+idPantalla);
        mySelect.checked=tablaDatosPantalla[constCOMPARTIDADOBLE];

        mySelect=document.getElementById("privadaBanyo"+idPantalla);
        mySelect.checked=tablaDatosPantalla[constCONBANYO];

        mySelect=document.getElementById("privada"+idPantalla);
        mySelect.checked=tablaDatosPantalla[constPRIVADA];

        mySelect=document.getElementById("todosHabitacion"+idPantalla);
        mySelect.checked=tablaDatosPantalla[constTODOSHABITACION];
    }

    if (idPantalla=="03" || idPantalla=="04") 
    {
        mySelect=document.getElementById("idNombre"+idPantalla);
        if (tablaDatosPantalla[constNOMBRE]!=undefined) 
        {
                mySelect.value=tablaDatosPantalla[constNOMBRE];
        }
    }	
}

function seleccionaPais(nuevoIdPais) 
{
    setSelectValue(document.getElementById("form01").idPais, nuevoIdPais);
    setSelectValue(document.getElementById("form02").idPais, nuevoIdPais);
    setSelectValue(document.getElementById("form03").idPais, nuevoIdPais);
    setSelectValue(document.getElementById("form04").idPais, nuevoIdPais);
}

function setSelectValue(selectElement, newValue)
{
    for (i=0; i<selectElement.length ;i++)
    {
        if( selectElement.options[i].value == newValue )
        {
            selectElement.selectedIndex=i;
        }
    }
	
    selectElement.onchange();
}

function selectedFocus()
{
    var formSelect = document.getElementById( "form01" );        
    formSelect.idPais.focus(); 
}

function inicializar() 
{
    
    var ahora = new Date();
    var dia = ahora.getDate();
    var mes = ahora.getMonth()+1;
    var anyo = ahora.getFullYear();                               
    var idCiudad=0;	
    var idPais=0;
    var idPantalla="01";
    var hotel1="false";
    var hotel2="false";
    var hotel3="false";
    var hotel4="false";
    var hotel5="false";
    var bed="false";
    var hostal="false";
    var apartamento="false";
    var todosHotel="false";
    var compartida="false";
    var compartidaBanyo="false";
    var compartidaDoble="false";
    var privadaBanyo="false";
    var privada="false";
    var todosHabitacion="false";		
    var nombre="";
    var noches="3";
    var huesped="1";		
    var idMoneda="978";
    var idOrden="precio";    
    var mySelect = document.getElementById("Any01");
    
    tablaDatosPantalla[constDIALLEGADA]=dia-1;
    tablaDatosPantalla[constMESLLEGADA]=mes-1;
    
    for (i=0; i<mySelect.length ;i++) 
    {
        if (mySelect.options[i].value==anyo) tablaDatosPantalla[constANYOLLEGADA]=i;
    }
    
    mySelect=document.getElementById("idMoneda01");
    for (i=0; i<mySelect.length ;i++) 
    {
        if (mySelect.options[i].value==idMoneda) tablaDatosPantalla[constMONEDA]=i;
    }
		
    if (idPantalla=="02" || idPantalla=="04") 
    {
        mySelect=document.getElementById("idOrden"+idPantalla);
        for (i=0; i<mySelect.length ;i++) 
        {
            if (mySelect.options[i].value==idOrden) mySelect.selectedIndex=i;
        }
        
        mySelect=document.getElementById("hostal"+idPantalla);
        if (hostal=="true") 
        {
            mySelect.checked =hostal;
        }
        
        mySelect=document.getElementById("bed"+idPantalla);
        if (bed=="true") 
        {
            mySelect.checked =bed;
        }
        
        mySelect=document.getElementById("apartamento"+idPantalla);
        if (apartamento=="true") 
        {
            mySelect.checked =apartamento;
        }
        
        mySelect=document.getElementById("hotel1"+idPantalla);
        if (hotel1=="true") 
        {
            mySelect.checked =hotel1;
        }
        
        mySelect=document.getElementById("hotel2"+idPantalla);
        if (hotel2=="true") 
        {
            mySelect.checked =hotel2;
        }
        
        mySelect=document.getElementById("hotel3"+idPantalla);
        if (hotel3=="true") {
                mySelect.checked =hotel3;
        }
        
        mySelect=document.getElementById("hotel4"+idPantalla);
        if (hotel4=="true") 
        {
            mySelect.checked =hotel4;
        }
        
        mySelect=document.getElementById("hotel5"+idPantalla);
        if (hotel5=="true") 
        {
            mySelect.checked =hotel5;
        }
        
        mySelect=document.getElementById("todosHotel"+idPantalla);
        if (todosHotel=="true") 
        {
            mySelect.checked =todosHotel;
        }	
        
        if (idPantalla=="02") 
        {	 			
            mySelect=document.getElementById("compartida"+idPantalla);
            if (compartida=="true") 
            {
                mySelect.checked =compartida;
            }
            
            mySelect=document.getElementById("compartidaBanyo"+idPantalla);
            if (compartidaBanyo=="true") 
            {
                mySelect.checked =compartidaBanyo;
            }
            
            mySelect=document.getElementById("compartidaDoble"+idPantalla);
            if (compartidaDoble=="true") 
            {
                mySelect.checked =compartidaDoble;
            }
            
            mySelect=document.getElementById("privadaBanyo"+idPantalla);
            if (privadaBanyo=="true")   
            {
                mySelect.checked =privadaBanyo;
            }
            
            mySelect=document.getElementById("privada"+idPantalla);
            if (privada=="true") 
            {
                mySelect.checked =privada;
            }
            
            mySelect=document.getElementById("todosHabitacion"+idPantalla);
            if (todosHabitacion=="true") 
            {
                    mySelect.checked =todosHabitacion;
            }
        }	
    }
	 	
    cargaContenido(selectedValue(document.getElementById("form"+idPantalla).idPais),idPantalla);
	 
    //mySelect=document.getElementById("idCiudad"+idPantalla);
    var wCiudad=0; 
    
    if((wCiudad!="")&&(wCiudad!=null))
    {
        document.getElementById("form"+idPantalla).idCiudad.value=wCiudad;
    }
    
    mySelect=document.getElementById("form"+idPantalla).idCiudad;	
    wAuxIdCiudad = idCiudad;

    if (idCiudad=="")
    {
        mySelect.disabled=true;
    }

    if (idPantalla=="03" || idPantalla=="04") 
    {
        mySelect=document.getElementById("idNombre"+idPantalla);
        mySelect.value=nombre;
    }
		
    if (idPantalla=="01" || idPantalla=="02") 
    {
        mySelect=document.getElementById("idNoches"+idPantalla);
        for (i=0; i<mySelect.length ;i++) 
        {
            if (mySelect.options[i].value==noches) mySelect.selectedIndex=i;
        }
        
        mySelect=document.getElementById("idHuesped"+idPantalla);
        for (i=0; i<mySelect.length ;i++) 
        {
            if (mySelect.options[i].value==huesped) mySelect.selectedIndex=i;
        }
        
        mySelect=document.getElementById("form"+idPantalla).idMoneda;
        for (i=0; i<mySelect.length ;i++) 
        {
            if (mySelect.options[i].value==idMoneda) mySelect.selectedIndex=i;
        }
    }else{
        mySelect=document.getElementById("idNoches01");
        for (i=0; i<mySelect.length ;i++) 
        {
            if (mySelect.options[i].value==noches) tablaDatosPantalla[constNOCHES]=i;
        }
		
        mySelect=document.getElementById("idHuesped01");
        for (i=0; i<mySelect.length ;i++) 
        {
            if (mySelect.options[i].value==huesped) tablaDatosPantalla[constHUESPED]=i;
        }
		
        mySelect=document.getElementById("form01").idMoneda;
        for (i=0; i<mySelect.length ;i++) 
        {
            if (mySelect.options[i].value==idMoneda) tablaDatosPantalla[constMONEDA]=i;
        }
    }

    if (idPantalla=="01" || idPantalla=="02") 
    {
        mySelect=document.getElementById("Dia"+idPantalla);
        for (i=0; i<mySelect.length ;i++) 
        {
            if (mySelect.options[i].value==dia) mySelect.selectedIndex=i;
        }
        mySelect=document.getElementById("Mes"+idPantalla);
        for (i=0; i<mySelect.length ;i++) 
        {
            if (mySelect.options[i].value==mes) mySelect.selectedIndex=i;
        }

        mySelect=document.getElementById("Any"+idPantalla);
        for (i=0; i<mySelect.length ;i++) 
        {
            if (mySelect.options[i].value==anyo) mySelect.selectedIndex=i;
        }
    }

    showPantallaHideRest(idPantalla);
    guardar(idPantalla);
}

function mostrarAvanzadaPorDestino() 
{   
    cambia("01","02");    
}

function muestraImagenEnSearch( visibility, display )
{
    miDiv = document.getElementById("imagenSubSecciones");        
    if(miDiv!=null)
    {                        
        imagenSubSecciones.style.visibility = visibility;           
        imagenSubSecciones.style.display = display;
    }	    
}

function mostrarSimplePorDestino() 
{
    cambia("02","01");
}

function mostrarSimplePorNombre() 
{
    cambia("04","03");
}

function mostrarPorNombre(idPantalla) 
{
    if (idPantalla=="02") 
    {	
        wDestino="avanzada";
        cambia("02","03");
    } else if (idPantalla=="01") 
    {            
        wDestino="simple";
        cambia("01","03");
    }
}

function mostrarPorDestino(idPantalla) 
{
    if (idPantalla=="04") 
    {	
        cambia("04","02");
    } else if (idPantalla=="03") 
    {
        if(wDestino=="simple")
        {
            cambia("03","01");
        }
        else
        {
            cambia("03","02");
        }
    }
}

function mostrarAvanzadaPorNombre() 
{
    cambia("03","04");
}

function cambia(pPantallaOrigen, pPantallaDestino)
{
    guardar(pPantallaOrigen);
    incorporar(pPantallaDestino);
    showPantallaHideRest(pPantallaDestino);
}

function showPantallaHideRest(pPantalla)
{
    if( pPantalla == "01" ) 
    {
        show("Busqueda01"); show("PestanyaBusqueda01");
    } else {
        hide("Busqueda01"); hide("PestanyaBusqueda01");
    }
	
    if( pPantalla == "02" ) 
    {
        show("Busqueda02"); show("PestanyaBusqueda02");
    } else {
        hide("Busqueda02"); hide("PestanyaBusqueda02");
    }
	
    if( pPantalla == "03" ) 
    {
        show("Busqueda03"); show("PestanyaBusqueda03");
    } else {
        hide("Busqueda03"); hide("PestanyaBusqueda03");
    }	
    
    if( pPantalla == "04" ) 
    {
            show("Busqueda04"); show("PestanyaBusqueda04");
    } else {
            hide("Busqueda04"); hide("PestanyaBusqueda04");
    }	
}

function show(divId)
{
    miDiv = document.getElementById(divId);        
    miDiv.style.visibility='visible';
    miDiv.style.display='inline';
}

function ocultarSearch()
{
    sec01 = document.getElementById("sector01");        
    sec01.style.visibility='hidden';
    sec01.style.display='none';
    sec02_a = document.getElementById("sector02_a");        
    sec02_a.style.visibility='hidden';
    sec02_a.style.display='none';
    sec02_b = document.getElementById("sector02_b");        
    sec02_b.style.visibility='hidden';
    sec02_b.style.display='none';
    sec02_c = document.getElementById("sector02_c");        
    sec02_c.style.visibility='hidden';
    sec02_c.style.display='none';
    sec02_d = document.getElementById("sector02_d");        
    sec02_d.style.visibility='hidden';
    sec02_d.style.display='none';
}

function mostrarSearch()
{
    sec01 = document.getElementById("sector01");             
    
    if ( sec01.style.display=='none') 
    {
        sec01.style.visibility='visible';
        sec01.style.display='block';        
        sec02_a = document.getElementById("sectorDerecha");        
        sec02_a.style.visibility='visible';
        sec02_a.style.display='block';      
    }
}

function hide(divId)
{
    miDiv = document.getElementById(divId);        
    miDiv.style.visibility='hidden';
    miDiv.style.display='none';
}

function checkearTodosHotel(chkbox) 
{
    miCheck = document.getElementById("hostal");
    miCheck.checked=chkbox.checked
    miCheck = document.getElementById("bed");
    miCheck.checked=chkbox.checked
    miCheck = document.getElementById("apartamento");
    miCheck.checked=chkbox.checked
    miCheck = document.getElementById("hotel1");
    miCheck.checked=chkbox.checked
    miCheck = document.getElementById("hotel2");
    miCheck.checked=chkbox.checked
    miCheck = document.getElementById("hotel3");
    miCheck.checked=chkbox.checked
    miCheck = document.getElementById("hotel4");
    miCheck.checked=chkbox.checked
    miCheck = document.getElementById("hotel5");
    miCheck.checked=chkbox.checked	
}

function repasarCheckHotel(chkbox) 
{
    if (chkbox.checked==false) 
    {
        miCheck = document.getElementById("todosHotel");
        miCheck.checked=chkbox.checked;
    } else {
        cuantos=0;
        miCheck = document.getElementById("hostal");
        if (miCheck.checked) cuantos++;
        miCheck = document.getElementById("bed");
        if (miCheck.checked) cuantos++;
        miCheck = document.getElementById("apartamento");
        if (miCheck.checked) cuantos++;
        miCheck = document.getElementById("hotel1");
        if (miCheck.checked) cuantos++;
        miCheck = document.getElementById("hotel2");
        if (miCheck.checked) cuantos++;
        miCheck = document.getElementById("hotel3");
        if (miCheck.checked) cuantos++;
        miCheck = document.getElementById("hotel4");
        if (miCheck.checked) cuantos++;
        miCheck = document.getElementById("hotel5");
        if (miCheck.checked) cuantos++;

        if (cuantos==8) 
        {
            miCheck = document.getElementById("todosHotel");
            miCheck.checked=chkbox.checked;
        }
    }
}

function checkearTodosHabitacion(chkbox) 
{
    miCheck = document.getElementById("compartida");
    miCheck.checked=chkbox.checked
    miCheck = document.getElementById("compartidaBanyo");
    miCheck.checked=chkbox.checked
    miCheck = document.getElementById("compartidaDoble");
    miCheck.checked=chkbox.checked
    miCheck = document.getElementById("privadaBanyo");
    miCheck.checked=chkbox.checked
    miCheck = document.getElementById("privada");
    miCheck.checked=chkbox.checked
}

function repasarCheckHabitacion(chkbox) 
{
    if (chkbox.checked==false) 
    {
        miCheck = document.getElementById("todosHabitacion");
        miCheck.checked=chkbox.checked;
    } else {	
        cuantos=0;
        miCheck = document.getElementById("compartida");
        if (miCheck.checked) cuantos++;
        miCheck = document.getElementById("compartidaBanyo");
        if (miCheck.checked) cuantos++;
        miCheck = document.getElementById("compartidaDoble");
        if (miCheck.checked) cuantos++;
        miCheck = document.getElementById("privadaBanyo");
        if (miCheck.checked) cuantos++;
        miCheck = document.getElementById("privada");
        if (miCheck.checked) cuantos++;
		
        if (cuantos==5) 
        {
            miCheck = document.getElementById("todosHabitacion");
            miCheck.checked=chkbox.checked;
        }
    }
}

function selectedValue(pSelect)
{
    return pSelect.options[pSelect.selectedIndex].value;
}

function hacerEnvio(TipoEnvio)
{
    var wForm = document.getElementById('formEnvio');
    wForm.habCom.value = "off";
    wForm.habComB.value = "off";
    wForm.habComCd.value = "off";
    wForm.habPriv.value = "off";
    wForm.habPrivB.value = "off";
    wForm.catAlbergue.value = "off";
    wForm.catBedBr.value = "off";
    wForm.catHotel1.value = "off";
    wForm.catHotel2.value = "off";
    wForm.catHotel3.value = "off";
    wForm.catHotel4.value = "off";
    wForm.catHotel5.value = "off";
    wForm.catApartamento.value = "off";
    var wError = false;
    var tipoConsulta = "03";
    if(document.getElementById("formulario").idCiudad.value=="")
    {
        alert(wLiteral_AlertCiudadObligatoria);
        wError=true;
    }
	
    if(wError==false && BuscaPor == "destino")
    {
        var wFecha = document.getElementById("Any").value + document.getElementById("Mes").value + document.getElementById("Dia").value;
        if(document.getElementById("formulario").idCiudad.value=="")
        {
            alert(wLiteral_AlertCiudadObligatoria);
            wError=true;
        } else if(check_dateNoPasado(wFecha, wLiteral_ErrorBusquedaFechaPasada, wLiteral_CajaTotalAvilabilityFechaIncorrecto)==false)
        {
            wError=true;
        }else if(document.getElementById("Noches").value=="-1")
        {            
            alert(wLiteral_AlertaNochesObligatorias);
            wError=true;
        }else if(document.getElementById("Huespedes").value=="-1")
        {            
            alert(wLiteral_AlertaHuespedesObligatoria);
            wError=true;
        }else if(document.getElementById("Huespedes").value>20 && document.getElementById("Noches").value>30)
        {            
            alert(wLiteral_AlertaEstanciasGrupos);
            wError=true;
        }
    }

    if(wError==false)
    {
        wForm.idCiudad.value=selectedValue(document.getElementById("formulario").idCiudad);		
        if( BuscaPor == "destino" ) 
        {
            wForm.diaLlegada.value=selectedValue(document.getElementById("Dia"));
            wForm.mesLlegada.value=selectedValue(document.getElementById("Mes"));
            wForm.anyoLlegada.value=selectedValue(document.getElementById("Any"));
            wForm.numNoches.value=selectedValue(document.getElementById("Noches"));
            wForm.numHuespedes.value=selectedValue(document.getElementById("Huespedes"));
            wForm.idDivisa.value=selectedValue(document.getElementById("formulario").idMoneda);
            wForm.nombre.value="";	
            tipoConsulta = "";
        }

        if( BuscaPor == "nombre" ) 
        {
            wForm.diaLlegada.value="";
            wForm.mesLlegada.value="";
            wForm.anyoLlegada.value="";
            wForm.numNoches.value="";			
            wForm.numHuespedes.value="";
            wForm.idDivisa.value="";
            wForm.nombre.value = document.getElementById("Nombre").value;
            tipoConsulta = "03";
        }

        if( TipoEnvio ) 
        {
            wForm.ordenacion.value=selectedValue(document.getElementById("idOrden"));
            if( document.getElementById("hostal").checked ) { wForm.catAlbergue.value="on"; };
            if( document.getElementById("bed").checked ) { wForm.catBedBr.value="on"; };
            if( document.getElementById("apartamento").checked ) { wForm.catApartamento.value="on"; };
            if( document.getElementById("hotel1").checked ) { wForm.catHotel1.value="on"; };
            if( document.getElementById("hotel2").checked ) { wForm.catHotel2.value="on"; };
            if( document.getElementById("hotel3").checked ) { wForm.catHotel3.value="on"; };
            if( document.getElementById("hotel4").checked ) { wForm.catHotel4.value="on"; };
            if( document.getElementById("hotel5").checked ) { wForm.catHotel5.value="on"; };
        }
            wForm.ordenacion.value="default";       		     
        wForm.habCom.value="on";
        wForm.habPriv.value="on";     		
        wForm.pestanyaBusqueda.value=tipoConsulta;
        wForm.submit();
    }
}

function nuevoAjax()
{ 
    var xmlhttp=false;
    try
    {
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try
        {            
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            if (!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp=new XMLHttpRequest();
        }
    }    
    return xmlhttp; 
}

function selectIdCiduad( valor )
{
    var mySelect=document.getElementById("formulario").idCiudad;

    if ( mySelect )
    {
        for (i=0; i<mySelect.length ;i++) 
        {
            if (mySelect.options[i].value + "" == valor + "") 
                mySelect.selectedIndex=i;
        }
    }	   
}

function cargaContenido(valor,numPag)
{

    ajax=nuevoAjax();    
    ajax.open("GET", wAction_CitiesCountry + valor, true); 
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        {   
            var old_tab_index = -1;

            if ( document.getElementById("idCiudad") )
                old_tab_index = document.getElementById("idCiudad").tabIndex;

            document.getElementById("comboCiudad").innerHTML=ajax.responseText;          

            if ( document.getElementById("idCiudad") && old_tab_index >= 0  )
                document.getElementById("idCiudad").tabIndex = old_tab_index;

            var mySelect=document.getElementById("formulario").idCiudad;
            wAuxIdCiudad=_ID_CIUDAD;

            if (wAuxIdCiudad!="")
            {
                mySelect.disabled=false;
                for (i=0; i<mySelect.length ;i++) 
                {
                    if (mySelect.options[i].value==wAuxIdCiudad) mySelect.selectedIndex=i;
                }
            }	    
            if(mySelect.length==0)
            {
                mySelect.disabled=true;
            }                                
        } 
    }
    ajax.send(null);	

}
     
function cargaContenidoCiudad(valor,numPag)
{
    ajax=nuevoAjax();    
    ajax.open("GET", wAction_CitiesCountry + valor + "&soloVisibles=0", true); 
    ajax.onreadystatechange=function() 
    { 
        if (ajax.readyState==4)
        {                                      
            var obj = document.getElementById("comboCiudad");
            //var ind = obj.tabIndex;

            obj.innerHTML=ajax.responseText;
            //obj.tabIndex = ind;
            
            var mySelect=document.getElementById("addyourhostelForm").idCiudad;
            wAuxIdCiudad=0
            if (wAuxIdCiudad!="")
            {
                mySelect.disabled=false;
                for (i=0; i<mySelect.length ;i++) 
                {
                    if (mySelect.options[i].value==wAuxIdCiudad) mySelect.selectedIndex=i;
                }
            }	    
            if(mySelect.length==0)
            {
                //mySelect.disabled=true;
            }                                
        } 
    }
    ajax.send(null);	
}

function agregarAFavoritos()
{            
    window.external.AddFavorite( "http://www.letsgobooking.com/", "Let's Go Booking - Online Bookings Worldwide" );                       
}

function sbAvanzada()
{
    var sb01 = document.getElementById("sbAvanzada01");     
    var sb02 = document.getElementById("sbAvanzada02");
    var sbBuscar = document.getElementById("sbBuscar01");
    var sbSinOrden = document.getElementById("sbSinOrden");
    var sbConOrden = document.getElementById("sbConOrden");
    
    if(sb02.style.visibility=="hidden" && sb02.style.display=="none")
    {
        sb01.style.visibility="hidden";
        sb01.style.display="none";    
        sb02.style.visibility="visible";
        sb02.style.display="inline";
        
        sbBuscar.style.visibility="hidden";        
        
        sbSinOrden.style.visibility = "hidden";
        sbSinOrden.style.display="none";        
        sbConOrden.style.visibility = "visible";
        sbConOrden.style.display = "inline";
    }else{
        sb01.style.visibility="visible";
        sb01.style.display="inline";
        sb02.style.visibility="hidden";
        sb02.style.display="none";
        
        sbBuscar.style.visibility="visible";
        
        sbConOrden.style.visibility = "hidden";
        sbConOrden.style.display="none";        
        sbSinOrden.style.visibility = "visible";
        sbSinOrden.style.display = "inline";
    }    
}

function sbBuscarPor()
{
    var sbPorDestino = document.getElementById("sbPorDestino");  
    var sbPorNombre = document.getElementById("sbPorNombre");  
    
    document.getElementById("idPais").focus();
    
    if(sbPorNombre.style.visibility=="hidden" && sbPorNombre.style.display=="none")
    {
        BuscaPor = "nombre";
        sbPorNombre.style.visibility = "visible";
        sbPorNombre.style.display = "inline";

        document.getElementById("sbBuscar01").tabindex = "4";   

        sbPorDestino.style.visibility = "hidden";
        sbPorDestino.style.display = "none";
        document.getElementById("sbMoneda").style.visibility="hidden";
        document.getElementById("sbMoneda").style.display="none";
        document.getElementById("sbLlegada").style.visibility="hidden";
        document.getElementById("sbLlegada").style.display="none";
        document.getElementById("sbNochesHuespedes").style.visibility="hidden";
        document.getElementById("sbNochesHuespedes").style.display="none";                                               
        document.getElementById("sbAvanzada02").style.display="none";
        document.getElementById("sbAvanzada02").style.visibility="hidden"; 
        document.getElementById("sbAvanzada01").style.visibility="visible";
        document.getElementById("sbAvanzada01").style.display="inline";        
        document.getElementById("sbConOrden").style.display="none";
        document.getElementById("sbConOrden").style.visibility="hidden"; 
        document.getElementById("sbSinOrden").style.visibility="hidden";
        document.getElementById("sbSinOrden").style.display="none";
        
        document.getElementById("sbNombre").style.visibility="visible";
        document.getElementById("sbNombre").style.display="inline";
        document.getElementById("sbBuscarNombre").style.visibility="visible";
        document.getElementById("sbBuscarNombre").style.display="inline";
        
        
    }else{
        BuscaPor = "destino";
        sbPorDestino.style.visibility = "visible";
        sbPorDestino.style.display = "inline";
        
        document.getElementById("sbBuscar01").tabindex = "9";   

        sbPorNombre.style.visibility = "hidden";
        sbPorNombre.style.display = "none";
        document.getElementById("sbNombre").style.visibility="hidden";
        document.getElementById("sbNombre").style.display="none";
        
                
        document.getElementById("sbLlegada").style.visibility="visible";
        document.getElementById("sbLlegada").style.display="inline";
        document.getElementById("sbNochesHuespedes").style.visibility="visible";
        document.getElementById("sbNochesHuespedes").style.display="inline";              
        document.getElementById("sbBuscarNombre").style.visibility="hidden";
        document.getElementById("sbBuscarNombre").style.display="none";
        document.getElementById("sbMoneda").style.visibility="visible";
        document.getElementById("sbMoneda").style.display="inline";
        
        document.getElementById("sbConOrden").style.display="none";
        document.getElementById("sbConOrden").style.visibility="hidden";         
        document.getElementById("sbSinOrden").style.visibility="visible";
        document.getElementById("sbSinOrden").style.display="inline"; 
        document.getElementById("sbBuscar01").style.visibility="visible";
    }
}
