//limita carecteres caixa comentarios
			var max=140;
			var ancho=300;
			function progresso_tecla(obj) {
				var progresso = document.getElementById("progresso");  
				if (obj.value.length < max) {
					var pos = ancho-parseInt((ancho*parseInt(obj.value.length))/140);
				} else {
					obj.value = obj.value.substring(0,max);
				} 
					progresso.innerHTML = "("+obj.value.length+" / "+max+")";
			}

//paginação de comentários (jquery.pagination)
            function pageselectCallback(page_index, jq){
                var new_content = jQuery('#hiddenresult div.result:eq('+page_index+')').clone();
                $('#Searchresult').empty().append(new_content);
                return false;
            }      
            function initPagination() {
                var num_entries = jQuery('#hiddenresult div.result').length;
                $("#Pagination").pagination(num_entries, {
                    callback: pageselectCallback,
                    items_per_page:1
                });
             }
            $(document).ready(function(){      
                initPagination();
            });         

//rotatividade dos banners (jquery.cycle)
	        $(document).ready(function() {
	    	$('.banners').cycle({
				fx: 'fade'
				});
			});

//Galeria de videos (jquery.youtubein)
	$(function() {
		$('a.youtubin').youtubin({
			swfWidth : 830,
			swfHeight : 415
			});
		});
	var outerLayout;
	$(document).ready(function () {

//Alinhamento (jquery.fixedposition)
		outerLayout = $('body').layout({
		south__showOverflowOnHover: true,
		west__size: 300,
		west__closable: false,
		west__spaceClosable: 0,
		west__spacing_open: 0,
		west__resizable: false,
		south__size: 24,
		south__closable: false,
		south__spaceClosable: 0,
		south__spacing_open: 0,
		south__resizable: false});

		$("#direita").fixedPosition({vpos:"bottom", hpos:"right"});
		
//Submenu (jquery.easing)
		$('#submenu li').css( {backgroundPosition: "0 0"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(375px 0)"}, {duration:700});
			$("#off"+this.id).css({display: "none"});
			$("#on"+this.id).css({display: "block"});
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:700});
			$("#off"+this.id).css({display: "block"});
			$("#on"+this.id).css({display: "none"});
		});
		
//Modal Window (dos popups)
		$('a[name=modal]').click(function(e) {
			e.preventDefault();
			var id = $(this).attr('href');
			var mat = 0;
			var mascaraHeight = $(document).height();
			var mascaraWidth = $(window).width();

			mat = $(this).attr('alt');
			if(mat>0){
				$(".window-content").html(
					$(".modal_dinamica" + mat).html()
				);
			}

			$('#mascara').css({'width':mascaraWidth,'height':mascaraHeight});
			$('#mascara').fadeIn(1000);	
			$('#mascara').fadeTo("slow",0.8);	
	
//Get whidth and height from window
			var winH = $(window).height();
			var winW = $(window).width();

			$(id).css('top',  winH/2-$(id).height()/2);
			$(id).css('left', winW/2-$(id).width()/2);
			$(id).fadeIn(2000); 
		});
		
		$('.window .close').click(function (e) {
			e.preventDefault();
			$('#mascara').hide();
			$('.window').hide();
		});	
			
		$('#mascara').click(function () {
			$(this).hide();
			$('.window').hide();
		});			

//Transicao (geral)
		$("body").css("display", "none");
		$("body").fadeIn(2000);

		$("#menu_aba a").click(function() {
			$("body").fadeOut(2000);
		});
	
//Transicao (corpo)
		$.timer(2250, function (timer) {
			$('#conteudo').slideDown("slow");
			timer.stop();
		});
		$.timer(2500, function (timer) {
			$('#voltar').slideDown("slow");
			timer.stop();
		});
		$.timer(2750, function (timer) {
			$("#titulo").slideDown("slow");
			timer.stop();
		});
		$.timer(3000, function (timer) {
			$("#corpo").slideDown("slow");
			timer.stop();
		});
	
//Carregando
		$().ajaxStart(function() {
			$('#loading').slideDown("slow");
		});
		$().ajaxStop(function() {
			$('#loading').slideUp("slow");
		});

//Menu
		$(".ui-layout-south").mouseover(function() {
			if ($("#menu_aba").is(":hidden")) {
				$("#menu_aba").css("z-index",18000).show("slow");
			} 
		});
		$(".ui-layout-south").mouseleave(function() {
			$.timer(18000, function (timer) {
				$("#menu_aba").slideUp("slow");
				timer.stop();
			});
		});

//Rolagem
		$("#corpo").jScrollPane({showArrows:true,dragMaxHeight:10});
		$("#Searchresult").jScrollPane({showArrows:true,dragMaxHeight:10});

	});

	function getUrlVars(url)
	{
	    var vars = [], hash;
	    var hashes = url.slice(url.indexOf('?') + 1).split('&');
	    for(var i = 0; i < hashes.length; i++)
	    {
	        hash = hashes[i].split('=');
	        vars.push(hash[0]);
	        vars[hash[0]] = hash[1];
	    }
	    return vars;
	}

//Galeria de fotos
	$(function() {
		$(".ngg-thumbnail a").click(function(){
			var url = $(this).attr("class");

			$.ajax({
				url: url,
				success: function(data) {
					$('.window-content').html(data);
				}
			});

			return false;
		});
	});
