                                                                    /*==========================================================================
                 EFECTOS, FUNCIONES Y METODOS - VIAJES PACIFICO
==========================================================================*/
$(document).ready(function(){

    /* ========================= CHANGUE FONDO X SECCION =================*/
    var ruta=$('#idem').text();

    function zonaActiva(capa) { //Funcion para resaltar menu Activo
        //$(capa).removeClass('cuf3'); //quitar clase cufon de font light
        $(capa).addClass('cufM'); // Añadir clase de cufon bold
        //Cufon.refresh();
    }

    switch (ruta) {
        case 'Home':
          zonaActiva('#home-m'); //llamara funcion segun idem
        break;        
        
        case 'Nosotros':
           zonaActiva('#nosotros-m');
        break;

        case 'Experiencia':
            zonaActiva('#experiencia-m');
        break;

        case 'Guia':
            zonaActiva('#guia-m');
        break;

        case 'Galeria':
            zonaActiva('#galeria-m');
        break;

        case 'Contactenos':
            zonaActiva('#contact-m');
        break;

        case 'ViajeMedida':
            $('#tab0').addClass('actived');
        break;

        case 'Habitaciones':
            $('#tab2').addClass('actived');
        break;

        case 'Tarifas':
            $('#tab3').addClass('actived');
        break;

        case 'CircuitoExpress':
            $('#tab4').addClass('actived');
            zonaActiva('#experiencia-m');
        break;
    }

    //RENDERIZADO DEL TEXTO
    Cufon.replace('a.idioma', {fontFamily:'Adelle Rg',hover: {textShadow: '1px 1px #333'}});
    Cufon.replace('.inputs-s span,  .noticias-cuerpo h3, .redes-sociales', {fontFamily:'Adelle lt',hover:true});
    Cufon.replace('.quick h3, .viajes h3, .title-paquete, .circuite-detalle-right h1', {fontFamily:'Adelle Rg', hover:true});
    //Cufon.replace('.cuf3,  .cuf5', {fontFamily:'Adelle lt', hover:true});
    Cufon.replace('#circuite-detalle-right h2, .extenciones-info, .caption', {fontFamily:'Adelle SB', hover:true});
    //Cufon.replace('.cufM', {fontFamily:'Adelle Rg', hover:true});
    Cufon.replace('.cuf7', {fontFamily:'Adelle Rg', textShadow: '1px 2px #333'});
    Cufon.replace('.cuf10', {fontFamily:'Adelle Rg', textShadow: '1px 2px #333'});
    Cufon.replace('.cuf11', {fontFamily:'Adelle lt', textShadow: '1px 2px #333'});
    //Cufon.replace('.itinerario p strong', {fontFamily:'Adelle Rg'});

   //EFECTO DE CURVAS EN LAS ESQUINAS DE LAS CAJAS
  // $('.search :text').addClass('text-search');

   //EFECTO DE SLIDER LECTOR DE NOTICIAS
   function lectorNews() {
	   $('.text-noticias p a').hover(
		 function() {
			 $(this).parent('p').css('background-color', '#D8CCA3');
		 },
		 function() {
			 $(this).parent('p').css('background-color', 'transparent');
	     }
	   );
	   
       $('.btn-up').click(function () {
            var p=$('div.text-noticias');
            var position = p.position();
            if (position.top < 0) {
                $(".text-noticias").animate({"top": "+=60px"}, 500, function() { $('.btn-up').removeAttr('disabled') } );
				$(this).attr("disabled","disabled");
            }
           
        });

        $('.btn-down').click(function () {
           
            var h=$("div.text-noticias").height();
            var p=$('div.text-noticias');
            var limit=(h-147);
            var posit = p.position()['top'];            
            if(posit > -limit) {
                $(".text-noticias").animate({top: "-=60px"}, 500, function() { $('.btn-down').removeAttr('disabled') } );
				$(this).attr("disabled","disabled");
            }
            
            
        });
   }
   lectorNews();
  
    //EFECTO DE BORRADO DEL TEXTO EN LA CAJA DE INGRESAR MAIL
    //$('input.mail-new').val('Tu correo...');
    $("input.mail-new").focus (function () {$(this).val('');});


    //EFECTO DE SLIDER HOVER EN EL MENU DE GUIA DE VIAJES
    function miniMenu() {
        //$(".menu-mini2").height($(".menu-mini2 ul").height());

        //Animar hacia el 1er Item
        $('.menu-mini2 .fondo-menu').stop().animate({top: -35}, {easing: '', duration:100});
        var topval;
        var realtop;
        $(".menu-mini2 li").hover(
            function() {
                //Asigno a la variable TOPVAL la position top del LI actual
                topval = $(this).position()['top'];
                realtop=(topval-41);
                
                //Aplico la animacion de fondo segun variable TOPVAL
                $('.menu-mini2 .fondo-menu').stop().animate({top: realtop}, {easing: '', duration:500});
            },

            function() {}
        );
    }
    //miniMenu();

    //EFECTO SLIDER y LIGHBOXDE GALERIA DE IMAGENES
    function galleryImg() {
        /*$('#eslider').jcarousel({
            start: 3
        });*/

        $(".ul-perfil li a img").fadeTo(0, 0.7);

        $(".ul-perfil li a").hover (
            function() {
                $("img", this).fadeTo(500, 1);
            },
            function() {
                $("img", this).fadeTo(300, 0.7);
            }
        );

        $('.ul-perfil li a').lightBox();
		$('.vista').lightBox();
    }
    galleryImg();

    /*function galeriaImages() {
         $(".g-imagenes li a img").fadeTo(0, 0.7);

        $(".g-imagenes li a").hover (
            function() {
                $("img", this).fadeTo(500, 1);
            },
            function() {
                $("img", this).fadeTo(300, 0.7);
            }
        );
    }
    galeriaImages();*/

    //COLOR DISTINTO A LOS DIV-TOUR
    $("#tours div:eq(1)").css({"background":"#5A6727 url(public/images/fondo/fondo_pie_tour2.jpg) no-repeat bottom", "margin":"0 3px"});
    $("#tours div:eq(2)").css("background", "#FCBA15 url(public/images/fondo/fondo_pie_tour3.jpg) no-repeat bottom");


    //EFECTO SLIDER PARA CABECERA EXPERIENCIAS
//    $("#slider").easySlider({
//        pause: 5000,
//        auto: true,
//        continuous: true,
//        numeric: true
//    });
    



    //EFECTOS DE TABS DE CABECERA EN EXPERIENCIAS
    function experTabs() {
        $(".ul-tabs li").bind ("click", function(e) {
            var id=$(this).attr('id');
            $('.ul-tabs li p').removeClass('tab-hover');
            $('.ul-tabs li a').removeClass('puntero');
            $('.ul-tabs li a').attr('href', '#');
            $('#mytabs > div').css('display', 'none');

            $('p', this).addClass('tab-hover');
            $('a', this).addClass('puntero');
            $('a', this).removeAttr('href');
            $('#mytabs > div:eq('+id+')').css('display', 'block');
            e.preventDefault();
        });
    }
    //experTabs();
    function Buscadores(cOculta, botton, direcc) {
        $(cOculta).hide(0);
        $(botton).click(function(e) {
            e.preventDefault();
            $(cOculta).show("slide", {direction: direcc}, 1000);
        });
    }

    function ocultarBusca(cOculta, botton, direcc) {
        $(botton).click(function(e) {
            e.preventDefault();
            $(cOculta).hide("slide", {direction: direcc}, 1000);
        });
    }


    function dataSlider() {
        Buscadores('#box-fbuscar', '#idbuscador', 'left');
        Buscadores('#box-whishlist', '#idwishlist', 'right');

        ocultarBusca('#box-fbuscar', '#btnCloseBus', 'left');
        ocultarBusca('#box-whishlist', '#btnCloseWis', 'right');

        $(".datepicker, .datep4").datepicker ({
            monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Deciembre'],
            showOn: 'button',
            buttonImage: '/public/images/calendar.png',
            buttonImageOnly: true,
            //buttonText: 'Choose',
            dateFormat:'yy-mm-dd',
            dayNamesMin:['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sa']
        });
    }
    dataSlider();

    //REDIMENSIONADO DE DIV-TOURS
    function redimenSionado() {
        var array=new Array();
        var count=$("#tours .div-tours").length;
        var mayor=0;

        $('.div-tours').each(function(i){
            var th=$('ul',this).height();
            array[i]=th;
        });

        for (var j=0;j<count;j++) {
            if (mayor<array[j]) {
                mayor=array[j];
            }
        }
        $(".div-tours ul").height(mayor);
    }
    redimenSionado();

    //SELECCION DE COSTA BACKGROUND-COLOR
    $('.region:eq(0) .cab-reg, .region:eq(0) .body-region, .region:eq(0) .pie-reg').css('background-color', '#ECE9E5');
    $('.region:eq(1)').css('margin', '0 15px');

    //Tabla Contactenos formato td:even
    $('.table-contacto tr td:even').addClass('tdeven');

    //Efecto Minimizar y maximizar Caja - Nosotros
    function mostrarBox() {
        $('#minimizar').toggle (
            function(e) {
                e.preventDefault();
                $('#nos-box').hide('fold', {direction: "right"}, 1000);
                $('img', this).attr('src','/public/images/btn/btn-max.png');
                $(this).attr('title','Maximizar');
            },
            function(e) {
                e.preventDefault();
                $('#nos-box').show('fold', {direction: "right"}, 1000);
                $('img', this).attr("src","/public/images/btn/btn-min.png");
                $(this).attr('title','Minimizar');
            }
        );

    }
    //mostrarBox();

    //Efecto de Alternas texto segun seleecion
    function verDescrip() {
        $('.ul-nosotros li a').click(function(e) {
            e.preventDefault();
            $('.ul-nosotros li a').removeClass('item-selecc');
            $(this).addClass('item-selecc');//Colorear Seleccionado

            var id = $(this).attr('href');

            var ntexto = $(id+' .div-oculto').html();
            var imgcorpo = $(id+' .img-pre').html();
            var text1 = $(id+' .pasteur').children('span:first').text();
            var text2 = $(id+' .pasteur').children('span:last').html();

            $('.box-nosotros').fadeOut(500, function(){
                $(this).fadeIn(100).html(ntexto);//Efecto Cambiar Texto segun item seleccionado.
            });

            $('#img-corpo').fadeOut(500, function(){
                $(this).fadeIn(100).html(imgcorpo);//Efecto Cambiar Imagen segun item seleccionado.
            });

            $('h1 span.cuf8').text(text1);//Efecto Cambiar Texto segun item seleccionado.
            $('h1 span.cuf9').html(text2);
            Cufon.refresh(); //Refrescar Cufon

            var line = $('.imgChangue h1').width();
            $('.whiteLine').width(line+15);
        });
    }
    verDescrip();

    //Tabs de Guia viajes
    $('.tab-guia:eq(1)').css({'margin':'0 7px'});
    //$('.tab-guia:eq(2)').css({'background-color':'#FBBA14'});

    //EFECTO DE FADETO PARA LA REDES SOCIALES
    function redCompartir() {
        $("#redc").hide(0);
        $('#redc2').toggle(
            function() {$("#redc").fadeIn(500);},
            function() {$("#redc").slideUp(200);}
        );
    }
    redCompartir();

    //EFECTO MANDA A UN AMIGO
    function sendFriend() {
         

        $('#btn-close').click (function(e) {
            e.preventDefault();
            $('.form-amigo').hide('fold', {direction: "bottom"}, 1000);
        });
        $('#sendAmigo').click (
            function(e) {
                e.preventDefault();
                $('.form-amigo').css('display','block');
            }
        );

    }
    sendFriend();

    //EFECTO SHOW CALENDAR
    $('#caja-calendar').hide(0);
    $('.box-calendar a').click (function(e) {//Abrir Calendario
        e.preventDefault();
        $('.caja-calendar').show('slide', {direction: "left"}, 1000);
    });

    $('#close-calendar').click (function(e) {//Ocultar Calendario
        e.preventDefault();
        $('.caja-calendar').hide('slide', {direction: "left"}, 1000);
    });

    //EFECTO SHOW OCULTAR TABS
    function mostrarTabs() {
	 //$("#tabs").tabs();
        
        $('.content-miniTab').hide(); //Ocultamos todos los tabs

        $('.miniTabs li a').click(function(e) {
            e.preventDefault();
            $('.miniTabs li a').removeClass('min-actived');
            $(this).addClass('min-actived');
            $('.content-miniTab').hide(0); //Ocultamos todos los tabs

            var activedTab=$(this).attr('href');
            $(activedTab).show(10);
            return false;
        });

        $('.miniTabs li:first a').trigger('click')
    }

		mostrarTabs() ;
		
        //EFECTO GALERIA - NO BORRAR BAJO PENA DE DESCUENTO
       $('.galeria-content > div').hide(); //Ocultamos todos los tabs 
        $('.tabs li').append('<img class="absoluto" src="/public/images/fondo/esquina_tab-1.png" width="18" height="29" /><img class="absoluto4" src="/public/images/fondo/esquina_tab-2.png" width="18" height="29" />');
        
        $('.tabs li a').click(function(e) {
            //e.preventDefault();
            $('.tabs li a').removeClass('min-actived');
            $(this).addClass('min-actived');
            $('.galeria-content > div').hide(); //Ocultamos todos los tabs 

            var activedTab=$(this).attr('href');
            $(activedTab).fadeIn();
            Cufon.refresh();
        });
        $('.tabs li:first a').trigger('click');
    
	
	
    //Acordion Formulario
    $('#table2').slideUp(0);
    $('a#btn-medida').click(function(e) {
           e.preventDefault();
           var tablef=$(this).attr('href');
           $(tablef).slideToggle('fast');
           //$(this).toggleClass('btn-desplegableOn');
    });
    //$('.btn-desplegable:first').trigger('click');

    //DatePicker Doble
    $(".datep2, .datep3").datepicker ({
            monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Deciembre'],
            dateFormat:'yy-mm-dd',
            dayNamesMin:['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sa'],
            numberOfMonths: 1
     });

     //Acordion de dias circuito express
     function acordionDias() {
         $('.ul-itiner li p').hide();
         $('.ul-itiner li').click (function(e) {
             e.preventDefault();             
             $('p', this).slideToggle(500);
             $('a', this).toggleClass('desplegableOn');
         });
     }
     acordionDias();

     //Funcion de Minimo de Personas
     function minPersonas() {
         var min=$('#minpasajeros').attr('title');
         var per=(min*20)-5;

         $('#minpasajeros').css('width', per+'px');
     }
     minPersonas();

function sliderScroll() {

     //Scroll the menu on mouse move above the #sidebar layer GUIA DE VIAJES
     $('#sidebar').mousemove(function(e) {

         //Sidebar Offset, Top value
         var s_top = parseInt($('#sidebar').offset().top);

         //Sidebar Offset, Bottom value
         var s_bottom = parseInt($('#sidebar').height() + s_top);

         //Roughly calculate the height of the menu by multiply height of a single LI with the total of LIs
         var mheight = parseInt($('#menu li').height() * $('#menu li').length);        

         //Calculate the top value
         //This equation is not the perfect, but it 's very close
         var top_value = Math.round(( (s_top - e.pageY) /203) * mheight / 2)

         //Animate the #menu by chaging the top value
         $('#menu').animate({top: (top_value)}, {queue:false, duration:800});
     });
}
sliderScroll();


//Funcion de efecto de Tab Itinerario
function ulItinerario() {
    $('.ul-itinerario li p').hide();
    $('a.btn-detalle').click(function(e) {
        e.preventDefault();
        $('.ul-itinerario li p').slideDown();
    });
}
ulItinerario();

function viewMenu() {

    $('#home-m, #nosotros-m, #galeria-m, contact-m').mouseover(function() {
        $('#viewSubmenu').fadeOut(70);
    });

    $('#experiencia-m, #guia-m').hover(
        function() {
            $('#viewSubmenu').fadeIn(70);
            $('#viewSubmenu').css('display', 'block');
            
            var idem = $(this).attr('id');

            var dataList = $('div[title$="'+idem+'"] ul').html();
            var dataProduct = $('div[title$="'+idem+'"] dl').html();

            $('#viewSubmenu ul').html(dataList);
            $('#viewSubmenu .carnecitas dl').html(dataProduct);
        }
    );

    $('#viewSubmenu').hover(
        function() {
            $('.favoTipo').live('click', function(e){
                e.preventDefault();
                var data = $('div[title$="experiencia-m"] dl').html();
                $('#viewSubmenu .carnecitas dl').html(data);
                
            });
        },
        function() {
            $(this).fadeOut(70);
        }
    );
}
viewMenu();




});


/* Gallery --------------------------------*/

/*$(
	function(){
		setupCarousel();
	});
		function setupCarousel () {
		$('#jquery-carousel').galleria({
			insert: '#main-photo-container',
			history: false,
			onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
				// fade in the image & caption
				if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
					image.css('display','none').fadeIn(1000);
				}
				caption.css('display','none').fadeIn(1000);
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// fade out inactive thumbnail
				_li.siblings().children('img.selected').fadeTo(500,0.5);
				
				// fade in active thumbnail
				thumb.fadeTo('fast',1).addClass('selected');
				
				// add a title for the clickable image
				image.attr('title','Next image >>');
			},
			onThumb : function(thumb) { // thumbnail effects goes here
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// if thumbnail is active, fade all the way.
				var _fadeTo = _li.is('.active') ? '1' : '0.5';
				
				// fade in the thumbnail when finnished loading
				thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
				
				// hover effects
				thumb.hover(
					function() {thumb.fadeTo('fast',1);},
					function() {_li.not('.active').children('img').fadeTo('fast',0.5 );} // don't fade out if the parent is active
				)
			}
		});
		
		$('#jquery-carousel').jcarousel( {vertical: true, scroll: 1  } );
		
		//$('#jquery-carousel').jcarousel({ vertical: true }); 
	}*/


/* Live Weather --------------------------------*/
var VipacLib = {
            main : {
			init : function() {
			VipacLib.liveWeather.init();
		}
	},
        liveWeather : {
		init : function() {
			this.parameters = {};
			this.parameters.op = 'clima';
			this.parameters.localidad_id = "PEXX0011"; // Lima,Lima
			this.getData(this.parameters);
                },
                getData : function(options) {
			$.ajax({
				url : "/getWeather.php",
				data : options,
				dataType: 'json',
				success: function(response){
					var clima = response.clima;
					$('#live-weather-temperature').html(clima.temperatura+'&deg; C');
					//$('#live-weather-location').html(clima.lugar);
                                        $('#live-weather-state').html(clima.estado);
                                        $('#live-weather-time').html(clima.hora);
					$('#live-weather-img').html('<img src="/public/images/iconos-clima/'+clima.codigo+'.png" id="weather-img"  width="62"  height="62" title="'+clima.estado+'" alt="'+clima.estado+'">');

				}
			});
		}
        },	
		
        ValidationForm : {
            init: function() {
                $(':text').val('');
                $('textarea').val('');

                $('#btn-borrar').click(function(e){
                    e.preventDefault();
                    $(':text').val('');
                    $('textarea').val('');
                });                
                
            }
        },
		
        //Funcion Turismo responsable
        UrlTurismo : {
            init: function() {
                var item=jQuery.url.segment(3);
                if (item=='5') {
                    jQuery('.ul-nosotros #itemID').trigger('click');
                }
            }
        },

        newsLetter: {
            init: function(mensaje) {
                $('#loader').css('display', 'block');
                $('#loader span').text(mensaje);
            }, //end Function

            ending: function(mensaje) {
                $('#loader span').text(mensaje);
                $('#loader').delay(1000).fadeOut();
            }//end Function
        }

 }


