/* AÇÕES INICIAIS
******************************************************/

$(function(){

	//
	/* ROLAGEM DE MENU ACOMPANHANDO SITE

	var menuTop = $('#nav').offset().top;
	$(window).scroll(function() {
		if($(this).scrollTop() > $("#nav").offset().top){
	    	$('#nav').css('position', "fixed");
	    	$('#nav').css('top', "0");
	    	$('#nav').css('z-index', "9999");
			$('#logging').css('display', "block");
    	} else if($("#nav").offset().top <= menuTop){
	    	$('#nav').css('position', "inherit");
			$('#logging').css('display', "none");
    	}
	});
	*/

	/* SLIDER
	******************************************/

	/**
	 *
	 * @access public
	 * @return void
	 **/
	window.onload = function(){

	    $('.slideshow').cycle({
			fx: 'fade'
		});


	    $('.banners_int').cycle({
			fx: 'fade',
			speed: 5000,
			fit: 1
			/*
    		before: function(){
    			$('.output').val($(this).parent().html());
    			$(this).css('width', $(this).parent().width());
    			$(this).find('img').css('width', $(this).parent().width());
    			$(this).parent().css('height', $(this).height());
    			$(this).parent().css('overflow', 'hidden');
			},
			after: function(){
    			$('.output').val($(this).parent().html());
    			$(this).css('width', $(this).parent().width());
    			$(this).find('img').css('width', $(this).parent().width());
    			$(this).parent().css('height', $(this).height());
    			$(this).parent().css('overflow', 'hidden');
			}
			*/
		});

		// galeria do header
		$('.gallery_header a').each(function(){
			h1 = $(this).height() / 2;
			h2 = $(this).parent().height() / 2;
			margintop = (h1 - h2)*-1;
			$(this).css('margin-top', margintop);
		});

		// eventos da lateral
		$('.destaque a.destaque_img img, .bloco_content .bloco_content_img img, .roteiros .grid_3 a .img img, .valeapena a img, .evento a div img, .lista_categoria .grid_3 .image a img').each(function(){

			//define TOP
			h1 = $(this).height() / 2;
			h2 = $(this).parent().height() / 2;
			margintop = (h1 - h2)*-1;
			$(this).css('margin-top', margintop);

			//define LEFT
			w1 = $(this).width() / 2;
			w2 = $(this).parent().width() / 2;
			marginleft = (w1 - w2)*-1;
			$(this).css('margin-left', marginleft);
		});

		$('.scroll_int').each(function(){
			largura = 0;
			$(this).find('.slide_item').each(function(){
				largura += $(this).outerWidth(true);
			});
			$(this).css({'width': largura, 'padding-bottom': 10});
		});

		$('.parceiros').jScrollPane();

		var t=setTimeout("ajustaAltura()", 1000);

	};
});

function ajustaAltura(){
	$('.jspContainer').each(function(){
		newheight = $(this).find('.jspPane').outerHeight(true);
		newheight += $(this).find('.jspHorizontalBar').outerHeight(true);
		$(this).height(newheight);
	});
	clearTimeout(t);
}
