// JavaScript Document
$(document).ready(function() {
	
	$('#s2').cycle({
		fx: 'fade',
		speed: 'fast',
		timeout: 0,
		next: '#next',
		prev: '#prev'
	});
	
	
	var fonte = 11;
	$('#aumenta_fonte').click(function(){
		if (fonte < 14){  
			fonte++;
			$('#content *').css({'font-size' : fonte+'px'});
			
			var fontH2 = $('h2').css('font-size');
			fontH2 = fontH2.replace('px','');
			fontH2++;
			$('h2').css({'font-size' : fontH2+'px'});
		}  
	});  
	$('#reduz_fonte').click(function(){
		if (fonte > 10){ 
			fonte--;   
			$('#content *').css({'font-size' : fonte+'px'});
			
			var fontH2 = $('h2').css('font-size');
			fontH2 = fontH2.replace('px','');
			fontH2--;
			$('h2').css({'font-size' : fontH2+'px'});
		}  
	});
	
	$('#imprimir').click(function(){
		window.open('popup_impressao.htm', 'mywindow','location=0,status=0,scrollbars=1,resizable=0,width=640,height=480');  
	});
	
	
	
	$("#btnFiltroBuscar").hide();
	loadDropDown("", "filtro", 1);   
 
});

$(function() {
	$('.listImagem a').lightBox({fixedNavigation:true});
});

function showDetalhes(div){
	if ($(div).parent().parent().next().css("display") == "none"){
		$(div).parent().parent().next().slideDown('slow');
	} else {
		$(div).parent().parent().next().slideUp('slow');
	}
}

function toggleMenu(objeto)
{
	var proximo = objeto.parent().next();
	if(proximo.attr('class') == "displaynone" || proximo.attr('class') == "")
	{
		proximo.toggle();
	} 
}

function loadDropDown(CD_FILTRO_PAI, idDrop, count)
{
	var c_1 = count-1;
	if ($("#"+idDrop+c_1+" option:first").val() == ""){	
		$("#"+idDrop+c_1+" option:first").remove();
	}
	
	$.ajax({
		url: "index.php",
		global: false,
		type: "POST",
		data: ({
			acao : "loadDropDown",
			CD_FILTRO_PAI : CD_FILTRO_PAI
		}),
		dataType: "json",
		async: true,
		success: function(resposta){
			$("#btnFiltroBuscar").hide();
			filtro = idDrop + count;
			for(var i=count; i <= 5; i++)
			{
				clearDropDown(idDrop+i);	
			}
			if (resposta.length) 
			{
				$("#"+filtro).show();
				jQuery.each(resposta, function(){
					$("#" + filtro).append("<option value='" + this.CD_FILTRO + "'>" + this.DS_NOME + "</option>");
				});
			}else{
				$("#btnFiltroBuscar").fadeIn("slow");
			}
		}
	});	
	
}

function clearDropDown(id)
{
	$("#"+id).children().remove();
	$("#"+id).append("<option value=''>-- Selecione --</option>");
	$("#"+id).hide();
}
