jQuery(document).ready(function() {
	// * ANIMAÇÃO DOS LINKS *
	var Duration = 150; //time in milliseconds		  
    jQuery('#eventos').hover(function() {
      jQuery('#eventos h2').animate({ paddingLeft: '15px' }, Duration);
    }, function() {
      jQuery('#eventos h2').animate({ paddingLeft: '0px' }, Duration);           
    });
    	  
    jQuery('#galerias').hover(function() {
      jQuery('#galerias h2').animate({ paddingLeft: '15px' }, Duration);
    }, function() {
      jQuery('#galerias h2').animate({ paddingLeft: '0px' }, Duration);           
    });
     
    jQuery('#videos').hover(function() {
        jQuery('#videos h2').animate({ paddingLeft: '15px' }, Duration);
      }, function() {
        jQuery('#videos h2').animate({ paddingLeft: '0px' }, Duration);           
      });
    
    jQuery('.img_galerias').hover(function() {
        $(this).addClass('img_galerias_hover');
      }, function() {
    	  $(this).removeClass('img_galerias_hover');           
      });

    // * FADE IN E FADE OUT DAS GALERIAS *
    $(".img_destaque").fadeTo("fast", 0.3); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	$(".img_destaque").hover(function(){
		$(this).fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
		},function(){
			$(this).fadeTo("fast", 0.3); // This should set the opacity back to 30% on mouseout
	});
	
	$(".img_galeria").fadeTo("fast", 0.3); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	$(".img_galeria").hover(function(){
		$(this).fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
		},function(){
			$(this).fadeTo("fast", 0.3); // This should set the opacity back to 30% on mouseout
	});
	
	$(".flyer_eventos").fadeTo("fast", 0.3); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	$(".flyer_eventos").hover(function(){
		$(this).fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
		},function(){
			$(this).fadeTo("fast", 0.3); // This should set the opacity back to 30% on mouseout
	});

    $(".flyer_eventos100").fadeTo("fast", 0.3); // This sets the opacity of the thumbs to fade down to 30% when the page loads    $(".flyer_eventos100").hover(function () {        $(this).fadeTo("fast", 1.0); // This should set the opacity to 100% on hover    }, function () {        $(this).fadeTo("fast", 0.3); // This should set the opacity back to 30% on mouseout
    });
	
	$("#facebook").fadeTo("fast", 0.6); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	$("#facebook").hover(function(){
		$(this).fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
		},function(){
			$(this).fadeTo("fast", 0.6); // This should set the opacity back to 30% on mouseout
	});
	
	// * FADE IN E FADE OUT DAS SETAS DAS GALERIAS *
	$("#antes").fadeTo("fast", 0.2); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	$("#antes").hover(function(){
		$(this).fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
		},function(){
			$(this).fadeTo("fast", 0.2); // This should set the opacity back to 30% on mouseout
	});
	
	$("#depois").fadeTo("fast", 0.2); // This sets the opacity of the thumbs to fade down to 30% when the page loads
	$("#depois").hover(function(){
		$(this).fadeTo("fast", 1.0); // This should set the opacity to 100% on hover
		},function(){
			$(this).fadeTo("fast", 0.2); // This should set the opacity back to 30% on mouseout
	});
	
	// CYCLE DOS EVENTOS NA PRIMEIRA PÁGINA *
	$('body').find('#evento').each(function(){			// encontra as divs com id='evento' e esconde todas menos uma
		$(this).cycle({
			fx: 'scrollUp',								// efeito de transição
			speed: 'slow',								// velocidade da transição
			timeout: 8000,								// tempo de espera de cada evento
			pager: $('body').find('.dest_cycle'),		// indica a div onde irá ser feita a paginação
			pagerAnchorBuilder: paginate				// dá a ordem de paginação
		});
	});
	function paginate(ind, el)
	{
		var i = ind + 1;
		return '<a class="slide">&bull;</a>';
	};
	
	// CYCLE DOS PARCEIROS NA PRIMEIRA PÁGINA *
	$('body').find('#parceiros ul').each(function(){		// encontra as divs com class='eventos' e esconde todas menos uma
		$(this).cycle({
			fx: 'fade',										// efeito de transição
			speed: 'slow',									// velocidade da transição
			timeout: 4000									// tempo de espera de cada evento
		});
	});
	
	// COLLAPSE DO FORM NA PÁGINA DOS SERVIÇOS
	$("#reserva").hide();
	//Slide up and down on click
	$(".reserva_btn").click(function(){
		$("#reserva").slideToggle("slow");
	});
	
	// CYCLE DAS FOTOS DAS INSTALAÇÕES DO 4EVERCLUB
	$('.ever_fotos').cycle({
		fx: 'fade' // choose your transition effect, ex: fade, scrollUp, shuffle, etc...
	});
});

// ANIMAÇÃO DO HIGHLIGHT DO MENU *
$.fn.lavalamb = function (ImgPath) {
    try {
        /* ImgPath:  Path of the image which you need to animate when you hover over a navigation link 
        this can be a shadow png image or a pointer image or underline image which you want to animate with a mouseover / mouseout action on a link
        Add css class "Highlight" to the node which is currently active, so the image will always be animated back to this node on mouseout
        */
        var LeftPos;
        $(this).append('<div id="lavalamp"><img src="' + ImgPath + '" alt="" /></div>'); //Appending lavalamb image to the html, this div can be skinned in the css.
        $(this).parent().css({ position: "relative" }); //setting the position
        $("#lavalamp").css({
            position: "absolute", top: "10px" // These css values can be edited to vertically position the lavalamb image
        });
        $(".Highlight a").css('color', '#b18032'); // These css values can be edited to vertically position the lavalamb image

        var resto = $("li.Highlight").css('width').replace('px', '') - $("#lavalamp").css('width').replace('px', '');  // posição inicial
        var deslocamento = parseInt(resto / 2); 																		 // posição inicial
        LeftPos = $("li.Highlight").position().left + deslocamento; 															 // posição inicial
        $("#lavalamp").animate({ left: LeftPos }, { queue: false, duration: 300, easing: "easeOutQuart" }); 					 // posição inicial
        var resto = $(this).css('width').replace('px', '') - $("#lavalamp").css('width').replace('px', ''); 			 // posição inicial

        $(this).find("li").hover(  //Link hover function
		 function () { 	//Rollover
		     var resto = $(this).css('width').replace('px', '') - $("#lavalamp").css('width').replace('px', '');
		     var deslocamento = parseInt(resto / 2);
		     LeftPos = $(this).position().left + deslocamento;
		     // - $(this).parent().offset().left; //calculating the left position
		     //LeftPos = (LeftPos - 20 + ($(this).width()/2)); //calculating the left position :( just tweeked the positioning a bit by adding 20px to the total)
		     $("#lavalamp").animate({ left: LeftPos }, { queue: false, duration: 400, easing: "easeInQuart" }); //Animating the image from the start position to the current mouseover position
		 },
		function () {
		    var resto = $("li.Highlight").css('width').replace('px', '') - $("#lavalamp").css('width').replace('px', '');
		    var deslocamento = parseInt(resto / 2);
		    LeftPos = $("li.Highlight").position().left + deslocamento;
		    $("#lavalamp").animate({ left: LeftPos }, { queue: false, duration: 400, easing: "easeOutQuart" }); //Animating the image back to the start position from the current mouseover position
		});
    }
    catch (e)
      { }
};
	
// FUNÇÃO PARA LIMITAR OS CAMPOS DE TEXTO SÓ A NUMEROS *
function isNumberKey(evt) {
	var charCode = (evt.which) ? evt.which : event.keyCode;
	if (charCode > 31 && (charCode < 48 || charCode > 57))
	return false;

	return true;
}

// FUNÇÃO PARA REMOVER O TEXTO DOS CAMPOS DE TEXTO QUANDO :FOCUS *
function toggle(id, valor){
	if(id.value==valor){
		id.value='';
	}else{
		if(id.value==''){
			id.value=valor;
		}
	}
}
