jQuery(document).ready(function(){
	
	var pathname = window.location.pathname
	if(pathname.indexOf("/en/")!=-1){
		
		//detecto se o idioma selecionado é ingles, baseando-me na url conter /en/. Se for, altero a url do link videos.
		
		jQuery(".page-item-92 a").attr("href", "http://www.tremdavale.org/novo/vbox/en/");
	}
	
	
		// http://plugins.jquery.com/project/nextALL
		jQuery(function($) {
			$.fn.reverse = function() {
				return this.pushStack(this.get().reverse(), arguments);
			};
			$.each( ['prev', 'next'], function(unusedIndex, name) {
				$.fn[ name + 'ALL' ] = function(matchExpr) {
					var $all = $('body').find('*').andSelf();
					$all = (name == 'prev')
						 ? $all.slice(0, $all.index(this)).reverse()
						 : $all.slice($all.index(this) + 1)
					;
					if (matchExpr) $all = $all.filter(matchExpr);
					return $all;
				};
			});
		});
		
	//detecto se estou no detalhe de uma galeria
	if(pathname.indexOf("/nggallery/")!=-1){
				jQuery('.gallery-detail > h3')
					.prevALL('h2:not(:first)')
					.hide()
				;
				jQuery('.gallery-detail > h3')
					.nextALL('h2')
					.hide()
				;
	};
	
	//jQuery('h2+div').find('h3').css('color', 'red');
	
	//CONTROLE TAMANHO TEXTO
	
	//primeiro, checo se já houve aumento de fonte, com este novo tamanho armazenado num cookie
	//em caso negativo, eu crio o cookie com o tamanho corrente da fonte do body
	var tamTextoCookie;
	if(!jQuery.cookie("tamTextoSalvo")) {
		tamTextoCookie = "100";
		//alert(tamTextoCookie);
		jQuery.cookie("tamTextoSalvo", tamTextoCookie, { path: '/' });
		currentFontSize = parseInt(jQuery.cookie("tamTextoSalvo"));
	}else {			
			//reset values
			//tamTextoCookie = 100; jQuery.cookie("tamTextoSalvo", tamTextoCookie, { path: '/' }); alert("Tamanho = 100%");
		currentFontSize = parseInt(jQuery.cookie("tamTextoSalvo"));
		jQuery('#container').css('font-size',  currentFontSize + "%");
	}
	
	//Recebe e configura o tamanho 
	function setSize() {

		jQuery('#container').css('font-size', currentFontSize + "%");                
		
		jQuery.cookie('tamTextoSalvo', currentFontSize, { path: '/' });
		return false;  
	}
		
	// Aumenta o tamanho da fonte
	jQuery("#amais").click(function(){	
		if (currentFontSize <= 120) {
			currentFontSize += 10;
			setSize();
		}
	});
	// Diminui o tamanho da fonte
	jQuery("#amenos").click(function(){
		if (currentFontSize > 100) {
			currentFontSize -= 10;
			setSize();
		}  
	});
	
	//noticias-list
	
	if(jQuery(".news-list").length == 0) {
		
		//esconde a lista de noticias na home
		jQuery("#noticias-list").css("display", "none");
		
		//esconde o menu News
		//jQuery(".page-item-29").css("display", "none");
		
	};
	
	//controla a navegacao entre os destaques na home	
	

});
if (jQuery("#destaques-cycle").length > 0) {		
			jQuery('#destaques-cycle').cycle({		
				prev:   '#bt-ant',
				next:   '#bt-prox',
				timeout: 0,
				fx:     'scrollHorz', 
				speed:  'slow'
			});
		}