var aPrimaRiga = new Array();	//Contiene gli spezzoni di testo da alternare per la prima riga nel banner
var aSecondaRiga = new Array();	//Contiene gli spezzoni di testo da alternare per la seconda riga
var iIntervalPrimaRiga = 5000;	//Ogni quanti msec cambia la scritta nella prima riga
var iIntervalSecondaRiga = 5000;	//Ogni quanti msec cambia la scritta nella seconda riga
var iElemTextPrimaRiga = 0;
var iElemTextSecondaRiga = 0;
var sPathUp = '../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../';
var sLinkUp = sPathUp.substr(0, glbLivFromHome*3);	//glbLivFromHome DEVE essere dichiarata come prima istruzione della pagina html


//Fine aggiunte GIAP
var ToolBar_Supported = false;
var Frame_Supported   = false;
var DoInstrumentation = false;

/*
if (navigator.userAgent.indexOf("MSIE") != -1 && 
	navigator.userAgent.indexOf("Windows") != -1 && 
	navigator.appVersion.substring(0,1) > 3)
{	//Trattasi di Internet Explorer in versione superiore alla 3.0
*/
	ToolBar_Supported = true;
//}

if (ToolBar_Supported)
{	//Inizializza variabili necessarie alla ritracciatura dell'area della toolbar
	var newLineChar = String.fromCharCode(10);
	var char34 = String.fromCharCode(34);
	var LastMSMenu = "";
	var CurICPMenu = "";
	var IsMSMenu = false;
	var IsMenuDropDown = true;
	var HTMLStr;
	var x = 0;
	var y = 0;
	var x2 = 0;
	var y2 = 0;
	var MSMenuWidth;
	var ToolbarMinWidth;
	var ToolbarMenu;
	var ToolbarBGColor;
	var ToolbarLoaded = false;
	var aDefMSColor  = new Array(3);
	var aDefICPColor = new Array(3);
	var aCurMSColor  = new Array(3);
	var aCurICPColor = new Array(3);
	var MSFont;
	var ICPFont;
	var MenuFontSize = 9;	//In punti
	var MaxMenu = 30;
	var TotalMenu = 0;
	var arrMenuInfo = new Array(30);

	// Output style sheet and toolbar ID
	document.write("<SPAN ID='StartMenu' STYLE='display:none;'></SPAN>");

	// Build toolbar template
	HTMLStr = 
		"<DIV ID='divBanner'     STYLE='position:absolute;left:0;top:0;background-color:white;width:100%'>" +
		"<DIV ID='idRow1'        STYLE='position:relative;height:0;'>" +
		//"<DIV ID='idRow1'        STYLE='position:relative;height:20;'>" +
		"<DIV ID='idICPBanner'   STYLE='position:absolute;top:0;left:0;height:60;width:283;overflow:hidden;vertical-align:top;'><!--BEG_ICP_BANNER--><!--END_ICP_BANNER--></DIV>" +
		//"<DIV ID='idMSMenuCurve' STYLE='position:absolute;top:0;left:250;height:20;width:18;overflow:hidden;vertical-align:top;'><IMG SRC='/library/toolbar/images/curve.gif' BORDER=0></DIV>" +
		"<DIV ID='idMSMenuPane'  STYLE='position:absolute;top:0;left:250;height:20;width:10;background-color:black;float:right;visibility:hidden;' NOWRAP><!--MS_MENU_TITLES--></DIV>" + 
		"</DIV>" +
		"<DIV ID='idRow2' STYLE='position:relative;left:283;height:60;'>" +
		"<DIV ID='idADSBanner'   STYLE='position:absolute;top:0;left:0;height:40;width:200;vertical-align:top;overflow:hidden;'><!--BEG_ADS_BANNER--><!--END_ADS_BANNER--></DIV>" +
		"<DIV ID='idMSCBanner'   STYLE='position:absolute;top:0;left:283;height:59;width:112;vertical-align:top;overflow:hidden;' ALIGN=CENTER><!--BEG_MSC_BANNER--><!--END_MSC_BANNER--></DIV>" +
		"</DIV>" +
		"<DIV ID='idRow3' STYLE='position:relative;height:20;width:100%'>" +
		"<DIV ID='idICPMenuPane' STYLE='position:absolute;top:0;left:0;height:20;background-color:black;' NOWRAP><!--ICP_MENU_TITLES--></DIV>" +
		"</DIV>" +
		"</DIV>" +
		"<SCRIPT TYPE='text/javascript'>" + 
		"   var ToolbarMenu = StartMenu;" + 
		"</SCRIPT>" + 
		"<DIV WIDTH=100%>";

	// Define event handlers
	window.onresize  = resizeToolbar;

	// Intialize global variables
	ToolbarBGColor	= "white";						// toolbar background color
	MSFont  = "xx-small Verdana";
	ICPFont = "bold xx-small Verdana";
	
	aDefMSColor[0]	= aCurMSColor[0]  = "black";	// bgcolor;
	aDefMSColor[1]	= aCurMSColor[1]  = "white";	// text font color
	aDefMSColor[2]  = aCurMSColor[2]  = "red";		// mouseover font color
	
	aDefICPColor[0]	= aCurICPColor[0] = "#6699CC";	// bgcolor;
	aDefICPColor[1] = aCurICPColor[1] = "white";	// text font color
	aDefICPColor[2] = aCurICPColor[2] = "red";		// mouseover font color

	initBannerPubblicitario();
}

// The hard-coded numbers in functions - drawToolbar() & resizeToolbar()
// correspond to the dimension of the four gif files:
//		ICP_BANNER: 60h x 283w
//		ADS_BANNER: 40h x 200w
//		MSC_BANNER: 40h x 112w
//		Curve:	    20h x 18w



var alto, forma, ucciF, ord, divisore;
	
function InizializzaBanner(sToday) {	//Imposta una volta per tutte le variabili da modificare, in funzione del browser
	if (navigator.appName == "Netscape")
	{	//Si tratta del browser Netscape
	   alto=".top=";
	   forma="document.";
	   ucciF="";
	   ord="window.pageYOffset";
	   divisore = 2;	//Aumentare questo valore per rendere il posizionamento del banner più graduale
	}
	else
	{
		alto=".pixelTop=";
		forma="";
		ucciF=".style";
	  ord="document.body.scrollTop";
	  divisore = 1;	//Explorer utilizzando l'evento "OnScroll" deve posizionare il banner immediatamente
	  document.getElementById("spanData").innerText = sToday;
	}
	cercoPosaB();
}	//Fine di "InizializzaBanner()"



var ordIni=0;

function cercoPosaB()
{
	ordIni=eval(ord);		//Posizione iniziale
}


function ridisegnaBanner() {	//Una volta che si sposta la pagina allora deve rimettere il banner nella sua posizione
	var spostoOrd=0;
	var levoOrd=0;

	if (ToolbarLoaded)
	{
		object="divBanner";
		ordB=eval(ord);
		levoOrd=ordIni-ordB;	//Distanza tra posizione iniziale ed attuale
		if (levoOrd)
		{	//C'è ancora qualcosa da spostare
			spostoOrd=Math.round(levoOrd/divisore);
			ordIni-=spostoOrd;
			eval(forma+object+ucciF+alto+ordIni);	//document.divBanner.top= il valore di "ordIni" (per Explorer invece è divBanner.style.pixelTop=)
		}
		if (navigator.appName == "Netscape") {
		    window.setTimeout("ridisegnaBanner();", 1000); 	//Perchè netscape non gestisce l'evento "OnScroll()" del body
		}
	}
}	//Fine di "ridisegnaBanner()"



function drawToolbar()
{
	HTMLStr += "</DIV>";
	document.write(HTMLStr);
	ToolbarLoaded = true;

	MSMenuWidth     = Math.max(idMSMenuPane.offsetWidth, (200+112));	//312
	ToolbarMinWidth = 283;	// + MSMenuWidth;

	divBanner.style.backgroundColor     = ToolbarBGColor;
	idMSMenuPane.style.backgroundColor  = aDefMSColor[0];
	idICPMenuPane.style.backgroundColor = aDefICPColor[0];
	resizeToolbar();

	for (i = 0; i < TotalMenu; i++) 
	{
	    thisMenu = document.getElementById(arrMenuInfo[i].IDStr);
		if (thisMenu != null)
		{
			if (arrMenuInfo[i].IDStr == LastMSMenu && arrMenuInfo[i].type == "R")
			{
				//Last MSMenu has to be absolute width
				arrMenuInfo[i].type = "A";
				arrMenuInfo[i].unit = 200;
			}
			if (arrMenuInfo[i].type == "A")
				thisMenu.style.width = arrMenuInfo[i].unit;
			else 
				thisMenu.style.width = Math.round(arrMenuInfo[i].width * arrMenuInfo[i].unit) + 'em';
		}
	}
}


function resizeToolbar()
{
	if (ToolBar_Supported == false) return;

	w = Math.max(ToolbarMinWidth, document.body.clientWidth) - ToolbarMinWidth;	//323
	//idMSMenuCurve.style.left  = (250+w);
	//idMSMenuPane.style.left   = 283;		//(250+w+18);
	//idMSMenuPane.style.width  = MSMenuWidth;

	//idADSBanner.style.left    = 0;	//(w+18);

	//idMSCBanner.style.left    = (w+18+200);
	//idMSCBanner.style.width   = (MSMenuWidth - 200);
	idMSCBanner.style.left    = 0;	//Qui vale la coordinata di destra
	idMSCBanner.style.width   = (document.body.clientWidth>283)? (document.body.clientWidth - 283):1;
	idICPMenuPane.style.width = ToolbarMinWidth + w;
}

function setToolbarBGColor(color)
{	
	ToolbarBGColor = color;
	if (ToolbarLoaded == true)
		divBanner.style.backgroundColor = ToolbarBGColor;
}	

function setMSMenuFont(sFont)
{	MSFont = sFont;
}

function setICPMenuFont(sFont)
{	ICPFont = sFont;
}

function setDefaultMSMenuColor(bgColor, fontColor, mouseoverColor)
{	
	if (bgColor   != "")	  aDefMSColor[0] = bgColor;
	if (fontColor != "")	  aDefMSColor[1] = fontColor;
	if (mouseoverColor != "") aDefMSColor[2] = mouseoverColor;
}

function setDefaultICPMenuColor(bgColor, fontColor, mouseoverColor)
{	
	if (bgColor   != "")	  aDefICPColor[0] = bgColor;
	if (fontColor != "")	  aDefICPColor[1] = fontColor;
	if (mouseoverColor != "") aDefICPColor[2] = mouseoverColor;
}

function setICPMenuColor(MenuIDStr, bgColor, fontColor, mouseoverColor)
{	
	if (ToolbarLoaded == false) return;

	// Reset previous ICP Menu color if any
	if (CurICPMenu != "")
	{
		PrevID = CurICPMenu.substring(4);
		CurICPMenu = "";
		setICPMenuColor(PrevID, aDefICPColor[0], aDefICPColor[1], aDefICPColor[2]);
	}

	var	id = "AM_" + "ICP_" + MenuIDStr;
	var thisMenu = document.getElementById(id);
	if (thisMenu != null)
	{
		CurICPMenu = "ICP_" + MenuIDStr;
		aCurICPColor[0] = bgColor;
		aCurICPColor[1] = fontColor;
		aCurICPColor[2] = mouseoverColor;

		// Change menu color
		if (bgColor != "")
			thisMenu.style.backgroundColor = bgColor;
		if (fontColor != "")
			thisMenu.style.color = fontColor;

		// Change subMenu color
		id = "ICP_" + MenuIDStr;
		thisMenu = document.getElementById(id);
		if (thisMenu != null)
		{
			if (bgColor != "")
				thisMenu.style.backgroundColor = bgColor;
			
			if (fontColor != "")
			{
				i = 0;
				id = "AS_" + "ICP_" + MenuIDStr;
				/*
				* TODO: modificare document.all
				*
				thisMenu = document.all.item(id,i);
				while (thisMenu != null)
				{
					thisMenu.style.color = fontColor;
					i += 1;
					thisMenu = document.all.item(id,i);
				}
				*/
			}
		}
	}
}


function setAds(Gif,Url,AltStr)
{	setBanner(Gif,Url,AltStr,"<!--BEG_ADS_BANNER-->","<!--END_ADS_BANNER-->");
}


function setICPBanner(Gif,Url,AltStr)
{	setBanner(Gif,Url,AltStr,"<!--BEG_ICP_BANNER-->","<!--END_ICP_BANNER-->");
}


function setMSBanner(Gif,Url,AltStr)
{	
	setBanner(Gif,Url,AltStr,"<!--BEG_MSC_BANNER-->","<!--END_MSC_BANNER-->");
}


function setBanner(BanGif, BanUrl, BanAltStr, BanBegTag, BanEndTag)
{
	begPos = HTMLStr.indexOf(BanBegTag);
	endPos = HTMLStr.indexOf(BanEndTag) + BanEndTag.length;
	
	SubStr = HTMLStr.substring(begPos, endPos);
	SrcStr = "";
	if (BanUrl != "")
		SrcStr += "<A Target='_top' HREF='" + formatURL(BanUrl, BanGif) + "'>";
	SrcStr += "<IMG SRC='" + BanGif + "' ALT='" + BanAltStr + "' BORDER=0>";
	if (BanUrl != "")
		SrcStr += "</A>";
	SrcStr = BanBegTag + SrcStr + BanEndTag;
	HTMLStr = HTMLStr.replace(SubStr, SrcStr);	
}


function setICPSubMenuWidth(MenuIDStr, WidthType, WidthUnit)
{	tempID = "ICP_" + MenuIDStr;
	setSubMenuWidth(tempID, WidthType, WidthUnit);
}


function setMSSubMenuWidth(MenuIDStr, WidthType, WidthUnit)
{	tempID = "MS_" + MenuIDStr;
	setSubMenuWidth(tempID, WidthType, WidthUnit);
}


function setSubMenuWidth(MenuIDStr, WidthType, WidthUnit)
{
	var fFound = false;
	if (TotalMenu == MaxMenu)
	{
		alert("Unable to process menu. Maximum of " + MaxMenu + " reached.");
		return;
	}
	for (i = 0; i < TotalMenu; i++)
		if (arrMenuInfo[i].IDStr == MenuIDStr)
		{
			fFound = true;
			break;
		}
	if (!fFound)
	{
		arrMenuInfo[i] = new menuInfo(MenuIDStr);
		TotalMenu += 1;
	}
	if (!fFound && WidthType.toUpperCase().indexOf("DEFAULT") != -1)
	{
		arrMenuInfo[i].type = "A";
		arrMenuInfo[i].unit = 160;
	}
	else
	{
		arrMenuInfo[i].type = (WidthType.toUpperCase().indexOf("ABSOLUTE") != -1)? "A" : "R";
		arrMenuInfo[i].unit = WidthUnit;
	}
}	//Fine di "setSubMenuWidth()"



// This function creates a menuInfo object instance.
function menuInfo(MenuIDStr)
{
	this.IDStr = MenuIDStr;
	this.type  = "";
	this.unit  = 0;
	this.width = 0;
	this.count = 0;
}

function updateSubMenuWidth(MenuIDStr)
{
	for (i = 0; i < TotalMenu; i++)
		if (arrMenuInfo[i].IDStr == MenuIDStr)
		{
			if (arrMenuInfo[i].width < MenuIDStr.length) 
				arrMenuInfo[i].width = MenuIDStr.length;
			arrMenuInfo[i].count = arrMenuInfo[i].count + 1;
			break;
		}
}

function addICPMenu(MenuIDStr, MenuDisplayStr, MenuHelpStr, MenuURLStr)
{ 	
	var bSecure;	//Passato come eventuale sesto parametro

	if (addICPMenu.arguments.length > 4)
		TargetStr = addICPMenu.arguments[4];
	else
		TargetStr = "_top";
	if (addICPMenu.arguments.length > 5)
		bSecure = addICPMenu.arguments[5];
	else
		bSecure = false;
	tempID = "ICP_" + MenuIDStr;
	addMenu(tempID, MenuDisplayStr, MenuHelpStr, MenuURLStr, TargetStr, true, bSecure); 
}

function addMSMenu(MenuIDStr, MenuDisplayStr, MenuHelpStr, MenuURLStr)
{	
	var bSecure;	//Passato come eventuale quinto parametro
	if (addMSMenu.arguments.length > 4)
		bSecure = addMSMenu.arguments[4];
	else
		bSecure = false;
	TargetStr = "_top";
	tempID = "MS_" + MenuIDStr;
	addMenu(tempID, MenuDisplayStr, MenuHelpStr, MenuURLStr, TargetStr, false, bSecure); 
	LastMSMenu = tempID;
}


function addMenu(MenuIDStr, MenuDisplayStr, MenuHelpStr, MenuURLStr, TargetStr, bICPMenu, bSecure)
{
	cFont   = bICPMenu? ICPFont : MSFont;
	cColor0 = bICPMenu? aDefICPColor[0] : aDefMSColor[0];
	cColor1 = bICPMenu? aDefICPColor[1] : aDefMSColor[1];
	cColor2 = bICPMenu? aDefICPColor[2] : aDefMSColor[2];
	tagStr  = bICPMenu? "<!--ICP_MENU_TITLES-->" : "<!--MS_MENU_TITLES-->";

	MenuStr = newLineChar;
	if (bICPMenu == false && LastMSMenu != "")
		MenuStr += "<SPAN STYLE='font:" + cFont + ";font-size:" + MenuFontSize + ";color:" + cColor1 + "'>|&nbsp;</SPAN>"; 
	MenuStr += "<A TARGET='" + TargetStr + "' TITLE='" + MenuHelpStr + "'" +
			   "   ID='AM_" + MenuIDStr + "'" +
			   "   STYLE='text-decoration:none;cursor:hand;font:" + cFont + ";font-size:" + MenuFontSize + ";background-color:" + cColor0 + ";color:" + cColor1 + ";'";
	if (MenuURLStr != "")
	{
		if (bICPMenu)
			MenuStr += " HREF='" + formatURL(MenuURLStr, ("ICP_" + MenuDisplayStr), bSecure) + "'";
		else
			MenuStr += " HREF='" + formatURL(MenuURLStr, ("MS_" + MenuDisplayStr), bSecure) + "'";
	}
	else
	    MenuStr += " HREF='' onclick='voceNonAttiva_Click(evt);'";
	MenuStr += 	" onmouseout="  + char34 + "mouseMenu(event, 'out' ,'" + MenuIDStr + "'); hideMenu(event);" + char34 +
				" onmouseover=" + char34 + "mouseMenu(event, 'over','" + MenuIDStr + "'); doMenu(event, '" + MenuIDStr + "');" + char34 + ">" +
				"&nbsp;" + MenuDisplayStr + "&nbsp;</a>";
	if (bICPMenu)
		MenuStr += "<SPAN STYLE='font:" + cFont + ";color:" + cColor1 + "'>&nbsp;|</SPAN>";
	MenuStr += tagStr;
	
	HTMLStr = HTMLStr.replace(tagStr, MenuStr);	
	setSubMenuWidth(MenuIDStr,"default",0);
}

function voceNonAttiva_Click(evt) {
    var oEvent = EventUtil.formatEvent(evt);
    //window.event.returnValue = false;
    oEvent.preventDefault();
    return;
}

function addICPSubMenu(MenuIDStr, SubMenuStr, SubMenuURLStr)
{	
	var bSecure;	//Passato come eventuale quinto parametro

	if (addICPSubMenu.arguments.length > 3)
		TargetStr = addICPSubMenu.arguments[3];
	else
		TargetStr = "_top";
	if (addICPSubMenu.arguments.length > 4)
		bSecure = addICPSubMenu.arguments[4];
	else
		bSecure = false;
	tempID = "ICP_" + MenuIDStr;
	addSubMenu(tempID,SubMenuStr,SubMenuURLStr,TargetStr,true,bSecure); 
}


function addMSSubMenu(MenuIDStr, SubMenuStr, SubMenuURLStr)
{	
	TargetStr = "_top";
	tempID = "MS_" + MenuIDStr;
	addSubMenu(tempID,SubMenuStr,SubMenuURLStr,TargetStr,false); 
}


function addSubMenu(MenuIDStr, SubMenuStr, SubMenuURLStr, TargetStr, bICPMenu,bSecure)
{
	cFont   = bICPMenu? ICPFont : MSFont;
	cColor0 = bICPMenu? aDefICPColor[0] : aDefMSColor[0];
	cColor1 = bICPMenu? aDefICPColor[1] : aDefMSColor[1];
	cColor2 = bICPMenu? aDefICPColor[2] : aDefMSColor[2];
	
	var MenuPos = MenuIDStr.toUpperCase().indexOf("MENU");
	if (MenuPos == -1) { MenuPos = MenuIDStr.length; }
	InstrumentStr = MenuIDStr.substring(0 , MenuPos) + "|" + SubMenuStr;;
	URLStr        = formatURL(SubMenuURLStr, InstrumentStr, bSecure);

	var LookUpTag  = "<!--" + MenuIDStr + "-->";
	var sPos = HTMLStr.indexOf(LookUpTag);
	if (sPos <= 0)
	{
		HTMLStr += newLineChar + newLineChar +
				"<SPAN ID='" + MenuIDStr + "'" +
				" STYLE='display:none;position:absolute;width:160;background-color:" + cColor0 + ";padding-top:0;padding-left:2;padding-bottom:12;z-index:9;'" +
				" onmouseout='hideMenu(event);'>";
		if (Frame_Supported == false || bICPMenu == false)
			HTMLStr += "<HR  STYLE='position:absolute;left:0;top:0;color:" + cColor1 + "' SIZE=1>";
		HTMLStr += "<DIV STYLE='position:relative;left:0;top:5;'>";
	}
	TempStr = newLineChar +
				"<A ID='AS_" + MenuIDStr + "'" +
				"   STYLE='text-decoration:none;cursor:hand;font:" + cFont + ";font-size:" + MenuFontSize + ";line-height:150%;color:" + cColor1 + "'" +
				"   HREF='" + URLStr + "' TARGET='" + TargetStr + "'" +
				" onmouseout=" + char34 + "mouseMenu(event, 'out' ,'" + MenuIDStr + "');" + char34 +
				" onmouseover=" + char34 + "mouseMenu(event, 'over','" + MenuIDStr + "');" + char34 + ">" +
				"&nbsp;" + SubMenuStr + "</A><BR>" + LookUpTag;
	if (sPos <= 0)
		HTMLStr += TempStr + "</DIV></SPAN>";
	else
		HTMLStr = HTMLStr.replace(LookUpTag, TempStr);	

	updateSubMenuWidth(MenuIDStr);	
}


function addICPSubMenuLine(MenuIDStr)
{	
	tempID = "ICP_" + MenuIDStr;
	addSubMenuLine(tempID,true);
}


function addMSSubMenuLine(MenuIDStr)
{	
	tempID = "MS_" + MenuIDStr;
	addSubMenuLine(tempID,false);
}


function addSubMenuLine(MenuIDStr, bICPMenu)
{
	var LookUpTag = "<!--" + MenuIDStr + "-->";
	var sPos = HTMLStr.indexOf(LookUpTag);
	if (sPos > 0)
	{
		cColor  = bICPMenu? aDefICPColor[1] : aDefMSColor[1];
		TempStr = newLineChar + "<HR STYLE='color:" + cColor + "' SIZE=1>" + LookUpTag;
		HTMLStr = HTMLStr.replace(LookUpTag, TempStr);
	}
}


function mouseMenu(evt, id, MenuIDStr) 
{
    var oEvent = EventUtil.formatEvent(evt);
    IsMSMenu = (MenuIDStr.toUpperCase().indexOf("MS_") != -1);
	IsMouseout = (id.toUpperCase().indexOf("OUT") != -1);

	if (IsMouseout)
	{
		color = IsMSMenu? aDefMSColor[1] : aDefICPColor[1];
		if (MenuIDStr == CurICPMenu && aCurICPColor[1] != "") 
			color = aCurICPColor[1];
	}
	else
	{
		color = IsMSMenu? aDefMSColor[2] : aDefICPColor[2];
		if (MenuIDStr == CurICPMenu && aCurICPColor[2] != "") 
			color = aCurICPColor[2];
}
    //oEvent.srcElement.style.color = color;
    oEvent.target.style.color = color;
	return;
}   //mouseMenu


function doMenu(evt, MenuIDStr) {
    var oEvent = EventUtil.formatEvent(evt);
    var thisMenu = document.getElementById(MenuIDStr);
	if (ToolbarMenu == null || thisMenu == null || thisMenu == ToolbarMenu) 
	{
	    //window.event.cancelBubble = true;
	    oEvent.stopPropagation();
		return false;
	}
	// Reset dropdown menu
	//window.event.cancelBubble = true;
	oEvent.stopPropagation();
	ToolbarMenu.style.display = "none";
	showElement("SELECT");
	showElement("OBJECT");
	ToolbarMenu = thisMenu;
	IsMSMenu = (MenuIDStr.toUpperCase().indexOf("MS_") != -1);

	// Set dropdown menu display position
	//x = oEvent.srcElement.offsetLeft + oEvent.srcElement.offsetParent.offsetLeft;
	x = oEvent.target.offsetLeft + oEvent.target.offsetParent.offsetLeft;
	if (MenuIDStr == LastMSMenu) {
	    //x += (oEvent.srcElement.offsetWidth - thisMenu.style.posWidth);
	    x += (oEvent.target.offsetWidth - thisMenu.style.posWidth);
	}
	//x2 = x + oEvent.srcElement.offsetWidth;
	x2 = x + oEvent.target.offsetWidth;
	y = (IsMSMenu) ? 
		 (idRow1.offsetHeight) :
		 (divBanner.offsetTop + idRow1.offsetHeight + idRow2.offsetHeight + idRow3.offsetHeight);
	thisMenu.style.top  = y;
	thisMenu.style.left = x;
	thisMenu.style.clip = "rect(0 0 0 0)";
	thisMenu.style.display = "block";

	// delay 2 millsecond to allow the value of ToolbarMenu.offsetHeight be set
	window.setTimeout("showMenu();", 20);
	return true;
}


function showMenu() 
{
	if (ToolbarMenu != null) 
	{ 
		IsMenuDropDown = (Frame_Supported && IsMSMenu == false)? false : true;
		if (IsMenuDropDown == false)
		{
			y = (y - ToolbarMenu.offsetHeight - idRow3.offsetHeight);
			if (y < 0) y = 0;
			ToolbarMenu.style.top = y;
		}
		y2 = y + ToolbarMenu.offsetHeight;

		ToolbarMenu.style.clip = "rect(auto auto auto auto)";
		hideElement("SELECT");
		hideElement("OBJECT");
    }
    return;
}   //showMenu() 


function hideMenu(evt)
{
    var oEvent = EventUtil.formatEvent(evt);
    if (ToolbarMenu != null && ToolbarMenu != StartMenu) 
	{
		// Don't hide the menu if the mouse move between the menu and submenus
	    //cY = event.clientY + document.body.scrollTop;
	    cY = oEvent.pageY;
	    if ((oEvent.clientX >= (x + 5) && oEvent.clientX <= x2) &&
			 ((IsMenuDropDown == true  && cY > (y-10) && cY <= y2)      ||
			  (IsMenuDropDown == false && cY >= y     && cY <= (y2+10)) ))
		{
		    //window.event.cancelBubble = true;
		    oEvent.stopPropagation();
			return; 
		}

		ToolbarMenu.style.display = "none";
		ToolbarMenu = StartMenu;
		//window.event.cancelBubble = true;
		oEvent.stopPropagation();
		showElement("SELECT");
		showElement("OBJECT");
	}
}

function hideElement(elmID)
{
	    for (i = 0; i < document.getElementsByTagName(elmID).length; i++) {
	        obj = document.getElementsByTagName(elmID)[i];
		if (! obj || ! obj.offsetParent)
			continue;

		// Find the element's offsetTop and offsetLeft relative to the BODY tag.
		objLeft   = obj.offsetLeft;
		objTop    = obj.offsetTop;
		objParent = obj.offsetParent;
		while (objParent.tagName.toUpperCase() != "BODY")
		{
			objLeft  += objParent.offsetLeft;
			objTop   += objParent.offsetTop;
			objParent = objParent.offsetParent;
		}
		// Adjust the element's offsetTop relative to the dropdown menu
		objTop = objTop - y;

		if (x > (objLeft + obj.offsetWidth) || objLeft > (x + ToolbarMenu.offsetWidth))
			;
		else if (objTop > ToolbarMenu.offsetHeight)
			;
		else if (IsMSMenu && (y + ToolbarMenu.offsetHeight) <= 80)
			;
		else
			obj.style.visibility = "hidden";
	}
}


function showElement(elmID)
{
    for (i = 0; i < document.getElementsByTagName(elmID).length; i++)
	{
	    obj = document.getElementsByTagName(elmID)[i];
		if (! obj || ! obj.offsetParent)
			continue;
		obj.style.visibility = "";
	}
}

function BaseURLcompleto()
{	//Ritorna la parte assoluta dell'URL, in funzione se siamo in localhost oppure no
	var URLStr = window.location.href;
	var urlParts = URLStr.split("/");
	var bSecure=false;
	if (BaseURLcompleto.arguments.length > 0 && urlParts[2]=="www.giap.it")
	{
	    //TODO: riattivare la seguente quando si sarà installato il certificato
		//bSecure = BaseURLcompleto.arguments[0];
	}
	return (bSecure ? "https://" : "http://") + urlParts[2] + "/";
}	//Fine di "BaseURLcompleto()"


function formatURL(URLStr, InstrumentStr)
{	//Completa l'URL, portandolo relativo alla posizione della pagina attuale
	var tempStr = URLStr;
	var bSecure = false;	//Eventualmente passato come terzo parametro

	if (formatURL.arguments.length > 2)
	{
		bSecure = formatURL.arguments[2];
	}
	if (false)
	{	//Quello che segue è l'ex-codice Microsoft... na' caciara!!!
		if (DoInstrumentation && URLStr != "" )
		{
			var ParamPos1 = URLStr.indexOf("?");
			var ParamPos2 = URLStr.lastIndexOf("?");
			var ParamPos3 = URLStr.toLowerCase().indexOf("target=");
			var ParamPos4 = URLStr.indexOf("#");
			var Bookmark  = "";
			var URL = URLStr;
			if (ParamPos4 >= 0)
			{
			 	URL = URLStr.substr(0, ParamPos4);
				Bookmark = URLStr.substr(ParamPos4);
			}
			
			if (ParamPos1 == -1)
				tempStr = "?MSCOMTB=";
			else if (ParamPos1 == ParamPos2 && ParamPos3 == -1)	
				tempStr = "&MSCOMTB=";
			else if (ParamPos1 == ParamPos2 && ParamPos3 != -1)	
				tempStr = "?MSCOMTB=";
			else if (ParamPos1 < ParamPos2)
				tempStr = "&MSCOMTB=";

			tempStr = URL + tempStr + InstrumentStr.replace(" ","%20") + Bookmark;
		}
	}
	else
	{	//Nuova impostazione, si limita a controllare se l'URL è assoluto (e non lo tocca)
		//oppure relativo, allora ci aggiunge il path relativo alla posizione della pagina chiamante
		var sBaseUrl = URLStr.toLowerCase().substr(0, 4);
		if (sBaseUrl != "http")
		{
			//Trattasi di url relativo, allora lo deve modificare
			//tempStr = sPathUp.substr(0, glbLivFromHome*3) + URLStr;
			tempStr = BaseURLcompleto(bSecure) + URLStr;
	    }
	}
	return tempStr;
}	//Fine di "formatURL()"


function setTextInLocalBanner(BanTextPrima, BanTextSeconda, BanUrl)
{	//Imposta uno spazio prefissato della toolbar con del testo
	//Assegnandogli anche una id in maniera da essere modificabile anche in seguito
	//Si utilizzeranno due paragrafi <P>, con due classi di stile distinte...
	//... banner e smallBanner, che dovranno essere già dichiarate.
	//Le id sono le seguenti:
	//per la <A> id = "linkLocalBanner"
	//Prima riga di testo id = "txtBanner"
	//Seconda riga di testo id = "txtSmallBanner"

	var BanBegTag = "<!--BEG_MSC_BANNER-->";
	var BanEndTag = "<!--END_MSC_BANNER-->";
	var begPos = HTMLStr.indexOf(BanBegTag);
	var endPos = HTMLStr.indexOf(BanEndTag) + BanEndTag.length;
	var SubStr = HTMLStr.substring(begPos, endPos);
	var SrcStr = "";
	if (BanUrl != "")
		//Se non viene passato un URL è un semplice messaggio di testo
		SrcStr += "<A CLASS=noDecoration ID=linkLocalBanner Target='_top' HREF='" + BanUrl + "'" +
					" language=" + char34 + "javascript" + char34 + " onmouseover=" + char34 + "MouseLocalBanner('over')" + char34 +
					" onmouseout=" + char34 + "MouseLocalBanner('out')" + char34 + 
					" onclick=" + char34 + "clearInterval(tmrTextInLocalBanner);" + char34 + ">";
	SrcStr += "<P class=banner id=txtBanner>&nbsp;</P>";	//" + BanTextPrima + "
	if (BanUrl != "")
		SrcStr += "</A>";
	SrcStr += "<P class=smallBanner id=txtSmallBanner>" + BanTextSeconda + "</P>";
	SrcStr = BanBegTag + SrcStr + BanEndTag;
	
	//Va a modificare il template contenuto in "HTMLStr"
	HTMLStr = HTMLStr.replace(SubStr, SrcStr);
}	//Fine di "setTextInLocalBanner"


function setImageInLocalBanner(BanGif, BanUrl, BanAltStr)
{	//A differenza di "setMSBanner", con questa si assegna una id alla image ed alla A
	//in maniera da essere modificabili anche nel corpo del documento
	//Le id sono le seguenti:
	//per la <A> id = "linkLocalBanner"
	//per la <IMG> id = "imgLocalBanner"
	//E' possibile anche inserire una immagine senza link, basta passare BanURL = ""
	
	var BanBegTag = "<!--BEG_MSC_BANNER-->";
	var BanEndTag = "<!--END_MSC_BANNER-->";
	
	var begPos = HTMLStr.indexOf(BanBegTag);
	var endPos = HTMLStr.indexOf(BanEndTag) + BanEndTag.length;
	
	var SubStr = HTMLStr.substring(begPos, endPos);
	var SrcStr = "";
	if (BanUrl != "")
		SrcStr += "<A ID=linkLocalBanner Target='_blank' HREF='" + BanUrl + "'>";
	SrcStr += "<IMG ID=imgLocalBanner SRC='" + BanGif + "' ALT='" + BanAltStr + "' BORDER=0>";
	if (BanUrl != "")
		SrcStr += "</A>";
	SrcStr = BanBegTag + SrcStr + BanEndTag;
	//Va a modificare il template contenuto in "HTMLStr"
	HTMLStr = HTMLStr.replace(SubStr, SrcStr);	
}	//Fine di "setLocalBanner"



function setNextTextInLocalBanner(NumRiga)
{	//Grazie ad una variabile modulare, varia il testo, prendendolo dall'array
	if (NumRiga == 1)
	{	//trattasi della prima riga
		if (aPrimaRiga.length)
		{	//Esiste un array di stringhe
			txtBanner.innerHTML = aPrimaRiga[iElemTextPrimaRiga];
			iElemTextPrimaRiga++;
			if (iElemTextPrimaRiga >= aPrimaRiga.length)
				iElemTextPrimaRiga = 0;
		}
	}
	else
	{	//Trattasi della seconda riga
		if (aSecondaRiga.length)
		{
			txtSmallBanner.innerHTML = aSecondaRiga[iElemTextSecondaRiga];
			iElemTextSecondaRiga++;
			if (iElemTextSecondaRiga >= aSecondaRiga.length)
				iElemTextSecondaRiga = 0;
		}
	}
}	//Fine di "setNextTextInLocalBanner"



function MouseLocalBanner(strAzione)
{	//Imposta un colore diverso per il testo inserito nel banner (riga superiore)
	var colore = (strAzione == 'out')?"#000D8F":"#ff9933";	//Cambiare quest'ultimo colore per la fase di evidenziazione (hover)

	txtBanner.style.color = colore;
}	//Fine di "MouseLocalBanner"


function doOutline()
{	//Gestisce la TreeView, reagendo al click del mouse
    var oEvent = EventUtil.formatEvent(EventUtil.getEvent());
    var img1 = new Image();
	img1.src = sLinkUp + "images/home_nuova/lg_arrow_rt.gif";
	var img2 = new Image();
	img2.src = sLinkUp + "images/home_nuova/lg_arrow_dn.gif";

	var srcId, srcElement, targetElement;
	srcElement = oEvent.srcElement;
	srcElement = oEvent.target;
	if (srcElement.className.toUpperCase() == "LEVEL1")
	{	//Allora è un elemento delle TreeView
		srcID = srcElement.id.substr(0, srcElement.id.length-1);
		targetElement = document.getElementById(srcID + "s");
		srcElement = document.getElementById(srcID + "i");

  	if (targetElement.style.display == "none")
  	{	//Si tratta di un elemento già espanso (lo richiude)
			targetElement.style.display = "";
			if (srcElement.className == "LEVEL1")
				srcElement.src = img2.src;
		}
		else
		{	//Si tratta di un elemento chiuso (lo espande)
			targetElement.style.display = "none";
			if (srcElement.className == "LEVEL1")
				srcElement.src = img1.src;
		}
	}
}	//Fine di "doOutline"


function initMenuToolbar()
{	//Traccia la toolbar con il menu ed il logo "Giap Network"
	if (ToolBar_Supported != null && ToolBar_Supported == true)
	{
		//To Turn on/off Frame support, set Frame_Supported = true/false.
		Frame_Supported = false;

		// Customize default ICP menu color - bgColor, fontColor, mouseoverColor
		setDefaultICPMenuColor("#369E75", "white", "#FFCC33");	//menu color originale: 005E39

		// Customize toolbar background color
		setToolbarBGColor("white");

		// display ICP Banner
		setICPBanner(sLinkUp + "images/Banner%20Giap.gif", "default.asp", "Giap Informatica Home");
		
		//***** Add ICP menus *****
		//Home
		addICPMenu("HomeMenu", "Giap Home", "", "default.asp");
		addICPSubMenu("HomeMenu", "Mappa del sito", "pagine/in_allestimento.asp");
		addICPSubMenu("HomeMenu", "Scrivici", "mailto:info@giap.it");
		
		//Notizie (Info e News)
		addICPMenu("EventsMenu", "Notizie", "", "pagine/in_allestimento.asp");
		addICPSubMenu("EventsMenu", "Promozione", "pagine/promozione.asp");
		addICPSubMenu("EventsMenu", "Programmi in uscita", "pagine/prodotti/TotoPlanet/totocalcio/caratteristiche_generali.asp");
		addICPSubMenu("EventsMenu", "Libri", "pagine/in_allestimento.asp");
		//addICPSubMenu("EventsMenu", "Edicola", "pagine/in_allestimento.asp");
		//addICPSubMenu("EventsMenu", "Calcio", "pagine/in_allestimento.asp");
		//addICPSubMenu("EventsMenu", "Formula 1", "pagine/in_allestimento.asp");

		//Prodotti
		addICPMenu("SupportMenu", "Prodotti", "", "pagine/prodotti/lvv/caratteristiche_generali.asp");
		addICPSubMenu("SupportMenu", "Lotto Vincente Visual", "pagine/prodotti/lvv/caratteristiche_generali.asp");
		addICPSubMenu("SupportMenu", "Nuovo Enalotto Visual", "pagine/prodotti/env/caratteristiche_generali.asp");
		addICPSubMenu("SupportMenu", "Totocalcio Planet", "pagine/prodotti/TotoPlanet/totocalcio/caratteristiche_generali.asp");
		//addICPSubMenu("SupportMenu", "Beniamino", "pagine/prodotti/info/beniamino.htm");
		
		//Acquista
		addICPMenu("AcquistaMenu", "E-Shop", "", "pagine/e-shop.asp");
		addICPSubMenu("AcquistaMenu", "Acquista Lotto Visual", "pagine/e-shop.asp?ID=1");
		addICPSubMenu("AcquistaMenu", "Acquista Enalotto Visual", "pagine/e-shop.asp?ID=2");
		addICPSubMenu("AcquistaMenu", "Acquista Totocalcio Planet", "pagine/e-shop.asp?ID=3");

		//MSDN Online
		addICPMenu("MSDNMenu", "Download", "", "pagine/prodotti/download.asp");
		addICPSubMenu("MSDNMenu", "Lotto Vincente Visual", "pagine/prodotti/download.asp?ID=1");
		addICPSubMenu("MSDNMenu", "Nuovo Enalotto Visual", "pagine/prodotti/download.asp?ID=2");
		addICPSubMenu("MSDNMenu", "Totocalcio Planet", "pagine/prodotti/download.asp?ID=3");
		addICPSubMenu("MSDNMenu", "Ultimi Concorsi", "pagine/prodotti/download.asp");
		addICPSubMenu("MSDNMenu", "Anteprime", "pagine/prodotti/download.asp");
		addICPSubMenu("MSDNMenu", "Help aggiornati", "pagine/prodotti/download.asp");
		addICPSubMenu("MSDNMenu", "Manuali elettronici", "pagine/prodotti/download.asp");
		
		//Developer Products
		addICPMenu("DeveloperMenu", "Supporto Clienti", "", "secure/supporto/index.asp", "_top", true);
		addICPSubMenu("DeveloperMenu", "Negozio personalizzato", "secure/supporto/index.asp?Uk=7rHu_9j", "_top", true);
		addICPSubMenu("DeveloperMenu", "Download personalizzato", "secure/supporto/index.asp?Uk=Fg5rHpP", "_top", true);
		addICPSubMenu("DeveloperMenu", "Domande più frequenti", "pagine/prodotti/faq.asp");
		addICPSubMenu("DeveloperMenu", "Codici Attivazione", "secure/supporto/index.asp?Uk=kjE_92", "_top", true);
		addICPSubMenu("DeveloperMenu", "Aggiornamenti Software", "secure/supporto/index.asp?Uk=uiye34", "_top", true);
		addICPSubMenu("DeveloperMenu", "Esperto on-line", "secure/supporto/index.asp?Uk=esp874tr", "_top", true);
		addICPSubMenu("DeveloperMenu", "Piano Newsletter", "secure/supporto/index.asp?Uk=nsjdnr56", "_top", true);
		addICPSubMenu("DeveloperMenu", "Modifica password", "secure/supporto/index.asp?Uk=adfs_9Wj", "_top", true);
		addICPSubMenu("DeveloperMenu", "Modifica dati personali", "secure/supporto/index.asp?Uk=pnd_3fk", "_top", true);
		addICPSubMenu("DeveloperMenu", "Verifica ordini", "secure/supporto/index.asp?Uk=ver87hFH_77", "_top", true);

		//Statistiche e Sistemi
		addICPMenu("StatMenu", "Statistiche & Sistemi", "", "giochi/lotto", "_blank");
		addICPSubMenu("StatMenu", "Lotto", "giochi/lotto","_blank");
		addICPSubMenu("StatMenu", "Super Enalotto", "giochi/superenalotto", "_blank");
		addICPSubMenu("StatMenu", "Totocalcio", "giochi/totocalcio", "_blank");
		addICPSubMenu("StatMenu", "Totogol", "giochi/totogol", "_blank");
		addICPSubMenu("StatMenu", "Tris", "giochi/tris", "_blank");
		addICPSubMenu("StatMenu", "Formula 101", "giochi/f101", "_blank");

		//Lavoro
		//addICPMenu("LavoroMenu", "Lavoro", "", "pagine/in_allestimento.asp");
		//addICPSubMenu("LavoroMenu","Rappresentante", "pagine/in_allestimento.asp");
		//addICPSubMenu("LavoroMenu","Rivenditore", "pagine/in_allestimento.asp");

		//Aggiunge un laterale destro che può essere utilizzato per la data
		MenuStr = newLineChar + "<SPAN ID='spanData' STYLE='font:Verdana;font-size:7.0pt;font-weight:bold;color:#A5E4CC;text-align:right;width:180;height:10;'>&nbsp;</SPAN>"; 
		HTMLStr = HTMLStr.replace("<!--ICP_MENU_TITLES-->", MenuStr);	
		setSubMenuWidth("DataMenu","relative",0);

	}
}	//Fine di "initMenuToolbar()"


var tmrTextInLocalBanner;

function initBannerPubblicitario()
{	//Traccia il banner pubblicitario con la frase
	var URLStr = window.location.href;
	var bSecure = (URLStr.substring(0, 5).toLowerCase().indexOf("https") >= 0);
	if (ToolBar_Supported)
	{	//La toolbar è gestita
		initMenuToolbar();
		//Sul lato destro del banner c'è una zona alta 60 pixel e larga quanto rimane
		//dove è possibile inserire del testo (modificabile anche in seguito utilizzando le id)
		//Le id sono le seguenti:
		//per la <A> id = "linkLocalBanner"
		//Prima riga di testo id = "txtBanner"
		//Seconda riga di testo id = "txtSmallBanner"

		//REMMARE UNA DELLE DUE ISTRUZIONI SEGUENTI
		
		//E' possibile scrivere su due righe, la prima con corpo grande e...
		//...la seconda con corpo più piccolino (e non linkabile)
		setTextInLocalBanner("", "", "pagine/esperto.asp");

		//... oppure una immagine (modificabile anche in seguito)
		//setImageInLocalBanner(formatURL("images/banner/giocotel430x60.gif", "", bSecure), "http://www.giocotel.it", "Il primo portale italiano per i giochi a pronostico. GRATUITO!");
		
		//ma non insieme (o il testo o l'immagine)
			
		//E per ultimo bisogna dare il comando di tracciamento
		drawToolbar();
			
		//E' sempre possibile cambiare il testo (o l'immagine) in "idMSCBanner" con DHTML
		tmrTextInLocalBanner = setInterval("setNextTextInLocalBanner(1)", 5000, "javascript");
			
		//Quindi attiva l'intercettazione dell'evento click
		document.onclick = doOutline;
	}	//End if
}	//Fine di "initBannerPubblicitario()"


function CambiaFrasiInBanner(sBig, sSmall, sUrl)
{	//Cambia le frasi pubblicitarie. I ritorni a capo sono indicati con il carattere #
	var ElementTxtBanner = document.getElementById("txtBanner");
	if (ElementTxtBanner != null)
	{	//Allora è gestito il banner di testo
		if (sSmall != "")
		{	//C'è da fare spazio anche alla seconda riga in piccolo
			txtBanner.style.marginTop = "-3.0pt";
			txtSmallBanner.style.marginTop = "-3.0pt";
		}
		else
		{	//C'è solo il messaggio in grande
			txtBanner.style.marginTop = "4.0pt";
			txtSmallBanner.style.marginTop = "0.0pt";
		}
		aPrimaRiga = sBig.split("#");
		document.getElementById("linkLocalBanner").href = formatURL(sUrl, "");
		txtSmallBanner.innerHTML = sSmall;
	}	//Chiude if (Gestisce il banner di testo?)
	return;
}	//Fine di "CambiaFrasiInBanner()"




// Routine di utilità per la gestione degli eventi
// Creato da Nicholas C. Zakas
// Modificato da Luigi Gaeta
// Ultima modifica 24-11-2008
// Versione 1.0.6
// Librerie richieste: nessuna

var EventUtil = new Object();
EventUtil.addEventHandler = function(oTarget, sEventType, fnHandler) {
    if (oTarget.addEventListener) {
        oTarget.addEventListener(sEventType, fnHandler, false);
    }
    else if (oTarget.attachEvent) {
        oTarget.attachEvent("on" + sEventType, fnHandler);
    }
    else {
        oTarget["on" + sEventType] = fnHandler;
    }
};

EventUtil.removeEventHandler = function(oTarget, sEventType, fnHandler) {
    if (oTarget.removeEventListener) {
        oTarget.removeEventListener(sEventType, fnHandler, false);
    }
    else if (oTarget.detachEvent) {
        oTarget.detachEvent("on" + sEventType, fnHandler);
    }
    else {
        oTarget["on" + sEventType] = null;
    }
};

EventUtil.formatEvent = function(oEvent) {
    var sUserAgent = navigator.userAgent;
    var isOpera = sUserAgent.indexOf("Opera") > -1;
    var isIE = sUserAgent.indexOf("compatible") > -1
               && sUserAgent.indexOf("MSIE") > -1
               && !isOpera;
    var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
    if (isIE && isWin && oEvent) {
        oEvent.charCode = (oEvent.type == "keypress") ? oEvent.keyCode : 0;
        oEvent.eventPhase = 2;
        oEvent.isChar = (oEvent.charCode > 0);
        var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
        oEvent.pageX = oEvent.clientX + scrollLeft; //document.body.scrollLeft;
        var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
        oEvent.pageY = oEvent.clientY + scrollTop;  //document.body.scrollTop;
        oEvent.preventDefault = function() {
            this.returnValue = false;
        };

        if (oEvent.type == "mouseout") {
            oEvent.relatedTarget = oEvent.toElement;
        }
        else if (oEvent.type == "mouseover") {
            oEvent.relatedTarget = oEvent.fromElement;
        }

        oEvent.stopPropagation = function() {
            this.cancelBubble = true;
        };

        oEvent.target = oEvent.srcElement;
        oEvent.time = (new Date).getTime();
    }
    return oEvent;
};  //formatEvent

EventUtil.getEvent = function() {
    if (window.event) {
        return this.formatEvent(window.event);
    }
    else {   //Arriva qui anche se trattasi di IE7!
        if (EventUtil.getEvent.caller.caller) {
            return EventUtil.getEvent.caller.arguments[0] || EventUtil.getEvent.caller.caller.arguments[0]; //A volte la chiamata è nidificata
        }
        else {
            return EventUtil.getEvent.caller.arguments[0];
        }
    }
};

