var menu_highlight_behavior = 
{
	'div.menu' : function(element)
					{
						element.onmouseover = 	function()
												{
													this.className = 'menu_highlight';
												},
						element.onmouseout = 	function()
												{
													this.className = 'menu';
												}
					},
					
	'div.menu_with_sub' : function(element)
					{
						element.onmouseover = 	function()
												{
													if ($('sub' + this.id).style.display == 'none')
													{
														this.className = 'menu_with_sub_highlight';
													}
													else
													{
														this.className = 'menu_with_sub_open_highlight';
													}
												},
						element.onmouseout = 	function()
												{
													if ($('sub' + this.id).style.display == 'none')
													{
														this.className = 'menu_with_sub';
													}
													else
													{
														this.className = 'menu_with_sub_open';
													}
												},
						element.onclick =		function()
												{
													if ($('sub' + this.id).style.display == 'none')
													{
														$('sub' + this.id).style.display = '';
														this.className = 'menu_with_sub_open_highlight';
													}
													else
													{
														$('sub' + this.id).style.display = 'none';
														this.className = 'menu_with_sub_highlight';
													}
													set_menu();
												}
					},


	'div.submenu' : function(element)
					{
						element.onmouseover = 	function()
												{
													this.className = 'submenu_highlight';
												},
						element.onmouseout = 	function()
												{
													this.className = 'submenu';
												}
					},
	'div.menu_with_sub_open' : function(element)
					{
						element.onmouseover = 	function()
												{
													this.className = 'menu_with_sub_open_highlight';
												},
						element.onmouseout = 	function()
												{
													this.className = 'menu_with_sub_open';
												},
						element.onclick =		function()
												{
													if ($('sub' + this.id).style.display == 'none')
													{
														$('sub' + this.id).style.display = '';
														this.className = 'menu_with_sub_open_highlight';
													}
													else
													{
														$('sub' + this.id).style.display = 'none';
														this.className = 'menu_with_sub_highlight';
													}
													set_menu();
												}

					}
};

Behaviour.register(menu_highlight_behavior);

function set_menu()
{
	var submenu = $$('.submenucontainer');
	var cookie_values = '';
	var url = 'ajax/remember_menu.php';
	
	for(i=0; i < submenu.length; i++)
	{
		if(submenu[i].style.display != 'none')
		{
			cookie_values += submenu[i].id + '|';
		}
	}

	var pars = 'cookie_values=' + cookie_values +'&ts='+Date.parse(Date());
	var myAjax = new Ajax.Request
	( 
		url, 
		{ 
			method: 'get', 
			parameters: pars
		}
	);
}