var w3gDialogsButtonLocale = {1:{'IT':'ok','EN':'ok'}, 0:{'IT':'annulla','EN':'cancel'}, 2:{'IT':'si','EN':'yes'}, 3:{'IT':'no','EN':'no'}};//var myOldId = 0; //new Array(-1,-1); // menu & pathmenu
var timer = new Array(-1,-1); // menu & pathmenu

var DOM2=(document.getElementById) ? 1:0;
var IE4 =(document.all) ? 1:0;
var NS4 =(document.layers) ? 1:0;
var openedMenu;
var popupVOffset=0;
//menu_vOffset could be defined before, otherwise default is 10 pixel
try {popupVOffset=menu_vOffset;} catch (e) {popupVOffset=10;};
//menu_hOffset allows to correct horizontal popup startpoint. -1 means no correction.@FV2005.10.11
var popupHOffset=0;
try {popupHOffset=menu_hOffset;} catch (e) {popupHOffset=-1;};

if (NS4 && DOM2) NS4=0;

function seeOverTags( myId, hideSelect ) {
	//menu_length 2007.02.15@FV no more used.	
	_see(myId, "subMenu", "menu", popupVOffset, popupHOffset,1000, 0, (hideSelect)?"showTags('SELECT')":"");
}

function seePathSubMenu( myId ) {
	if (pathMenu_vOffset!=null)
		_see(myId, "pathSubMenu", "pathMenu", pathMenu_vOffset, -1, 1000, 1, "showTags('SELECT')");
	else
		_see(myId, "pathSubMenu", "pathMenu", 0, -1, 1000, 1, "showTags('SELECT')");
}

/*Pass -1 to hide all menus otherwise the number of menu to display*/
/*The name of the layer should be "subMenu"+number*/
function _see(myId, mySubmenu, myMenu, myOffsetV, myOffsetH, myTimeOut, myIndex, add2timeOut){

	// with negative value hide myId menu	
	if((myId<0)){
		//activeEl=mySubmenu+myOldId;
		activeEl=mySubmenu+(-myId);
		if(NS4){
			timer[myIndex]=setTimeout("_doSee('"+activeEl+"',true)", myTimeOut);
		} else {
			timer[myIndex]=setTimeout("_doSee('"+activeEl+"',true)", myTimeOut/2);
		}
	}
/*j starts with 1 because first DIV is never displayed because it's a logo element*/
	if (myId>=0){ // hide all other menus except current myId
		//window.status="menuSelected="+myId+" top="+document.getElementById(myMenu+myId).offsetTop+"-"+myOffsetV+" left="+myOffsetH;
		var exitLoop = false;
		for (j=1 ; !exitLoop ; j++) {
			exitLoop = ! ((NS4) ? document.layers[thisLayer] : document.getElementById(mySubmenu+j));
			if (!exitLoop && j!=myId) {
				if(NS4){ 
					thisLayer=mySubmenu+j;
					_doSee(thisLayer,true);
					//document.layers[thisLayer].visibility="hide";
				} else { 
					_doSee(mySubmenu+j,true);
					//document.getElementById(mySubmenu+j).style.visibility="hidden"
				}
			}
		}
		//clear deleyed hide action
		if(timer[myIndex]>0){
			window.clearTimeout(timer[myIndex]);
		}
		//show current myId menu at correct position
		if(NS4){
			thisLayer=mySubmenu+myId;
			parentLayer=myMenu+myId;
			if ((myOffsetV!=0)||(myOffsetH!=-1)) document.layers[thisLayer].moveTo((myOffsetH==-1)?document.layers[parentLayer].pageX:myOffsetH,document.layers[parentLayer].pageY-myOffsetV);
			_doSee(thisLayer);			
		} else {
			var myObj=_doSee(mySubmenu+myId)
			//myObj.style.visibility = "visible";
			//myObj.style.display = "block";
			if (myOffsetV!=0) myObj.style.top=document.getElementById(myMenu+myId).offsetTop-myOffsetV+"px";
			if (myOffsetH!=-1) myObj.style.left=myOffsetH;
		}
	}
}
function _doSee(element,doHide){
	if(!doHide)doHide=false;
	if(NS4){
		element =document.layers[element]
		element.visibility=doHide?'hide':'show';
	} else {
		element = $(element)
		element.style.visibility=doHide?'hidden':'visible';
		if(!doHide)element.style.display = 'block';
	}
	if(!doHide){
		openedMenu =element.hideOverlappedSelect();
	}else{
		element.showOverlappedSelect();
	}
	return element;
	
}


function setBG( obj ) {
	// 2009.02.17@SO Cambio anche lo stile dell'eventuale ancora figlia...
	if(typeof Prototype != 'undefined'){
		obj = $(obj);
		var anchor = obj.down();
		if(anchor!=null && anchor.tagName.toUpperCase() == 'A' && anchor.className.indexOf('item_menu') >= 0){
			anchor = $(anchor);
			anchor.addClassName('item_menu_setBG');
		}	
	}
    var colorId=obj.id.split("_"); //id name contains menu coordinates used to map idColors if configured
    try {
	  if (menu_bgMouseover instanceof Array) 
	    obj.style.backgroundColor = menu_bgMouseover[colorId[2]-1][colorId[3]] !=null ? menu_bgMouseover[colorId[2]-1][colorId[3]] : menu_bgMouseover[colorId[2]-1][0];
	  else
		obj.style.backgroundColor = menu_bgMouseover;
    }catch (e) {
		obj.style.backgroundColor = "#999999";
	}	
}

function resetBG( obj ) {
	// 2009.02.17@SO Cambio anche lo stile dell'eventuale ancora figlia...
	if(typeof Prototype != 'undefined'){
		obj = $(obj);
		var anchor = obj.down();
		if(anchor!=null && anchor.tagName.toUpperCase() == 'A' && anchor.className.indexOf('item_menu') >= 0){
			anchor.removeClassName('item_menu_setBG');
		}
	}
	obj.style.backgroundColor = "";
}

function clickLink( obj ) {
    var linkId=obj.id.split("item_menu_"); //id name contains menu coordinates 
    try { location.href=document.getElementById("item_menu_A"+linkId[1]).href;
    }catch (e) {}
}

// 2008.11.12@SO Gestione click anche su div del menù principale...
function clickLinkMain( obj ) {
    var linkId=obj.id.split("titolo_max"); //id name contains menu coordinates 
    try { location.href=document.getElementById("mMenu"+linkId[1]).href;
    }catch (e) {}
}
