function initMenu() {
$('#menu ul').hide();


		var cookie = $.cookie("menu");
//alert('#menu .' + cookie);
		if(cookie == "" || String(cookie).length < 1) {
			//$('#' + this.id + '.expandfirst ul:first').show();
		}
		else {			
			$('#menu .' + cookie).next().show();
			$('#menu .' + cookie).css('background','url(/immagini/menu_left_minus.jpg)');
			$('#menu .' + cookie).css('background-repeat','no-repeat');
			$('#menu .' + cookie).css('background-position','98%');
		}                                              


$('#menu li a').click(
function(event) {
	event.preventDefault();

//alert('#menu .' + this.className);
$.cookie("menu", "", { path: '/' });
$.cookie("menu", this.className, { path: '/' });
	var checkElement = $(this).next();



if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
	$('#menu ul:visible').slideUp('fast');
	$(this).css('background','url(/immagini/menu_left_arrow.jpg)');
			$(this).css('background-repeat','no-repeat');
			$(this).css('background-position','98%'); 
	 
	//return false;
}
if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
$('#menu ul:visible').slideUp('fast');
checkElement.slideDown('fast');
$(this).css('background','url(/immagini/menu_left_minus.jpg)');
			$(this).css('background-repeat','no-repeat');
			$(this).css('background-position','98%'); 
//return false;
}
//$(this).next().slideToggle('fast');
//location.href=$(this).attr("href");
var goto = $(this).attr("href")
window.setTimeout(function() {
    location.href=goto;
}, 2000);
}
);
}
$(document).ready(function() {initMenu();});




