// JavaScript Document
$(function() {
	// Hide all the content except the first
	$('.accordian li ul').hide();
	$('.accordian li.top').css('cursor', 'pointer');
	// Handle the click event
	$('.accordian li.top a').click( function() {
		$(this).addClass("clicado");
		//
		// get Top ID
		var menu = $(this).parents("div:first").attr('id');
		// Get the content that needs to be shown
		var cur = $(this).parents("li.top:first");
		//
		var clicked = $(this);
		//
		var level = $(cur).attr("class");
		//
		if(menu != "menu_2"){
			cur.find('a.hasUL').css("background-image", "url(../images/hasM_o.png)");
		}else{
			cur.find('a.hasUL').css("background-image", "url(../images/hasM2_o.png)");
		}
		cur.find('a:first').css("color", "#000");
		//Entra aqui o cliclo de reset à cor dos links
		$('li.top ul a').not(this).css("color", "");
		//
		$(this).css("color", "#000");
		// Get the content that needs to be hidden
		var old = $('.accordian li.activo');
		old.removeClass('activo');
		cur.addClass('activo');
		// Make sure the content that needs to be shown 
		// isn't already visible
		if ( cur.find('ul').is(':visible'))
			return false;

		// Hide the old content
		old.find('ul:visible').slideToggle(500);
		//
		var menuold = old.parents("div:first").attr('id');
		//
		if(menuold != "menu_2"){
			old.find('a.hasUL').css("background-image", "url(../images/hasM.png)");
			old.find('a:first').css("color", "");
		}else{
			old.find('a.hasUL').css("background-image", "url(../images/hasM2.png)");
			old.find('a:first').css("color", "");
		}
		// Show the new content
		cur.find('ul').stop().slideToggle(500);
		//return false;
	});
});
