function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function tabOn(mydiv) {
	for(i=1;i<=ntab;i++) {
		myObj=MM_findObj('tabdiv'+i);
		if (i==mydiv) myObj.style.display="block";
		else  myObj.style.display="none";
	}
}

function apriPop(myUrl,myWinName,myWidth,myHeight,myPars) {
	var winl = (screen.width - myWidth) / 2;
	var wint = (screen.height - myHeight) / 2;
	parameters = myPars + '';
	if (parameters == '') parameters = ',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no';
	gwin=window.open(myUrl,myWinName,'width='+myWidth+',height='+myHeight+',left='+winl+',top='+wint+parameters);
	if (gwin) gwin.focus();
}

/*
function UB_showHideObject(){var i,p,v,obj,args=UB_showHideObject.arguments;for(i=0;i<(args.length-1);i+=2){if((obj=MM_findObj(args[i]))!=null){v=args[i+1];if(obj.style){obj=obj.style;v=(v=='off')?'none':(v=='on')?'block':v;};obj.display=v;}}}
*/
qualeEraAttivo = "";
function UB_showHideObject(idSub, azione){
	if(azione=='on')
	{
		valDisp = "block";
			
		$(".menu1liv").find("li").each(function(){
			if($(this).children().attr("class")=="active")
				qualeEraAttivo = $(this).attr("qualeJQ");
		});
	}
	else
		valDisp = "none";
	//alert(qualeEraAttivo);

	$(".menu2liv").each(function(){
		$(this).css("display","none")			 
	});
	
	$("#"+idSub+"").css("display",valDisp);
	
	if(qualeEraAttivo!="" && azione=="off")
	{
		//alert($(".menu2liv[qualeJQ="+qualeEraAttivo+"]").html());
		$(".menu2liv[qualeJQ="+qualeEraAttivo+"]").css("display","block");
	}
}

var activeMNU,subTimeoutID,activeELM;

function UB_subMNUoff(myMNU){
	if(subTimeoutID){
		clearTimeout(subTimeoutID)
	};
	UB_showHideObject(myMNU,'off');
	subTimeoutID='';
	activeMNU='';
	subTimeoutID='';
	activeMNU='';
	if(activeELM){
		activeELMclassName=activeELM.firstChild.className;
		activeELM.firstChild.className=activeELMclassName.lastIndexOf(' ')?activeELMclassName.substring(0,activeELMclassName.lastIndexOf(' ')):' ';
		activeELM='';
	}
}
function UB_timeout(myMNU,myTimeout){
	myTimeout=myTimeout?myTimeout:333;
	subTimeoutID=setTimeout("UB_subMNUoff('"+ myMNU +"')",myTimeout);
}

function UB_subMNUon(myMNU,myElement){
	//alert(activeMNU)
	if(myMNU==activeMNU){
		if(subTimeoutID){
			clearTimeout(subTimeoutID)
		};
		subTimeoutID='';
		return;
	};
	if(activeMNU){
		UB_subMNUoff(activeMNU)
	};
	activeMNU=myMNU;
	UB_showHideObject(myMNU,'on');
	if(myElement){
		myElement.firstChild.className=(myElement.firstChild.className)?myElement.firstChild.className+' active':'active';activeELM=myElement;
	}
}
