$(document).ready(function(){
/************************************
 * Definições
 ***********************************/

 /***********************************
 * Eventos disparados ao carregar a pagina
 ***********************************/
	css();
	accordionMenu();
 /***********************************
 * Atribuir eventos
 ***********************************/
	$("a.modal").fancybox({
		'overlayOpacity':  0.8,
		'overlayColor': '#000'
	});
	$(".lista-parceiros a").fancybox({
		'width': 600,
		'height': 500,
		'autoDimensions':false,
		'overlayOpacity':  0.8,
		'overlayColor': '#000'
	});
 /***********************************
 * Funcoes
 ***********************************/
	/* Adiciona algumas regras CSS não suportadas por todos navegadores */
	function css(){
		$(".lista-parceiros li:nth-child(5n+1)").css("clear","left");
		$(".listaProdutos").hide();
	}
	
	function accordionMenu(){
		$("#titulo_maquinas_novas, #titulo_maquinas_usadas, #titulo_pecas_servicos").click(function(){
																									
			var lista = $(this).next(".listaProdutos");
			
			if ( lista.css("display") == "block" ){
				return false;
			}
		
			$(".listaProdutos").slideUp().prev().removeClass('aberto').addClass('fechado');
			
			lista.slideToggle();
			lista.prev().removeClass('fechado').addClass('aberto');
		});
		//$(".listaProdutos:first").show();
		var atual = $(".listaProdutos .atual");
		if(atual.length > 0){
			atual.parent().show();
		}
		else
		{
			$(".listaProdutos:first").show();
		}
	}
	
	$("#tabela tr:odd").css("background-color", "#f4f4f4");
	$("#tabela tr:first").css("font-weight", "bold");
	
/* FIM *****************************/
});
