if(document.all){
	var var_display='block';
}else{
	var var_display='table-row';
}


function MM_findObj(theObj, theDoc){
  var p, i, foundObj;
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length){
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++){
    foundObj = theDoc.forms[i][theObj];
  }
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++){
    foundObj = findObj(theObj,theDoc.layers[i].document);
  }
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  return foundObj;
}

function switch_menu(obj, r_id) {
	if(MM_findObj('riga_'+r_id).style.display=='none'){
		obj.src="../images/nodochiudi.gif";
		MM_findObj('riga_'+r_id).style.display=var_display;
	}else{
		obj.src="../images/nodoapri.gif";
		MM_findObj('riga_'+r_id).style.display="none";
	}
}

function Controllo_eliminazione(page_link) {
	var esito = confirm("Sei sicuro di voler procedere con l'eliminazione?");
	if(esito==true){
		location.href=page_link;
	}else{
		return esito;
	}
}

//// INIZIO FUNZIONI PER MENU CATEGORIE

var menu_over = 0;
var livello_over = 0;
var ritardo_menu = 300;
var table_over = 0;
var table_livello = 0;

function entra_menu(id, livello){
	menu_over=id;
	livello_over=livello;
	setTimeout("ctrl_menu()",ritardo_menu);
}

function esci_menu() { //v6.0
	menu_over=0;
	livello_over=0;
	setTimeout("ctrl_menu()",ritardo_menu);
}

function ctrl_menu(){
	if(menu_over==0 && table_over!=0){
		menu_over=table_over;
		livello_over=table_livello;
	}
	for(n=(1 + parseInt(livello_over)); n<=(aMenuLivelli.length - 1); n++){
		for (i=0; i < aMenuLivelli[n].length; i++){
			if (aMenuLivelli[n][i]==menu_over){
				MM_showHideLayers(aMenuLivelli[n][i],'','show');
			}else{
				MM_showHideLayers(aMenuLivelli[n][i],'','hidden');
			}
		}
	}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style){
    	obj=obj.style;
    	v=(v=='show')?'visible':(v=='hide')?'hidden':v;
    }
    obj.visibility=v; }
}

function P7_Snap() { //v2.62 by PVII
  var x,y,ox,bx,oy,p,tx,a,b,k,d,da,e,el,args=P7_Snap.arguments;a=parseInt(a);
  for (k=0; k<(args.length-3); k+=4)
   if ((g=MM_findObj(args[k]))!=null) {
    el=eval(MM_findObj(args[k+1]));
    a=parseInt(args[k+2]);b=parseInt(args[k+3]);
    x=0;y=0;ox=0;oy=0;p="";tx=1;da="document.all['"+args[k]+"']";
    if(document.getElementById) {
     d="document.getElementsByName('"+args[k]+"')[0]";
     if(!eval(d)) {d="document.getElementById('"+args[k]+"')";if(!eval(d)) {d=da;}}
    }else if(document.all) {d=da;} 
    if (document.all || document.getElementById) {
     while (tx==1) {p+=".offsetParent";
      if(eval(d+p)) {x+=parseInt(eval(d+p+".offsetLeft"));y+=parseInt(eval(d+p+".offsetTop"));
      }else{tx=0;}}
     ox=parseInt(g.offsetLeft);oy=parseInt(g.offsetTop);var tw=x+ox+y+oy;
     if(tw==0 || (navigator.appVersion.indexOf("MSIE 4")>-1 && navigator.appVersion.indexOf("Mac")>-1)) {
      ox=0;oy=0;if(g.style.left){x=parseInt(g.style.left);y=parseInt(g.style.top);
      }else{var w1=parseInt(el.style.width);bx=(a<0)?-5-w1:-10;
      a=(Math.abs(a)<1000)?0:a;b=(Math.abs(b)<1000)?0:b;
      x=document.body.scrollLeft + event.clientX + bx;
      y=document.body.scrollTop + event.clientY;}}
   }else if (document.layers) {x=g.x;y=g.y;var q0=document.layers,dd="";
    for(var s=0;s<q0.length;s++) {dd='document.'+q0[s].name;
     if(eval(dd+'.document.'+args[k])) {x+=eval(dd+'.left');y+=eval(dd+'.top');break;}}}
   if(el) {e=(document.layers)?el:el.style;
   var xx=parseInt(x+ox+a),yy=parseInt(y+oy+b);
   if(navigator.appName=="Netscape" && parseInt(navigator.appVersion)>4){xx+="px";yy+="px";}
   if(navigator.appVersion.indexOf("MSIE 5")>-1 && navigator.appVersion.indexOf("Mac")>-1){
    xx+=parseInt(document.body.leftMargin);yy+=parseInt(document.body.topMargin);
    xx+="px";yy+="px";}e.left=xx;e.top=yy;}}
}
//// FINE FUNZIONI MENU CATEGORIE 

////FUNZIONI PER RIDURRE LO SPAZIO DI CRENATURA CARATTERI
function crenatura_caratteri(){
	for(n=0; n<aTitoli.length; n++){
		MM_findObj('span_mis_char').style.fontSize=aTitoli[n]["size"];
		MM_findObj('span_mis_char').innerHTML=aTitoli[n]["testo"];
		var diff_width=(MM_findObj('span_mis_char').offsetWidth - aTitoli[n]["length"]);
		if(diff_width>0){
			var num=0;
			while(diff_width>0){
				num++;
				MM_findObj('span_mis_char').style.letterSpacing='-'+num+'px';
				diff_width=(MM_findObj('span_mis_char').offsetWidth - aTitoli[n]["length"]);
			}
			MM_findObj('span_mis_char').style.letterSpacing='0px';
			MM_findObj(aTitoli[n]["obj"]).style.letterSpacing='-'+num+'px';
		}
	}
}
function crenatura_caratteri_apertura(){
	MM_findObj('div_mis_char_aper').innerHTML=MM_findObj('obj_tit_aper').innerHTML;
	if(MM_findObj('div_mis_char_aper').offsetHeight > 55){
		var num=0;
		while(MM_findObj('div_mis_char_aper').offsetHeight > 55){
			num++;
			MM_findObj('div_mis_char_aper').style.letterSpacing='-'+num+'px';
		}
		MM_findObj('obj_tit_aper').style.letterSpacing='-'+num+'px';
	}
}
////FINE CRENATURA

////FUNZIONI PER IL DRAG&DROP
function ddInit(e){
	topDog=isIE ? "BODY" : "HTML";
	whichDog=isIE ? document.all.LayerFinderBooking : document.getElementById("LayerFinderBooking"); 
	whichDogMainMenu=isIE ? document.all.MainMenuLayer : document.getElementById("MainMenuLayer"); 
	
	hotDog=isIE ? event.srcElement : e.target;  
	while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog&&hotDog.id!="DragBar"){
	  hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
	}  
	if (hotDog.id=="titleBar"){
	  offsetx=isIE ? event.clientX : e.clientX;
	  offsety=isIE ? event.clientY : e.clientY;
	  nowX=parseInt(whichDog.style.left);
	  nowY=parseInt(whichDog.style.top);
	  ddEnabled=true;
	  document.onmousemove=dd;
	}
	if (hotDog.id=="DragBar"){
	  offsetxMainMenu=isIE ? event.clientX : e.clientX;
	  offsetyMainMenu=isIE ? event.clientY : e.clientY;
	  nowXMainMenu=parseInt(whichDogMainMenu.style.left);
	  nowYMainMenu=parseInt(whichDogMainMenu.style.top);
	  ddEnabled=true;
	  document.onmousemove=ddMainMenu;
	}
}

function dd(e){
	if (!ddEnabled) return;
	whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}
function ddMainMenu(e){
	if (!ddEnabled) return;
  whichDogMainMenu.style.left=isIE ? nowXMainMenu+event.clientX-offsetxMainMenu : nowXMainMenu+e.clientX-offsetxMainMenu; 
  whichDogMainMenu.style.top=isIE ? nowYMainMenu+event.clientY-offsetyMainMenu : nowYMainMenu+e.clientY-offsetyMainMenu;
  return false;  
}

function ddN4(whatDog){
	if (!isN4) return;
	N4=eval(whatDog);
	N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
	N4.onmousedown=function(e){
	  N4.captureEvents(Event.MOUSEMOVE);
	  N4x=e.x;
	  N4y=e.y;
	}
	N4.onmousemove=function(e){
		if (isHot){
	  	N4.moveBy(e.x-N4x,e.y-N4y);
	  	return false;
		}
	}
	N4.onmouseup=function(){
	  N4.releaseEvents(Event.MOUSEMOVE);
	}
}
////FINE FUNZIONI DRAG&DROP