/// <refrence path="mootools-1.2.3-core-yc.js" />
/// <refrence path="mootools-1.2.3.1-more.js" />

////////////////////////////////
// HEIGHT
var timeoutDelay = 2000;
var limitHeight = 780;
var isSmallScreen = false;
var height = 0;

if (Browser.Engine.trident)
    height = document.documentElement.clientHeight;
else
    height = window.innerHeight;
    
//if (height < limitHeight)
	isSmallScreen = true;

// function that sets margin-top to container of big sub menu items
function setMarginTop(element)
{
	if (Browser.Engine.trident) // IE
	    $(element).firstChild.style.marginTop = ($$('#areaHeader')[0].clientHeight - 1 - $(element).firstChild.clientHeight) + 'px';
	else
		$(element).firstChild.nextSibling.style.marginTop = ($$('#areaHeader')[0].clientHeight - 1 - $(element).firstChild.nextSibling.clientHeight) + 'px';
}


///////////////////////////////////
// MOOTOOLS
var subMenu = null;
var redMenu = null;
var contentArea = null;
var allowClickForm = false;
var allowClickBody = false;

window.addEvent('domready', function ()
{

	new OverText($(searchTextClientID));

	subMenu = [new Fx.Morph('bigSubMenuA'),
			   new Fx.Morph('bigSubMenuNs'),
			   new Fx.Morph('bigSubMenuSp'),
			   new Fx.Morph('bigSubMenuP')];
	if (!isSmallScreen)
		redMenu = [new Fx.Slide('redSubMenuAi'), new Fx.Slide('redSubMenuAr'), new Fx.Slide('redSubMenuC')];
	else
		redMenu = [new Fx.Morph('redSubMenuAi'), new Fx.Morph('redSubMenuAr'), new Fx.Morph('redSubMenuC')];

	if ($('tab_left'))
		contentArea = new Fx.Morph('tab_left', { duration: 1000 });

	subMenu.each(function (item, index) { item.set({ 'opacity': 0, 'height': 'auto' }); }); // IE does not support 'opacity' property
	//	so set height first and then change it
	// to opacity here
	
	
	var subMenuTimeout = [null, null, null, null];
	var redMenuTimeout = [null, null, null];
	var mouseMoved = false;

	//////////////////// L'Azienda ////////////////////////
	$$('#bigMenuA > a')[0].addEvent('click', function (e)
	{
		subMenuTimeout.each(function (item, index) { $clear(item); });
		redMenuTimeout.each(function (item, index) { $clear(item); });
		subMenu.each(function (item, index) { item.set({ 'opacity': 0 }); });
		if (!isSmallScreen)
			redMenu.each(function (item, index) { item.hide(); });
		else
			redMenu.each(function (item, index) { item.set({ 'margin-top': 0, 'height': 0 }); });

		$('bigSubMenu').setStyle('display', 'block');
		subMenu[0].set({ 'opacity': 1 });
		setMarginTop('bigSubMenuA');
		if ($('googlemaps'))
			$('googlemaps').setStyle('display', 'none');
		//if (contentArea) contentArea.set({'opacity': 0});
	});
	$$('#bigMenuA').addEvent('mouseover', function (e)
	{
	    if (menuOne && mouseMoved)
	        $$('#bigMenuA > a')[0].fireEvent('click');
	    mouseMoved = true;
	});
	$('bigMenuA').addEvent('mouseout', function (e)
	{
		if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
			subMenuTimeout[0] = setTimeout('subMenu[0].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
		else
			subMenuTimeout[0] = setTimeout('subMenu[0].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
	});
	$$('#bigSubMenuA > ul > li').each(function (LIitem, LIindex)
	{
		LIitem.addEvent('mouseover', function (e)
		{
			subMenuTimeout.each(function (item, index) { $clear(item); });
			redMenuTimeout.each(function (item, index) { $clear(item); });
		});
		LIitem.addEvent('mouseout', function (e)
		{
			if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
				subMenuTimeout[0] = setTimeout('subMenu[0].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
			else
				subMenuTimeout[0] = setTimeout('subMenu[0].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
		});
	});

	////////////////////// Nostro Sistema ///////////////////////
	$$('#bigMenuNs > a')[0].addEvent('click', function (e)
	{
		subMenuTimeout.each(function (item, index) { $clear(item); });
		redMenuTimeout.each(function (item, index) { $clear(item); });
		subMenu.each(function (item, index) { item.set({ 'opacity': 0 }); });
		if (!isSmallScreen)
			redMenu.each(function (item, index) { item.hide(); });
		else
			redMenu.each(function (item, index) { item.set({ 'margin-top': 0, 'height': 0 }); });

		$('bigSubMenu').setStyle('display', 'block');
		subMenu[1].set({ 'opacity': 1 });
		setMarginTop('bigSubMenuNs');
		if ($('googlemaps'))
			$('googlemaps').setStyle('display', 'none');
		//if (contentArea) contentArea.set({'opacity': 0});
	});
	$$('#bigMenuNs').addEvent('mouseover', function (e)
	{
	    if (menuTwo && mouseMoved)
	        $$('#bigMenuNs > a')[0].fireEvent('click');
	    mouseMoved = true;
	});
	$('bigMenuNs').addEvent('mouseout', function (e)
	{
		if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
			subMenuTimeout[1] = setTimeout('subMenu[1].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
		else
			subMenuTimeout[1] = setTimeout('subMenu[1].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
	});
	$$('#bigSubMenuNs > ul > li').each(function (LIitem, LIindex)
	{
		LIitem.addEvent('mouseover', function (e)
		{
			subMenuTimeout.each(function (item, index) { $clear(item); });
			redMenuTimeout.each(function (item, index) { $clear(item); });
		});
		LIitem.addEvent('mouseout', function (e)
		{
			if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
				subMenuTimeout[1] = setTimeout('subMenu[1].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
			else
				subMenuTimeout[1] = setTimeout('subMenu[1].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
		});
	});

	////////////////////////// I 7 plus ///////////////////////////////
	$$('#bigMenuSp > a')[0].addEvent('click', function (e)
	{
		subMenuTimeout.each(function (item, index) { $clear(item); });
		redMenuTimeout.each(function (item, index) { $clear(item); });
		subMenu.each(function (item, index) { item.set({ 'opacity': 0 }); });
		if (!isSmallScreen)
			redMenu.each(function (item, index) { item.hide(); });
		else
			redMenu.each(function (item, index) { item.set({ 'margin-top': 0, 'height': 0 }); });

		$('bigSubMenu').setStyle('display', 'block');
		subMenu[2].set({ 'opacity': 1 });
		setMarginTop('bigSubMenuSp');
		if ($('googlemaps'))
			$('googlemaps').setStyle('display', 'none');
		//if (contentArea) contentArea.set({'opacity': 0});
	});
	$$('#bigMenuSp').addEvent('mouseover', function (e)
	{
	    if (menuThree && mouseMoved)
	        $$('#bigMenuSp > a')[0].fireEvent('click');
	    mouseMoved = true;
	});
	$('bigMenuSp').addEvent('mouseout', function (e)
	{
		if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
			subMenuTimeout[2] = setTimeout('subMenu[2].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
		else
			subMenuTimeout[2] = setTimeout('subMenu[2].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
	});
	$$('#bigSubMenuSp > ul > li').each(function (LIitem, LIindex)
	{
		LIitem.addEvent('mouseover', function (e)
		{
			subMenuTimeout.each(function (item, index) { $clear(item); });
			redMenuTimeout.each(function (item, index) { $clear(item); });
		});
		LIitem.addEvent('mouseout', function (e)
		{
			if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
				subMenuTimeout[2] = setTimeout('subMenu[2].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
			else
				subMenuTimeout[2] = setTimeout('subMenu[2].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
		});
	});









	/////////////////// Prodotti //////////////////////////
	$$('#bigMenuP > a')[0].addEvent('click', function (e)
	{
		subMenuTimeout.each(function (item, index) { $clear(item); });
		redMenuTimeout.each(function (item, index) { $clear(item); });
		subMenu.each(function (item, index) { item.set({ 'opacity': 0 }); });
		if (!isSmallScreen)
			redMenu.each(function (item, index) { item.hide(); });
		else
			redMenu.each(function (item, index) { item.set({ 'margin-top': 0, 'height': 0 }); });

		$('bigSubMenu').setStyle('display', 'block');
		subMenu[3].set({ 'opacity': 1 });
		setMarginTop('bigSubMenuP');
		if ($('googlemaps'))
			$('googlemaps').setStyle('display', 'none');
		//if (contentArea) contentArea.set({'opacity': 0});
	});
	$$('#bigMenuP').addEvent('mouseover', function (e)
	{
	    if (menuFour && mouseMoved)
	        $$('#bigMenuP > a')[0].fireEvent('click');
	    mouseMoved = true;
	});
	$('bigMenuP').addEvent('mouseout', function (e)
	{
		if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
			subMenuTimeout[3] = setTimeout('subMenu[3].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay * 3);
		else
			subMenuTimeout[3] = setTimeout('subMenu[3].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay * 3);
	});
	$$('#bigSubMenuP > ul > li > div').each(function (LIitem, LIindex)
	{
		LIitem.addEvent('mouseover', function (e)
		{
			subMenuTimeout.each(function (item, index) { $clear(item); });
			redMenuTimeout.each(function (item, index) { $clear(item); });
		});
		LIitem.addEvent('mouseout', function (e)
		{
			subMenuTimeout.each(function (item, index) { $clear(item); });
			redMenuTimeout.each(function (item, index) { $clear(item); });
			if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
				subMenuTimeout[3] = setTimeout('subMenu[3].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay * 3);
			else
				subMenuTimeout[3] = setTimeout('subMenu[3].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay * 3);
		});
	});
	$$('#bigSubMenuP > ul > li > ul > li').each(function (LIitem, LIindex)
	{
		LIitem.addEvent('mouseover', function (e)
		{
			subMenuTimeout.each(function (item, index) { $clear(item); });
			redMenuTimeout.each(function (item, index) { $clear(item); });
		});
		LIitem.addEvent('mouseout', function (e)
		{
			subMenuTimeout.each(function (item, index) { $clear(item); });
			redMenuTimeout.each(function (item, index) { $clear(item); });
			if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
				subMenuTimeout[3] = setTimeout('subMenu[3].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay * 3);
			else
				subMenuTimeout[3] = setTimeout('subMenu[3].start({\'opacity\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\'); $(\'bigSubMenu\').setStyle(\'display\', \'none\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay * 3);
		});
	});










	/////////////////// Area informativa /////////////////////
	$('redMenuAiLink').addEvent('click', function (e)
	{
        allowClickForm = true;
        allowClickBody = true;
		subMenuTimeout.each(function (item, index) { $clear(item); });
		redMenuTimeout.each(function (item, index) { $clear(item); });
		subMenu.each(function (item, index) { item.set({ 'opacity': 0 }); });
		if (!isSmallScreen)
			redMenu.each(function (item, index) { item.hide(); });
		else
			redMenu.each(function (item, index) { item.set({ 'margin-top': 0, 'height': 0 }); });

		if (!isSmallScreen)
		{
			redMenu[0].show();
		}
		else
		{
			var elHeight = 0;
			if (Browser.Engine.trident) // IE
			{
				if ($('redSubMenuAi').firstChild)
					elHeight = $('redSubMenuAi').firstChild.offsetHeight;
			}
			else
			{
				if ($('redSubMenuAi').firstChild.nextSibling)
					elHeight = $('redSubMenuAi').firstChild.nextSibling.clientHeight;
			}

			redMenu[0].set({ 'margin-top': (elHeight * -1 - 2), 'height': elHeight });
			//if (contentArea) contentArea.set({'opacity': 0});
		}
	});
	$('redMenuAiLink').addEvent('mouseout', function (e)
	{
		if (!isSmallScreen)
		{
			if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
				redMenuTimeout[0] = setTimeout('redMenu[0].slideOut(); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay * 3);
			else
				redMenuTimeout[0] = setTimeout('redMenu[0].slideOut(); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay * 3);
		}
		else
		{
			if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
				redMenuTimeout[0] = setTimeout('redMenu[0].start({\'margin-top\': 0, \'height\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
			else
				redMenuTimeout[0] = setTimeout('redMenu[0].start({\'margin-top\': 0, \'height\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
		}
	});
	$$('#redSubMenuAi > ul > li').each(function (LIitem, LIindex)
	{
		LIitem.addEvent('mouseover', function (e)
		{
			subMenuTimeout.each(function (item, index) { $clear(item); });
			redMenuTimeout.each(function (item, index) { $clear(item); });
		});
		LIitem.addEvent('mouseout', function (e)
		{
			if (!isSmallScreen)
			{
				if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
					redMenuTimeout[0] = setTimeout('redMenu[0].slideOut(); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
				else
					redMenuTimeout[0] = setTimeout('redMenu[0].slideOut(); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
			}
			else
			{
				if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
					redMenuTimeout[0] = setTimeout('redMenu[0].start({\'margin-top\': 0, \'height\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
				else
					redMenuTimeout[0] = setTimeout('redMenu[0].start({\'margin-top\': 0, \'height\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
			}
		});
	});





	/////////////////// Area riservata /////////////////////
	$('redMenuArLink').addEvent('click', function (e)
	{		
        allowClickForm = true;
        allowClickBody = true;
		subMenuTimeout.each(function (item, index) { $clear(item); });
		redMenuTimeout.each(function (item, index) { $clear(item); });
		subMenu.each(function (item, index) { item.set({ 'opacity': 0 }); });
		if (!isSmallScreen)
			redMenu.each(function (item, index) { item.hide(); });
		else
			redMenu.each(function (item, index) { item.set({ 'margin-top': 0, 'height': 0 }); });

		if (!isSmallScreen)
		{
			redMenu[1].show();
		}
		else
		{
			var elHeight = 0;
			if (Browser.Engine.trident) // IE
			{
				if ($('redSubMenuAr').firstChild)
					elHeight = $('redSubMenuAr').firstChild.offsetHeight;
			}
			else
			{
				if ($('redSubMenuAr').firstChild.nextSibling)
					elHeight = $('redSubMenuAr').firstChild.nextSibling.clientHeight;
			}

			redMenu[1].set({ 'margin-top': (elHeight * -1 - 2), 'height': elHeight });
			//if (contentArea) contentArea.set({'opacity': 0});
		}
	});
	$('redMenuArLink').addEvent('mouseout', function (e)
	{
	
		if (!isSmallScreen)
		{
			if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
				redMenuTimeout[1] = setTimeout('redMenu[1].slideOut(); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay * 3);
			else
				redMenuTimeout[1] = setTimeout('redMenu[1].slideOut(); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay * 3);
		}
		else
		{
			if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
				redMenuTimeout[1] = setTimeout('redMenu[1].start({\'margin-top\': 0, \'height\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
			else
				redMenuTimeout[1] = setTimeout('redMenu[1].start({\'margin-top\': 0, \'height\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
		}
	});
	$$('#redSubMenuAr > ul > li').each(function (LIitem, LIindex)
	{
		LIitem.addEvent('mouseover', function (e)
		{
			subMenuTimeout.each(function (item, index) { $clear(item); });
			redMenuTimeout.each(function (item, index) { $clear(item); });
		});
		LIitem.addEvent('mouseout', function (e)
		{
			if (!isSmallScreen)
			{
				if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
					redMenuTimeout[1] = setTimeout('redMenu[1].slideOut(); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
				else
					redMenuTimeout[1] = setTimeout('redMenu[1].slideOut(); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
			}
			else
			{
				if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
					redMenuTimeout[1] = setTimeout('redMenu[1].start({\'margin-top\': 0, \'height\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
				else
					redMenuTimeout[1] = setTimeout('redMenu[1].start({\'margin-top\': 0, \'height\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
			}
		});
	});











	///////////// Contatti ////////////////////////
	$('redMenuCLink').addEvent('click', function (e)
	{
		subMenuTimeout.each(function (item, index) { $clear(item); });
		redMenuTimeout.each(function (item, index) { $clear(item); });
		subMenu.each(function (item, index) { item.set({ 'opacity': 0 }); });
		if (!isSmallScreen)
			redMenu.each(function (item, index) { item.hide(); });
		else
			redMenu.each(function (item, index) { item.set({ 'margin-top': 0, 'height': 0 }); });

		if (!isSmallScreen)
		{
			redMenu[1].show();
		}
		else
		{
			var elHeight = 0;
			if (Browser.Engine.trident) // IE
			{
				if ($('redSubMenuC').firstChild)
					elHeight = $('redSubMenuC').firstChild.offsetHeight;
			}
			else
			{
				if ($('redSubMenuC').firstChild.nextSibling)
					elHeight = $('redSubMenuC').firstChild.nextSibling.clientHeight;
			}

			redMenu[1].set({ 'margin-top': (elHeight * -1 - 2), 'height': elHeight });
			//if (contentArea) contentArea.set({'opacity': 0});
		}
	});
	$('redMenuCLink').addEvent('mouseout', function (e)
	{
		if (!isSmallScreen)
		{
			if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
				redMenuTimeout[1] = setTimeout('redMenu[1].slideOut(); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
			else
				redMenuTimeout[1] = setTimeout('redMenu[1].slideOut(); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
		}
		else
		{
			if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
				redMenuTimeout[1] = setTimeout('redMenu[1].start({\'margin-top\': 0, \'height\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
			else
				redMenuTimeout[1] = setTimeout('redMenu[1].start({\'margin-top\': 0, \'height\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
		}
	});
	$$('#redSubMenuC > ul > li').each(function (LIitem, LIindex)
	{
		LIitem.addEvent('mouseover', function (e)
		{
			subMenuTimeout.each(function (item, index) { $clear(item); });
			redMenuTimeout.each(function (item, index) { $clear(item); });
		});
		LIitem.addEvent('mouseout', function (e)
		{
			if (!isSmallScreen)
			{
				if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
					redMenuTimeout[1] = setTimeout('redMenu[1].slideOut(); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
				else
					redMenuTimeout[1] = setTimeout('redMenu[1].slideOut(); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
			}
			else
			{
				if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
					redMenuTimeout[1] = setTimeout('redMenu[1].start({\'margin-top\': 0, \'height\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
				else
					redMenuTimeout[1] = setTimeout('redMenu[1].start({\'margin-top\': 0, \'height\': 0}); if ($(\'googlemaps\')) $(\'googlemaps\').setStyle(\'display\', \'block\');'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
			}
		});
	});

	$('RenderForm').addEvent('click', function (e)
	{
	    if (allowClickForm)
	    {
	        allowClickForm = false;
	        return;
	    }
		subMenu.each(function (item, index) { item.set({ 'opacity': 0 }); });
		if (!isSmallScreen)
			redMenu.each(function (item, index) { item.hide(); });
		else
			redMenu.each(function (item, index) { item.set({ 'margin-top': 0, 'height': 0 }); });
			
		$('bigSubMenu').setStyle('display', 'none');
		if ($('googlemaps'))
			$('googlemaps').setStyle('display', 'block');
	});

	$(document.body).addEvent('click', function (e)
	{
	    if (allowClickBody)
	    {
	        allowClickBody = false;
	        return;
	    }
		subMenu.each(function (item, index) { item.set({ 'opacity': 0 }); });
		if (!isSmallScreen)
			redMenu.each(function (item, index) { item.hide(); });
		else
			redMenu.each(function (item, index) { item.set({ 'margin-top': 0, 'height': 0 }); });
			
		$('bigSubMenu').setStyle('display', 'none');
		if ($('googlemaps'))
			$('googlemaps').setStyle('display', 'block');
	});









	//////////////// ACCORDION for Products big menu /////////////////
	$$('#bigSubMenuP > ul > li > div > img').each(function (item)
	{
	    item.addEvent('click', function(e)
	    {
	        allowClickForm = true;
	        allowClickBody = true;
	        
	        $$('#bigSubMenuP > ul > li > ul').each(function(subitem)
	        {
	            subitem.setStyle('display', 'none');
	        });
	        if ($(this).get('src') == rootApplicationPath + 'images/arrow.png')
	        {
	            $(this).getParent().getParent().getChildren('ul').setStyle('display', 'block');
	            $(this).set('src', rootApplicationPath + 'images/arrow-open.png');
	        }
	        else
	        {
	            $(this).getParent().getParent().getChildren('ul').setStyle('display', 'none');
	            $(this).set('src', rootApplicationPath + 'images/arrow.png');
	        }
		    setMarginTop('bigSubMenuP');
	    });
	});
	//////////////// ACCORDION for Products big menu /////////////////
//	var productsMenuResizeTimer = null;
//	var productsMenuAccordion = new Accordion($$('#bigSubMenuP > ul > li > div'), $$('#bigSubMenuP > ul > li > ul'), {
//		trigger: 'mouseover',
//		opacity: false,
//		display: -1,
//		onComplete: function ()
//		{
//			$clear(productsMenuResizeTimer);
//			$clear(subMenuTimeout[3]);

//			if (!Browser.Engine.trident || (Browser.Engine.trident && document.querySelectorAll))
//				subMenuTimeout[3] = setTimeout('subMenu[3].start({\'opacity\': 0});'/*if (contentArea) contentArea.start({\'opacity\': 1});'*/, timeoutDelay);
//			else
//				subMenuTimeout[3] = setTimeout('subMenu[3].start({\'opacity\': 0});'/*if (contentArea) contentArea.set({\'opacity\': 1});'*/, timeoutDelay);
//		},
//		onActive: function ()
//		{
//			var resizeMarginTop = function () { setMarginTop('bigSubMenuP'); }
//			productsMenuResizeTimer = resizeMarginTop.periodical(25);
//		}
//	});





	//////////// GOOGLE MAPS ///////////////
	if ($("googlemaps"))
	{
		var latLng = new google.maps.LatLng(41.143575, 16.409512);
		var myOptions = {
			zoom: 5,
			disableDefaultUI: true,
			navigationControl: true,
			navigationControlOptions: {
				style: google.maps.NavigationControlStyle.SMALL
			},
			center: latLng,
			mapTypeId: google.maps.MapTypeId.ROADMAP
		};

		var map = new google.maps.Map($("googlemaps"), myOptions);
		var beachMarker = new google.maps.Marker({
			position: latLng,
			map: map,
			icon: 'images/googleicon.png'
		});

//		var setZoom = function (zoom)
//		{
//			this.setZoom(zoom);
//		}
//		setZoom.delay(2500, map, 8);
//		setZoom.delay(5000, map, 11);
//		setZoom.delay(7500, map, 13);
//		setZoom.delay(10000, map, 15);
	}
	
	
	
	////////////// SHOW MENU UPON OPENING THE PAGE ////////////////
//	if (tabRef == "l-azienda")
//	    $$('#bigMenuA > a')[0].fireEvent('click');
//	else if (tabRef == "il-nostro-mondo")
//	    $$('#bigMenuNs > a')[0].fireEvent('click');
//	else if (tabRef == "7-plus")
//	    $$('#bigMenuSp > a')[0].fireEvent('click');
//	else if (tabRef == "prodotti")
//	    $$('#bigMenuP > a')[0].fireEvent('click');
//	else if (tabRef == "intranet")
//	    $$('#redMenuArLink').fireEvent('click');
//	else if (tabRef == "contatti")
//	    $$('#redMenuCLink').fireEvent('click');
});