$(document).ready(function(){
	
	var not_alt = $('#not_inteiro').height()+20;
	/*if ($('#not_inteiro').height()>68){
		$('#not_inteiro').height(68);
	}
	else{
		$('#leiamais').hide();
	}*/
	
	$('#leiamais').click(function(){
		$('#leiamais').hide();
		$('#not_parcial').hide();
		$('#not_inteiro').show();
		$('#not_inteiro').height($('#not_parcial').height());
		$('#not_inteiro').animate({height:not_alt});
	});
	
	ajustaMenus();
	
	$('.form').bind('focusin focusout',function() {
		$(this).toggleClass('formhover');
	});
	
	$('ul.lv1 > li').bind('mouseenter mouseleave',function() {
		$(this).children('ul.lv2').toggle();
		$(this).children('a').toggleClass('hover');
	});
	
	$('ul.lv2 > li').bind('mouseenter mouseleave',function() {
		$(this).children('a').toggleClass('hover');
	});
	
	$('ul.lv1 > li').last().css('margin-right','0px');
	
	$('#ampliacao').load(function(){
		$('.galeriaMiddle > div').height($('#ampliacao').height());
		$('#ampliacao').fadeIn();
	});
	
	$('.galeriaThumbs > img').click(function(){
		var src = $(this).attr('src');
		src = src.replace('thumb','');
		$('#ampliacao').hide();
		$('#ampliacao').attr('src',src);
	});
	
	var img = new Image();
  $(img).load(function (){
		ajustaLogo();
	}).attr('src', $('#logo > img').attr('src'));
	
});

function ajustaLogo(){
	var size = $('#logo').height();
	size -= $('#logo > img').height();
	$('#logo > img').css('margin-top',size/2);
}

function alteraFonte(dir){
	var minimo=12, maximo = 18;
	var aux = $('.texto').css('fontSize');
	if (aux==undefined) aux=12;
	else aux = parseInt(aux.replace("px",""));
	if(dir=="+") aux+=2;
	if(dir=="-") aux-=2;
	if (aux<minimo) aux=minimo;
	if (aux>maximo) aux=maximo;
	if ($('.texto').children('p, span'))
		$('.texto').children('p, span').css('fontSize',aux+"px");
	$('.texto').css('fontSize',aux+"px");
}

function ajustaMenus(){
	$('ul.lv2').each(function(){
		var totalWidth = $(this).width();
		if (totalWidth < $(this).parent('li').width()){
			totalWidth = $(this).parent('li').width();
			if (( $.browser.msie ) && ($.browser.version == '6.0') ) {
				totalWidth +=  ($(this).width() - $(this).outerWidth()); //bug do IE6
			}
		}
		if (( $.browser.msie ) && ($.browser.version == '6.0') ) {}
		else {
			totalWidth +=  ($(this).width() - $(this).outerWidth()); //bordas
		}
		totalWidth -= parseInt($(this).children('li').children('a').css("padding-right")) + parseInt($(this).children('li').children('a').css("padding-left")); //padding
		$(this).children('li').children('a').each(function() {
			$(this).width(totalWidth);
		});
	});
}

