 
function MenuOpen(Att){

	if(set_open_close != ""){
		var error_str = "Devi prima Salvare o Annullare l'operazione di modifica precedente"
		SVopenWin('include_App/varie/error_str.asp?erro='+error_str,320,205,false,true);
	}else{
	
		document.getElementById("MenuCont-"+Att).className = "menumod_open";
		//document.getElementById("work-"+Att).className = "workarea_open"
		document.getElementById("DragCmd-"+Att).className = "menumod_comand_open";
		
		document.getElementById("selectionSet"+Att+"1").style.background="#ffffff url('include_app/include_img/Jcrop.gif')"
		document.getElementById("selectionSet"+Att+"2").style.background="#ffffff url('include_app/include_img/Jcrop.gif')"
		document.getElementById("selectionSet"+Att+"3").style.background="#ffffff url('include_app/include_img/Jcrop.gif')"
		document.getElementById("selectionSet"+Att+"4").style.background="#ffffff url('include_app/include_img/Jcrop.gif')"
		
		//addStr = '<ul><li><a unselectable="on" href="#" >Aggiungi</a></li></ul>';
		addStr = "";
		addStr += '<ul><li><a unselectable="on" href="javascript:MenuSave(\&quot;'+Att+'\&quot;)" >Salva</a></li></ul>';
		addStr += '<ul><li><a href="javascript:MenuClose(\&quot;'+Att+'\&quot;,false)" >Annulla</a></li></ul>';
		
		document.getElementById("DragCmd-"+Att).innerHTML = addStr
		
		memo_dati = document.getElementById("Drag-"+Att).getElementsByTagName("div")[0].cloneNode(true);
		
		/////////////////////////////////////////////////////////////////////////////////
		document.getElementById("gost_menu").style.display = "block";
		document.getElementById("gost_menu").style.visibility = "visible";
		/////////////////////////////////////////////////////////////////////////////////
		
		set_open_close = Att
		_MenuSet_LI(Att);
		//document.write(document.getElementById('DragCont-'+Att).parentNode.innerHTML)
	}
}


function MenuClose(Att,save){
	
	set_open_close = "";
	
	document.getElementById("MenuCont-"+Att).className = "menumod";
	document.getElementById("DragCmd-"+Att).className = "menumod_comand";
	document.getElementById("DragCmd-"+Att).innerHTML = '<ul><li><a unselectable="on" href="javascript:MenuOpen(\&quot;'+Att+'\&quot;)" >Modifica</a></li></ul>';
	
	document.getElementById("selectionSet"+Att+"1").style.background="#444444"
	document.getElementById("selectionSet"+Att+"2").style.background="#444444"
	document.getElementById("selectionSet"+Att+"3").style.background="#444444"
	document.getElementById("selectionSet"+Att+"4").style.background="#444444"
	
	if(!save){
		objj = document.getElementById("Drag-"+Att).getElementsByTagName("div")[0]
		document.getElementById("Drag-"+Att).removeChild(objj)
		document.getElementById("Drag-"+Att).appendChild(memo_dati);
	}
	
	
}


function _MenuSet_LI(Att){
	

	var exit_LI;
	var Obj_sel = document.getElementById("Drag-"+Att);
	var LI_sel = Obj_sel.getElementsByTagName("li")
		
	var LI_Des = document.getElementById("Drag-"+Att);
	
	var LI_Clo_Dest = document.getElementById('DragMemo-'+Att)
	
	
	
	for(var i=0; i<LI_sel.length; i++){
		
		
		
		var LI_obj_now = LI_sel[i];
		var LI_obj_rght = LI_sel[i];
		
		if(LI_obj_now.id.split("-")[0]=="arg"){
		
			CloneNode_LI = LI_obj_now.cloneNode(true);
			

			
			LI_Clo_Dest.innerHTML = ""
			
			var str_newcreate = '';
	
			str_newcreate +='<div  unselectable="on" class="drug" id="Drag-'+Att+'-'+i+'" onmousedown="menufile(this.id,\&quot;'+LI_obj_rght.id+'\&quot;)" >'; 
			
			str_newcreate +='<div unselectable="on" class="spacer_up" id="spacer_up-U-'+Att+'-'+i+'" onmouseover="thisDrop(\&quot;'+Att+'-'+i+'\&quot;,this.id)" onmouseout="outDrop(\&quot;'+Att+'-'+i+'\&quot;,this.id)"></div>';
			str_newcreate +='<div unselectable="on" class="spacer_sx" id="spacer_sx-U-'+Att+'-'+i+'" onmouseover="thisDrop(\&quot;'+Att+'-'+i+'\&quot;,this.id)" onmouseout="outDrop(\&quot;'+Att+'-'+i+'\&quot;,this.id)"></div>'
			str_newcreate +='<div class="DragCont"  unselectable="on" id="ConDragInner-'+Att+'-'+i+'"></div>';
			str_newcreate +='<div  unselectable="on" class="spacer_dx" id="spacer_dx-D-'+Att+'-'+i+'" onmouseover="thisDrop(\&quot;'+Att+'-'+i+'d\&quot;,this.id)" onmouseout="outDrop(\&quot;'+Att+'-'+i+'\&quot;,this.id)"></div>';
			str_newcreate +='<div unselectable="on" class="spacer_dw" id="spacer_dw-D-'+Att+'-'+i+'" onmouseover="thisDrop(\&quot;'+Att+'-'+i+'d\&quot;,this.id)" onmouseout="outDrop(\&quot;'+Att+'-'+i+'\&quot;,this.id)"></div>';
			if(LI_obj_now.getElementsByTagName("ul").length>0){

				str_newcreate +='<div class="movDrag_ul"  unselectable="on" onmousedown="DragDrop(\&quot;'+Att+'-'+i+'\&quot;)"></div>';
			}else{
				str_newcreate +='<div class="movDrag"  unselectable="on" onmousedown="DragDrop(\&quot;'+Att+'-'+i+'\&quot;)"></div>';
			}
			str_newcreate +='<div class="clear"></div></div><div class="clear"></div>';
			
			/////////////////////////////////////////////////////////////////////////
			
			
			LI_Clo_Dest.innerHTML = ""
			LI_Clo_Dest.innerHTML = str_newcreate;
			document.getElementById("ConDragInner-"+Att+"-"+i).appendChild(CloneNode_LI)
			LI_Clo_Dest.getElementsByTagName("li")[0].setAttribute("unselectable","on")
			CloneTrensfert_LI = LI_Clo_Dest.getElementsByTagName("div")[0]
			
			LI_sel[i].replaceNode(CloneTrensfert_LI,LI_obj_now)
			
			//var offsetH = CloneNode_LI.parentNode.offsetHeight
			
					
			
			/*document.getElementById('spacer_sx-U-'+Att+'-'+i).style.height = offsetH
			document.getElementById('spacer_dx-D-'+Att+'-'+i).style.height = offsetH*/
			
			

			
			
		}else{
		
			CloneNode_LI = LI_obj_now.cloneNode(true);
			
			LI_Clo_Dest.innerHTML = ""
			
			var str_newcreate = '';
	
			str_newcreate +='<div  unselectable="on" class="drug" id="Drag-'+Att+'-'+i+'" onmousedown="menufile(this.id,\&quot;'+LI_obj_rght.id+'\&quot;)" >'; 
			str_newcreate +='<div class="DragCont"  unselectable="on" id="ConDragInner-'+Att+'-'+i+'"></div>';
			str_newcreate +='</div>';
			
			/////////////////////////////////////////////////////////////////////////
			
			LI_Clo_Dest.innerHTML = ""
			LI_Clo_Dest.innerHTML = str_newcreate;
			document.getElementById("ConDragInner-"+Att+"-"+i).appendChild(CloneNode_LI)
			LI_Clo_Dest.getElementsByTagName("li")[0].setAttribute("unselectable","on")
			CloneTrensfert_LI = LI_Clo_Dest.getElementsByTagName("div")[0]
			
			LI_sel[i].replaceNode(CloneTrensfert_LI,LI_obj_now)
			
		}
		
		
	
	}
	
	var UL_sel = document.getElementById("Drag-"+Att).getElementsByTagName("ul")
		
	for(var o=0; o<UL_sel.length; o++){
		var UL_sel_att = UL_sel[o].getAttribute("id")
		
		if(UL_sel_att && UL_sel_att!="gost_menu"){
			UL_sel[o].className= "topmenuEdit"
			var str_newcat = '<div unselectable="on" class="spacerCat" id="spacer-IT-'+Att+'-'+UL_sel_att+'" onmouseover="thisDrop(this.id,this.id)" onmouseout="outDrop(this.id,this.id)"></div>'
			LI_Clo_Dest.innerHTML = str_newcat;
			CloneTrensfert_UL = LI_Clo_Dest.getElementsByTagName("div")[0]
			UL_sel[o].appendChild(CloneTrensfert_UL)
		}
	}
	
}

function DragDrop(Att){
	
	Att_ried = Att.split("-")[0]+"-"+Att.split("-")[1]
	
	stratDrag(Att)
	
	document.getElementById("druggers-"+Att_ried).innerHTML =	""
	LI_obj_Clo_Now = document.getElementById("Drag-"+Att)
	LI_Clo_Drag = LI_obj_Clo_Now.cloneNode(true);
	document.getElementById("druggers-"+Att_ried).appendChild(LI_Clo_Drag);
	document.getElementById("ConDragInner-"+Att).style.visibility = "hidden";
	document.getElementById("Drag-"+Att).style.display = "none";
	document.getElementById("druggers-"+Att_ried).style.visibility = "visible";
	document.getElementById("druggers-"+Att_ried).style.unselectable = "on";
	
}

function stratDrag(id){
			
	set_Drag = true;
	
	isIE = document.all;
	tempX = isIE ? (window.event.clientX+4) : e.clientX;
	tempY = isIE ? (window.event.clientY+4) : e.clientY;
	
	if(set_Drag){
		document.getElementById("druggers-"+Att_ried).style.left=tempX+"px";
		document.getElementById("druggers-"+Att_ried).style.top=tempY+"px";
	}
	document.onmousemove = XY;
	
}

function DragDropStop(Att){
	stopDrag(Att)
}

function stopDrag(){
		
		//alert(sotmenumax)
		
		if(set_Drag){
			
			var obj_drag = document.getElementById("druggers-"+Att_ried).getElementsByTagName("div")[0].getAttribute("id")
			var obj_drag_ary = obj_drag.split("-");
			var obj_drag_sel = obj_drag_ary[1]+"-"+obj_drag_ary[2]+"-"+obj_drag_ary[3]
			
			if(pos_drag && testSotmenu(pos_drag)){
				
				var pos_drag_ary = pos_drag.split("-");
				var UorD = pos_drag_ary[1];
				var pos_drag_rif = pos_drag_ary[2]+"-"+pos_drag_ary[3]+"-"+pos_drag_ary[4];
				var Att = pos_drag_ary[2]+"-"+pos_drag_ary[3];
				
				var obj_drag_sel_go = document.getElementById("Drag-"+obj_drag_sel)
				
				if(UorD=="U"||UorD=="D"){
				var obj_drag_rif_go = document.getElementById("Drag-"+pos_drag_rif)
				var parent_obj_rif = obj_drag_rif_go.parentNode;
				}
				
				var y = document.getElementById('DragMemo-'+Att);
				y.appendChild(obj_drag_sel_go);
				
				document.getElementById("ConDragInner-"+obj_drag_sel).style.visibility = ""; 
				document.getElementById("Drag-"+obj_drag_sel).style.display = "";
				document.getElementById("druggers-"+Att_ried).style.visibility = "hidden";
				
				if(UorD == "U"){
						x = obj_drag_rif_go;											
				}else if(UorD == "D"){
						x = obj_drag_rif_go.nextSibling;
				}else if(UorD == "IT"){
						pos_IT = document.getElementById(pos_drag);
						x = pos_IT.parentNode;
				}
				
				
				if(UorD=="U"||UorD=="D"){
					while (x){
						try
							  {
								z = x.nextSibling
								y.appendChild(x)
								x = z
							  }catch(err){
								//alert("1")
							  }
						
						
					}
					
					w= document.getElementById('DragMemo-'+Att).getElementsByTagName("div")[0]
					
					while (w){
						try
							  {
								j = w.nextSibling
								parent_obj_rif.appendChild(w)
								w = j
							  }catch(err){
								//alert("2")
							  }
						
						
					}
				}else{
					m= document.getElementById('DragMemo-'+Att).getElementsByTagName("div")[0]
					x.appendChild(m)
					x.appendChild(pos_IT)
				}
				
				//alert(pos_drag);
				var control = pos_drag.split("-");
				if(control[1]=="IT"){
					document.getElementById(pos_drag).style.backgroundColor = "#ff6600";
					document.getElementById(pos_drag).style.border = "2px solid #ff6600";
				}else{
					/*document.getElementById(pos_drag).style.backgroundColor = "#cccccc";
					document.getElementById(pos_drag).style.border = "2px solid #CCCCCC";*/
					document.getElementById(pos_drag).style.backgroundColor = "#CBFAFE";
					document.getElementById(pos_drag).style.border = "2px solid #CBFAFE";
				}
			}else{
				
				document.getElementById("ConDragInner-"+obj_drag_sel).style.visibility = "";
				document.getElementById("Drag-"+obj_drag_sel).style.display = "";
				document.getElementById("druggers-"+Att_ried).style.visibility = "hidden";
			}
			
		}
		
		
	
		set_Drag = false;
}

function thisDrop(Att,id){
	//alert(Att)

	if(Att!=null&&id!=null){
		
		if(set_Drag){
			if(Att == id){
			document.getElementById(id).style.backgroundColor = "#FF6600";
			document.getElementById(id).style.border = "2px solid #FF6600";
			}else{
			/*document.getElementById(id).style.backgroundColor = "#cccccc";
			document.getElementById(id).style.border = "2px solid #CCCCCC";*/
			document.getElementById(id).style.backgroundColor = "#CBFAFE";
			document.getElementById(id).style.border = "2px solid #CBFAFE";
			}
			pos_drag = id
		}
		pos_drag = id
	}else{
		pos_drag = null
	}
	
	//alert(pos_drag)
}
	
function outDrop(Att,id){
	
	if(Att == id){
		document.getElementById(id).style.backgroundColor = "#FF6600";
		document.getElementById(id).style.border = "0px";
	}else{
		document.getElementById(id).style.backgroundColor = "#cccccc";
		document.getElementById(id).style.border = "0px";
	}
}

function testSotmenu(obj){
	
	var pos_set_test =obj.split("-");
	var Att = pos_set_test[2]+"-"+pos_set_test[3];
	
	var obj_rel = document.getElementById(obj); 
	var obj_drg_distin = document.getElementById('druggers-'+Att).getElementsByTagName("ul");
	
	aa = 0
	aaa = 0
	returning = true
	
	while (obj_rel){	
		try{
			if(obj_rel.tagName=="UL" && obj_rel.id.split("-")[0]== "cat"){aa++;}
			obj_rel = obj_rel.parentNode;
		}catch(err){}
	}; 
	
	if(obj_drg_distin.length > 0){
		
		var set_aaa = 0
		var memo_aaa = 0
		for(i=0; i<obj_drg_distin.length; i++){
			obj_seyt = obj_drg_distin[i]
			while(obj_seyt){	
				try{
					if(obj_seyt.tagName=="UL" && obj_seyt.id.split("-")[0]== "cat"){set_aaa++;}
					obj_seyt = obj_seyt.parentNode;
				}catch(err){}
			};
			if(set_aaa>=memo_aaa){
				aaa = set_aaa	
			}
			set_aaa = 0;
		}
		
	}
	
	a = aa+aaa
	if(a>=sotmenumax){
		
		var error_str = 'Siamo spiacenti ma il limite di sottocategorie &eacute; fissato ad un numero di '+sotmenumax+' unit&aacute;.'
		SVopenWin('include_App/varie/error_str.asp?erro='+error_str,320,205,false,true);
		
		returning = false
		
	}
	
	return returning
}



	
	
function XY(e){
	
	if (!e) e = window.event;
	if (e)
	{
			isIE = document.all;
			tempX = isIE ? (e.clientX+4) : e.clientX;
			tempY = isIE ? (e.clientY+4) : e.clientY;
		if(set_Drag){
			document.getElementById("druggers-"+Att_ried).style.left=tempX+"px";
			document.getElementById("druggers-"+Att_ried).style.top=tempY+"px";
		}
	}
}

function addCat(id){
	x.appendChild(pos_IT)
}





function MenuSave(id){
	
	
	document.getElementById("gost_menu").removeAttribute("style");
	document.getElementById("xxx_gost_menu").style.display="block"
	
	var obj_IT_LI = document.getElementById(id);
	
	
	var obj_Save_LI = obj_IT_LI.getElementsByTagName("li");
	
	for(var i=0; i<obj_Save_LI.length; i++){
		obj_Save_LI[i].parentNode.parentNode.replaceNode(obj_Save_LI[i],obj_Save_LI[i].parentNode.parentNode);
		
	}
	
	var obj_Del_div = obj_IT_LI.getElementsByTagName("div")
	var num_div = obj_Del_div.length;
	
	for(var o=(num_div-1); o>=0; o--){
		if(obj_Del_div[o].className=="spacerCat"){
			obj_Del_div[o].parentNode.removeChild(obj_Del_div[o]);
		}
	}

	//var obj_ggg = document.getElementById("Drag-"+id).innerHTML
	var obj_Save_LI = obj_IT_LI.getElementsByTagName("li")
	var obj_Del_div = obj_IT_LI.getElementsByTagName("div")
	
	
	//var obj_ggg = getXHTML(trim_SV(document.getElementById("Drag-"+id).innerHTML));
	var obj_ggg = document.getElementById("Drag-"+id).innerHTML;
	
	//var obj_ggg = document.getElementById("Drag-"+id).innerHTML;

	document.getElementById("newMemo").innerHTML= "";
	document.getElementById("newMemo").innerHTML = obj_ggg

	for(var o=0; o<obj_Save_LI.length; o++){
		this_node = document.getElementById("newMemo").getElementsByTagName("li")[o].getElementsByTagName("a")[0]
		
		var href_thisNode = this_node.name;
		
		while (href_thisNode.search("_")>-1){
			  href_thisNode = href_thisNode.replace("_","/")  
		}
	
		newNODE = document.createElement("vs")
		newNODE.innerHTML = href_thisNode;
		this_node.replaceNode(newNODE,this_node)
		//alert(document.getElementById("newMemo").innerHTML)
	}
	
	
	obj_ggg = getXHTML(trim_SV(document.getElementById("newMemo").innerHTML));
	//obj_ggg = document.getElementById("newMemo").innerHTML;
	

	var id_arr = id.split("-")
	var url_id_arr = id_arr[1];
	//alert(url_id_arr)
	while (url_id_arr.indexOf("_")>-1){
		url_id_arr = url_id_arr.replace("_","/")
	}
	//alert(url_id_arr)

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		//alert ("il tuo browser non supporta ajax!");
		var error_str = "Il tuo browser non supporta ajax!"
		SVopenWin_lvl2('include_App/varie/error_str.asp?erro='+error_str,320,205,false,true);
		return;
	} 
	  
	var url_menu='include_App/Administrator/menu_edit.asp';
	var parameters_menu = obj_ggg+'<url>vs_'+url_id_arr 
	
	xmlHttp.open('POST', url_menu, true);
	xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	xmlHttp.setRequestHeader("Content-length", parameters_menu.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(parameters_menu);

	//alert(ggg)
	document.getElementById("newMemo").innerHTML = "";
	
	
	MenuClose(id,true);
	
}


document.oncontextmenu=new Function("return false");
function menufile(div_name,obj_now,e) {

  if(!e) e=window.event;

  var vDoc=(document.documentElement && document.documentElement.scrollTop)?document.documentElement:document.body;

  var mouseX=window.event.clientX-12;
  var mouseY=window.event.clientY-12;

  
  if (navigator.appName == 'Microsoft Internet Explorer' && event.button==2 && cntr_eve){
		
		
		if(obj_now.indexOf("xx")<0){
			
			cntr_eve = false;		
			
			document.getElementById("menufile_div").style.display = "";
			document.getElementById("menufile_div").style.left = mouseX;
			document.getElementById("menufile_div").style.top = mouseY;
			//document.getElementById("menufile_div").attachEvent("onmouseout",closediv("menufile_div"))
			
			
			
			var htmlinner = '<div style="width:100%;top:0px; height:5px; float:left" onmouseover="closediv(\&quot;'+obj_now+'\&quot;)"></div>';
			
			htmlinner +=    '<div style="width:80px">'
			//htmlinner += 	'<div style="border:1px solid red;width:5px;height:20px;float:left" onmouseover="closediv(\&quot;'+obj_now+'\&quot;)"></div>';
			htmlinner +=	'<div style="float:left;height:20px; width:60px;">' ;
			htmlinner += 		'<table style="float:left;width:100%;"><tr><td><div style="width:5px;height:20px;float:left;left:0px;" onmouseover="closediv(\&quot;'+obj_now+'\&quot;)"></div></td><td><span onclick="rename_bot(\''+obj_now+'\')" style="cursor:pointer">Rinomina</span></td><td><div style="width:5px;height:20px; float:right; " onmouseover="closediv(\&quot;'+obj_now+'\&quot;)"></div></td></tr></table><br/>';
			htmlinner += 	'</div>'
		//	htmlinner += 	'<div style="border:1px solid green;width:5px;height:20px; float:right; " onmouseover="closediv(\&quot;'+obj_now+'\&quot;)"></div>';
			htmlinner +=	'</div>'
			
			//htmlinner += 	'<div style="width:5px;height:20px;float:left" onmouseover="closediv(\&quot;'+obj_now+'\&quot;)"></div>';
			htmlinner +=	'<div style="float:left;height:20px; width:110">' ;
			htmlinner += 	  	'<table style="float:left;width:100%;"><tr><td><div style="width:5px;height:20px;float:left" onmouseover="closediv(\&quot;'+obj_now+'\&quot;)"></div></td><td><span onclick="cancella_bot(\''+div_name+'\')" style="cursor:pointer">Cancella</span></td><td><div style="width:5px;height:20px; float:left " onmouseover="closediv(\&quot;'+obj_now+'\&quot;)"></div></td></tr></table><br/>';
			htmlinner += 	'</div>'
			//htmlinner += 	'<div style="width:5px;height:20px; float:left " onmouseover="closediv(\&quot;'+obj_now+'\&quot;)"></div>';
			
			htmlinner +=	'<div style="width:60px; height:5px; float:left" onmouseover="closediv(\&quot;'+obj_now+'\&quot;)"></div>';
			document.getElementById("menufile_div").innerHTML = htmlinner;
			
			var obj_now = document.getElementById(obj_now);  
			while (obj_now){	
				try{
					if(obj_now.tagName=="UL" && obj_now.id.split("-")[0] != ""){
						obj_now.style.visibility = "visible";
						obj_now.style.display = "block";
						//obj_now.style.position = "absolute";
					}
					obj_now = obj_now.parentNode;
				}catch(err){}
			};
  		
		}else if(obj_now.indexOf("xxx")<0){
		
			cntr_eve = false;		
			
			document.getElementById("menufile_div").style.display = "";
			document.getElementById("menufile_div").style.left = mouseX;
			document.getElementById("menufile_div").style.top = mouseY;
			
			
			
			var htmlinner = '<div style="width:60px; height:5px; float:left" onmouseover="closediv(\&quot;'+obj_now+'\&quot;)"></div>';
			
			htmlinner += 	'<div style="width:5px;height:20px;float:left" onmouseover="closediv(\&quot;'+obj_now+'\&quot;)"></div>';
			htmlinner +=	'<div style="float:left;height:20px; width:60px">' ;
			htmlinner += 		'<span onclick="rename_bot(\''+obj_now+'\')" style="cursor:pointer">Rinomina</span><br/>';
			htmlinner += 	'</div>'
			htmlinner += 	'<div style="width:5px;height:20px; float:left " onmouseover="closediv(\&quot;'+obj_now+'\&quot;)"></div>';
			
			htmlinner +=	'<div style="width:60px; height:5px; float:left" onmouseover="closediv(\&quot;'+obj_now+'\&quot;)"></div>';
			document.getElementById("menufile_div").innerHTML = htmlinner;
			
			var obj_now = document.getElementById(obj_now);  
			while (obj_now){	
				try{
					if(obj_now.tagName=="UL" && obj_now.id.split("-")[0] != ""){
						obj_now.style.visibility = "visible";
						obj_now.style.display = "block";
						obj_now.style.position = "absolute";
					}
					obj_now = obj_now.parentNode;
				}catch(err){}
			};	
		}	
   }
   return false;
   event.button = null;
}

function closediv(id){
	
	if(fine_pss){
		var obj_now = document.getElementById(id);  
		
		//obj_now.style.visibility = "hidden";
		//obj_now.style.display = "none";
		while (obj_now){
			//alert(obj_now.tagName+" - "+obj_now.id)
			//alert(obj_now.id.split("-")[0])
			try{
				
				if(obj_now.tagName=="UL" && obj_now.id.split("-")[0] != "" && obj_now.id.split("-")[0] != "gost_menu"){
					//alert("OK")
					obj_now.style.visibility = "";
					obj_now.style.display = "";
					obj_now.style.position = "";
				}
				obj_now = obj_now.parentNode;
			}catch(err){}
		};
		
		document.getElementById("menufile_div").style.display = "none";
		cntr_eve = true;
	}
}

var obj_now; 
var obj_link;

var memo_nambot;
var memo_contbot;
var memo_attlink;

function rename_bot(obj){
	presetobj = obj
	fine_pss = false;
	
	document.getElementById("menufile_div").style.display = "none";
	
	obj_now = document.getElementById(obj); 
	obj_link = obj_now.getElementsByTagName("a")[0];
	
	memo_nambot = obj_link.innerHTML
	memo_contbot = obj_now.innerHTML
	memo_attlink = obj_link.href
	
	SVopenWin('include_App/mod_screen/html/renamebot.asp?obj='+obj+'&nomebot='+memo_nambot,300,200,false,false);
	
	//obj_link.href = 'javascript:document.getElementById(\&quot;nomeboto\&quot;).focus();';
	//obj_link.innerHTML =  '<input onblur="close_rename_bot(\&quot;'+obj+'\&quot;,true)" onclick="this.focus();this.select()" style="margin-left:25px; width:100px" type="text" value="'+memo_nambot+'" id="nomeboto" />';	
}

function mod_menu_link(obj,txt){
		var obj_sel = document.getElementById(obj)
		var obj_link = obj_sel.getElementsByTagName("a")[0];
		var obj_url = obj_sel.getElementsByTagName("a")[0].name;
		while(obj_url.indexOf("_")>-1){
			obj_url = obj_url.replace("_","/")	
		}
		var url_go = url_p;
		url_go = url_go.split("-");
		//alert(obj_url)
		if(obj_url.indexOf("/")>0){
			url_go = "VS_"+obj_url;
		}else{
			url_go = "VS_"+url_go[1]+obj_url;
		}
		//alert(url_go)
		////////////////////////////////////////////////////////////////////////////////////////////////
		
		
		var ajax_text
		var memo_moment = document.getElementById("newMemo");
		
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		  {
		  //alert ("il tuo browser non supporta ajax!");
		  var error_str = "Il tuo browser non supporta ajax!"
		  parent.parent.SVopenWin_lvl2('include_App/varie/error_str.asp?erro='+error_str,320,205,false,true);
		  return;
		  } 
		  
		/*
		 
		xmlHttp.open("GET",url,true);
		
		xmlHttp.onreadystatechange=function()
		{
			if(xmlHttp.readyState==4){
				
				
				ajax_text = String(xmlHttp.responseText);
				ajax_text = letturaLink(ajax_text,txt);
				
			}
		}
		*/
		var url=url_go; 
		ajax_text = obj_link.cloneNode(true);
		var memo_moment = document.getElementById("newMemo");
		memo_moment.appendChild(ajax_text) ;
		ajax_text = memo_moment.innerHTML;
		ajax_text = getXHTML(trim_SV(ajax_text));
		
		var parameters_menu = ajax_text+"<url>"+url;	
		//alert(ajax_text)
		
		xmlHttp.open('POST','include_App/Administrator/menu_edit.asp', true);
		xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlHttp.setRequestHeader("Content-length", parameters_menu.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(parameters_menu);
		
		memo_moment.innerHTML = ""
		//////////////////////////////////////////////////////////////////////////////////////////////////	
}
/*
function letturaLink(ajax_text,txt){
	var memo_moment = document.getElementById("newMemo");
	memo_moment.innerHTML = ajax_text ;
	memo_moment.getElementsByTagName("a")[0].innerHTML = txt;
	ajax_text = memo_moment.innerHTML;
	ajax_text = getXHTML(trim_SV(ajax_text));
	return ajax_text
}
*/

function close_rename_bot(obj,nambot,set){
	if(set){
		document.getElementById(obj).getElementsByTagName("a")[0].innerHTML= nambot;
		mod_menu_link(obj,nambot)
		
	}
	fine_pss = true;
	cntr_eve = true;
	closediv(obj)
	presetobj = "";
}

function cancella_bot(obj){
		x = document.getElementById(obj);
		closediv(obj)
		y = document.getElementById(obj).parentNode;
		y.removeChild(x)
		cntr_eve = true;
		
}

function generate_Element(url_set,nome_set,typ_set){
	
	

	var str_insert = ""
	var str_now
	var con_li = 0
	var con_ul = 0
	
	var temp_li = 0
	var memo_li = 0
	var temp_ul = 0
	var memo_ul = 0
	
	
	target_menu = document.getElementById(menu_id_set)
	target_menu_li = target_menu.getElementsByTagName("li")
	target_menu_ul = target_menu.getElementsByTagName("ul")
	
	for(i=0; i<target_menu_li.length; i++){
			elem_li_now = target_menu_li[i]
			if (elem_li_now.id.indexOf("arg")>-1){
				temp_li = elem_li_now.id.split("-")[1]
				//alert(temp_li)
				if(Number(temp_li)>Number(memo_li)){
					memo_li = temp_li
				}
			}
	}
	memo_li++
	
	for(i=0; i<target_menu_ul.length; i++){
			elem_ul_now = target_menu_ul[i]
			if (elem_ul_now.id.indexOf("cat")>-1){
				temp_ul = elem_ul_now.id.split("-")[1]
				//alert(temp_li)
				if(Number(temp_ul)>Number(memo_ul)){
					memo_ul = temp_ul
				}
			}
	}
	memo_ul++
	
	get_ghost = document.getElementById("xxx_gost_menu")
	//GENERAZIONE CATEGORIA
	if(typ_set){
		
		//str_insert = '<li id="arg-14" unselectable="on">'+nome_set+'<vs>'+url_se+'</vs><ul id="cat-6"></ul></li>'
		
		str_html = '<li id="arg-'+memo_li+'" >'
		if(url_set=='false'){
			
				xmlHttp_CAT=GetXmlHttpObject();
				if (xmlHttp_CAT==null){
				  //alert ("il tuo browser non supporta ajax!");
				  var error_str = "Il tuo browser non supporta ajax!"
				  SVopenWin_lvl2('include_App/varie/error_str.asp?erro='+error_str,320,205,false,true);
				  return;
				} 
				
				parameters = nome_set

				var url_s='include_App/administrator/newcat.asp';
				
				xmlHttp_CAT.open('POST', url_s, true);
				xmlHttp_CAT.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
				xmlHttp_CAT.setRequestHeader("Content-length", parameters.length);
				xmlHttp_CAT.setRequestHeader("Connection", "close");
			
				xmlHttp_CAT.onreadystatechange=function()
				{
					if(xmlHttp_CAT.readyState==4){
						
						url_set = String(xmlHttp_CAT.responseText);
						
						//alert("url_set: "+url_set)
						
						
						str_html += '<a href="javascript: var varvuota" name="'+url_set+'" >'+nome_set+'</a>'
						str_html += '<ul id="cat-'+memo_ul+'" onmouseover="showmenu()" onmouseout="hiddenmenu()"></ul></li>'
						get_ghost.innerHTML += str_html
						//alert("str_html: "+str_html)
						//alert("html ghost: "+get_ghost.innerHTML)
						
						MenuOpen(menu_id_set)
						MenuSave(menu_id_set)
						MenuClose(menu_id_set,true)
					
					}
				}
				xmlHttp_CAT.send(parameters);
				
			
			
		}else{
			
			str_html += '<a href="index_start.asp?url_p='+url_set+'-IT" name="_'+url_set+'_menu.html" >&nbsp;&nbsp;'+nome_set+'</a>'
			str_html += '<ul id="cat-'+memo_ul+'"></ul></li>'
			get_ghost.innerHTML += str_html
			
			MenuOpen(menu_id_set)
			MenuSave(menu_id_set)
			MenuClose(menu_id_set,true)	
			
		}
		
	
	//GENERAZIONE ARGOMENTO
	}else{
		
		str_html = '<li id="arg-'+memo_li+'"><a href="index_start.asp?url_p='+url_set+'-IT" name="_'+url_set+'_menu.html" >&nbsp;&nbsp;'+nome_set+'</a></li>'
	
		get_ghost.innerHTML += str_html
		
		MenuOpen(menu_id_set)
		MenuSave(menu_id_set)
		MenuClose(menu_id_set,true)	
	
	}
	
}
