﻿/**
What a Menu


*/
function initSliderMenu(menu_id) {
	var $_main_menu = $('#' + menu_id);
	var $_headers = $_main_menu.find('div.menu_section');
	var $_section_submenu = $_headers.find('ul.section_ul');

	$_headers.each(function(i)
	{
		var $_cur_obj = $(this);

		$_cur_obj.hover
		(
			function()
			{
				var $_this_id = $(this).attr('id');
				var $_section_text = $('#' + $_this_id + ' .section_text');
				var $_section_image = $('#' + $_this_id + ' .section_image');
				var $_height = $_section_image.find('img').height();
				$_section_text.stop().animate({top: '-' + $_height + 'px'}, 150);
				$_section_image.stop().animate({top: '0px'}, 150);
				var $_submenu = $('#' + $_this_id + ' div.section_list');
				$_submenu.stop(true, true).slideDown(150);
				
				// gestione voci secondo livello
				var $_subvoice = $_submenu.find("a.menu_lv2");
				//var $_subvoice = $_submenu.find("li.section_li");
				$_subvoice.each(function(j)
				{
					var $_cur_voice = $(this);
					$_cur_voice.hover
					(
						function()
						{
							$_section_image.stop().animate({top: '-' + ($_height * (j + 1)) + 'px'}, 50);
						},
						function()
						{
							// do nothing
							//$_section_image.stop().animate({top: '0px'}, 50);
						}
					)
				});
				
				// ripristino l'immagine di sezione quando non sono sopra nessuna voce si secondo livello
				var $_sub_ul = $_submenu.find('ul.section_ul');
				$_sub_ul.mouseleave(function(evt)
				{
					$_section_image.stop().animate({top: '0px'}, 50);
				});
				
			},
			function()
			{
				var $_this_id = $(this).attr('id');
				$('#' + $_this_id + ' .section_text').stop().animate({top: '0px'},150);
				$('#' + $_this_id + ' .section_image').stop().animate({top: '63px'},150);
				var $_submenu = $('#' + $_this_id + ' div.section_list');
				$_submenu.stop(true, true).slideUp(150);
			}
		);
	});
};

/**
* Init
*/
/*
$(document).ready(function()
{
	initMenus();
	initSliderMenu('slide_menu');
});
*/


