$( document ).ready(function() {

    //-------------- [ Slider] --------------//
    jQuery(function(){
      jQuery('#camera_wrap_1').camera({
        thumbnails: false, //MiniFoto
        time: 1500, //Tiempo
        loader: 'bar', //pie, bar tipo de cargador
        loaderColor: '#000000', //ColorLoader
        loaderBgColor: '#0000000', //ColorBackGroundLoader
        fx: 'random', //Efecto
        mobileFx: 'random', //Efecto Mobile
        hover: false, //Stop Hover
        height: '38%', //Altura
        minHeight: '300px', //Altura Minima
        autoAdvance: true, //autoplay
        navigation: false, //arrows
        pagination: true, //dots
        playPause: false, //play pause hiden
        loaderPadding: 0, //loder bar
        loaderOpacity:0.1, //Opacidar Bar Loader
        barDirection: 'leftToRight', //direccion Bar Loader
        barPosition: 'bottom', //'bottom', 'left', 'top', 'right'
      });
    });
    //-------------- [ Fin Slider ] --------------//

    //-------------- [ Datapicker ] --------------//
    $(function () {
    $.datepicker.setDefaults($.datepicker.regional["es"]);
      $("#fecida").datepicker({
      firstDay: 1
      });
      $("#fecreg").datepicker({
      firstDay: 1
      });
    });
    //-------------- [ Fin Datapicker ] --------------//

    //-------------- [ Wow ] --------------//
    var wow = new WOW(
      {
        boxClass:     'wow',      // animated element css class (default is wow)
        animateClass: 'animated', // animation css class (default is animated)
        offset:       0,          // distance to the element when triggering the animation (default is 0)
        mobile:       true,       // trigger animations on mobile devices (default is true)
        live:         true,       // act on asynchronously loaded content (default is true)
        callback:     function(box) {
          // the callback is fired every time an animation is started
          // the argument that is passed in is the DOM node being animated
        },
        scrollContainer: null // optional scroll container selector, otherwise use window
      }
    );
    wow.init();
    setTimeout(function() {
        $("#flot-air").fadeOut(1500);
    },15000);
    //-------------- [ Fin - Wow ] --------------//

    //-------------- [ MenuTop ] --------------//
    $(window).scroll(function(){

      //menu top
      if ( $(this).scrollTop() > 130 ){
        $('.cont-menu').addClass('cont-menu2');
      } else {
        $('.cont-menu').removeClass('cont-menu2');
      }

      //cont-logo2
      if ( $(this).scrollTop() > 0 ){
        $('.cont-logo').addClass('cont-logo2');
      } else {
        $('.cont-logo').removeClass('cont-logo2');
      }

      //slider
      if ( $(this).scrollTop() > 0 ){
        $('.slider').addClass('slider2');
      } else {
        $('.slider').removeClass('slider2');
      }
    });
    //-------------- [ Fin MenuTop ] --------------//



    //-------------- [ Validator ] --------------//
      $("#ok").hide();

      $("#form-contacto").validate({
          rules: {
            nombre: { required: true, minlength: 2},
            apellidos: { required: true,minlength: 2},
            pais: { required: true,minlength: 2},
            numero: { required:true, minlength: 7, number:true},
            correo: { required: true, email: true},
            mensaje: { required:true, minlength: 2},
          },
          messages: {
            nombre: "Campo invalido",
            apellidos: "Campo invalido",
            pais: "Campo invalido",
            numero: "Campo invalido",
            correo: "Campo invalido",
            mensaje: "Campo invalido",
          },
      });
      $("#form-contacto-en").validate({
          rules: {
            nombre: { required: true, minlength: 2},
            apellidos: { required: true,minlength: 2},
            pais: { required: true,minlength: 2},
            numero: { required:true, minlength: 7, number:true},
            correo: { required: true, email: true},
            mensaje: { required:true, minlength: 2},
          },
          messages: {
            nombre: "Invalid field",
            apellidos: "Invalid field",
            pais: "Invalid field",
            numero: "Invalid field",
            correo: "Invalid field",
            mensaje: "Invalid field",
          },
      });

      $("#formid-cotizar").validate({
          rules: {
            destino: { required: true,minlength: 2},
            datepicker: { required: true,minlength: 2},
            datepicker2: { required: true,minlength: 2},
            adultos: { required:true, minlength: 1, number:true},
            ninos: { required:true, minlength: 1, number:true},
            ninos2: { required:true, minlength: 1, number:true},
            nombre: { required: true, minlength: 2},
            apellidos: { required: true,minlength: 2},
            pais: { required: true,minlength: 2},
            numero: { required:true, minlength: 7, number:true},
            correo: { required: true, email: true},
            mensaje: { required:true, minlength: 2},
          },
          messages: {
            destino: "Campo invalido",
            datepicker: "Campo invalido",
            datepicker2: "Campo invalido",
            adultos: "Campo invalido",
            ninos: "Campo invalido",
            ninos2: "Campo invalido",
            nombre: "Campo invalido",
            apellidos: "Campo invalido",
            pais: "Campo invalido",
            numero: "Campo invalido",
            correo: "Campo invalido",
            mensaje: "Campo invalido",
          },
      });

      $("#formid-cotizar-en").validate({
          rules: {
            destino: { required: true,minlength: 2},
            datepicker: { required: true,minlength: 2},
            datepicker2: { required: true,minlength: 2},
            adultos: { required:true, minlength: 1, number:true},
            ninos: { required:true, minlength: 1, number:true},
            ninos2: { required:true, minlength: 1, number:true},
            nombre: { required: true, minlength: 2},
            apellidos: { required: true,minlength: 2},
            pais: { required: true,minlength: 2},
            numero: { required:true, minlength: 7, number:true},
            correo: { required: true, email: true},
            mensaje: { required:true, minlength: 2},
          },
          messages: {
            destino: "Invalid field",
            datepicker: "Invalid field",
            datepicker2: "Invalid field",
            adultos: "Invalid field",
            ninos: "Invalid field",
            ninos2: "Invalid field",
            nombre: "Invalid field",
            apellidos: "Invalid field",
            pais: "Invalid field",
            numero: "Invalid field",
            correo: "Invalid field",
            mensaje: "Invalid field",
          },
      });
    
    //-------------- [ FIN Validator ] --------------//


    //-------------- [ Carusel 2 ] --------------//
    var owl = $('.owl-carousel2');
    owl.owlCarousel({
        items: 1,
        loop: true,
        margin: 5,
        autoplay: true,
        lazyLoad: true,
        autoplayTimeout: 1500,
        autoplayHoverPause: true,
        responsive: {
            0: {
                items: 1,
                dots: false
            },
            600: {
                items: 1,
                dots: false,
                nav: false
            },
            960: {
                items: 1,
                dots: false,
                nav: false
            },
            1200: {
                items: 1,
                dots: false,
                nav: false
            }
        }
    });
    //-------------- [ Fin Carusel  ] --------------//


    //-------------- [ Carusel 1 ] --------------//
    var owl = $('.owl-carousel1');
    owl.owlCarousel({
        items: 1,
        loop: true,
        margin: 5,
        autoplay: true,
        lazyLoad: true,
        autoplayTimeout: 1500,
        autoplayHoverPause: true,
        responsive: {
            0: {
                items: 1,
                dots: false
            },
            600: {
                items: 1,
                dots: false,
                nav: false
            },
            960: {
                items: 1,
                dots: true,
                nav: false
            },
            1200: {
                items: 1,
                dots: true,
                nav: false
            }
        }
    });
    //-------------- [ Fin Carusel  ] --------------//


    //-------------- [ FancyBox  ] --------------//
    $(".ifancybox").fancybox({
         'openEffect': 'elastic',
         'width' : '75%',
         'height' : '75%',
         'autoScale' : false,
         'transitionIn' : 'elastic',
         'transitionOut' : 'elastic',
         'type' : 'iframe',
         'scrolling' : 'no'

     });

    $("a.grouped_elements").fancybox({
        'openEffect': 'elastic',
        'transitionIn'  :   'elastic',
        'transitionOut' :   'elastic',
        'speedIn'       :   600, 
        'speedOut'      :   200, 
        'overlayShow'   :   false,
        'titleShow': true
    });
    //-------------- [ FancyBox  ] --------------//

    //-------------- [ Click Alerta Mantenimiento  ] --------------//
    $( ".btn-alet" ).on( "click", function() {
        alert('Página en mantenimiento');
    });
    //-------------- [ Click Alerta Mantenimiento Fin  ] --------------//

    //-------------- [ Plugin de height ] --------------//
    equalheight = function(container){

    var currentTallest = 0,
         currentRowStart = 0,
         rowDivs = new Array(),
         $el,
         topPosition = 0;
     $(container).each(function() {

       $el = $(this);
       $($el).height('auto')
       topPostion = $el.position().top;

       if (currentRowStart != topPostion) {
         for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
           rowDivs[currentDiv].height(currentTallest);
         }
         rowDivs.length = 0; // empty the array
         currentRowStart = topPostion;
         currentTallest = $el.height();
         rowDivs.push($el);
       } else {
         rowDivs.push($el);
         currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
      }
       for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
         rowDivs[currentDiv].height(currentTallest);
       }
     });
    }

    $(window).load(function() {
      equalheight('.row .port-item');
      equalheight('.row .port-item2');
      equalheight('.row .port-item3');
    });

    $(window).resize(function(){
      equalheight('.row .port-item');
      equalheight('.row .port-item2');
      equalheight('.row .port-item3');
    });
    //-------------- [ FIN - Plugin de height ] --------------//


});


//-------------- [Menu - Responsive] --------------//

$(document).ready(main);
var contador = 1;
function main () {
    $('.menu_bar').click(function(){
        if (contador == 1) {
            $('.menu nav').animate({
                left: '0%'
            });
            //$('.menu_bar').addClass('menu_bar2');
            $('#btn_bar').removeClass('tg-menu');
            $('#btn_bar').addClass('tg-cross');
            $('#btn_bar2').addClass('menu_bar2');
            //animate('.sumak2-cross', 'animated jello');
            contador = 0;
        } else {
            contador = 1;
            $('.menu nav').animate({
                left: '-100%'
            });
            //$('.menu_bar').removeClass('menu_bar2');
            $('#btn_bar').removeClass('tg-cross');
            $('#btn_bar').addClass('tg-menu');
            $('#btn_bar2').removeClass('menu_bar2');
            //animate('.sumak2-menu', 'animated jello');
        }
    });  
    $('.menu nav ul li').click(function(){
        contador = 1;
        $('.menu nav').animate({
          left: '-100%'
        });
    });

}
//-------------- [Fin/ Menu - Responsive] --------------//
