﻿
    function SetUniqueRadioButton(nameregex, current)
    {        
       re = new RegExp(nameregex);
       for(i = 0; i < document.forms[0].elements.length; i++)
       {
          elm = document.forms[0].elements[i]
          if (elm.type == 'radio')
          {
             if (re.test(elm.name))
             {
                elm.checked = false;
             }
          }
       }
       current.checked = true;
    }

    function SetUniqueCat(nameregex, current)
    {
       //Averiguo la cantidad de categorias contando los callapsiblepanels        
       var CantPanels = 0;

       for(i = 0; i < document.forms[0].elements.length; i++)
       {
            elm = document.forms[0].elements[i]
            if (elm.name.indexOf("rdbCategorias")>0)
                CantPanels = CantPanels + 1;
       }
              
       //Marco el radio button corespondiente       
       re = new RegExp(nameregex);
       index = 0;
       for(i = 0; i < document.forms[0].elements.length; i++)
       {
          elm = document.forms[0].elements[i]
          if (elm.type == 'radio')
          {
             if (re.test(elm.name))
             {                                           
                elm.checked = false;
                if (current.name == elm.name)
                    sel = index;
                index = index + 1;     
             }
          }
       }
       current.checked = true;
        
       //Abro el panel correspondiente y cierro los demas
       for (num = 0; num < CantPanels; num++) 
       {
         
          if (num != sel)
              {
              aux = num;
              if (num < 10)
              aux = "0" + aux;
              //contr.set_Collapsed(true); //Se Cierra
              //document.getElementById("ctl00_cphPrincipal_ctrlAlojamientos_rptrCategorias_ctl" + aux + "_pnlHoteles").style.display='none';
              //document.getElementById("ctl00_cphPrincipal_ctrlAlojamientos_rptrCategorias_ctl" + aux + "_pnlHoteles").style.height='0 px';
              document.getElementById("ctl00_cphPrincipal_ctrlAlojamientos_rptrCategorias_ctl" + aux + "_divMargen").className='alojamiento-seleccion hidden';
            
              }
          else
          {           
              //contr.set_Collapsed(false); //Se Expande
              //Busco el precio seleccionado en la categoria
              ind = 0;
              aux = sel;
              if (sel < 10)
                aux = "0" + aux;
              seleccionad=aux;
              //document.getElementById("ctl00_cphPrincipal_ctrlAlojamientos_rptrCategorias_ctl" + aux + "_pnlHoteles").style.display='block';
              //document.getElementById("ctl00_cphPrincipal_ctrlAlojamientos_rptrCategorias_ctl" + aux + "_pnlHoteles").style.height='auto';
              document.getElementById("ctl00_cphPrincipal_ctrlAlojamientos_rptrCategorias_ctl" + aux + "_divMargen").className='alojamiento-seleccion seleccionado ';
              //precioSel = document.getElementById("ctrlAlojamientos_rptrCategorias_ctl" + aux + "_lstOpciones_" + ind);  
              precioSel = document.getElementById("ctl00_cphPrincipal_ctrlAlojamientos_rptrCategorias_ctl" + aux + "_lstOpciones_" + ind);  
              while (precioSel.checked != true)
              {
                ind = ind + 1;
                //precioSel = document.getElementById("ctrlAlojamientos_rptrCategorias_ctl" + aux + "_lstOpciones_" + ind);                            
                precioSel = document.getElementById("ctl00_cphPrincipal_ctrlAlojamientos_rptrCategorias_ctl" + aux + "_lstOpciones_" + ind);                            
              }     
              ActualizarImporte("Aloj", precioSel.value);
              //document.getElementById("ctl00_cphPrincipal_ctrlAlojamientos_rptrCategorias_ctl" + aux + "_rdbCategorias").scrollIntoView(true);
              //document.getElementById("ctl00_cphPrincipal_ctrlAlojamientos_rptrCategorias_ctl" + aux + "_rdbCategorias").focus();
          }
       } 
    }
function CambiarHabitaciones()
{
//alert('loquesea');
   var Habita = document.getElementById("ctl00_cphPrincipal_ctrlHabitaciones_ddlHabitaciones");
   for(i = 0; i < Habita.options.length; i++)
   {
        if (i <= Habita.selectedIndex)
            document.getElementById("ctl00_cphPrincipal_ctrlHabitaciones_rptrHabitaciones_ctl0" + i + "_divCamas").style.display='';
        else
            $("#ctl00_cphPrincipal_ctrlHabitaciones_rptrHabitaciones_ctl0" + i + "_divCamas").css("display","none");
    }
}
    function ActualizarImporte(ctrl, importe)
    {
        //var alojam = document.getElementById("ctrlAlojamientos_lblImporteAloj");
        //var vuelos = document.getElementById("ctrlVuelos_lblImporteVuel");
        //var extras = document.getElementById("ctrlExtras_lblImporteExtr");
        //var total = document.getElementById("ctrlExtras_lblPrecioNum");

        var alojam = document.getElementById("ctl00_cphPrincipal_ctrlAlojamientos_lblImporteAloj");
        var vuelos = document.getElementById("ctl00_cphPrincipal_ctrlVuelos_lblImporteVuel");
        var extras = document.getElementById("ctl00_cphPrincipal_ctrlExtras_lblImporteExtr");
        var total = document.getElementById("ctl00_cphPrincipal_ctrlExtras_lblPrecioNum");

        if (ctrl == "Aloj") 
            alojam.innerHTML = importe;
        if (ctrl == "Vuel") 
            vuelos.innerHTML = importe;        
        if (ctrl == "Extr")
            extras.innerHTML = extras.innerHTML;
        total.innerHTML = total.innerHTML.replace('€','');
        total.innerHTML = parseFloat(alojam.innerHTML.replace(',','.')) + parseFloat(vuelos.innerHTML.replace(',','.')) + parseFloat(extras.innerHTML.replace(',','.'));
        total.innerHTML = total.innerHTML.replace('.',',') + '€'        
    }
    
    function CambioEnExtras(rptr, current, importe)
    { 
       //var extras = document.getElementById("ctrlExtras_lblImporteExtr");           
       var extras = document.getElementById("ctl00_cphPrincipal_ctrlExtras_lblImporteExtr");           
       estIni = !current.checked;
       for(i = 0; i < document.forms[0].elements.length; i++)
       {
          elm = document.forms[0].elements[i];
          if (elm.type == 'checkbox')
          {
              if (elm.name.indexOf(rptr) == 0)
              {
                  //Si dehabilito un checkbox Resto su importe
                  if ((elm.checked == true) && (elm != current))
                    {
                        idPrecio = elm.name.replace('chkExtra','lblPrecio')
                        while (idPrecio.indexOf('$') != -1)
                             idPrecio = idPrecio.replace('$','_');
                        lblPrecio = document.getElementById(idPrecio);                        
                        extras.innerHTML = parseFloat(extras.innerHTML.replace(',','.')) - parseFloat(lblPrecio.innerHTML.replace(',','.'))
                    }
                  elm.checked = false;
              }
          }
       }
       if (estIni == false)
          {
          current.checked = true;
          extras.innerHTML = parseFloat(extras.innerHTML.replace(',','.')) + parseFloat(importe.replace(',','.'))              
          }
       else
          extras.innerHTML = parseFloat(extras.innerHTML.replace(',','.')) - parseFloat(importe.replace(',','.'))
       extras.innerHTML = extras.innerHTML.replace('.',',')
     } 

function MostrarUpdateProgress()
{
//alert('loquesea');
    if (document.getElementById("ctl00_cphPrincipal_UpdateProgress1"))
  document.getElementById("ctl00_cphPrincipal_UpdateProgress1").style.display='';
  //document.getElementById("ie6select").style.display='';
    if (document.getElementById("ctl00_cphPrincipal_ctrlCalendario_divCalendario"))
  document.getElementById("ctl00_cphPrincipal_ctrlCalendario_divCalendario").style.display='';
    if (document.getElementById("ctl00_cphPrincipal_ctrlAlojamientos_divAlojamientos"))
  document.getElementById("ctl00_cphPrincipal_ctrlAlojamientos_divAlojamientos").style.display='';
    if (document.getElementById("ctl00_cphPrincipal_ctrlVuelos_divPrincipal"))
  document.getElementById("ctl00_cphPrincipal_ctrlVuelos_divPrincipal").style.display='';
    if (document.getElementById("ctl00_cphPrincipal_ctrlExtras_divExtras"))
  document.getElementById("ctl00_cphPrincipal_ctrlExtras_divExtras").style.display='';
    if (document.getElementById("ctl00_cphPrincipal_ctrlHabitaciones_pnlBuscar"))
  document.getElementById("ctl00_cphPrincipal_ctrlHabitaciones_pnlBuscar").style.display='none';  
}

function OcultarPaneles()
{
    $("#ctl00_cphPrincipal_ctrlCalendario_divCalendario").css("display","none");
    $("#ctl00_cphPrincipal_ctrlAlojamientos_divAlojamientos").css("display","none");
    $("#ctl00_cphPrincipal_ctrlVuelos_divPrincipal").css("display","none");
    $("#ctl00_cphPrincipal_ctrlHabitaciones_pnlBuscar").css("display","none");
    $("#ctl00_cphPrincipal_ctrlHabitaciones_pnlBuscar").css("display","");

}

function CambiarCapaFicha(tab)
{
    for(var i=1;i<=5;i++)
    {
        if(tab==i)
        {
            //alert('Ficha' + tab + ' i=' + i + ' en si');
            if(i==1)
            {
                document.getElementById("ctl00_cphPrincipal_tabFicha"+i).className = "first-child active";
            }
            else
            {
                document.getElementById("ctl00_cphPrincipal_tabFicha"+i).className = "active";
            }
            document.getElementById("ctl00_cphPrincipal_ctrlFichaPaquete_divFicha"+i).style.display = "";

        }
        else
        {
            //alert('Ficha' + tab + ' i=' + i + ' en no');
             if(i==1)
            {
                document.getElementById("ctl00_cphPrincipal_tabFicha"+i).className = "";
            }
            else
            {
                document.getElementById("ctl00_cphPrincipal_tabFicha"+i).className = "";
            }       
            document.getElementById("ctl00_cphPrincipal_ctrlFichaPaquete_divFicha"+i).style.display = "none";

        }
  
    }
}
function MostrarMasHotel(name){
if (!$('#' + name + '_lblDescri').is(':visible')) {
        $('#' + name + '_lblDescri').slideDown(0);
        $('#' + name + '_lblDescriMas').slideUp(0);
        $('#' + name + '_lblMasInfoHotel').html('...+Info');
    } else {
        $('#' + name + '_lblDescri').slideUp(0);
        $('#' + name + '_lblDescriMas').slideDown(0);
        $('#' + name + '_lblMasInfoHotel').html('...-Info');

    }
}



function MuestraPopUpCalendario(id)
{     
    var html = '<div>'+
    '<div style="text-align:left; margin-top:15px; margin-left:15px;"><span>Precio final por persona para '+ $("#ctl00_cphPrincipal_ctrlFichaPaquete_lblDuracion").text() +'</span></div>'
    +'</div>';
    var posicion = $("#"+id+"").offset();

$("#VentanaCalendario").html(html);
if(true)
{
    jQuery.each(jQuery.browser, function(i) 
    {
           if($.browser.msie && ($.browser.version == "7.0"))
           {
                posicion.top = posicion.top;
                posicion.left = posicion.left - 135;
           }
           else if($.browser.msie)
           {
                posicion.top = posicion.top;
                posicion.left = posicion.left - 135;
           }           
           else if ($.browser.mozilla)
           {           
                posicion.top = posicion.top;// - 10;
                posicion.left = posicion.left - 135;// - 239;80
           }
           else
           {
                posicion.top = posicion.top - 5;
                posicion.left = posicion.left - 160;
           }
    });
}
   $("#VentanaCalendario").show();
   
  
$("#VentanaCalendario").offset(posicion);
//Añade el hotel a los que habia anteriormente

	
//$("#Prueba").show();
    //alert("juanito duerme en la oficina es como los chinos");
}

