// JS de index.html
$(function() {
    // MODALS
      // Pinto en el desplegable la selección modal y cierro la ventana modal
      $("#myModal1").on('click','a', function(){
          $('#btn-buscar-movile').html('<img src="img/cargando-blanco.gif" width="10" alt="Buscar cruceros"/>');
          var relacionado = $(this).parents("div").attr('relacionado');
          var modalSelector = $(this);
          $("button.myModal1").html(modalSelector.html());
          $('#'+relacionado).val($(this).parents("li").attr('value'));
          setTimeout(function() { $('#myModal1').modal('hide'); },200);
          getDestinosMobile();
          getMesesMobile();
          getDuracionesMobile();
          getPuertosMobile();
          getNavierasMobile();
          getNumCrucerosMobile();
      });
      // Pinto en el desplegable la selección modal y cierro la ventana modal
      $("#myModal2").on('click','a', function(){
          $('#btn-buscar-movile').html('<img src="img/cargando-blanco.gif" width="10" alt="Buscar cruceros"/>');
          var relacionado = $(this).parents("div").attr('relacionado');
          var modalSelector = $(this);
          $("button.myModal2").html(modalSelector.html());
          $('#'+relacionado).val($(this).parents("li").attr('value'));
          setTimeout(function() { $('#myModal2').modal('hide'); },200);
          getDestinosMobile();
          getMesesMobile();
          getDuracionesMobile();
          getPuertosMobile();
          getNavierasMobile();
          getNumCrucerosMobile();
      });
      // Pinto en el desplegable la selección modal y cierro la ventana modal
      $("#myModal3").on('click','a', function() {
          $('#btn-buscar-movile').html('<img src="img/cargando-blanco.gif" width="10" alt="Buscar cruceros"/>');
          var relacionado = $(this).parents("div").attr('relacionado');
          var modalSelector = $(this);
          $("button.myModal3").html(modalSelector.html());
          $('#'+relacionado).val($(this).parents("li").attr('value'));
          setTimeout(function() { $('#myModal3').modal('hide'); },200);
          getDestinosMobile();
          getMesesMobile();
          getDuracionesMobile();
          getPuertosMobile();
          getNavierasMobile();
          getNumCrucerosMobile();
      });
      // Pinto en el desplegable la selección modal y cierro la ventana modal
      $("#myModal4").on('click','a', function() {
          $('#btn-buscar-movile').html('<img src="img/cargando-blanco.gif" width="10" alt="Buscar cruceros"/>');
          var relacionado = $(this).parents("div").attr('relacionado');
          var modalSelector = $(this);
          $("button.myModal4").html(modalSelector.html());
          $('#'+relacionado).val($(this).parents("li").attr('value'));
          setTimeout(function() { $('#myModal4').modal('hide'); },200);
          getDestinosMobile();
          getMesesMobile();
          getDuracionesMobile();
          getPuertosMobile();
          getNavierasMobile();
          getNumCrucerosMobile();
      });
      // Pinto en el desplegable la selección modal y cierro la ventana modal
      $("#myModal5").on('click','a', function() {
          $('#btn-buscar-movile').html('<img src="img/cargando-blanco.gif" width="10" alt="Buscar cruceros"/>');
          var relacionado = $(this).parents("div").attr('relacionado');
          var modalSelector = $(this);
          $("button.myModal5").html(modalSelector.html());
          $('#'+relacionado).val($(this).parents("li").attr('value'));
          setTimeout(function() { $('#myModal5').modal('hide'); },200);
          getDestinosMobile();
          getMesesMobile();
          getDuracionesMobile();
          getPuertosMobile();
          getNavierasMobile();
          getNumCrucerosMobile();
      });
      // Pinto en el desplegable la selección modal y cierro la ventana modal
      $("#myModal6").on('click','a', function() {
          $('#btn-buscar-movile').html('<img src="img/cargando-blanco.gif" width="10" alt="Buscar cruceros"/>');
          var relacionado = $(this).parents("div").attr('relacionado');
          var modalSelector = $(this);
          $("button.myModal6").html(modalSelector.html());
          $('#'+relacionado).val($(this).parents("li").attr('value'));
          setTimeout(function() { $('#myModal6').modal('hide'); },200);
          getDestinosMobile();
          getMesesMobile();
          getDuracionesMobile();
          getPuertosMobile();
          getNavierasMobile();
          getNumCrucerosMobile();
      });
      // Pinto en el desplegable la selección modal y cierro la ventana modal
      $("#myModal9").on('click','a', function() {
          $('#btn-buscar-movile').html('<img src="img/cargando-blanco.gif" width="10" alt="Buscar cruceros"/>');
          var relacionado = $(this).parents("div").attr('relacionado');
          var modalSelector = $(this);
          $("button.myModal9").html(modalSelector.html());
          $('#'+relacionado).val($(this).parents("li").attr('value'));
          setTimeout(function() { $('#myModal9').modal('hide'); },200);
          getDestinosMobile();
          getMesesMobile();
          getDuracionesMobile();
          getPuertosMobile();
          getNavierasMobile();
          getNumCrucerosMobile();
      });

    desplegables();
});

jQuery(document).ready(function($) {
 $temp1=0;
 menu_movil_pc();
 $(window).resize(function() {
  if($(window).width() <= 770 && $temp1==0){
    $temp1=1;
    menu_movil_pc();
  }
  if($(window).width() >= 771 && $temp1==1){
    $temp1=0;
    menu_movil_pc();
    $( ".GetSelect" ).change(function() {
      getUrlSelec($(this).attr('id'));
    });//::END->change
  }
});
  $("#mvsearch").hide();
});//::END->Ready

function menu_movil_pc() {
 if($(window).width() <= 770){
  $(".lupa").show();
  $("#menu_movil").html($("#menu_home").html());
  // $("#menu_home").html('');
  $( ".GetSelect" ).change(function() {
      getUrlSelec($(this).attr('id'));
  });//::END->change
}else{
  if($("#menu_movil").html()!="")
    $("#menu_home").html($("#menu_movil").html())
  $("#menu_movil").html('');
  
}
}//::END->menu_movil_pc()

function ImgError(source) {
    source.src = "/storage/caras/no.jpg";
    source.onerror = "";
    return true;
}
$(function() {
    getUrlSelec();
    $('.tab_destacados').click(function(event) {
        var tab = event.target.getAttribute('tab-rel');
        $('.tab_destacados').removeClass('active');
        $('.tab_destacados[tab-rel=' + tab + ']').addClass('active');
        $('.cont-destacados').css('display', 'none');
        $('.cont-destacados[cont-rel=' + tab + ']').css('display', '');
    });
});

var name3Slider="";
    function loadHeadSlider() {
        var name3="searcher"; 
        window[name3]=$("#header-slider");
        window[name3Slider]=name3+"Slider";
        window[name3Slider]=window[name3].lightSlider( {
            loop: true, 
            keyPress:false, 
            gallery:false, 
            controls:true, 
            pager:false, 
            item:1, 
            slideMargin:0, 
            speed:700, 
            pause:4000, 
            auto:true
        });
        var prev3="."+name3+" .slideControls .slidePrev";
        var next3="."+name3+" .slideControls .slideNext";
        $(prev3).click(function() {
            window[name3Slider].goToPrevSlide()
        });
        $(next3).click(function() {
            window[name3Slider].goToNextSlide()
        });
    }
    
function loadHeadSliderMax() {
        var name3="searcher"; 
        window[name3]=$("#header-slider");
        window[name3Slider]=name3+"Slider";
        window[name3Slider]=window[name3].lightSlider( {
            loop: true, 
            keyPress:false, 
            gallery:false, 
            controls:true, 
            pager:false, 
            item:3, 
            slideMargin:1, 
            speed:700, 
            pause:4000, 
            auto:true,
            pauseOnHover: true,
        });
        var prev3="."+name3+" .slideControls .slidePrev";
        var next3="."+name3+" .slideControls .slideNext";
        $(prev3).click(function() {
            window[name3Slider].goToPrevSlide()
        });
        $(next3).click(function() {
            window[name3Slider].goToNextSlide()
        });           
     }
jQuery(document).ready(function($) {  
  HeadSlider()
});
function HeadSlider() {
  $contimg= $("#header-slider>div>a").toArray().length;
   $bW=$(window).width()+17;

   if($bW > '1490'){
    if($contimg > 2){
      loadHeadSliderMax();
      $(".searcher__bg>.lSSlideOuter>.lSSlideWrapper").css({
        width: '4050px',
        maxWidth: '4050px',
        display: 'block',
        margin: 'auto',
        'margin-left': '-530px !important'
      });
      $(".searcher__bg>.lSSlideOuter").addClass('medio')
      $(".searcher__bg>.lSSlideOuter>.lSSlideWrapper").addClass('intermedio')
    }else{
      loadHeadSlidersimple($contimg);
    }
   }else{
    loadHeadSlider();
   }
   function loadHeadSlidersimple($contimg){
      if($contimg==1){
        $(".slideControls").remove();
      }
      $("#header-slider>div>a>img").css({
          display: 'block',
          margin : 'auto'
        })
      $("#style").remove()
      loadHeadSlider();
   }
}