var Att_memo
var id_url
var url_temp
var backup_Att
var Att_mod_fotog
var Att_del_global

var highest = 0

function FotoOpen(Att){
	
	//menufile('"&foldering&"','')
	Att_mod_fotog = Att
	
	id_url =""
	id_url = Att.split("-")[1]
	Att_del_global = Att
	var llen =  document.getElementById("Foto-"+Att).getElementsByTagName("div")	
	url_temp = id_url

	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')"
	
	while(url_temp.indexOf("_")>-1){
		url_temp = url_temp.replace("_","/")
	}
	backup_Att = Att
	//alert(Att)
	//document.getElementById("Foto_skin").src = "VS_SKIN/foto.vs/"+id_url+"/foto.html";
	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("FotoCmd-"+Att).className = "menumod_comand_open";
		//addStr = '<ul><li><a unselectable="on" href="#" >Aggiungi</a></li></ul>';
		addStr = "";
		//addStr += '<ul><li><a href="javascript:editfoto(\&quot;\&quot;,\&quot;'+Att+'\&quot;,false)" >+ Foto Veloce</a></li></ul>';
		addStr += '<ul><li><a href="javascript:editfoto(\&quot;\&quot;,\&quot;'+Att+'\&quot;,true)" >+ Foto</a></li></ul>';
		//addStr += '<ul><li><a href="javascript:insertFotoNew(\&quot;\&quot;,\&quot;'+Att+'\&quot;,\&quot;\&quot;)" >+ es insert</a></li></ul>';
		addStr += '<ul><li><a unselectable="on" href="javascript:FotoSave(\&quot;'+Att+'\&quot;)" >Salva</a></li></ul>';
		addStr += '<ul><li><a href="javascript:FotoClose(\&quot;'+Att+'\&quot;,false)" >Annulla</a></li></ul>';
		
		document.getElementById("FotoCmd-"+Att).innerHTML = addStr
		
		memo_dati = document.getElementById("Foto-"+Att).getElementsByTagName("div")[0].cloneNode(true)
		set_open_close = Att
		
		var Att_d = ""
		Att_memo = Att
		
		//alert(Att_memo)
		
		_FotoSet_LI(Att);
	}
	
	
	milkbox.initialize()
	
}


function FotoClose(Att,save){
	
	set_open_close = "";
	
	document.getElementById("MenuCont-"+Att).className = "menumod";
	document.getElementById("FotoCmd-"+Att).className = "menumod_comand";
	document.getElementById("FotoCmd-"+Att).innerHTML = '<ul><li><a unselectable="on" href="javascript:FotoOpen(\&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){
		document.getElementById("Foto-"+Att).innerHTML = "";
		document.getElementById("Foto-"+Att).appendChild(memo_dati);
		alert(document.getElementById("Foto-"+Att).innerHTML)
		//milkbox.initialize();

	}else{
		milkbox.initialize();	
	}
	
}

var imgs
var storeit
var miniID

function Foto_Change(Att_mod){
	imgs = document.getElementById("Foto-"+Att_mod).getElementsByTagName("img")
	storeit = document.getElementById("Foto-"+Att_mod).getElementsByTagName("div")
	
	Att_mod = Att_mod.split("-")
	
	var att_tempp = Att_mod[1]

	var start = Att_mod[1].indexOf("fotogallery_")+12
	var end = Att_mod[1].indexOf("#")
	
	Att_mod[1] = Att_mod[1].substring(start,end)
	
	miniID = att_tempp+"-"+Att_mod[1]+"#"
	//alert(miniID)
	//alert(document.getElementById(miniID+(1)).id)

	var i_prima = 0
	var i_finale = 0
	var tempid
	

	for(i=0;i<storeit.length;i++){
		
		if(storeit[i].className == "div_foto"){
			
			tempid = storeit[i].id
			var start = tempid.lastIndexOf("#")
			tempid=Number(tempid.substr(start+1))
			if(highest<tempid){highest = tempid}
			
		}		
			
	}
	
	highest = miniID+(highest+1)
	
	while(highest.indexOf("#")>-1){
		
		highest = highest.replace("#","$")
	}
	
	//alert("addFoto")
	//SVopenWin('include_App/mod_screen/html/fotogallery.asp?highest='+highest,500,20,false,true);
	SVopenWin('include_App/visivamod/html/insert_image.asp?url_pag='+url_pag+'&idd=true&highest='+highest,500,200,true,true);
}
	
	
function fotofile(id,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){
		
		document.getElementById("fotofile_div").style.display = "";
		document.getElementById("fotofile_div").style.left = mouseX;
		document.getElementById("fotofile_div").style.top = mouseY;

		var htmlinner = ""
		//htmlinner += '<a style="color:#000;text-decoration:none;" href="javascript:editfoto(\&quot;'+id+'\&quot;,\&quot;\&quot;,false)">Modifica veloce</a><br/>'
		htmlinner += '<a style="color:#000;text-decoration:none;" href="javascript:editfoto(\&quot;'+id+'\&quot;,\&quot;\&quot;,true)">Modifica</a><br/>'
		htmlinner += '<a style="color:#000;text-decoration:none;" href="javascript:deletefoto(\&quot;'+id+'\&quot;)">Cancella</a>'
		document.getElementById("fotofile_div").innerHTML = htmlinner;
		
	   
	   
	   }
}

function deletefoto(id){

	box = document.getElementById("Foto-"+id)
	box.parentNode.removeChild(box);

	
}

function editfoto(idd,iid,type_in){
	//var idd2 = idd
	//idd = idd.substring(idd.lastIndexOf("#")+1)
	var divFoto = document.getElementById(backup_Att)
	
	var divFotoNow = divFoto.getElementsByTagName("div")
	
	//alert(miniID)
	//alert(document.getElementById(miniID+(1)).id)

	var i_prima = 0
	var i_finale = 0
	var tempid
	

	for(i=0;i<divFotoNow.length;i++){
		
		if(divFotoNow[i].className == "div_foto"){
			
			tempid = divFotoNow[i].id
			var start = tempid.lastIndexOf("#")
			tempid=Number(tempid.substr(start+1))
			if(highest<tempid){highest = tempid}
			
		}		
			
	}
	
	
	//idd2 = idd2.split("_")[1]
	if(idd ==""){
		idd = "true";
	}else{
		while(idd.indexOf("#")>0){
			idd = idd.replace("#","$")
		}
	}
	
	if(idd ==""){
		iid = "";
	}else{
		while(iid.indexOf("#")>0){
			iid = iid.replace("#","$")
		}
	}
	//alert(document.getElementById(idd).innerHTML)
	//SVopenWin('include_App/mod_screen/html/foto_text_edit.asp?url_pag='+url_pag+'&idd='+idd+'&idd2='+idd2,500,200,false,true);
	if(type_in){
		SVopenWin('include_App/visivamod/html/insert_image.asp?idd='+idd+'&highest='+highest+'&iid='+iid+"&urlp="+url_p,500,200,true,true);
	}else{
		SVopenWin('include_App/mod_screen/html/photoeditspped.asp?idd='+idd+'&highest='+highest+'&iid='+iid+"&urlp="+url_p,500,200,false,true);
	}
}


function clear_fotofile(){
	document.getElementById("fotofile_div").style.display = "none";
	document.getElementById("fotofile_div").style.left = 0;
	document.getElementById("fotofile_div").style.top = 0;
}

function insertFotoNew(foto_str,iid,obj_now){
	
	document.getElementById(iid).innerHTML += getXHTML(trim_SV(foto_str))
	var obj_now_foto = document.getElementById(obj_now);
	
	createNewFoto(obj_now_foto);
	milkbox.initialize();
}

function createNewFoto(LI_obj_now){
	
	CloneNode_LI = LI_obj_now.cloneNode(true);
	var id = LI_obj_now.id
	
	var LI_Clo_Dest = document.getElementById('FotoMemo-'+Att_memo)						//alert(CloneNode_LI.id)
												
	var str_newcreate = '';
	str_newcreate +='<div style=""border:5px solid #f00"" onmousedown="fotofile(\&quot;'+id+'\&quot;)" unselectable="on" class="drugf" id="Foto-'+id+'" >';
	
	str_newcreate +='<div class="DragCont"  unselectable="on" id="ConDragInner-'+id+'" ></div>';
	
	str_newcreate +='<div style="width:30px;background-color:#ffffff" unselectable="on" class="foto_spacer_sx" id="spacer_sx-U-'+id+'" onmouseover="FotothisDrop(\&quot;'+id+'\&quot;,this.id)" onmouseout="FotooutDrop(\&quot;'+id+'\&quot;,this.id)"></div>'
	
	
	str_newcreate +='<div style="width:30px;background-color:#ffffff"  unselectable="on" class="foto_spacer_dx" id="spacer_dx-D-'+id+'" onmouseover="FotothisDrop(\&quot;'+id+'d\&quot;,this.id)" onmouseout="FotooutDrop(\&quot;'+id+'\&quot;,this.id)"></div>';

	str_newcreate +='<div class="movDrag_f" id="movDrag"  unselectable="on"  onmousedown="FotoDragDrop(\&quot;'+id+'\&quot;)"></div>'
	str_newcreate +='</div>';
	
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////

	LI_Clo_Dest.innerHTML = ""
	LI_Clo_Dest.innerHTML = str_newcreate;
	document.getElementById("ConDragInner-"+id).appendChild(CloneNode_LI)
	
	LI_Clo_Dest.getElementsByTagName("div")[0].setAttribute("unselectable","on")
	
	CloneTransfert_LI = LI_Clo_Dest.getElementsByTagName("div")[0]		
	LI_obj_now.replaceNode(CloneTransfert_LI,LI_obj_now)

}

function _FotoSet_LI(Att){
	
		 
	var exit_LI;
	//var Obj_sel = document.getElementById("foto_contain");
	var Obj_sel = document.getElementById("Foto-"+Att);
	//alert(Obj_sel.innerHTML)
	
	
	var Foto_LI_sel = Obj_sel.getElementsByTagName("div")
	Foto_Att = Att.split("-")[1]
	//alert(Foto_Att)
	
	
	//alert("___"+Att)
	
		for(var i=0; i<Foto_LI_sel.length; i++){
			var Foto_LI_att = Foto_LI_sel[i].getAttribute("id")
			//alert(Foto_LI_att)
			////////////////////////////asdasdasdasdasdasd////////////////////////////////////////////////////////////
				Foto_LI_att = Foto_LI_att.split("-")[0]
			//alert(Foto_LI_att)
					var foto_id=Foto_LI_sel[i].parentNode.id.split("-")[0]
					if ((Foto_LI_att == Foto_Att) && !(foto_id == "ConDragInner") ){
						
						//alert(Foto_LI_att)
						var LI_obj_now = Foto_LI_sel[i];
						//alert(LI_obj_now)
						createNewFoto(LI_obj_now)
						
						
						
					}
	}
	
}

function FotoDragDrop(Att){
	
	//ATT = OGGETTO CHE STO DRAGGANDO
	//ATT_D = OGGETTO GRANDE
	//Att_ried = Att.split("-")[0]+"-"+Att.split("-")[1]
	Att_ried = backup_Att
	Att_memo = Att
	Att_d = backup_Att	
	//alert(Att_ried+"/////"+Att_d+"/////"+Att)
	//Att_d = Att
	//
	
	FotostartDrag(Att_ried)
	
	document.getElementById("f_druggers-"+Att_d).innerHTML =	""
	LI_obj_Clo_Now = document.getElementById("Foto-"+Att)
	LI_Clo_Drag = LI_obj_Clo_Now.cloneNode(true);
	document.getElementById("f_druggers-"+Att_d).appendChild(LI_Clo_Drag);
	document.getElementById("ConDragInner-"+Att).style.visibility = "hidden";
	document.getElementById("Foto-"+Att).style.display = "none";
	document.getElementById("f_druggers-"+Att_d).style.visibility = "visible";
	document.getElementById("f_druggers-"+Att_d).style.unselectable = "on";
	
}
var ss = ""
function FotostartDrag(id){
	
	//id = id.split("-")[1]
	//alert(id)
	//alert(document.getElementById("f_druggers-"+backup_Att).innerHTML)
	ss = 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("f_druggers-"+id).style.left=tempX+"px";
		document.getElementById("f_druggers-"+id).style.top=tempY+"px";
	}
	document.onmousemove = fXY;
	
}

function FotostopDrag(){
	
		

		if(set_Drag){
			//alert(document.getElementById("f_druggers-"+Att_d).innerHTML)
			var obj_drag = document.getElementById("f_druggers-"+Att_d).getElementsByTagName("div")[0].getAttribute("id")
			//id ogg che sto draggando
			var obj_drag_ary = obj_drag.split("-");
			//array id spezzettato
			var obj_drag_sel = obj_drag_ary[1]+"-"+obj_drag_ary[2]
			//alert(obj_drag_sel)
			//foto-fotot00....cont-html-8 (contenitore che sto draggando)
			var obj_drag_cont = obj_drag_ary[1]+"-"+obj_drag_ary[2]//+"-"+obj_drag_ary[3]
			//alert("obj_drag_cont"+obj_drag_cont)
			//alert(obj_drag_ary[3])
		//	alert('FotoMemo-'+obj_drag_cont)
			if(pos_drag){
				
				document.getElementById(pos_drag).style.backgroundColor = "#FFFFFF";
				document.getElementById(pos_drag).style.border = "3px solid #0CF";
				
				var pos_drag_ary = pos_drag.split("-");
				var UorD = pos_drag_ary[1];
				//alert("UorD"+UorD)
				
				var pos_drag_rif = pos_drag_ary[2]+"-"+pos_drag_ary[3]
				//  il pezzo di ID per quello ceh draggo (INUTILE , = obj_drag_sel )
				//alert(pos_drag_rif)				
				var Att = pos_drag_ary[2]+"-"+pos_drag_ary[3];
				//foto-foto00

				var obj_drag_sel_go = document.getElementById("Foto-"+obj_drag_sel)
			//	alert(obj_drag_sel_go.id)
				//alert("Foto-"+pos_drag_rif)
				//contenitore grande in cui appendchild alla fine
				
				
				if(UorD=="U"||UorD=="D"){
				//alert("d--"+pos_drag_rif)
					var obj_drag_rif_go = document.getElementById("Foto-"+pos_drag_rif)
					//alert(obj_drag_rif_go.id)
					var parent_obj_rif = obj_drag_rif_go.parentNode;
				}
				
				var y = document.getElementById('FotoMemo-'+Att_d); //era DragMemo
				
				y.appendChild(obj_drag_sel_go);		
				
				
				//alert(y.innerHTML)
				//alert("fatto")
				document.getElementById("ConDragInner-"+obj_drag_sel).style.visibility = "visible"; 
				document.getElementById("Foto-"+obj_drag_sel).style.display = "block";
				document.getElementById("f_druggers-"+Att_d).style.visibility = "hidden";
				
				if(UorD == "U"){
					//alert(UorD)
					
						x = obj_drag_rif_go;
						//alert(x.innerHTML)
						// l oggetto dell area sensibile su cui sgancio										
				}else if(UorD == "D"){
					//alert(UorD)
						x = obj_drag_rif_go.nextSibling;
				}
				
				///////////////////////////////////////////////////
				
				if(UorD=="U"||UorD=="D"){
					//alert("subito prima while"+UorD)
					while (x){
						//alert("while")
						try
							  {
								z = x.nextSibling
								y.appendChild(x)
								x = z
							  }catch(err){
								//alert("1")
							  }
						
						
					}
					
					w= document.getElementById('FotoMemo-'+Att_d).getElementsByTagName("div")[0]
					
					while (w){
						//alert("w")
						try
							  {
								j = w.nextSibling
								parent_obj_rif.appendChild(w)
								w = j
							  }catch(err){
								//alert("2")
							  }
						
					
					}	
					
				}else{
					m= document.getElementById('FotoMemo-'+Att_d).getElementsByTagName("div")[0]
					//alert("penultimo else")
					x.appendChild(m)
					//x.appendChild(pos_IT)
					}
				
				//alert(pos_drag);
			}else{
				//alert("ultimo else")
				//document.getElementById("ConDragInner-"+obj_drag_sel).style.display = "";
				//alert(obj_drag_sel)
				document.getElementById("ConDragInner-"+obj_drag_sel).style.visibility = "visible";
				
				document.getElementById("Foto-"+obj_drag_sel).style.display = "block";
				//document.getElementById("Foto-"+obj_drag_sel).style.border="1px solid #0f0"
				document.getElementById("f_druggers-"+Att_d).style.visibility = "hidden";
			}
			
		}
	set_Drag = false;
}

function FotothisDrop(Att,id){
	
	

	if(Att!=null&&id!=null){
		
		if(set_Drag){
			if(Att == id){
				//alert()
			document.getElementById(id).style.backgroundColor = "#FF6600";
			document.getElementById(id).style.border = "3px solid #FF6600";
			}else{
				//alert("c")
			document.getElementById(id).style.backgroundColor = "#ff6600";
			document.getElementById(id).style.border = "3px solid #00ff00";
			}
			pos_drag = id
		}
		pos_drag = id
		//alert(id)
	}else{
		pos_drag = null
	}
	
	//alert(pos_drag)
}
	
function FotooutDrop(Att,id){
	
	if(Att == id){
		document.getElementById(id).style.backgroundColor = "#FFFFFF";
		document.getElementById(id).style.border = "3px solid #0CF";
	}else{
		document.getElementById(id).style.backgroundColor = "#FFFFFF";
		document.getElementById(id).style.border = "3px solid #0CF";
	}
}

	
	
function fXY(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("f_druggers-"+Att_d).style.left=tempX+"px";
			document.getElementById("f_druggers-"+Att_d).style.top=tempY+"px";
		}
	}
}


function addCat(id){
	x.appendChild(pos_IT)
}



var cont_gallery
var id_specifico

function FotoSave(id){
	
	
	
	id_specifico = id
	
	
	var ajax_text
	cont_gallery = document.getElementById("Foto-"+id);
		
	var url="VS_"+url_temp;
	
	//	alert(url)

	//AJAX///////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////
	
	xmlhttp=GetXmlHttpObject();
	  if (window.XMLHttpRequest) { // Mozilla, Safari,...
			http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {
				//http_request.overrideMimeType('text/xml');
				// See note below about this line
			}
		} else if (window.ActiveXObject) { // IE
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		  
	 http_request.open("GET",url,true);
	
	 http_request.onreadystatechange=function()
	{
		
		if( http_request.readyState == 4){
			
				ajax_text =  http_request.responseText		
				//alert(ajax_text)
				insert(ajax_text)
		}
	}
	
	http_request.send(null);

	//AJAX///////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////

	
	
}


function insert(a){

	// contenitore switch
	var cont_switch = document.getElementById("Foto_order");
	var cont_da_salv = document.getElementById("Foto_backup");
	
	// stringa vs
	var stringt = getXHTML(trim_SV(a))
	
	while(stringt.indexOf("<vs>")>-1){
			stringt = stringt.replace("<vs>","[vs]")
			stringt = stringt.replace("</vs>","[/vs]")
	}
	
	// contenitore stringa letta
	var cont_VS_save = document.getElementById("Foto_save")
	// inserimento stringa vs nel contenitore
	cont_VS_save.innerHTML = stringt	
	
	// div contenitore della fotogallery vs
	var Blen =  cont_VS_save.getElementsByTagName("div")[0]
	// elementi fotogallery vs
	var Blen_gal = Blen.getElementsByTagName("div")
	
	// div contenitore fotogallery effettiva
	var len = cont_gallery.getElementsByTagName("div")[0];
	// elemento fotogallery effettiva
	var len_gal = len.getElementsByTagName("div")
	
	
	var axs = 0;
	for(i=0;i<len_gal.length;i++){
		
		// ciclo for sul numero di foto in fotogallery effettiva
		if(len_gal[i].className == "div_foto"){
			saveDivClone = len_gal[i].cloneNode(true) ;
			cont_da_salv.appendChild(saveDivClone);
			// controllo se è un elemento foto della fotogallery
			var exist = true;
			for(a=0;a<Blen_gal.length;a++){
				// ciclo for sul numero di foto in fotogallery vs
				if(Blen_gal[a].id==len_gal[i].id){
					// caso in cui trova l'elemento e lo copia come swich
					cont_switch.appendChild(Blen_gal[a])
					exist = false;
				}
			}
			if(exist){
				// creazione parte dei <vs> per cont_switch
				// estrazione indirizzo per i vs
				var pre_set = len_gal[i].id.split("-")[0].replace("fotogallery_fotofo","")
				var endend = pre_set.indexOf("#")
				var cont_set = pre_set.substring(pre_set,endend);
				
				
				var id_clone = len_gal[i].id
				var elementCrate = len_gal[i].cloneNode(true);
				var serchDiv = elementCrate.getElementsByTagName("div")
				
				for(x=0; x<serchDiv.length; x++){
					
					if(serchDiv[x].id.indexOf(cont_set)>-1){
						var idElement = serchDiv[x].id
						newNODE = document.createElement("vs")
						
						while(idElement.indexOf("_")>-1){
							idElement = idElement.replace("_","/")
							idElement = idElement.replace("_","/")
						}
						if(idElement.indexOf("/")==0){
								//alert()
								idElement = idElement.replace(url_p.split("-")[0],"nome")
						}
						
						newNODE.innerHTML = idElement;
						//alert(newNODE.innerHTML)
						serchDiv[x].replaceNode(newNODE,serchDiv[x])
						
						var replce_set = elementCrate.innerHTML
						while(replce_set.indexOf("<vs>")>-1){
							replce_set =replce_set.replace("<vs>","[vs]")
							replce_set = replce_set.replace("</vs>","[/vs]")
						}
						elementCrate.innerHTML = replce_set
						x=0
						
						//alert("settings: \n"+elementCrate.innerHTML)
					}
				}
				
				cont_switch.appendChild(elementCrate)
				
			}
		
		}
	}
	
	Blen.innerHTML = ""
	Blen.innerHTML = cont_switch.innerHTML
	cont_switch.innerHTML = ""
	
	//SALVATAGGIO DELLA PAGINA CONTENENTE I VS
	xmlHttp_set=GetXmlHttpObject();
	if (xmlHttp_set==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;
	} 
	
	
	var url_s='Include_app/administrator/gallery_save_ajax.asp';

	var url_temp = Blen.id
	while(url_temp.indexOf("_")>-1){
		url_temp = url_temp.replace("_","/")	
	}
	url_temp = url_temp.replace("foto-","")
	
	var instr = cont_VS_save.innerHTML
	
	while(instr.indexOf("[vs]")>-1){
		instr = instr.replace("[vs]","<vs>")
		instr = instr.replace("[/vs]","</vs>")
	}
	
	var invio_VS_save = getXHTML(trim_SV(instr));
	var parameters = invio_VS_save+"<url>"+url_temp;
	
	//alert(cont_VS_save.innerHTML)
	//alert(url_temp)
	
	
	
	xmlHttp_set.open('POST', url_s, true);
	xmlHttp_set.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	xmlHttp_set.setRequestHeader("Content-length", parameters.length);
	xmlHttp_set.setRequestHeader("Connection", "close");
	xmlHttp_set.send(parameters);
	
	// PESCANDO DA cont_switch TENERE UNA VARIABILE TEMPORANEA CON I CONTENUTI POI FARE UNA CHIAMATA AJAX PER MODIFICARE IL TUTTO

	

	for (z=0; z<Blen_gal.length; z++){
		//alert(len_gal[z].id)
		var pre_set = Blen_gal[z].id.split("-")[0].replace("fotogallery_fotofo","")
		var endend = pre_set.indexOf("#")
		var cont_set = pre_set.substring(pre_set,endend);
		
		var nowId = Blen_gal[z].id
		
		var idURL_int = cont_gallery.document.getElementById(nowId)
		var idURLDiv  =  idURL_int.getElementsByTagName("div")
		
		for(y=0; y<idURLDiv.length; y++){
			
			if(idURLDiv[y].id.indexOf(cont_set)>-1){
				var URLElement = idURLDiv[y].id
				while(URLElement.indexOf("_")>-1){
					URLElement = URLElement.replace("_","/")
				}
				var cloneURLElement = idURLDiv[y].cloneNode(true)
				cont_switch.innerHTML = "";
				cont_switch.appendChild(cloneURLElement)
				if(URLElement != null){
					
					if(URLElement.indexOf("/")>0){
						URLElement = "VS_"+URLElement;
					}else{
						//alert(url_p)
						URLElement = "VS_"+url_p.split("-")[1]+URLElement;
					}
					//alert("A:"+URLElement)
					
					var contUrlElement = getXHTML(trim_SV(cont_switch.innerHTML))
					//alert("B:"+contUrlElement)
					
					xmlHttp_cont=GetXmlHttpObject();
					if (xmlHttp_cont==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;
					} 
					 
					var url_s='Include_app/administrator/editfile.asp';
					
					var parameters = contUrlElement+"<url>"+URLElement;
	
					xmlHttp_cont.open('POST', url_s, true);
					xmlHttp_cont.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
					xmlHttp_cont.setRequestHeader("Content-length", parameters.length);
					xmlHttp_cont.setRequestHeader("Connection", "close");
					xmlHttp_cont.send(parameters);
					
				}
			}
		}
	
	}
	/*
	for(i=0;i<len.length;i++){
		
		if(len[i].className == "div_foto"){
			len[i].id+="-TEMP"
		}
	}
	*/
	
	len.innerHTML = "";
	len.innerHTML = cont_da_salv.innerHTML;
	cont_da_salv.innerHTML = "";
	
	document.getElementById("Foto_order").innerHTML = "";
	document.getElementById("Foto_save").innerHTML = "";
	document.getElementById("FotoMemo-"+id_specifico).innerHTML=""
	//alert(document.getElementById("Foto-"+id_specifico).innerHTML)
	
	
	FotoClose(id_specifico,true);		
}

