$(document).ready(function() {
    smoothScroll();
    showHide();
    overNoticias();
    
    $(".decrease").click(function(){ fontSize("minus") }).blur() //blur() aqui remove o foco do elemento, logo após o clique
    $(".increase").click(function(){ fontSize("plus") }).blur()
    
    $("a[rel='external']").attr("target", "blank");
});

/* SMOOTH SCROLL */
function smoothScroll() {
	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target
			|| $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body')
				.animate({scrollTop: targetOffset}, 1000);
			return false;
			}
		}
	});
}

/* MUDA O BACKGROUND DA HOME DE ACORDO COM O CONTEUDO DO FLASH */
function changeBodyClass(cssClass) {
	$("body").removeAttr('class').addClass(cssClass);
}

/* SHOW/HIDE LAYERS PRO CONTATO */
function showHide() {
		$('#empty, #atendimentoCliente, #trabalheConosco, #linhaEtica').hide().find("input, textarea").attr("disabled", true);
		$("#area").change(function() {
		    $("#" + this.value).show().siblings().hide().find("input, textarea").attr("disabled", true);
		    $("#" + this.value).show().find("input, textarea").removeAttr("disabled");
		});
		$('#area' + $(this).find('option:selected').attr('id')).show().find("input, textarea").removeAttr("disabled");
	$("#area").change();
}

/* HOVER PARA AS LISTAGENS DE NOTÍCIAS */
function overNoticias() {
	$('#outrasNoticias li, #listagem li').bind("mouseenter",function() {
		$(this).find('a').addClass('bold');
	}).bind("mouseleave",function() {
		$(this).find('a').removeClass('bold');
	});
}

function fontSize(action, container){
    container = typeof(container) != 'undefined' ? container : "#content" //se não for especificado um container será "div.texto"
    
	baseSize = parseInt($(container+" p").css("font-size")) //extraímos o font-size padrão, tomando como base o p do nosso container
	
	
 
    $els = $(container+" p");
 
    $els.each(function(){
        $fs = parseInt($(this).css("font-size"));
        if(action=="plus" && baseSize < 16){ 
            $fs+=1;
        }
        else if(
            action == "minus" && baseSize > 11) {
        $fs -= 1;
               }
        $(this).css("font-size", $fs)
    })
}

    
