var popon = 0;
var GLOPopup;

include(GLOPubblicatiComuni + '/Include_JS/NEWpopup.js');

var GLOenablepopon = 0;
var GLOattributiID = 0;
var GLOTipologieProgetto = "";
var BufferCreated = false;


try
{
  // se enablepopon = 1 allora abilito i JSPopup........
  var esiste = enablepopon;
  GLOenablepopon = enablepopon;
}
catch(e)
{
    GLOenablepopon = 0;  
}
finally
{  
}


//TODO
//Gestione delle traduzioni
//MODIFICHE
//V2
//2006-09-14 Aggiunto gestione parametro AutoRedrawToc per redraw (in sito.js e ColonnaDX_Mappa.asp)
//Variabili Globali 

try
{
  var esiste = GLOPubblicatiComuni;
}
catch(e)
{
    GLOPubblicatiComuni = '/PubblicatiComuni';  
}
finally
{
 
}



var strLayerAttiviGLO='';
var qualedb = ""; //stringa identificativa del db da passare !
var pubxml; 
var rispostaxml;
var xml;
var risultatodichiama;
var pubpathimmagini;
var guidSession='';
var tree1 = null;
var hostName=document.location.host;
var myMap1=null;
var gdManagerWS='http://' + document.location.host +  '/GDManagerWS/GDManagerFW.asmx/'; 
var waitLoading=true; //Indica che sto ancora caricando la pagina

var strCodaLayerCheck=''; //Mantiene una coda con l'elenco dei layer attivi nel formato idlayer,stato;

//se pieno questo si usa il wrapper !!!!!!!
//var gdManagerWrapper=GLOPubblicatiComuni + '/aspwrapper.asp'; 
//var gdManagerWrapper=''; 
//se pieno questo si usa il wrapper !!!!!!!

try
{
  var esiste = gdManagerWrapper;
}
catch(e)
{
    gdManagerWrapper = '';  
}
finally
{
  
}

//Gestione Layer e Tree
var ActiveLayerIndex=-1;
var ActiveLayerName='';
var ActiveLayerFeatureType='';
var ActiveLayerAttrib='';
var ActiveLayerTreeName='';
var ActiveLayerAnalisiIndex=-1;
var ActiveGroupIndex='';
var LayerName = new Array();
var LayerID = new Array();
var LayerVisible = new Array();
var LayerIsFeature = new Array();
var LayerMinScale = new Array();
var LayerMaxScale = new Array();
//Progetto Visualizzato
var NomeProgetto='';
var idProgetto='';
var idVista='';
//Estensione Mappa
var limitXmin=0;
var limitYmin=0;
var limitXmax=0;
var limitYmax=0;
//Estensione Overview
var ovlimitXmin=0;
var ovlimitYmin=0;
var ovlimitXmax=0;
var ovlimitYmax=0;

var mapXmin=0;
var mapXmax=0;
var mapYmin=0;
var mapYmax=0;

var last_mapXmin=0;
var last_mapXmax=0;
var last_mapYmin=0;
var last_mapYmax=0;
var arrBackZoom= new Array();

var bordoDxMappa=0;
var bordoTopMappa=0;
var mouseX=0;
var mouseY=0;
var LarghezzaMappa=0;
var AltezzaMappa=0;
var AutoRedrawToc=true; //Abilita il ridisegno automatico ad ogni cambio di un checkbox nell'albero della TOC
var mouseTool=''; //Indica che operazione sto compiendo col mouse : ZOOMIN,ZOOMOUT,DRAG,PAN
var lingua=1;
var parser;
var domDoc;
//Configurazione
LarghezzaMappa=400;
AltezzaMappa=400;
AutoRedrawToc=false;
var abilitaLog=false;
var elencoCampiIdNascosti=',FeatureID,OBJECTID,#ID#,IDXSHAPE,FID';
var OverviewDinamica=false; //Se true l'overview è caricata chiedendola al server come mappa, se false viene visualizzata l'img fornita da manager e salvata nella variabile OverviewImg
var OverviewImg='';
var gd_loading=GLOPubblicatiComuni + '/imgmappa/button_loading.gif';
var enableExport=true; //Abilita l'export attributi in CSV
var enableTooltip=true; //Abilita i tooltip
var enableTooltipContinui=false; //Abilita i tooltip per tutto il tempo della pagina senza gestire il bottone TOOLTIP
var enableTooltipBox=false; //Abilita i tooltip con box di selezione
var zoomMinimo=1000;

var hideAttrNames=''; //Nomi Attributi da nascondere dopo identify es. $FID$OBJECTID$

//Dimensione e posizione finestra degli attributi
var attrWinX=50; //Coordinata di visualizzazione
var attrWinY=50;
var attrWinDimX=300;
var attrWinDimY=300;
var attrWindowMode=2; //Può valere 1=div con parsing JS,2=div con richiamo a attrib.aspx


// Luca Gestione Array Viewpoints
var x_list_js = new Array();
var y_list_js = new Array();
var descrizione_list_js = new Array();	
var immagine_list_js = new Array();
var color_list_js = new Array();
var link_list_js = new Array();
var note_list_js = new Array();
var tipologia_list_js = new Array();
var TipoView_list_js = new Array();
var percorso_list_js = new Array();

var _drawPercorso = null;

//Variabili per la selezione
var IDFeatureSelezionata='';
var IDALLFeatureSelezionate='';
var CampoFeatureSelezionata='';
var globalXmlSelezione='';
var globalCoordinateSelezione='';
var globalCoordinateDisegno='';
var gloFormatoXmlLayer='R';
var gloUrlUltimaIdentify='';
var gloTipoUltimaIdentify='';
var gloDataMappa=''; //Data a cui richiedere il DrawProject

var gloBufferRaggio=0;
var gloBufferXCentro;
var gloBufferYCentro;
var gloBufferArrX=new Array();
var gloBufferArrY=new Array();

var gloXTooltip=0;
var gloYTooltip=0;
var gloXTooltip_last=0;
var gloYTooltip_last=0;
//Legenda
var strHtmlLegenda='';
var strLayerAttiviLegenda='';
var arrLayerAttiviLegenda;
var zoomAutomatico=false;   //Fa lo zoom automatico all'estensione delle feature selezionate
var zoomAutomaticoRicerca=false;   //Fa lo zoom automatico all'estensione delle feature selezionate trovate nella ricerca
var linkAutomatico=false;   //Se trova un solo risultato che contiene un link apre il link in automatico
var chiudiTabellaAttribSeEsisteLink=false;   //Se linkAutomatico=true e trovo un solo risultato nascondo la finestra degli attributi
var useAttribWindow=false; //Se vero usa una finestra esterna, altrimenti un iframe di nome "ifattr"
document.write('<script type="text/javascript" src="' + GLOPubblicatiComuni + '/include_JS/xmldom.js"></script>');
document.write ('<iframe src="' + GLOPubblicatiComuni + '/frameprototype.htm" id="protoframe" name="protoframe" style="width:1px;height:1px;position:absolute;top:-100px;left:-100px;"></iframe>');

//Icona per Punti Overlay
a = GLOPubblicatiComuni + '/images/tooltip/mm_20_red.png';
b = GLOPubblicatiComuni + '/images/tooltip/mm_20_shadow.png';
var  myIcon;  
//Disegno sulla mappa
//var drawLayer=null;
     
//Autenticazione Utente
var txtUtente='';
var txtPassword='';

  function initializePopup(){
  
       if (GLOenablepopon == 1)
	   {  
			GLOPopup = null;
			GLOPopup = new JPopup();  
       }
   }
   
  function nascondiPopup()
  {
		if (parent.GLOenablepopon == 1 && parent.popon == 1 && window.self.name == 'zyxabc')
		{ 
			parent.GLOPopup.hide();
			parent.popon = 0;
		}
		if (GLOenablepopon == 1 && popon == 1 && window.self.name != 'zyxabc')
		{  
			GLOPopup.hide();
			popon= 0;
		}
  }
   
   function goPopup()
   {
		if (parent.GLOenablepopon == 1 && popon == 0  && window.self.name == 'zyxabc')
		{  
			parent.GLOPopup.show(parent.GLOPubblicatiComuni + '/popup.htm',340,50,null,'Attendere Prego..');
			parent.popon = 1;
		}
		
		if (GLOenablepopon == 1 && popon == 0  && window.self.name != 'zyxabc')
		{  
			GLOPopup.show(GLOPubblicatiComuni + '/popup.htm',340,50,null,'Attendere Prego..');
			popon = 1;
		}
   }

//FUNZIONI GENERALI PER LA PAGINA 
//Gestione CSS
function settavisono(id,vis)
{
   //Modifica per gestione coda dei layer che sarà usata prima di aggiornare la mappa
   if (strCodaLayerCheck == '')
        strCodaLayerCheck+=id+','+vis;
    else
        strCodaLayerCheck+=';'+id+','+vis;
        
   /*
   var xmlurl='';
   xmlurl=gdManagerWS+'FW_SetVisibleORNotVisibleOnSessionThemes?GUIDSession=' + guidSession + '&TXTIdItem=' + id + '&Formato='+gloFormatoXmlLayer+'&state=' + vis ;
   var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
   var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
   xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_SetVisibleORNotVisibleOnSessionThemes',urlpara); 
   pubxml = ripulisciXml(xxx);
   return pubxml;
   */
}
    function getDocumentPopup(windowName)
    {
        var winPop;          
  
        try
        {
            //Prova a trovare una finestra di tipo "popup"
            winPop=document.getElementById(windowName+'_c').contentWindow.document;
        }
        catch (e) {
        }                
        if (winPop == undefined)
        try
        {
            winPop=document.getElementById(windowName).contentWindow.document;        
        }
        catch (e) {                }    
        
        if (winPop == undefined)
        try
        {
             winPop=document;    
        }
        catch (e) {               }   
        
        
        return winPop;
    }

function delBufferDisegnoServer()
{
   var xmlurl='';
   xmlurl=gdManagerWS+'FW_DelBufferDisegno?GUIDSession=' + guidSession;
   var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
   var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
   window.frames['protoframe'].getWSAjaxRequestWrapper('FW_DelBufferDisegno',urlpara); 

}
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}
function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

//Gestisce i box richiudibili nella pagina
function apri_chiudi(titolo){
if(document.getElementById(titolo).style.display == "none"){
 document.getElementById(titolo).style.display = "";
 
 document.getElementById('img_a_c_'+ titolo).src=GLOPubblicatiComuni + "/imgmappa/chiudi.png";

}else{
	document.getElementById(titolo).style.display = "none";
	document.getElementById('img_a_c_'+ titolo).src=GLOPubblicatiComuni + "/imgmappa/apri.png";
	}
}

function checkDataMappa_click(check)
{
    //alert(check);
    if (check.checked == true)
    {
        document.getElementById("boxDataMappa").style.display = 'block';        
        document.getElementById("boxDataMappa").style.visibility = 'visible';       
    }
    else
    {
        document.getElementById("boxDataMappa").style.display = 'none';        
        document.getElementById("boxDataMappa").style.visibility = 'hidden';       
    }
    //boxDataMappa
}

function glogetDataMappa()
{
    var ret='';
    
    if (document.getElementById("chkDataMappa"))
    {
        if (document.getElementById("chkDataMappa").checked == true)
        {
            if (document.getElementById("txtDataMappa") != '')
                ret=document.getElementById("txtDataMappa").value;
        }
    }
    
    return ret;
}

//Calcolo DPI Schermo //http://members.ping.de/~sven/dpi.html
function round2 (i) {
    return Math.round(i * 100) / 100;
}

//dimx X dimy è la dimensione : es. 1024 X 768
function getdpi (diag) {
    var x = screen.width;
    var y= screen.height;
    var centimetri= round2(diag * 2.54);
    var xd = Math.sqrt( Math.pow(diag,2) / (1+ (Math.pow(y,2) / Math.pow(x,2))));
    var yd = y/x * diag;
    return(x/xd);
}

//Ottiene l'elenco degli elementi con la classe indicata
function getElementsByClass(searchClass,node,tag) {
  var classElements = new Array();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if (pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}
//Elimina le parti superflue dall'XML per ottenere solo il testo
function ripulisciXml(xml)
{
    
    var st='';
    if (xml.replace = null )
        alert(xml);
    if (xml != '')
    {
        st = replaceExtChars(xml.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
        st=st.replace("<string xmlns=\"GDManagerWS\" />","");
        st=st.replace("<?xml version=\"1.0\"?>","");
        st=st.replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>","");
        st=st.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>","");
    }    

    return st;
}

//Elimina tutti i div messi da jsGraphics
function ripulisciDrawLayer(lasciaTesti){
    var app;
    
    app=getElementsByClass("div_wz_jsgraphics");
    
    var i=0;
    
    for (i=0;i<app.length;i++)
    {
        app[i].parentNode.removeChild(app[i]);
    }

    //Se true non elimino i testi scritti
    if ((lasciaTesti == null) || (lasciaTesti == false))
    {
    
      eliminaTesti();
      
    }

}    
function fineDisegno(lasciaTesti)
{
  arrXDraw=new Array();
  arrXDrawReal=new Array();
  
  arrYDraw=new Array();
  arrYDrawReal=new Array();
  
  myMap1.arrXDraw=new Array();
  myMap1.arrXDrawReal=new Array();
  
  myMap1.arrYDraw=new Array();
  myMap1.arrYDrawReal=new Array();
  

  a=0;
  b=0;
  lunghezza=0;
  lunghezza_ultimo_segmento=0;
  
  ripulisciDrawLayer();
}

function eliminaTesti(){

  app=getElementsByClass("div_wz_text");

  var i=0;
  
  for (i=0;i<app.length;i++)
  {
      app[i].parentNode.removeChild(app[i]);
  }
      


}
//Azzeramento di tutte le variabili che gestiscono la selezione
function AzzeraVariabiliSelezione(){
	IDFeatureSelezionata='';
	IDALLFeatureSelezionate='';
	CampoFeatureSelezionata='';
	globalXmlSelezione='';
	globalCoordinateSelezione='';
	globalCoordinateDisegno='';
    gloBufferRaggio=0;
    gloBufferXCentro=0;
    gloBufferYCentro=0;    

    if (document.getElementById("txtIdSelezione"))
    	document.getElementById("txtIdSelezione").value=IDALLFeatureSelezionate;
}
//Ottiene il Comune relativo alla vista
function getComuneVista(idvista)
{
	//alert("getelencotemi");
    var xmlurl='';
    xmlurl=gdManagerWS+'FW_GetViewCatastoComune';
    var urlhost = xmlurl;
    var urlpara = 'GUIDSession='+guidSession+'&idvista='+idvista;
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetViewCatastoComune',urlpara); 
    pubxml = ripulisciXml(xxx);
    viewXMLLog(pubxml);
    return pubxml;    
} 
//Caricamento elenco Temi
function getXMLElencoTemi()
{
	//alert("getelencotemi");
    var xmlurl='';
    xmlurl=gdManagerWS+'FW_GetElencoTemi';
    var urlhost = xmlurl;
    var urlpara = 'GUIDSession='+guidSession;
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetElencoTemi',urlpara); 
    pubxml = ripulisciXml(xxx);
    viewXMLLog(pubxml);
    return pubxml;    
} 
//Caricamento albero al primo livello
function getXMLElencoGruppi(idGruppoPadre)
{
	//alert("getelencotemi");
    var xmlurl='';
    xmlurl=gdManagerWS+'FW_GetXMLSessParziale';
    var urlhost = xmlurl;
    
    if ((idGruppoPadre == null ) || (idGruppoPadre == '' ) || (idGruppoPadre == '0' ))
        idNodo='PRIMONODO';
    else
        idNodo=idGruppoPadre;
        
    var urlpara = 'GUIDSession='+guidSession+'&nodocompreso=SI&TXTIdItem='+idNodo;
        
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetXMLSessParziale',urlpara); 
    
    pubxml = ripulisciXml(xxx);
    viewXMLLog(pubxml);
    return pubxml;    
}
//Caricamento elenco Temi
function caricaElencoTemi(listBox)
{
    var xml;
    var numNodi=0;
    var intLoop;
    
    xml=getXMLElencoTemi(); //document.gdmanager.response.value;
    
    var objDom = Sarissa.getDomDocument();
    var serializer = new XMLSerializer(); 
    objDom = (new DOMParser()).parseFromString(xml, "text/xml");
    
    var objNodeList = objDom.selectNodes("/elenco/tema");
    
    var numNodi=objNodeList.length;

    for (intLoop = 0; intLoop < numNodi; intLoop++) {
        AddToList(listBox,objNodeList.item(intLoop).getAttribute("IDFramework"),objNodeList.item(intLoop).getAttribute("aliasname"));
    }
    

    return true;
}
//Caricamento elenco Progetti
function getXMLElencoProgetti()
{
    var xmlurl='';
    xmlurl=gdManagerWS+'FW_GetProjects';
    var urlhost = xmlurl;
    var urlpara = 'TXTOnlyIDLanguage=ALL&WHICHDB=' + qualedb+'&GroupNumber1=&GroupNumber2=&TXTUte='+txtUtente+'&TXTUTEPWD='+txtPassword;
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetProjects',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);
    return pubxml;    
} 
//Caricamento elenco Progetti
function caricaElencoProgetti()
{
    var xml;
    var numNodi=0;
    var intLoop;
    xml=getXMLElencoProgetti(); //document.gdmanager.response.value;

    var objDom = Sarissa.getDomDocument();
    var serializer = new XMLSerializer(); 
    objDom = (new DOMParser()).parseFromString(xml, "text/xml");
    
    var objNodeList = objDom.selectNodes("/projects/project");
    
    var numNodi=objNodeList.length;

    for (intLoop = 0; intLoop < numNodi; intLoop++) {
        AddToList(document.gdmanager.progetti,objNodeList.item(intLoop).getAttribute("id"),objNodeList.item(intLoop).getAttribute("name"));
    }
    
    return true;
}
//Caricamento elenco Viste del progetto
function getXMLElencoViste(idProgetto)
{
    var xmlurl='';
    xmlurl=gdManagerWS+'FW_GetProjectViews';
    var urlhost = xmlurl;
    var urlpara = 'TXTOnlyIDLanguage=ALL&WHICHDB=' + qualedb+'&TXTIDProject='+idProgetto+'&TXTUte='+txtUtente+'&TXTUTEPWD='+txtPassword;
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetProjectViews',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);
    return pubxml;
} 
//Caricamento elenco Viste
function caricaElencoViste(idProgetto)
{
    var xml;
    var numNodi=0;
    var intLoop;
    xml=getXMLElencoViste(idProgetto); //document.gdmanager.response.value;

    var objDom = Sarissa.getDomDocument();
    var serializer = new XMLSerializer(); 
    objDom = (new DOMParser()).parseFromString(xml, "text/xml");
    
    var objNodeList = objDom.selectNodes("/views/view");
    
    var numNodi=objNodeList.length;

    for (intLoop = 0; intLoop < numNodi; intLoop++) {
        AddToList(document.gdmanager.viste,objNodeList.item(intLoop).getAttribute("id"),objNodeList.item(intLoop).getAttribute("name"));
    }
    

    return true;
}
//Connessione al Progetto
function connetti(idProgetto,idVista,utente,pwd)
{
    var xmlurl='';
    
	if (gdManagerWrapper != '')
	{
				xmlurl=gdManagerWrapper+'FW_Connection?WHICHDB=' + qualedb + '&TXTIDProject='+idProgetto+'&TXTIDLanguage=1&TXTPassword=&TXTIDVistaDerivata='+idVista+'&TXTUTE='+utente+'&TXTUTEPWD='+pwd;
	}
	else 
	{
				xmlurl=gdManagerWS+'FW_Connection?WHICHDB=' + qualedb + '&TXTIDProject='+idProgetto+'&TXTIDLanguage=1&TXTPassword=&TXTIDVistaDerivata='+idVista+'&TXTUTE='+utente+'&TXTUTEPWD='+pwd;
	}
    

    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_Connection',urlpara); 
    viewXMLLog(xxx);
    guidSession=ripulisciXml(xxx);
  
    if (guidSession.indexOf("ERROR") > 0)
		{
		guidSession="";
		return guidSession;
		}
	else
		return guidSession;
}

function getExtent(MyguidSession)
{
    var xmlurl='';
    var guid='';
    
    if (typeof(MyguidSession) == 'undefined')
        guid=guidSession;
    else
        guid=MyguidSession;     
        
    //xmlurl=gdManagerWS+'FW_Extension?GUIDSession='+guidSession+'&TXTIdItem=0&nodocompreso=SI';
    xmlurl=gdManagerWS+'FW_Extension?GUIDSession='+guid+'&Tipo=INIZIALE';
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_Extension',urlpara); 
    pubxml = ripulisciXml(xxx);

    
    viewXMLLog(pubxml);  
    getExtentdaXML(pubxml);
}
//Caricamento Extent
function getExtentdaXML(xml)
{
    var numNodi=0;
    var intLoop;
    var extArray;
    xml=xml.replace("<estensione>","");    
    xml=xml.replace("</estensione>","");    
    extArray=xml.split(" ");
    limitXmin=extArray[0];
    limitYmin=extArray[1];
    limitXmax=extArray[2];
    limitYmax=extArray[3];
    
    mapXmin=extArray[0];
    mapXmax=extArray[2];
    mapYmin=extArray[1];
    mapYmax=extArray[3];
    
    return true;
}
//Caricamento Extent
/* OLD : Legge a Partire da FW_GetXMLSessParziale
function getExtentdaXML()
{
    var xml;
    var numNodi=0;
    var intLoop;
    var extArray;
    xml=pubxml; //document.gdmanager.response.value;
    var objDom = new XMLDoc(xml);
    //find the first TAG1 node
    var domTree = objDom.docNode;
    
    var firstTag1Node = domTree; //.getElements("item");
    viewXMLLog(firstTag1Node.getAttribute("estensioneINIZIALE"));
    extArray=firstTag1Node.getAttribute("estensioneINIZIALE").split(" ");
    limitXmin=extArray[0];
    limitYmin=extArray[1];
    limitXmax=extArray[2];
    limitYmax=extArray[3];
    mapXmin=extArray[0];
    mapXmax=extArray[2];
    mapYmin=extArray[1];
    mapYmax=extArray[3];
    return true;
}
//Caricamento Extent
/* OLD: Legge a partire da GetXMLActiveProject
function getExtentdaXML()
{
    var xml;
    var numNodi=0;
    var intLoop;
    var extArray;
    xml=pubxml; //document.gdmanager.response.value;
    var objDom = new XMLDoc(xml);
    //find the first TAG1 node
    var domTree = objDom.docNode;
    var firstTag1Node = domTree.getElements("item");
    viewXMLLog(firstTag1Node[0].getAttribute("estensioneINIZIALE"));
    extArray=firstTag1Node[0].getAttribute("estensioneINIZIALE").split(" ");
    limitXmin=extArray[0];
    limitYmin=extArray[1];
    limitXmax=extArray[2];
    limitYmax=extArray[3];
    mapXmin=extArray[0];
    mapXmax=extArray[2];
    mapYmin=extArray[1];
    mapYmax=extArray[3];
    return true;
}
*/
function getXMLElencoTemi()
{
    var xmlurl='';
    xmlurl=gdManagerWS+'FW_GetElencoTemi?GUIDSession='+guidSession;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetElencoTemi',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);
    return pubxml;
}

function getElencoTemiCombo(){

    var xml;
    var numNodi=0;
    var intLoop;
    var extArray;
    xml=getXMLElencoTemi(); //document.gdmanager.response.value;
    
    var objDom = Sarissa.getDomDocument();
    var serializer = new XMLSerializer(); 
    objDom = (new DOMParser()).parseFromString(xml, "text/xml");
    
    var objNodeList = objDom.selectNodes("/elenco/tema");
    
    var numNodi=objNodeList.length;
    elenco_temi_combo='';

	
	var cc=0;
	while(cc<numNodi){
		//alert(firstTag1Node[cc].getAttribute("name"));
        if (objNodeList.item(cc).getAttribute("IDFramework") == ActiveLayerIndex)
    		elenco_temi_combo+='<option selected="selected" value="'+objNodeList.item(cc).getAttribute("IDFramework")+'">'+objNodeList.item(cc).getAttribute("aliasname") + '</option>';
	    else
            elenco_temi_combo+='<option value="'+objNodeList.item(cc).getAttribute("IDFramework")+'">'+objNodeList.item(cc).getAttribute("aliasname") + '</option>';
        cc++;
		}
		//alert(elenco_temi_combo);
    return elenco_temi_combo;
}
//passandogli il nome del tema originale , ne restitisce l'id
function getIdTemaByName(nome_tema){

    var xml;
    var numNodi=0;
    var intLoop;
    var extArray;
	var id_tema;
    xml=getXMLElencoTemi(); //document.gdmanager.response.value;
    
    var objDom = Sarissa.getDomDocument();
    var serializer = new XMLSerializer(); 
    objDom = (new DOMParser()).parseFromString(xml, "text/xml");
    
    //alert(serializer.serializeToString(objDom));
    
    var objNodeList = objDom.selectNodes("/elenco/tema");
    
    //alert(objNodeList.length);

	var num_nodi=objNodeList.length;

    //alert(serializer.serializeToString(objNodeList[0]));
    //alert(objNodeList.item(0).getAttribute("Name"));
	
	var cc=0;
    id_tema='';
	while ((cc<num_nodi) && (id_tema == '')){
	//while ((cc<num_nodi) ){
		//alert(firstTag1Node[cc].getAttribute("name"));
		if(objNodeList.item(cc).getAttribute("name") == nome_tema)
		    {
                id_tema=objNodeList.item(cc).getAttribute("IDFramework");
            }
		cc++;
		}
		
    return id_tema;
}
//passandogli il nome del tema, ne restitisce l'id
function getIdTema(alias_tema){

    var xml;
    var numNodi=0;
    var intLoop;
    var extArray;
	var id_tema;
    xml=getXMLElencoTemi(); //document.gdmanager.response.value;
    
    var objDom = Sarissa.getDomDocument();
    var serializer = new XMLSerializer(); 
    objDom = (new DOMParser()).parseFromString(xml, "text/xml");
    
    //alert(serializer.serializeToString(objDom));
    
    var objNodeList = objDom.selectNodes("/elenco/tema");
    
    //alert(objNodeList.length);

	var num_nodi=objNodeList.length;

    //alert(serializer.serializeToString(objNodeList[0]));
    //alert(objNodeList.item(0).getAttribute("Name"));
	
	var cc=0;
    id_tema='';
	while ((cc<num_nodi) && (id_tema == '')){
	//while ((cc<num_nodi) ){
		//alert(firstTag1Node[cc].getAttribute("name"));
		if(objNodeList.item(cc).getAttribute("aliasname") == alias_tema)
		    {
                id_tema=objNodeList.item(cc).getAttribute("IDFramework");
            }
		cc++;
		}
		
    return id_tema;
}

function getIdGruppo(nomeGruppo){

    var xml;
    var numNodi=0;
    var intLoop;
    var extArray;
	var idGruppo;
    xml=getXMLElencoGruppi(); //document.gdmanager.response.value;
    xml='<elenco>' + xml + '</elenco>';
    var objDom = Sarissa.getDomDocument();
    var serializer = new XMLSerializer(); 
    objDom = (new DOMParser()).parseFromString(xml, "text/xml");
    
    //alert(serializer.serializeToString(objDom));
    //alert(objDom.nodes.length);    
 
    var objNodeList = objDom.selectNodes("/elenco/item");
    
   	var num_nodi=objNodeList.length;

    //alert(serializer.serializeToString(objNodeList[0]));
    //alert(objNodeList.item(0).getAttribute("Name"));
	
	var cc=0;
    idGruppo='';
	while ((cc<num_nodi) && (idGruppo == '')){
	//while ((cc<num_nodi) ){
		//alert(firstTag1Node[cc].getAttribute("name"));
		//alert(objNodeList.item(cc).getAttribute("text"));
        
        if(objNodeList.item(cc).getAttribute("text") == nomeGruppo)
		    {
                idGruppo=objNodeList.item(cc).getAttribute("id");
            }
        
		cc++;
		}
		
    return idGruppo;
}
/*
function getIdTema(nome_tema){

    var xml;
    var numNodi=0;
    var intLoop;
    var extArray;
	var id_tema;
    xml=getXMLElencoTemi(); //document.gdmanager.response.value;
    var objDom = new XMLDoc(xml);
    //find the first TAG1 node
    var domTree = objDom.docNode;
	
    var firstTag1Node = domTree.getElements("tema");
    viewXMLLog(firstTag1Node[0].getAttribute("name"));
	var num_nodi=domTree.getElements("tema").length;
    
	
	var cc=0;
	while(cc<num_nodi){
		//alert(firstTag1Node[cc].getAttribute("name"));
		if(firstTag1Node[cc].getAttribute("name") == nome_tema)
		id_tema=firstTag1Node[cc].getAttribute("IDFramework");
		cc++;
		}
		
    return id_tema;
}
*/

// Luca
// Richiesta Viewpoints Boano
function GetNomeProgetto(numero) {

    var xmlurl='';
    
	if (gdManagerWrapper != '')
	{
				xmlurl=gdManagerWrapper+'FW_GetProjects?TXTOnlyIDLanguage=1&WHICHDB='+ qualedb  +'&GroupNumber1=&GroupNumber2=&TXTUTE='+ user  +'&TXTUTEPWD='+ pwd;
	}
	else 
	{
				xmlurl=gdManagerWS+'FW_GetProjects?TXTOnlyIDLanguage=1&WHICHDB='+ qualedb  +'&GroupNumber1=&GroupNumber2=&TXTUTE='+ user  +'&TXTUTEPWD='+ pwd;
	}    

    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetProjects',urlpara); 
    
    viewXMLLog(xxx);
	progetti=ripulisciXml(xxx);
  
	if (document.implementation && document.implementation.createDocument)
	{	// Mozilla
		var parser=new DOMParser();
		var doc=parser.parseFromString(progetti,"text/xml");
	}
	else
	{	// IE
		var doc=new ActiveXObject("Microsoft.XMLDOM");
		doc.async="false";
		doc.loadXML(progetti);
	}
	
	x=doc.documentElement;
	
	for(j=0; j<x.childNodes.length; j++) {
		if(x.childNodes[j].getAttribute("id") == numero)
			return x.childNodes[j].getAttribute("name");
	}
}

function GetNomeVista(numero) {

    var xmlurl='';
    
	if (gdManagerWrapper != '')
	{
				xmlurl=gdManagerWrapper+'FW_GetProjectViews?TXTOnlyIDLanguage=1&WHICHDB='+ qualedb  +'&TXTIDProject='+ idProgetto +'&TXTUTE='+ user  +'&TXTUTEPWD='+ pwd;
	}
	else 
	{
				xmlurl=gdManagerWS+'FW_GetProjectsViews?TXTOnlyIDLanguage=1&WHICHDB='+ qualedb  +'&TXTIDProject='+ idProgetto +'&TXTUTE='+ user  +'&TXTUTEPWD='+ pwd;
	}    

    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetProjectViews',urlpara); 
    
    viewXMLLog(xxx);
	viste=ripulisciXml(xxx);
  
	if (document.implementation && document.implementation.createDocument)
	{	// Mozilla
		var parser=new DOMParser();
		var doc=parser.parseFromString(viste,"text/xml");
	}
	else
	{	// IE
		var doc=new ActiveXObject("Microsoft.XMLDOM");
		doc.async="false";
		doc.loadXML(viste);
	}
	
	x=doc.documentElement;
	
	for(j=0; j<x.childNodes.length; j++) {
		if(x.childNodes[j].getAttribute("id") == numero)
			return x.childNodes[j].getAttribute("name");
	}
}

function getViewpoints(guidSession,Xmin,Xmax,Ymin,Ymax,Tipologia,TipoRichiesta)
{
    var xmlurl='';

	if (gdManagerWrapper != '')
	{
				xmlurl=gdManagerWrapper+'FW_ViewPoints?GUIDSession=' + guidSession + '&XMIN=' + Xmin + '&YMIN=' + Ymin + '&XMAX=' + Xmax + '&YMAX=' + Ymax + '&TXTIDTipologia=' + Tipologia+'&TXTConsideraVPProgetto=SI&TXTFiltraTipologieVisibiliVista=SI';
	}
	else 
	{
				xmlurl=gdManagerWS+'FW_ViewPoints?GUIDSession=' + guidSession + '&XMIN=' + Xmin + '&YMIN=' + Ymin + '&XMAX=' + Xmax + '&YMAX=' + Ymax + '&TXTIDTipologia=' + Tipologia+'&TXTConsideraVPProgetto=SI&TXTFiltraTipologieVisibiliVista=SI';
	}    

    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_ViewPoints',urlpara); 
    
    viewXMLLog(xxx);
    viewpoints=ripulisciXml(xxx);
  
    if (viewpoints.indexOf("ERROR") > 0)
		{
		viewpoints="";
		return viewpoints;
		}
	else
		return viewpoints;
}
/*
// Luca - Viewpoint Versione 1
function getTipologie(guidSession) {

    var xmlurl='';
    
	if (gdManagerWrapper != '')
	{
				xmlurl=gdManagerWrapper+'FW_TipologieViewPoints?GUIDSession=' + guidSession;
	}
	else 
	{
				xmlurl=gdManagerWS+'FW_TipologieViewPoints?GUIDSession=' + guidSession;
	}    

    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_TipologieViewPoints',urlpara); 
    
    viewXMLLog(xxx);
    tipologie=ripulisciXml(xxx);
  
    if (tipologie.indexOf("ERROR") > 0)
		{
		tipologie="";
		return tipologie;
		}
	else
		return tipologie;
}
*/

// Luca - Viewpoint Versione 1
function getTipologie(guidSession,TipoRichiesta) {

    var xmlurl='';
    
	if (gdManagerWrapper != '')
	{
				xmlurl=gdManagerWrapper+'FW_TipologieViewPoints?GUIDSession=' + guidSession + '&TXTConsideraVPProgetto=SI&TXTFiltraTipologieVisibiliVista=SI';
	}
	else 
	{
				xmlurl=gdManagerWS+'FW_TipologieViewPoints?GUIDSession=' + guidSession + '&TXTConsideraVPProgetto=SI&TXTFiltraTipologieVisibiliVista=SI';
	}    

    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_TipologieViewPoints',urlpara); 
    
    viewXMLLog(xxx);
    tipologie=ripulisciXml(xxx);
  
    if (tipologie.indexOf("ERROR") > 0)
		{
		tipologie="";
		return tipologie;
		}
	else
		return tipologie;
}


// Luca - Fa richiesta al webservice per ottenere le tipologie disponibili
function CaricaTipologie(TipoRichiesta) {
			
	tipologie = getTipologie(guidSession,TipoRichiesta);	
	
	document.getElementById("catVP").innerHTML = ""; 
	
	if (document.implementation && document.implementation.createDocument)
	{	// Mozilla
		var parser=new DOMParser();
		var doc=parser.parseFromString(tipologie,"text/xml");
	}
	else
	{	// IE
		var doc=new ActiveXObject("Microsoft.XMLDOM");
		doc.async="false";
		doc.loadXML(tipologie);
	}
	
	x=doc.documentElement;
	
	if(document.getElementById("catVP") != null) {
	
		document.getElementById("catVP").innerHTML = "<table border='1'>";

		var j,foto;			
		for(j=0; j<x.childNodes.length; j++) {
			foto = x.childNodes[j].getAttribute('IMMAGINETIPOLOGIA');
			tipologia_list_js.push(x.childNodes[j].getAttribute('id'));
			if(foto != "") 
				document.getElementById("catVP").innerHTML = document.getElementById("catVP").innerHTML + '<tr><td><input style="border=0;" onclick="Change_Tipologia(guidSession,' + x.childNodes[j].getAttribute('id') + '); " type="checkbox" checked name="group1" id=' + x.childNodes[j].getAttribute('id') + ' value=' + x.childNodes[j].getAttribute('compareallascala') + '></td><td><img src=' + GLOBase + foto + '></td><td>' + x.childNodes[j].getAttribute('name') + '</td><br></tr>';
			else
  				document.getElementById("catVP").innerHTML = document.getElementById("catVP").innerHTML + '<tr><td><input style="border=0;" onclick="Change_Tipologia(guidSession,' + x.childNodes[j].getAttribute('id') + '); " type="checkbox" checked name="group1" id=' + x.childNodes[j].getAttribute('id') + ' value=' + x.childNodes[j].getAttribute('compareallascala') + '></td><td></td><td>' + x.childNodes[j].getAttribute('name') + '</td><br></tr>';
		}

		for(j=0; j<x.childNodes.length; j++) {	
			CaricaVP(guidSession,x.childNodes[j].getAttribute('id'),TipoRichiesta);
		}
		
		document.getElementById("catVP").innerHTML = document.getElementById("catVP").innerHTML + "</table>";		
	}
}	

function SwapTipologieVistaProgetto() {
	
	myMap1.ClearPunti();
	Deseleziona_Tipologia();
	tipologia_list_js = new Array();
	TipoView_list_js = new Array();
	
	if(document.getElementById("Swap").checked == true) 
		GLOTipologieProgetto = "SI";
	else
		GLOTipologieProgetto = "";
		
	CaricaTipologie(GLOTipologieProgetto);
	
	}

function Change_Tipologia(idSession,Tipologia) {

	if(Tipologia != "") {  // Change da comando 
		
		if (document.getElementById(Tipologia).checked == true) {
			var j, trovata=0;
			for(j=0; j<x_list_js.length; j++) {
				if(TipoView_list_js[j] == Tipologia  && document.getElementById(Tipologia).value >= myMap1.GetScala()) {
					myMap1.addViewPoints(x_list_js[j],y_list_js[j],descrizione_list_js[j],note_list_js[j],immagine_list_js[j],color_list_js[j]);
					trovata = 1; 
					}	
			}
			if (trovata == 0)
				CaricaVP(idSession,Tipologia,GLOTipologieProgetto);
		}
		else 
		{
			
			myMap1.ClearPunti(); 
			var j;
			for(j=0; j<x_list_js.length; j++) {
				if(document.getElementById(TipoView_list_js[j]).checked == true && document.getElementById(TipoView_list_js[j]).value >= myMap1.GetScala()) 
					myMap1.addViewPoints(x_list_js[j],y_list_js[j],descrizione_list_js[j],note_list_js[j],immagine_list_js[j],color_list_js[j]);		
			}		
		}
		AggiornaPercorsi("");
	}
	else {			// Change dopo redraw
		var j;
		for(j=0; j<x_list_js.length; j++) {
			if(document.getElementById(TipoView_list_js[j]).checked == true) {
				if(document.getElementById(TipoView_list_js[j]).value == "" || document.getElementById(TipoView_list_js[j]).value >= myMap1.GetScala()) 
					myMap1.addViewPoints(x_list_js[j],y_list_js[j],descrizione_list_js[j],note_list_js[j],immagine_list_js[j],color_list_js[j]);		
}}}}

function Deseleziona_Tipologia() {
	
	var i;
	for(i=0; i<tipologia_list_js.length; i++) {
	
		if (document.getElementById(tipologia_list_js[i]).checked == true)
			document.getElementById(tipologia_list_js[i]).checked = false;
	}
	x_list_js = new Array();
	y_list_js = new Array();
	descrizione_list_js = new Array();
	immagine_list_js = new Array();
	color_list_js = new Array();
	link_list_js = new Array();
	note_list_js = new Array();
	
}

// Luca - Fa richiesta al webservice per ottenere i viewpoint della determinata tipologia
function CaricaVP(idSession,Tipologia,TipoRichiesta) {

		var viewpoints;
		
		viewpoints = getViewpoints(idSession,parseInt(mapXmin),parseInt(mapYmin),parseInt(mapXmax),parseInt(mapYmax),Tipologia,TipoRichiesta);
		
		while(viewpoints.indexOf("\n") > 0)
			viewpoints = viewpoints.replace("\n","");	
			
		while(viewpoints.indexOf("<br>") > 0) 
			viewpoints = viewpoints.replace("<br>","");

		if (document.implementation && document.implementation.createDocument)
		{	// Mozilla
			var parser=new DOMParser();
			var doc=parser.parseFromString(viewpoints,"text/xml");
		}
		else
		{	// IE
			var doc=new ActiveXObject("Microsoft.XMLDOM");
			doc.async="false";
			doc.loadXML(viewpoints);
		}
		
		tmp=doc.documentElement;
		
		var z;
		
		for(z=0; z<tmp.childNodes.length; z++) {

			x_list_js.push(tmp.childNodes[z].getAttribute('x'));
			y_list_js.push(tmp.childNodes[z].getAttribute('y'));
			descrizione_list_js.push(tmp.childNodes[z].getAttribute('descrizione'));
			immagine_list_js.push(tmp.childNodes[z].getAttribute('IMMAGINETIPOLOGIA'));
			color_list_js.push(tmp.childNodes[z].getAttribute('COLORETIPOLOGIA'));
			link_list_js.push(tmp.childNodes[z].getAttribute('LINK'));	
			note_list_js.push(tmp.childNodes[z].getAttribute('NOTE'));
	
			if(Tipologia == "") {
				TipoView_list_js.push(100000);	
				Tipologia = 100000;
			}
			else
				TipoView_list_js.push(Tipologia);	
				
		if(document.getElementById(Tipologia).value == "" || document.getElementById(Tipologia).value >= myMap1.GetScala()) 
			myMap1.addViewPoints(tmp.childNodes[z].getAttribute('x'),tmp.childNodes[z].getAttribute('y'),tmp.childNodes[z].getAttribute('descrizione'),tmp.childNodes[z].getAttribute('NOTE'),tmp.childNodes[z].getAttribute('IMMAGINETIPOLOGIA'),tmp.childNodes[z].getAttribute('COLORETIPOLOGIA'));				
		}
		
}

//Luca - Viewpoint
function CaricaViewPoints() {
			
	var i;
			
	if(x_list_js.length > 0) {	
		for(i=0; i<x_list_js.length; i++)	
		myMap1.addViewPoints(x_list_js[i],y_list_js[i],descrizione_list_js[i],note_list_js[i],immagine_list_js[i],color_list_js[i]);
	}
}	

function CercaIdViewpoints(x,y){
	var trovato = 0,i=0;
	if(x_list_js.length > 0) {	
		while(i < x_list_js.length | trovato == 1)	{
			if(x_list_js[i] == x ) {	
				trovato = 1;
				return i;
			}
		i++;
}}}	

function getViewpointPercorsi(guidSession,idPercorso)
{
    var xmlurl='';
    
	if (gdManagerWrapper != '')
	{
				xmlurl=gdManagerWrapper+'FW_PercorsiViewPoints?GUIDSession=' + guidSession + '&TXTIdPercorso=' + idPercorso;
	}
	else 
	{
				xmlurl=gdManagerWS+'FW_PercorsiViewPoints?GUIDSession=' + guidSession + '&TXTIdPercorso=' + idPercorso;
	}    

    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_PercorsiViewPoints',urlpara); 
    
    viewXMLLog(xxx);
    viewpoints=ripulisciXml(xxx);
  
    if (viewpoints.indexOf("ERROR") > 0)
		{
		viewpoints="";
		return viewpoints;
		}
	else
		return viewpoints;
}

function getPercorsi(guidSession,TipoRichiesta) {

    var xmlurl='';
    
	if (gdManagerWrapper != '')
			xmlurl=gdManagerWrapper+'FW_PercorsiElenco?GUIDSession=' + guidSession + '&TXTConsideraVPProgetto=SI&TXTFiltraPercorsiVisibiliVista=SI';
	else 
			xmlurl=gdManagerWS+'FW_PercorsiElenco?GUIDSession=' + guidSession + '&TXTConsideraVPProgetto=SI&TXTFiltraPercorsiVisibiliVista=SI';

    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_PercorsiElenco',urlpara); 
    
    viewXMLLog(xxx);
    percorsi=ripulisciXml(xxx);

	
    if (percorsi.indexOf("ERROR") > 0)
		{
		percorsi="";
		return percorsi;
		}
	else
		return percorsi;
}

function CaricaListaPercorsi(TipoRichiesta) {
			
	var percorsi = new String();
	
	goPopup();
	
	percorsi = getPercorsi(guidSession,TipoRichiesta);	
		
		
	if (document.implementation && document.implementation.createDocument)
	{	// Mozilla
		var parser=new DOMParser();
		var doc=parser.parseFromString(percorsi,"text/xml");
	}
	else
	{	// IE
		var doc=new ActiveXObject("Microsoft.XMLDOM");
		doc.async="false";
		doc.loadXML(percorsi);
	}	
	
	x=doc.documentElement;
	
	if(document.getElementById("catPR") != null) {
		document.getElementById("catPR").innerHTML = '<table cellspacing=0 cellpadding=0 class="testo_ricerca" style="width:100%;">';
		var j,foto;			
		for(j=0; j<x.childNodes.length; j++) {
		
			percorso_list_js.push("percorso" + x.childNodes[j].getAttribute('id'));
			
			if (document.implementation && document.implementation.createDocument) 
				document.getElementById("catPR").innerHTML = document.getElementById("catPR").innerHTML + '<tr width="100%" onMouseover="this.bgColor=\'#C46856\'; document.getElementById(\'stampa'+ x.childNodes[j].getAttribute('id') +'\').style.display = \'\';" onMouseout="this.bgColor=\'white\'; document.getElementById(\'stampa'+ x.childNodes[j].getAttribute('id') +'\').style.display = \'none\';" ><td width="50%" ><input style="border=0;" onclick="goPopup(); AggiornaPercorsi('+ x.childNodes[j].getAttribute('id') +');" type="radio" value="' + x.childNodes[j].getAttribute('id') + '" id="percorso' + x.childNodes[j].getAttribute('id') + '" name=' + x.childNodes[j].getAttribute('compareallascala') + '>' + x.childNodes[j].getAttribute('name') + '</td><td width="50%" ><input style="border:0; display:none;" onclick="goPopup(); window.open( \'PrintPercorsi.asp?id=' + x.childNodes[j].getAttribute('id') +  ' \',\'_blank\');" type="button" value="Stampa Percorso" id="stampa' + x.childNodes[j].getAttribute('id') + '" ></td></tr>';
			else {
				document.getElementById("catPR").innerHTML = document.getElementById("catPR").innerHTML + '<tr><td><input style="border:0" onclick="goPopup(); AggiornaPercorsi('+ x.childNodes[j].getAttribute('id') +');" type="radio" value="' + x.childNodes[j].getAttribute('id') + '" id="percorso' + x.childNodes[j].getAttribute('id') + '" name=' + x.childNodes[j].getAttribute('compareallascala') + '></td><td></td><td>' + x.childNodes[j].getAttribute('name') + '</td><br></tr>';
				
			}
		}
		document.getElementById("catPR").innerHTML = document.getElementById("catPR").innerHTML + "</table>";
	}
	
	nascondiPopup();
}	


function CaricaViewpointPercorsi(idPercorso) {

	var j;
	var coord_x = new Array();
	var coord_y = new Array();
	var tappe = new String();

	tappe = getViewpointPercorsi(guidSession,idPercorso);
	
	while(tappe.indexOf ("\n") > 0 ) 
		tappe = tappe.replace("\n","");

	while(tappe.indexOf ("<br>") > 0 ) 
		tappe = tappe.replace("<br>","");
	
	if (document.implementation && document.implementation.createDocument) {	// Mozilla
		var parser=new DOMParser();
		var doc=parser.parseFromString(tappe,"text/xml");
	}
	else {	// IE
		var doc=new ActiveXObject("Microsoft.XMLDOM");
		doc.async="false";
		doc.loadXML(tappe);
	}
	
	tmp=doc.documentElement;

	ripulisciDrawLayer(true);

	for(j=0; j<tmp.childNodes.length; j++) {
		coord_x.push(myMap1.xReal2pixel(tmp.childNodes[j].getAttribute('x')));
		coord_y.push(myMap1.yReal2pixel(tmp.childNodes[j].getAttribute('y')));
		myMap1.addPunto(tmp.childNodes[j].getAttribute('x'),tmp.childNodes[j].getAttribute('y'),tmp.childNodes[j].getAttribute('descrizione'),tmp.childNodes[j].getAttribute('NOTE'),0);
	}

	if(_drawPercorso == null) {		
		_drawPercorso = new jsGraphics("mappa");
		_drawPercorso.setPrintable(true);
	}
	
	_drawPercorso.setStroke(3);
	_drawPercorso.setColor("#0000FF");	
	_drawPercorso.drawPolyline(coord_x,coord_y);
	_drawPercorso.paint();
}

function AggiornaPercorsi(idPercorso)  {
	
	if(idPercorso != "") {	// After click
		if (document.getElementById("percorso" + idPercorso).checked == true)
			if(document.getElementById("percorso" + idPercorso).name == null || document.getElementById("percorso" + idPercorso).name == "" || document.getElementById("percorso" + idPercorso).name >= myMap1.GetScala()) 
				CaricaViewpointPercorsi(idPercorso);
		else 
			ripulisciDrawLayer(true);
			
		if (document.getElementById("Swap").checked == true)
			Change_Tipologia(guidSession,'',"SI");
		else
			Change_Tipologia(guidSession,'',"");	
			
		nascondiPopup();		
	}
	else {	// After redraw
		var i;
		for(i=0; i<percorso_list_js.length; i++) 
		{
			if(document.getElementById(percorso_list_js[i]).checked == true) {
				if(document.getElementById(percorso_list_js[i]).name == null || document.getElementById(percorso_list_js[i]).name == "" || document.getElementById(percorso_list_js[i]).name >= myMap1.GetScala()) 
					CaricaViewpointPercorsi(document.getElementById(percorso_list_js[i]).value);	
			}
		}
		
	}
	
}

function SwapPercorsiVistaProgetto() {
	
	Deseleziona_Percorso();
	
	percorso_list_js = new Array();

	if(document.getElementById("Swap2").checked == true) 
		CaricaListaPercorsi("SI");
	else
		CaricaListaPercorsi("SI");
		
	nascondiPopup();
}

function Deseleziona_Percorso() {
	
	ripulisciDrawLayer(true);

	var i;
	for(i=0; i<percorso_list_js.length; i++) {
	
		if (document.getElementById(percorso_list_js[i]).checked == true)
			document.getElementById(percorso_list_js[i]).checked = false;
	}
}

// Fine Modifiche Luca per Asti

function saveLastExtent(xmin,xmax,ymin,ymax)
{
    var str='';
    
    str=xmin+' '+ymin+' '+xmax+' '+ymax;
    arrBackZoom.push(str);
}

//Disegno Mappa
function getMappa(xmin,ymin,xmax,ymax)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    /*
    var strLayerAttivi='';
    var arrLayerAttivi;
    strLayerAttivi=tree1.getAllChecked();
    arrLayerAttivi=strLayerAttivi.split(",");
    xmlLayer='<layers>';
    for (i=0;i<arrLayerAttivi.length;i++)
        if (arrLayerAttivi[i] != "") xmlLayer=xmlLayer+"<layer IDFramework='"+arrLayerAttivi[i]+"' visible='True'></layer>";
    xmlLayer=xmlLayer+'</layers>';
    */
    xmlLayer=getXMLLayerAttivi(guidSession);
    var xmlSelezione= '';
    xmlSelezione=globalXmlSelezione; //getXMLSelezioneALL();
    var xmlCoordinateDisegno='';
    xmlCoordinateDisegno=globalCoordinateDisegno;
    var thisdate=getDataUnivoca();
    gloDataMappa=glogetDataMappa();
    //saveLastExtent(xmin,ymin,xmax,ymax);
    xmlurl=gdManagerWS+"FW_DrawProject?TXTListaCOORDSPolTodraw="+xmlCoordinateDisegno+"&GUIDSession="+guidSession+"&XMIN="+xmin+"&XMAX="+xmax+"&YMIN="+ymin+"&YMAX="+ymax+"&PixelsIMGX="+LarghezzaMappa+"&PixelsIMGY="+AltezzaMappa+"&TXTXMLListaIDFeaturesDaSelezionare='"+xmlSelezione+"'&TXTXMLListaLayers=" +xmlLayer+"&TXTDateRequest="+gloDataMappa+"&dataora="+thisdate;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_DrawProject',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);
    //setTimeout("disegnadaXML();",1000);
    disegnadaXML();
}
//Restituisce l'URL dell'immagine della Mappa 
function getUrlMappa(xmin,ymin,xmax,ymax,sizeX,sizeY,usaScalimetro)
{
    var url='';
    var xmlLayer='';
    var i=0;
    var xmlLayer= getXMLLayerAttivi(guidSession);
    var xmlSelezione= '';
    xmlSelezione=globalXmlSelezione; //getXMLSelezioneALL();
    var xmlCoordinateDisegno='';
    xmlCoordinateDisegno=globalCoordinateDisegno;    
	var thisdate=getDataUnivoca();
    gloDataMappa=glogetDataMappa();
    //saveLastExtent(xmin,ymin,xmax,ymax);
    url="/gdproxy/map.aspx?TXTListaCOORDSPolTodraw="+xmlCoordinateDisegno+"&GUIDSession="+guidSession+"&XMIN="+xmin+"&XMAX="+xmax+"&YMIN="+ymin+"&YMAX="+ymax+"&PixelsIMGX="+sizeX+"&PixelsIMGY="+sizeY+"&TXTXMLListaIDFeaturesDaSelezionare='"+xmlSelezione+"'&TXTXMLListaLayers=" +xmlLayer+"&dataora="+thisdate;
    if (usaScalimetro == "SI")
        url += "&SCALIMETER=SI";
    else
        url += "&SCALIMETER=NO";
    return url;
}
//Restituisce l'URL dell'immagine della Mappa 
function getUrlMappaWS(xmin,ymin,xmax,ymax,sizeX,sizeY,usaScalimetro)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var xmlLayer= getXMLLayerAttivi(guidSession);
    var xmlSelezione= '';
    xmlSelezione=globalXmlSelezione; //getXMLSelezioneALL();
    var xmlCoordinateDisegno='';
    xmlCoordinateDisegno=globalCoordinateDisegno;     
	var thisdate=getDataUnivoca();
    gloDataMappa=glogetDataMappa();
    
    xmlurl=gdManagerWS+"FW_DrawProject?TXTListaCOORDSPolTodraw="+xmlCoordinateDisegno+"&GUIDSession="+guidSession+"&XMIN="+xmin+"&XMAX="+xmax+"&YMIN="+ymin+"&YMAX="+ymax+"&PixelsIMGX="+sizeX+"&PixelsIMGY="+sizeY+"&TXTXMLListaIDFeaturesDaSelezionare='"+xmlSelezione+"'&TXTXMLListaLayers=" +xmlLayer+"&TXTDateRequest="+gloDataMappa+"&dataora="+thisdate;
    if (usaScalimetro == "SI")
        xmlurl += "&SCALIMETER=SI";
    else
        xmlurl += "&SCALIMETER=NO";
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_DrawProject',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);
    return getImgUrldaXML();
}
//Crea la struttura XML per passarlo alle funzioni del WS
function getXMLLayerAttivi(guidSession)
{
    /*
    var xmlLayer='';
    var strLayerAttivi='';
    var arrLayerAttivi;
    strLayerAttivi=tree1.getAllChecked();
    arrLayerAttivi=strLayerAttivi.split(",");
    xmlLayer='<layers>';
    for (i=0;i<arrLayerAttivi.length;i++)
        if (arrLayerAttivi[i] != "") xmlLayer=xmlLayer+"<layer IDFramework='"+arrLayerAttivi[i]+"' visible='True'></layer>";
    xmlLayer=xmlLayer+'</layers>';
    return xmlLayer;
    */
    /*
    //AGO
    if (strLayerAttiviGLO == '')
        strLayerAttiviGLO = settavisono("0",1);
    return strLayerAttiviGLO;
    //AGO
    */
   if ((strLayerAttiviGLO != '') && (strCodaLayerCheck == ''))
        //Nessun cambiamento nella visibilità dei layer
        return strLayerAttiviGLO;
    
   if ((strLayerAttiviGLO == '') && (strCodaLayerCheck == ''))
        //Richiamo la funzione con 0,1 per ottenere l'elenco dei layer attivi iniziali
        strCodaLayerCheck='0,1';
    
    
        
   var xmlurl='';
   var xmltemp='';
   var arrtmp;
   var arrtmp2;
   
   arrtmp=strCodaLayerCheck.split(";");
   
   xmltemp='<themes>';
   for (var i=0;i<arrtmp.length;i++)
   {
        arrtmp2=arrtmp[i].split(",");
        xmltemp+="<theme TXTIdItem='"+arrtmp2[0]+"' state='"+arrtmp2[1]+"' />";
   }

   xmltemp+='</themes>';
    
   xmlurl=gdManagerWS+'FW_SetVisibleORNotVisibleOnSessionThemesMULTI?GUIDSession=' + guidSession + '&totOperations=' + xmltemp + '&Formato='+gloFormatoXmlLayer;
   var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
   xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_SetVisibleORNotVisibleOnSessionThemesMULTI',urlpara); 
   pubxml = ripulisciXml(xxx);
   strLayerAttiviGLO=pubxml;
   
   return pubxml;
}

	
function ZoomSelezioneAll(xmin,ymin,xmax,ymax)
{
    //globalXmlSelezione=getXMLSelezioneALL();
    //myMap1.zoomExtent(xmin,ymin,xmax,ymax);
    var p_perc=0.20;
    var wx     = xmax - xmin;
    var wx_new = wx * p_perc;
    var kx     = (wx_new - wx) / 2;
    var wy     = ymax - ymin;
    var wy_new = wy * p_perc;
    var ky     = (wy_new - wy) / 2;
    globalXmlSelezione=getXMLSelezioneALL();
    //myMap1.zoomExtent(xmin,ymin,xmax,ymax);
    //myMap1.zoomExtent(xmin + kx,  ymin + ky,xmax - kx, ymax - ky);
    if (xmin == xmax)
        //Se faccio lo zoom su un punto imposto lo zoom a una scala minima
        myMap1.zoomExtent(xmin + kx,  ymin + ky,xmax - kx, ymax - ky,zoomMinimo);
    else
        myMap1.zoomExtent(xmin + kx,  ymin + ky,xmax - kx, ymax - ky);
    
}
function ZoomSelezioneSingolo(xmin,ymin,xmax,ymax,idFeature)
{

    IDFeatureSelezionata=idFeature;
    var p_perc=0.30;
    var wx     = xmax - xmin;
    var wx_new = wx * p_perc;
    var kx     = (wx_new - wx) / 2;
    var wy     = ymax - ymin;
    var wy_new = wy * p_perc;
    var ky     = (wy_new - wy) / 2;


    globalXmlSelezione=getXMLSelezioneSingolo();
    //myMap1.zoomExtent(xmin,ymin,xmax,ymax);
    if (xmin == xmax)
        //Se faccio lo zoom su un punto imposto lo zoom a una scala minima
        myMap1.zoomExtent(xmin + kx,  ymin + ky,xmax - kx, ymax - ky,zoomMinimo);
    else
        myMap1.zoomExtent(xmin + kx,  ymin + ky,xmax - kx, ymax - ky);
    
}

function ZoomExtent(xmin,ymin,xmax,ymax)
{
   //alert(xmin+'   '+ymin+'  '+xmax+'   '+ymax);
   myMap1.zoomExtent(xmin ,  ymin ,xmax , ymax );
}

function ZoomLast()
{
    var str='';
    //xmin+' '+ymin+' '+xmax+' '+ymax;
    if (arrBackZoom.length <= 1)
        return true;
        
    str=arrBackZoom.pop();
    str=arrBackZoom.pop();
    
    var extArray=str.split(" ");
        
    //alert(str);
    ZoomExtent(parseFloat(extArray[0]) ,parseFloat(extArray[1]),parseFloat(extArray[2]) , parseFloat(extArray[3]) );
}

//Creo la struttura xml da passare alla funzione DrawProject
function getXMLSelezioneSingolo()
{
    var xmlSel='';
    //<featuresTosel IDFramework='"+ActiveLayerIndex+"'><cond nameField='LABEL' valueField='Venaria'/></featuresTosel >
    if ((IDFeatureSelezionata != '') && (ActiveLayerIndex != 0))
        //xmlSel="<featuresTosel IDFramework='"+ActiveLayerIndex+"'><cond nameField='"+CampoFeatureSelezionata+"' valueField='"+IDFeatureSelezionata+"'/></featuresTosel>";
		xmlSel="<rfeaturesTosel IDFramework='"+ActiveLayerIndex+"'>"+CampoFeatureSelezionata+"~"+IDFeatureSelezionata+"</rfeaturesTosel>";
    	
	return xmlSel;
}
//Creo la struttura xml da passare alla funzione DrawProject
function getXMLSelezioneALL()
{
    var xmlSel='';
    var arrSel;
    var intNElements;
    //<featuresTosel IDFramework='"+ActiveLayerIndex+"'><cond nameField='LABEL' valueField='Venaria'/></featuresTosel >
    if (IDALLFeatureSelezionate != '')
    {
        arrSel=IDALLFeatureSelezionate.split(",");
        //xmlSel="<featuresTosel IDFramework='"+ActiveLayerIndex+"'>";
        xmlSel="<rfeaturesTosel IDFramework='"+ActiveLayerIndex+"'>";
        for (intNElements = 0;intNElements < arrSel.length ; intNElements++){
            //xmlSel +="<cond nameField='"+CampoFeatureSelezionata+"' valueField='"+arrSel[intNElements]+"'/>";
            if (intNElements == 0)
				xmlSel +=CampoFeatureSelezionata+'~'+arrSel[intNElements];
			else
				xmlSel +="|"+CampoFeatureSelezionata+'~'+arrSel[intNElements];
			
        }
        //xmlSel+="</featuresTosel>";
        xmlSel+="</rfeaturesTosel>";
    }
    else
        //xmlSel="<featuresTosel ></featuresTosel>";
        xmlSel="<rfeaturesTosel ></rfeaturesTosel>";
    return xmlSel;
}
function AggiungiSelezione(idFeature)
{
    if (IDALLFeatureSelezionate == "" )
        IDALLFeatureSelezionate= idFeature;
    else
        IDALLFeatureSelezionate += "," + idFeature;
        
    if (document.getElementById("txtIdSelezione"))
    	document.getElementById("txtIdSelezione").value=IDALLFeatureSelezionate;
}
//identifica
function doIdentifyPunto(xmappa,ymappa,idTema)
{
    var xmin=0;
    var xmax=0;
    var ymin=0;
    var ymax=0;
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    
    goPopup();
    
    if ((idTema == '' ) || (idTema == -1)) return false;
    //Calcolo un rettangolo di dimensione minima per identificarlo
    xmin=parseInt(xmappa)-myMap1.wPixel2real(5);
    ymin=parseInt(ymappa)-myMap1.hPixel2real(5);
    xmax=parseInt(xmappa)+myMap1.wPixel2real(5);
    ymax=parseInt(ymappa)+myMap1.hPixel2real(5);
    var thisdate=getDataUnivoca();
    xmlurl=gdManagerWS+"FW_IdentifyByRectOnTheme?GUIDSession="+guidSession+"&XMINRECT="+xmin+"&XMAXRECT="+xmax+"&YMINRECT="+ymin+"&YMAXRECT="+ymax+"&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFramework="+idTema+"&dataora="+thisdate+"&tooltip=&whichtooltip=&TXTListaPuntiPerIdentify=&TXTListaPuntiPerIdentifyBufferSize=";

    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    gloUrlUltimaIdentify=urlpara;
    gloTipoUltimaIdentify='FW_IdentifyByRectOnTheme';
    
    if (attrWindowMode == 1)
    {
        xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByRectOnTheme',urlpara); 
        pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
        viewXMLLog(pubxml);
    }
    else
    { /*
        if (useAttribWindow == true)
        {
            pubxml='';
            // 
            var nomeDiv="risultDiv"+ Math.random();
            new popUp(attrWinX,attrWinY,attrWinDimX,attrWinDimY,nomeDiv , "/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnTheme&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames , "","", "white", "black", " normal 12px verdana","Risultati" , "#3A6EA5", "white", "#dddddd", "gray", "black", false, true, true, true, false,attrWindowMode);
            setCookie('ris_ambiti', "/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnTheme&exp="+enableExport+"&"+urlpara, 864000);
            showbox(nomeDiv);         
        }
        else
        {
            //Uso l'iframe che deve esistere nella finestra della mappa
            window.frames['ifattr'].document.location.href="/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnThemeMULTI&exp="+enableExport+"&"+urlpara;
        }
        */
        
        var urlattrib = "/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnTheme&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames;

        if (useAttribWindow == true)
        {
            pubxml='';

            var nomeDiv= "attributi111";
            
            if (document.getElementById(nomeDiv + "_c") != null) {
				
				
				var newDiv = document.createElement("div");
				newDiv.innerHTML = '<iframe id="ifattr' + GLOattributiID + '" name="ifattr' + GLOattributiID + '" frameborder="0" style="height:100px; width:'+ attrWinDimX +'px;" src="'+ urlattrib +'" ></iframe>';				
				
				document.getElementById(nomeDiv + "_c").appendChild(newDiv);
				
				GLOattributiID = GLOattributiID + 1;
            }            
            else {
				new popUp(attrWinX,attrWinY,attrWinDimX,attrWinDimY,nomeDiv , urlattrib , "",'<div><iframe id="ifattr' + GLOattributiID + '" name="ifattr' + GLOattributiID + '" frameborder="0" style="height:100px; width:'+ attrWinDimX +'px;" src="'+ urlattrib +'" ></iframe></div>', "white", "black", " normal 12px verdana","Risultati" , "#3A6EA5", "white", "#dddddd", "gray", "black", false, true, true, true, false,1);
				GLOattributiID = 1;				
            }
            
            GLOattributiID = GLOattributiID + 1;
            showbox(nomeDiv);         
        }
        else
        {
            //Uso l'iframe che deve esistere nella finestra della mappa
			var newDiv = document.createElement("div");
			
			newDiv.innerHTML = '<iframe id="ifattr' + GLOattributiID + '" name="ifattr' + GLOattributiID + '" frameborder="0" style="height:100px; width:'+ LarghezzaMappa +'px;" src="'+ urlattrib +'" ></iframe>';				
				
			document.getElementById("attributi").appendChild(newDiv);
			
			GLOattributiID = GLOattributiID + 1;
		}    
    }
    
    try
    {
      onIdentify(pubxml);
    }
    catch(e)
    {}
    finally
    {}
    
}
function getIdFeature(xmappa,ymappa,idTema,campo)
{
    var xmin=0;
    var xmax=0;
    var ymin=0;
    var ymax=0;
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var retstr='';
    var ret;
    
    if (campo == '')
        campo='OBJECTID';
        
 // 
    
    if ((idTema == '' ) || (idTema == -1)) return false;
    //Calcolo un rettangolo di dimensione minima per identificarlo
    xmin=parseInt(xmappa)-myMap1.wPixel2real(5);
    ymin=parseInt(ymappa)-myMap1.hPixel2real(5);
    xmax=parseInt(xmappa)+myMap1.wPixel2real(5);
    ymax=parseInt(ymappa)+myMap1.hPixel2real(5);
    var thisdate=getDataUnivoca();
    xmlurl=gdManagerWS+"FW_IdentifyByRectOnTheme?GUIDSession="+guidSession+"&XMINRECT="+xmin+"&XMAXRECT="+xmax+"&YMINRECT="+ymin+"&YMAXRECT="+ymax+"&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFramework="+idTema+"&dataora="+thisdate+"&tooltip=&whichtooltip=&TXTListaPuntiPerIdentify=&TXTListaPuntiPerIdentifyBufferSize=";
    //var xmltmp;
    //xmltmp=gdManagerWS+"FW_IdentifyByRectOnThemeMULTI?GUIDSession="+guidSession+"&XMINRECT="+xmin+"&XMAXRECT="+xmax+"&YMINRECT="+ymin+"&YMAXRECT="+ymax+"&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFrameworksLIST=&dataora="+thisdate+"&tooltip=&whichtooltip=&TXTListaPuntiPerIdentify=&TXTListaPuntiPerIdentifyBufferSize=";
    //alert(xmltmp);

    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    gloUrlUltimaIdentify=urlpara;
    gloTipoUltimaIdentify='FW_IdentifyByRectOnTheme';
    
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByRectOnTheme',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);
    
    ret=getArrayValori(pubxml,campo);
    
    for (var i=0;i<ret.length;i++)
    {
        if (retstr != "")
            retstr+=";";
        retstr+=ret[i];    
    }
    
    return retstr;
}
//identifica con drilldown
function doIdentifyPuntoMulti(xmappa,ymappa,idTemi)
{
    var xmin=0;
    var xmax=0;
    var ymin=0;
    var ymax=0;
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    
	goPopup();

    
    
    //Calcolo un rettangolo di dimensione minima per identificarlo
    xmin=parseInt(xmappa)-myMap1.wPixel2real(5);
    ymin=parseInt(ymappa)-myMap1.hPixel2real(5);
    xmax=parseInt(xmappa)+myMap1.wPixel2real(5);
    ymax=parseInt(ymappa)+myMap1.hPixel2real(5);
    var thisdate=getDataUnivoca();
    xmlurl=gdManagerWS+"FW_IdentifyByRectOnThemeMULTI?GUIDSession="+guidSession+"&XMINRECT="+xmin+"&XMAXRECT="+xmax+"&YMINRECT="+ymin+"&YMAXRECT="+ymax+"&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFrameworksLIST=&dataora="+thisdate+"&tooltip=&whichtooltip=&TXTListaPuntiPerIdentify=&TXTListaPuntiPerIdentifyBufferSize=&TXTIDGroupLayers="+ActiveGroupIndex;


    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    gloUrlUltimaIdentify=urlpara;
    gloTipoUltimaIdentify='FW_IdentifyByRectOnThemeMULTI';
    
    if (attrWindowMode == 1)
    {
        xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByRectOnThemeMULTI',urlpara); 
        pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
        viewXMLLog(pubxml);
        //Visualizzo in un IFRAME il risultato della richiesta di identify
        //window.frames['datiframe'].document.location.href=xmlurl;
        //VisualizzaAttributi(pubxml);
    }
    else
    {
        if (useAttribWindow == true)
        {
            pubxml='';
            // 
            var nomeDiv="risultDiv"+ Math.random();
            new popUp(attrWinX,attrWinY,attrWinDimX,attrWinDimY,nomeDiv , "/gdproxy/attribmulti.aspx?comando=FW_IdentifyByRectOnThemeMULTI&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames , "","", "white", "black", " normal 12px verdana","Risultati" , "#3A6EA5", "white", "#dddddd", "gray", "black", false, true, true, true, false,attrWindowMode);
            showbox(nomeDiv);         
        }
        else
        {
            //Uso l'iframe che deve esistere nella finestra della mappa
            window.frames['ifattr'].document.location.href="/gdproxy/attribmulti.aspx?comando=FW_IdentifyByRectOnThemeMULTI&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames;
        }
    }
    try
    {
      onIdentify(pubxml);
    }
    catch(e)
    {}
    finally
    {}
    
}
//identifica
function doIdentifyBox(xmin,ymin,xmax,ymax,idTema)
{
	
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var thisdate=getDataUnivoca();
    if ((idTema == '' ) || (idTema == -1)) return false;
    
    xmlurl=gdManagerWS+"FW_IdentifyByRectOnTheme?GUIDSession="+guidSession+"&XMINRECT="+xmin+"&XMAXRECT="+xmax+"&YMINRECT="+ymin+"&YMAXRECT="+ymax+"&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFramework="+idTema+"&dataora="+thisdate+"&tooltip=&whichtooltip=&TXTListaPuntiPerIdentify="+globalCoordinateSelezione+"&TXTListaPuntiPerIdentifyBufferSize=";
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    gloUrlUltimaIdentify=urlpara;
    gloTipoUltimaIdentify='FW_IdentifyByRectOnTheme';
	
	goPopup();
    
    if (attrWindowMode == 1)
    {
        xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByRectOnTheme',urlpara); 
        pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
        viewXMLLog(pubxml);
        //Visualizzo in un IFRAME il risultato della richiesta di identify
        //window.frames['datiframe'].document.location.href=xmlurl;
        //VisualizzaAttributi(pubxml);
    }
    else
    {	
        var urlattrib = "/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnTheme&exp=" + enableExport + "&" + urlpara + "&hideAttr="+hideAttrNames;
        if (useAttribWindow == true)
        {
            pubxml='';

            var nomeDiv= "attributi000";
            
            if (document.getElementById(nomeDiv + "_c") != null) {
		
				var newDiv = document.createElement("div");
				newDiv.innerHTML = '<iframe id="ifattr' + GLOattributiID + '" name="ifattr' + GLOattributiID + '" frameborder="0" style="height:100px; width:'+ attrWinDimX +'px;" src="'+ urlattrib +'" ></iframe>';				
				
				document.getElementById(nomeDiv + "_c").appendChild(newDiv);
				
				GLOattributiID = GLOattributiID + 1;
            }            
            else {
				new popUp(attrWinX,attrWinY,attrWinDimX,attrWinDimY,nomeDiv , "/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnTheme&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames , "",'<div><iframe id="ifattr' + GLOattributiID + '" name="ifattr' + GLOattributiID + '" frameborder="0" style="height:100px; width:'+ attrWinDimX +'px;" src="'+ urlattrib +'" ></iframe></div>', "white", "black", " normal 12px verdana","Risultati" , "#3A6EA5", "white", "#dddddd", "gray", "black", false, true, true, true, false,1);
				GLOattributiID = 1;		
            }
            
            GLOattributiID = GLOattributiID + 1;
            showbox(nomeDiv);         
        }
        else
        {
            //Uso l'iframe che deve esistere nella finestra della mappa
			var newDiv = document.createElement("div");
			
			newDiv.innerHTML = '<iframe id="ifattr' + GLOattributiID + '" name="ifattr' + GLOattributiID + '" frameborder="0" style="height:100px; width:'+ LarghezzaMappa +'px;" src="'+ urlattrib +'" ></iframe>';				
				
			document.getElementById("attributi").appendChild(newDiv);
			
			GLOattributiID = GLOattributiID + 1;
		}    
    }
       
    try
    {
      onIdentify(pubxml);
    }
    catch(e)
    {}
    finally
    {}
   
}
function doIdentifyBoxMulti(xmin,ymin,xmax,ymax,idTemi)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0;
        
    var thisdate=getDataUnivoca();
    xmlurl=gdManagerWS+"FW_IdentifyByRectOnThemeMULTI?GUIDSession="+guidSession+"&XMINRECT="+xmin+"&XMAXRECT="+xmax+"&YMINRECT="+ymin+"&YMAXRECT="+ymax+"&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFrameworksLIST=&dataora="+thisdate+"&tooltip=&whichtooltip=&TXTListaPuntiPerIdentify=&TXTListaPuntiPerIdentifyBufferSize=&TXTIDGroupLayers="+ActiveGroupIndex;

    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    gloUrlUltimaIdentify=urlpara;
    gloTipoUltimaIdentify='FW_IdentifyByRectOnThemeMULTI';
    
    goPopup();

    if (attrWindowMode == 1)
    {
        xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByRectOnThemeMULTI',urlpara); 
        pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
        viewXMLLog(pubxml);
        //Visualizzo in un IFRAME il risultato della richiesta di identify
        //window.frames['datiframe'].document.location.href=xmlurl;
        //VisualizzaAttributi(pubxml);
    }
    else
    {
        if (useAttribWindow == true) {
            pubxml='';
            var nomeDiv="risultDiv"+ Math.random();
            new popUp(attrWinX,attrWinY,attrWinDimX,attrWinDimY,nomeDiv , "/gdproxy/attribmulti.aspx?comando=FW_IdentifyByRectOnThemeMULTI&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames , "","", "white", "black", " normal 12px verdana","Risultati" , "#3A6EA5", "white", "#dddddd", "gray", "black", false, true, true, true, false,attrWindowMode);
            showbox(nomeDiv);         
        }
        else {
            //Uso l'iframe che deve esistere nella finestra della mappa
            window.frames['ifattr'].document.location.href="/gdproxy/attribmulti.aspx?comando=FW_IdentifyByRectOnThemeMULTI&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames;
        }
    }
    
    try
    {
      onIdentify(pubxml);
    }
    catch(e)
    {}
    finally
    {}
    
}

//identifica
function doSelectBox(xmin,ymin,xmax,ymax,idTema)
{
	

    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var thisdate=getDataUnivoca();
    
   	goPopup();
        
    if ((idTema == '' ) || (idTema == -1)) return false;
    xmlurl=gdManagerWS+"FW_IdentifyByRectOnTheme?GUIDSession="+guidSession+"&XMINRECT="+xmin+"&XMAXRECT="+xmax+"&YMINRECT="+ymin+"&YMAXRECT="+ymax+"&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFramework="+idTema+"&dataora="+thisdate+"&tooltip=&whichtooltip=&TXTListaPuntiPerIdentify="+globalCoordinateSelezione+"&TXTListaPuntiPerIdentifyBufferSize=1";
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    gloUrlUltimaIdentify=urlpara;
    gloTipoUltimaIdentify='FW_IdentifyByRectOnTheme';
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByRectOnTheme',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);
    //Visualizzo in un IFRAME il risultato della richiesta di identify
    //window.frames['datiframe'].document.location.href=xmlurl;
    //VisualizzaAttributi(pubxml);

    try
    {
      onSelect(pubxml);
    }
    catch(e)
    {}
    finally
    {}
    
    nascondiPopup();
    
}
//Esegue una funzione di identificazione e restituisce l'XML dei dati
//a una funzione chiamata in callback
function doIdentifyBox_Callback(xmin,ymin,xmax,ymax,idTema,callbFunction)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var thisdate=getDataUnivoca();
    if ((idTema == '' ) || (idTema == -1)) return false;
    xmlurl=gdManagerWS+"FW_IdentifyByRectOnTheme?GUIDSession="+guidSession+"&XMINRECT="+xmin+"&XMAXRECT="+xmax+"&YMINRECT="+ymin+"&YMAXRECT="+ymax+"&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFramework="+idTema+"&dataora="+thisdate+"&tooltip=&whichtooltip=&TXTListaPuntiPerIdentify=&TXTListaPuntiPerIdentifyBufferSize=";
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    gloUrlUltimaIdentify=urlpara;
    gloTipoUltimaIdentify='FW_IdentifyByRectOnTheme';
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByRectOnTheme',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
	callbFunction(pubxml);
    return true;
	
}
//identifica
function doIdentifyPoly(arrX,arrY,idTema)
{
    var i=0;
    var TXTListaPuntiPerIdentify='';

	goPopup();
    
    if (arrX != null)
    {
        for (i=0;i<arrX.length;i++) {
            //alert(arrX[i]);
            if ( i != 0 )
                TXTListaPuntiPerIdentify+=";";
            TXTListaPuntiPerIdentify+=arrX[i]+" "+arrY[i];
        }

        if (arrX.length >0)
            TXTListaPuntiPerIdentify+=";"+arrX[0]+" "+arrY[0];
    }
    else

    
	
    //alert(TXTListaPuntiPerIdentify);
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var thisdate=getDataUnivoca();
    if ((idTema == '' ) || (idTema == -1)) return false;
    xmlurl=gdManagerWS+"FW_IdentifyByRectOnTheme?GUIDSession="+guidSession+"&XMINRECT=&XMAXRECT=&YMINRECT=&YMAXRECT=&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFramework="+idTema+"&dataora="+thisdate+"&tooltip=&whichtooltip=&TXTListaPuntiPerIdentify="+TXTListaPuntiPerIdentify+"&TXTListaPuntiPerIdentifyBufferSize=0";
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    gloUrlUltimaIdentify=urlpara;
    gloTipoUltimaIdentify='FW_IdentifyByRectOnTheme';

    
    if (attrWindowMode == 1)
    {
        xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByRectOnTheme',urlpara); 
        pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
        viewXMLLog(pubxml);
        //Visualizzo in un IFRAME il risultato della richiesta di identify
        //window.frames['datiframe'].document.location.href=xmlurl;
        //VisualizzaAttributi(pubxml);
    }
    else
    {
        if (useAttribWindow == true)
        {
            pubxml='';
            // 
            var nomeDiv="risultDiv"+ Math.random();
            
            new popUp(attrWinX,attrWinY,attrWinDimX,attrWinDimY,nomeDiv , "/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnTheme&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames , "","", "white", "black", " normal 12px verdana","Risultati" , "#3A6EA5", "white", "#dddddd", "gray", "black", false, true, true, true, false,attrWindowMode);
            showbox(nomeDiv);         
        }
        else
        {
            //Uso l'iframe che deve esistere nella finestra della mappa
            window.frames['ifattr'].document.location.href="/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnTheme&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames;
        }  
    }


    try
    {
      onIdentify(pubxml);
    }
    catch(e)
    {}
    finally
    {}

}
//identifica
function doIdentifyGeometria(coorSelezione,idTema,bufferSize)
{
	
    var i=0;
    var TXTListaPuntiPerIdentify='';
    if (globalCoordinateSelezione != '')
        TXTListaPuntiPerIdentify=coorSelezione;
    
    //Se richiamato con idTema=-1 allora recupera l'attuale tema di analisi
    if ((idTema == '') || (idTema == -1))
        idTema=LayerTmp;
    
    //alert(TXTListaPuntiPerIdentify);
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var thisdate=getDataUnivoca();

	goPopup();

    if ((idTema == '' ) || (idTema == -1)) return false;
    xmlurl=gdManagerWS+"FW_IdentifyByRectOnTheme?GUIDSession="+guidSession+"&XMINRECT=&XMAXRECT=&YMINRECT=&YMAXRECT=&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFramework="+idTema+"&dataora="+thisdate+"&tooltip=&whichtooltip=&TXTListaPuntiPerIdentify="+TXTListaPuntiPerIdentify+"&TXTListaPuntiPerIdentifyBufferSize="+bufferSize;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    gloUrlUltimaIdentify=urlpara;
    gloTipoUltimaIdentify='FW_IdentifyByRectOnTheme';

    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByRectOnTheme',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    
    
    if (attrWindowMode == 1)
    {
        xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByRectOnTheme',urlpara); 
        pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
        viewXMLLog(pubxml);
        //Visualizzo in un IFRAME il risultato della richiesta di identify
        //window.frames['datiframe'].document.location.href=xmlurl;
        //VisualizzaAttributi(pubxml);
    }
    else
    {
        if (useAttribWindow == true)
        {
            pubxml='';
            // 
            var nomeDiv="risultDiv"+ Math.random();
            new popUp(attrWinX,attrWinY,attrWinDimX,attrWinDimY,nomeDiv , "/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnTheme&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames , "","", "white", "black", " normal 12px verdana","Risultati" , "#3A6EA5", "white", "#dddddd", "gray", "black", false, true, true, true, false,attrWindowMode);
            showbox(nomeDiv);         
        }
        else
        {
            //Uso l'iframe che deve esistere nella finestra della mappa
            window.frames['ifattr'].document.location.href="/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnTheme&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames;
        }  
    }
    
    //Visualizzo in un IFRAME il risultato della richiesta di identify
    //window.frames['datiframe'].document.location.href=xmlurl;
    //VisualizzaAttributi(pubxml);
    
    
    try
    {
      onIdentify(pubxml);
    }
    catch(e)
    {}
    finally
    {}

}
//identifica - Luca Modifiche
function doSelectPoly(arrX,arrY,idTema)
{
	
    var i=0;
    var TXTListaPuntiPerIdentify='';

    for (i=0;i<arrX.length;i++) {
        //alert(arrX[i]);
        if ( i != 0 )
            TXTListaPuntiPerIdentify+=";";
        TXTListaPuntiPerIdentify+=arrX[i]+" "+arrY[i];
    }
    TXTListaPuntiPerIdentify+=";"+arrX[0]+" "+arrY[0];
	
	goPopup();
	
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var thisdate=getDataUnivoca();
    if ((idTema == '' ) || (idTema == -1)) return false;

	xmlurl=gdManagerWS+"FW_IdentifyByRectOnTheme?GUIDSession="+guidSession+"&XMINRECT=&XMAXRECT=&YMINRECT=&YMAXRECT=&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFramework="+idTema+"&dataora="+thisdate+"&tooltip=&whichtooltip=&TXTListaPuntiPerIdentify="+TXTListaPuntiPerIdentify+"&TXTListaPuntiPerIdentifyBufferSize=0";

    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,10000000);
    gloUrlUltimaIdentify=urlpara;
    gloTipoUltimaIdentify='FW_IdentifyByRectOnTheme';

    if (attrWindowMode == 1)
    {		
		xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByRectOnTheme',urlpara); 
		pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
		viewXMLLog(pubxml);

    }
    else
    {
				
        if (useAttribWindow == true)
        {
					
            pubxml='';
            var nomeDiv="risultDiv"+ Math.random();
            new popUp(attrWinX,attrWinY,attrWinDimX,attrWinDimY,nomeDiv , "/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnTheme&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames , "","", "white", "black", " normal 12px verdana","Risultati" , "#3A6EA5", "white", "#dddddd", "gray", "black", false, true, true, true, false,attrWindowMode);
            showbox(nomeDiv);         
        }
        else
        {					
            //Uso l'iframe che deve esistere nella finestra della mappa
            window.frames['ifattr'].document.location.href="/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnTheme&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames;
        }
    }
    
    myMap1.ClearPunti();


    try
    {
      onIdentify(pubxml);
    }
    catch(e)
    {}
    finally
    {}
}

//identifica
function getAreaPoly(arrX,arrY)
{

    var i=0;
    var TXTListaPunti='';

    for (i=0;i<arrX.length;i++) {
        //alert(arrX[i]);
        if ( i != 0 )
            TXTListaPunti+=";";
        TXTListaPunti+=arrX[i]+" "+arrY[i];
    }
     
    //Aggiungo di nuovo il primo punto per chiudere il poligono
    TXTListaPunti+=";"+arrX[0]+" "+arrY[0];
   
    //alert(TXTListaPunti);
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var thisdate=getDataUnivoca();
    xmlurl=gdManagerWS+"FW_GetAreaOrPerimeterPoligonOrLine?GUIDSession="+guidSession+"&tipo=AREA&TXTListaPuntiLineaOPoligono="+TXTListaPunti+"&dataora="+thisdate;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetAreaOrPerimeterPoligonOrLine',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);
    //alert(pubxml);
    //Visualizzo in un IFRAME il risultato della richiesta di identify
    //window.frames['datiframe'].document.location.href=xmlurl;
    //Visualizza(pubxml);
    return pubxml;
}

//Luca
function getPerimetroPoly(arrX,arrY)
{

    var i=0;
    var TXTListaPunti='';

    for (i=0;i<arrX.length;i++) {
        //alert(arrX[i]);
        if ( i != 0 )
            TXTListaPunti+=";";
        TXTListaPunti+=arrX[i]+" "+arrY[i];
    }
     
    //Aggiungo di nuovo il primo punto per chiudere il poligono
    TXTListaPunti+=";"+arrX[0]+" "+arrY[0];
   
    //alert(TXTListaPunti);
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var thisdate=getDataUnivoca();
    xmlurl=gdManagerWS+"FW_GetAreaOrPerimeterPoligonOrLine?GUIDSession="+guidSession+"&tipo=PERIMETRO&TXTListaPuntiLineaOPoligono="+TXTListaPunti+"&dataora="+thisdate;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetAreaOrPerimeterPoligonOrLine',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);
    //alert(pubxml);
    //Visualizzo in un IFRAME il risultato della richiesta di identify
    //window.frames['datiframe'].document.location.href=xmlurl;
    //Visualizza(pubxml);
    return pubxml;
}

function DisegnaCirconferenza(xx,yy,r)
{
    var thisdate=getDataUnivoca();

    xmlurl=gdManagerWS+"FW_BufferCreate?GUIDSession="+guidSession+"&TXTListaPuntiPerIdentify="+xx+" "+yy+"&TXTListaPuntiPerIdentifyBufferSize="+Math.ceil(r);
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    window.frames['protoframe'].getWSAjaxRequestWrapper('FW_BufferCreate',urlpara,null); 
    BufferCreated = true;
}

function CancellaBuffer()
{
    var thisdate=getDataUnivoca();

    xmlurl=gdManagerWS+"FW_BufferCreate?GUIDSession="+guidSession+"&TXTListaPuntiPerIdentify="+1+" "+1+"&TXTListaPuntiPerIdentifyBufferSize="+Math.ceil(1);
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    window.frames['protoframe'].getWSAjaxRequestWrapper('FW_BufferCreate',urlpara,null); 
    BufferCreated = false;
}
//identifica
function IdentifyCirconferenza(idFramework, xx,yy,r)
{
	
    var xmin=0;
    var xmax=0;
    var ymin=0;
    var ymax=0;
    var xmlurl='';
    var xmlLayer='';
    var i=0
    
   	goPopup();
    

    var thisdate=getDataUnivoca();

    xmlurl=gdManagerWS+"FW_IdentifyByRectOnTheme?GUIDSession="+guidSession+"&XMINRECT="+round2(mapXmin)+"&XMAXRECT="+round2(mapXmax)+"&YMINRECT="+round2(mapYmin)+"&YMAXRECT="+round2(mapYmax)+"&CURXMIN="+round2(mapXmin)+"&CURXMAX="+round2(mapXmax)+"&CURYMIN="+round2(mapYmin)+"&CURYMAX="+round2(mapYmax)+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFramework="+idFramework+"&dataora="+thisdate+"&tooltip=&whichtooltip=&TXTListaPuntiPerIdentify="+xx+" "+yy+"&TXTListaPuntiPerIdentifyBufferSize="+Math.ceil(r);
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
 
    gloUrlUltimaIdentify=urlpara;
    gloTipoUltimaIdentify='FW_IdentifyByRectOnTheme';
    
    if (attrWindowMode == 1)
    {
        xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByRectOnTheme',urlpara); 
        pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
        viewXMLLog(pubxml);
   }
    else
    {
        if (useAttribWindow == true)
        {
            pubxml='';
            var nomeDiv="risultDiv"+ Math.random();
            new popUp(attrWinX,attrWinY,attrWinDimX,attrWinDimY,nomeDiv , "/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnTheme&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames , "","", "white", "black", " normal 12px verdana","Risultati" , "#3A6EA5", "white", "#dddddd", "gray", "black", false, true, true, true, false,attrWindowMode);
            showbox(nomeDiv);         
        }
        else
        {
            //Uso l'iframe che deve esistere nella finestra della mappa
            window.frames['ifattr'].document.location.href="/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnTheme&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames;
        }   
    }
    myMap1.redraw();

}
function DisegnaBufferLinea(arrX,arrY,bufferSize)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var TXTListaPuntiPerIdentify='';
      
    for (i=0;i<arrX.length;i++) {
        if ( i != 0 )
            TXTListaPuntiPerIdentify+=";";
        TXTListaPuntiPerIdentify+=arrX[i]+" "+arrY[i];
    }
    
    var thisdate=getDataUnivoca();
    xmlurl=gdManagerWS+"FW_BufferCreate?GUIDSession="+guidSession+"&TXTListaPuntiPerIdentify="+TXTListaPuntiPerIdentify+"&TXTListaPuntiPerIdentifyBufferSize="+bufferSize;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    window.frames['protoframe'].getWSAjaxRequestWrapper('FW_BufferCreate',urlpara,null); 
    BufferCreated = true;
    return true;
    
}

function DisegnaBufferArea(arrX,arrY,bufferSize)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var TXTListaPuntiPerIdentify='';
      
    for (i=0;i<arrX.length;i++) {
        if ( i != 0 )
            TXTListaPuntiPerIdentify+=";";
        TXTListaPuntiPerIdentify+=arrX[i]+" "+arrY[i];
    }
    TXTListaPuntiPerIdentify+=";";
    TXTListaPuntiPerIdentify+=arrX[0]+" "+arrY[0];
    
    var thisdate=getDataUnivoca();
    xmlurl=gdManagerWS+"FW_BufferCreate?GUIDSession="+guidSession+"&TXTListaPuntiPerIdentify="+TXTListaPuntiPerIdentify+"&TXTListaPuntiPerIdentifyBufferSize="+bufferSize;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    window.frames['protoframe'].getWSAjaxRequestWrapper('FW_BufferCreate',urlpara,null); 
    BufferCreated = true;
    return true;
    
}

function DisegnaBufferPoligono(strXY,bufferSize)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var TXTListaPuntiPerIdentify='';

    // 
    
    TXTListaPuntiPerIdentify=strXY;
    //alert(strXY);
    
    var thisdate=getDataUnivoca();
    xmlurl=gdManagerWS+"FW_BufferCreate?GUIDSession="+guidSession+"&TXTListaPuntiPerIdentify="+TXTListaPuntiPerIdentify+"&TXTListaPuntiPerIdentifyBufferSize="+bufferSize;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    window.frames['protoframe'].getWSAjaxRequestWrapper_asincrono('FW_BufferCreate',urlpara,null); 

    return true;
    
}
function IdentifyBufferLinea(idFramework,arrX,arrY,bufferSize)
{
    var xmin=0;
    var xmax=0;
    var ymin=0;
    var ymax=0;
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var TXTListaPuntiPerIdentify='';

	goPopup();

    for (i=0;i<arrX.length;i++) {
        //alert(arrX[i]);
        if ( i != 0 )
            TXTListaPuntiPerIdentify+=";";
        TXTListaPuntiPerIdentify+=arrX[i]+" "+arrY[i];
    }
    
    var thisdate=getDataUnivoca();
	//alert(gdManagerWS+"FW_IdentifyByRectOnTheme?GUIDSession="+guidSession+"&XMINRECT="+xmin+"&XMAXRECT="+xmax+"&YMINRECT="+ymin+"&YMAXRECT="+ymax+"&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFramework="+ID_FW+"&dataora="+thisdate+"&tooltip=&whichtooltip=&TXTListaPuntiPerIdentify="+xx+" "+yy+"&TXTListaPuntiPerIdentifyBufferSize="+r);

    //Disegno Buffer
    /*
    xmlurl=gdManagerWS+"FW_BufferCreate?GUIDSession="+guidSession+"&TXTListaPuntiPerIdentify="+TXTListaPuntiPerIdentify+"&TXTListaPuntiPerIdentifyBufferSize="+bufferSize;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);


    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_BufferCreate',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);

    return true;
    */
    
    xmlurl=gdManagerWS+"FW_IdentifyByRectOnTheme?GUIDSession="+guidSession+"&XMINRECT="+round2(mapXmin)+"&XMAXRECT="+round2(mapXmax)+"&YMINRECT="+round2(mapYmin)+"&YMAXRECT="+round2(mapYmax)+"&CURXMIN="+round2(mapXmin)+"&CURXMAX="+round2(mapXmax)+"&CURYMIN="+round2(mapYmin)+"&CURYMAX="+round2(mapYmax)+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFramework="+idFramework+"&dataora="+thisdate+"&tooltip=&whichtooltip=&TXTListaPuntiPerIdentify="+TXTListaPuntiPerIdentify+"&TXTListaPuntiPerIdentifyBufferSize="+bufferSize;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    /*
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByRectOnTheme',urlpara); 
    
	pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);
    //Visualizzo in un IFRAME il risultato della richiesta di identify
    //window.frames['datiframe'].document.location.href=xmlurl;
   // alert(pubxml);
	onIdentify(pubxml);
    */
    gloUrlUltimaIdentify=urlpara;
    gloTipoUltimaIdentify='FW_IdentifyByRectOnTheme';
    
    if (attrWindowMode == 1)
    {
        xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByRectOnTheme',urlpara); 
        pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
        viewXMLLog(pubxml);
        //Visualizzo in un IFRAME il risultato della richiesta di identify
        //window.frames['datiframe'].document.location.href=xmlurl;
        //VisualizzaAttributi(pubxml);
    }
    else
    {
        if (useAttribWindow == true)
        {
            pubxml='';
            // 
            var nomeDiv="risultDiv"+ Math.random();
            new popUp(attrWinX,attrWinY,attrWinDimX,attrWinDimY,nomeDiv , "/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnTheme&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames , "","", "white", "black", " normal 12px verdana","Risultati" , "#3A6EA5", "white", "#dddddd", "gray", "black", false, true, true, true, false,attrWindowMode);
            showbox(nomeDiv);         
        }
        else
        {
            //Uso l'iframe che deve esistere nella finestra della mappa
            window.frames['ifattr'].document.location.href="/gdproxy/attrib.aspx?comando=FW_IdentifyByRectOnTheme&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames;
        }   
    }
    myMap1.redraw();
}
//attiva il disegno dei tooltip
function getTooltip(xmin,ymin,xmax,ymax,idTema,rifMap)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var thisdate=getDataUnivoca();
    if ((idTema == '' ) || (idTema == -1)) return false;
    xmlurl=gdManagerWS+"FW_IdentifyByRectOnTheme?GUIDSession="+guidSession+"&XMINRECT="+xmin+"&XMAXRECT="+xmax+"&YMINRECT="+ymin+"&YMAXRECT="+ymax+"&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFramework="+idTema+"&dataora="+thisdate+"&tooltip=TRUE&whichtooltip=&TXTListaPuntiPerIdentify=&TXTListaPuntiPerIdentifyBufferSize=";
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByRectOnTheme',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    //rifMap.addPunto(xmin,ymin,"TIP");
    VisualizzaTip(pubxml,rifMap)
}
//Tooltip Dinamici
function getSingleTooltip(x,y,idTema)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var thisdate=getDataUnivoca();
    if ((idTema == '' ) || (idTema == -1)) return false;
    xmlurl=gdManagerWS+"FW_IdentifyByRectOnTheme?GUIDSession="+guidSession+"&XMINRECT="+x+"&XMAXRECT="+x+"&YMINRECT="+y+"&YMAXRECT="+y+"&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFramework="+idTema+"&dataora="+thisdate+"&tooltip=TRUE&whichtooltip=&TXTListaPuntiPerIdentify=&TXTListaPuntiPerIdentifyBufferSize=";
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    window.frames['protoframe'].getWSAjaxRequestWrapper_asincrono('FW_IdentifyByRectOnTheme',urlpara,visualizzaSingoloTooltip); 
    
}
function getSingleTooltipTimer(idTema)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var thisdate=getDataUnivoca();
    
    if ((gloXTooltip != 0) && (gloYTooltip != 0) && (gloXTooltip_last != gloXTooltip) && (gloYTooltip_last != gloYTooltip))
    {
        if ((idTema == '' ) || (idTema == -1)) return false;
        xmlurl=gdManagerWS+"FW_IdentifyByRectOnTheme?GUIDSession="+guidSession+"&XMINRECT="+gloXTooltip+"&XMAXRECT="+gloXTooltip+"&YMINRECT="+gloYTooltip+"&YMAXRECT="+gloYTooltip+"&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFramework="+idTema+"&dataora="+thisdate+"&tooltip=TRUE&whichtooltip=&TXTListaPuntiPerIdentify=&TXTListaPuntiPerIdentifyBufferSize=";
        var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
        var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
        window.frames['protoframe'].getWSAjaxRequestWrapper_asincrono('FW_IdentifyByRectOnTheme',urlpara,visualizzaSingoloTooltip);
        gloXTooltip_last=gloXTooltip;
        gloYTooltip_last=gloYTooltip;
    }
    if (enableTooltipContinui == true)
        setTimeout("getSingleTooltipTimer('"+idTema+"');",1000);    
    else
    {
        if (azione == 'tooltip')
            setTimeout("getSingleTooltipTimer('"+ActiveLayerIndex+"');",1000);    
    }

    
}
function visualizzaSingoloTooltip(myxml)
{

    var strvalori='';
    
    myxml = replaceExtChars(myxml.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    
    var objDom = Sarissa.getDomDocument();
    var serializer = new XMLSerializer(); 
    objDom = (new DOMParser()).parseFromString(myxml, "text/xml");
    
    var aliasNodeList = objDom.selectNodes("/attributes/aliases/alias");
    var RigheNodeList = objDom.selectNodes("/attributes/riga");
    
    for (intNElements = 0;intNElements < RigheNodeList.length ; intNElements++){
    
        var rigaN=objDom.selectNodes("/attributes/riga["+(intNElements+1)+"]/att");
        
        strvalori='';
        //Ciclo sui valori degli attributi di questa riga
        if (rigaN.length>0)
        {
            for (var i=0; i<rigaN.length; i++)
            {
                if (strvalori == '')
                    strvalori=aliasNodeList.item(i).getAttribute("aliasname")+'='+rigaN.item(i).getAttribute("value")
                else
                    strvalori+='<br />'+aliasNodeList.item(i).getAttribute("aliasname")+'='+rigaN.item(i).getAttribute("value")
            }
        }
        
    }
    
    if (strvalori != '')
    {
        //myMap1.addPunto(gloXTooltip,gloYTooltip,"campoTip","valoreTip");
        if (document.getElementById('txtTooltip'))
        {   
              var p_obj=document.getElementById('txtTooltip');
              p_obj.innerHTML=strvalori; 
              p_obj.style.position    = 'absolute';
              p_obj.style.left    = DL_GetElementLeft(document.getElementById('mappa'))+myMap1.xReal2pixel(gloXTooltip)+'px';
              p_obj.style.top     = DL_GetElementTop(document.getElementById('mappa'))+myMap1.yReal2pixel(gloYTooltip)+'px';
              p_obj.style.display = 'block';        
              p_obj.style.visibility = 'visible';        
        }
    }
    else
    {
      nascondiToolTip();
    }
}
function nascondiToolTip()
{
    if (document.getElementById('txtTooltip'))
    {   
          var p_obj=document.getElementById('txtTooltip');
          
          p_obj.innerHTML='';
          p_obj.style.display = 'none';
          
    }   
}
//Richiesta coordinate di una feature dato ID
//Usa : FW_ThemeGetFeatureCoords
function GetCoordinateByCampiById(idFramework,campoId,valoreId)
{
    var xmlSelezione='';

	xmlSelezione='<attrvalues>';
	
	xmlSelezione += "<att name='"+campoId+"' valore='"+valoreId+"' />";
	
	xmlSelezione += "</attrvalues>";
	
	var xml='';
	
	xml= GetCoordinateByCampi (idFramework,xmlSelezione);
	
    xml=xml.replace('\n',"");
    
	return xml;
	
}
//Richiesta coordinate di una feature dato un elenco di campi e valori
//XMLFieldsValues ha la forma «attrvalues»«att name='campo1' valore='valorecampo1' /» «att name='campon' valore='valorecampon' /» «/attrvalues»
//Usa : FW_ThemeGetFeatureCoords
function GetCoordinateByCampi(idFramework,xmlCampiSelezione)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0
    
    var thisdate=getDataUnivoca();
	//alert(gdManagerWS+"FW_IdentifyByRectOnTheme?GUIDSession="+guidSession+"&XMINRECT="+xmin+"&XMAXRECT="+xmax+"&YMINRECT="+ymin+"&YMAXRECT="+ymax+"&CURXMIN="+mapXmin+"&CURXMAX="+mapXmax+"&CURYMIN="+mapYmin+"&CURYMAX="+mapYmax+"&PixDimeWIN_X="+LarghezzaMappa+"&PixDimeWIN_Y="+AltezzaMappa+"&IDFramework="+ID_FW+"&dataora="+thisdate+"&tooltip=&whichtooltip=&TXTListaPuntiPerIdentify="+xx+" "+yy+"&TXTListaPuntiPerIdentifyBufferSize="+r);

    xmlurl=gdManagerWS+"FW_ThemeGetFeatureCoords?GUIDSession="+guidSession+"&IDFramework="+idFramework+"&dataora="+thisdate+"&XMLFieldsValues="+xmlCampiSelezione+"&XMIN="+limitXmin+"&XMAX="+limitXmax+"&YMIN="+limitYmin+"&YMAX="+limitYmax+"&PixelsIMGX="+LarghezzaMappa+"&PixelsIMGY="+AltezzaMappa;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_ThemeGetFeatureCoords',urlpara); 
    
    pubxml = ripulisciXml(xxx);

    pubxml=pubxml.replace("<coords>","");
    pubxml=pubxml.replace("</coords>","");
	viewXMLLog(pubxml);
    //Visualizzo in un IFRAME il risultato della richiesta di identify
    //window.frames['datiframe'].document.location.href=xmlurl;
	//alert(pubxml);
	
	return pubxml;
}
//Visualizza gli attributi in una lista <select />
function VisualizzaAttributi(xml)
{
    var xml;
    var numNodi=0;
    var intLoop;
    ClearList(document.gdmanager.lista_attributi);
    var objDom = new XMLDoc(xml);
    if (objDom.docNode)
    {
        //find the first TAG1 node
        var domTree = objDom.docNode;
        //Prendo il noto "riga"
        var firstTag1Node = domTree.getElements("riga");
        //Se ci sono delle righe
        if (firstTag1Node.length > 0 ) 
        {
            
            for (intNElements = 0;intNElements < firstTag1Node.length ; intNElements++){
                //Prendo i nodi "att"
                var firstTag2Node = firstTag1Node[intNElements].getElements("att");
                numNodi=firstTag2Node.length;
                for (intLoop = 0; intLoop < numNodi; intLoop++) {
                    //document.gdmanager.response.value=document.gdmanager.response.value+'||'+firstTag1Node[intLoop].getAttribute("name");
                    //AddToList(document.gdmanager.attributi,firstTag2Node[intLoop].getText(),firstTag2Node[intLoop].getText());
                    AddToList(document.gdmanager.lista_attributi,firstTag2Node[intLoop].getAttribute("name"),firstTag2Node[intLoop].getAttribute("name") +" : " + firstTag2Node[intLoop].getAttribute("value"));
                }
                AddToList(document.gdmanager.lista_attributi,"----------------------","-");
            }
        }
    }
    return true;
}
//Visualizza gli attributi in una tabella
function VisualizzaAttributiTabella_ClassicDom(xml,chiudiTabella)
{
    var xml;
    var numNodi=0;
    var intLoop;
    var str='';
    var extArray;
    var strsel='';
    var strvalori='';
    var strzoom='';
    var winMappa='';
    var strAllId='';
    var trovatoLink=false;
    var trovatoRisultati=false;
    var st='';
    
    if (chiudiTabella == null) chiudiTabella=false;
    /*
    var xml2 = xml;
    xml2 = xml2.replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>","<?xml version=\"1.0\" encoding=\"utf-8\"?><?xml-stylesheet type=\"text/xsl\" href=\"http://gis-test/web%5FVenaria%5Fgdmanager_mscross/xsl/attributes.xsl\"?>");
    //var xml2 = xml.replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>","");
    var Win2 = open("","Dati","width=575,height=250,scrollbars=yes,resizable=yes");
    Win2.document.writeln(xml2);
    Win2.document.close();
    return true;
    */    
    document.body.style.cursor = "wait";
    if (useAttribWindow)
        winMappa ='opener';
    else
        winMappa='parent';
    AzzeraVariabiliSelezione();
    
    if (useAttribWindow)
    {
        var Win1 = open("","DataWindow","width=575,height=250,scrollbars=yes,resizable=yes");
        Win1.document.writeln("Ricerca dati ..........");
    }
    var objDom = new XMLDoc(xml);
    if (objDom.docNode)
    {
        //find the first TAG1 node
        var domTree = objDom.docNode;
        //Prendo il nodo "aliases" per il titolo della tabella
        var firstTag1Node = domTree.getElements("aliases");
        //Se ci sono delle righe
        if (firstTag1Node.length > 0 ) 
        {
            str +='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
            str += '<html xmlns="http://www.w3.org/1999/xhtml">';
	        str +='<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
		    str +='<link media="screen" href="css/Info.css" type="text/css" rel="stylesheet" />';
		    str +='<title>Risultati</title>';
            str +='	</head> <body >';
            if ((enableExport == true) && (gloUrlUltimaIdentify != '') )
            	//Aggiungo un link di download csv
            	str+='<a href="/gdproxy/exportcsv.aspx?comando='+gloTipoUltimaIdentify+'&'+gloUrlUltimaIdentify+'" target="_blank" >Export CSV</a>&nbsp;|&nbsp;';;
            extArray=domTree.getAttribute("estensione").split(" ");
			//str +="<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#eee8aa\" border=\"0\" style=\"position:absolute; top:0px;\">";
            //str +="<tr><td class=\"titoloAttrib\" colspan=\"2\" width=\"100%\" align=\"center\" height=\"10\" ><b>Risultati</b></td></tr>";
            //str +="</table>"; 
            if (useAttribWindow)
                str += '<a href="#" onclick="javascript:window.close();" >Chiudi</a>&nbsp;|&nbsp;';
            //else
            //    str += '<a href="#" onclick="javascript:document.location.href=\'vuoto.asp\'; return false;" >Chiudi</a>&nbsp;|&nbsp;';

            str += '<a href="#" onclick="javascript:'+winMappa+'.ZoomSelezioneAll('+extArray[0]+','+extArray[1]+','+extArray[2]+','+extArray[3]+'); return false;" >Zoom Tutti</a>';
            str += '&nbsp;|&nbsp;<a href="#" onclick="javascript:'+winMappa+'.globalXmlSelezione=\'\'; '+winMappa+'.myMap1.redraw(); return false;" >Cancella Selezione</a>';
            //str+='<div id="tabellaAttr" name="tabellaAttr" style="width:500px; height:200px; overflow:auto;">';            
            str+='<table class="tabellaAttrib" cellpadding="0" cellspacing="0" >';            
            for (intNElements = 0;intNElements < firstTag1Node.length ; intNElements++){
                //Prendo i nodi "att"
                var firstTag2Node = firstTag1Node[intNElements].getElements("alias");
                numNodi=firstTag2Node.length;
                str=str + '<tr>';
                //str+='<th>Zoom</th>';
                str+='<th class="titoloAttrib" >Sel</th>';
                for (intLoop = 0; intLoop < numNodi; intLoop++) {
                    if (elencoCampiIdNascosti.indexOf(firstTag2Node[intLoop].getAttribute("name")) == -1){
                        str=str + '<th class="titoloAttrib" >'
                        //document.gdmanager.response.value=document.gdmanager.response.value+'||'+firstTag1Node[intLoop].getAttribute("name");
                        //AddToList(document.gdmanager.attributi,firstTag2Node[intLoop].getText(),firstTag2Node[intLoop].getText());
                        //AddToList(document.gdmanager.lista_attributi,firstTag2Node[intLoop].getAttribute("name"),firstTag2Node[intLoop].getAttribute("name") +" : " + firstTag2Node[intLoop].getAttribute("value"));
                        str=str + firstTag2Node[intLoop].getAttribute("aliasname");
                        str=str + '</th>';
                    }
                }
                str=str + '</th>';
            }
            //Prendo il nodo "riga" per il titolo della tabella
            var firstTag3Node = domTree.getElements("riga");
            //Se ci sono delle righe
            if (firstTag3Node.length > 0 ) 
            {
                trovatoRisultati=true;
                for (intNElements = 0;intNElements < firstTag3Node.length ; intNElements++){
                    //Prendo i nodi "att"
                    var firstTag4Node = firstTag3Node[intNElements].getElements("att");
                    numNodi=firstTag4Node.length;
                    if (numNodi > 0 )
                    {
                        str=str + '<tr>';
                        strsel='';
                        strvalori='';
                        if (firstTag3Node[intNElements].getAttribute("estensione"))
                        {
                            extArray=firstTag3Node[intNElements].getAttribute("estensione").split(" ");
                            strzoom='<td class="valoreAttrib" ><a href="#" onclick="javascript:'+winMappa+'.ZoomSelezioneSingolo('+extArray[0]+','+extArray[1]+','+extArray[2]+','+extArray[3]+',\'\'); return false;" alt="Zoom" ><img border="0" height="20" src="' + GLOPubblicatiComuni + '/images/lente.gif"/> </a></td>';
                            //str+='<td><a href="#" onclick="javascript:myMap1.zoomExtent('+extArray[0]+','+extArray[1]+','+extArray[2]+','+extArray[3]+');+'\');" >Zoom</a></td>';
                        }
                        else
                            strzoom='<td class="valoreAttrib" >&nbsp;</td>';
                        IDFeatureSelezionata='';
                        for (intLoop = 0; intLoop < numNodi; intLoop++) {
                            if (elencoCampiIdNascosti.indexOf(firstTag2Node[intLoop].getAttribute("name")) == -1)
                                {
                                strvalori+='<td class="valoreAttrib" >';
                                //document.gdmanager.response.value=document.gdmanager.response.value+'||'+firstTag1Node[intLoop].getAttribute("name");
                                //AddToList(document.gdmanager.attributi,firstTag2Node[intLoop].getText(),firstTag2Node[intLoop].getText());
                                //AddToList(document.gdmanager.lista_attributi,firstTag2Node[intLoop].getAttribute("name"),firstTag2Node[intLoop].getAttribute("name") +" : " + firstTag2Node[intLoop].getAttribute("value"));
                                //MCS : Gestione dei campi di tipo Link 
                                //La Struttura può contenere uno o + link :
                                //Link Singolo: <att name="doc" value="Edificio.htm" link="yes" /> 
                                //Link Multiplo:
                                /*                             
                                 * - <att name="formula_1" value="" link="yes">
                                 * - <urls>
                                 *   <url>004.pdf</url> 
                                 *   <url>004.html</url> 
                                 *   </urls>
                                 *   </att>
                                 */
                                if (firstTag4Node[intLoop].getAttribute("link") ) 
                                {
                                    if (firstTag4Node[intLoop].getAttribute("link") == "yes" ) 
                                    {
                                       
                                        if (firstTag4Node[intLoop].getAttribute("value") != "" ) 
                                        {
                                            //Link Singolo
                                            st=firstTag4Node[intLoop].getAttribute("value");
                                            //alert(st);
                                            st=st.replace(/amp;/g,"");
                                            strvalori+= '<a href="' + st + '" target="_blank">link</a>';
                                            //Se c'è una riga e esite un link lo apro
                                            if ((linkAutomatico == true) && (firstTag3Node.length == 1)) {  
                                                trovatoLink=true;
                                                var link='';
                                                link=firstTag4Node[intLoop].getAttribute("value");
                                                link=link.replace("&amp;amp;","&");
                                                window.open(link,"_blank");
                                            }                                         
                                        }
                                        else
                                        {
                                            //Link MUltiplo
                                            /*                             
                                             * - <att name="formula_1" value="" link="yes">
                                             * - <urls>
                                             *   <url>004.pdf</url> 
                                             *   <url>004.html</url> 
                                             *   </urls>
                                             *   </att>
                                             */
                                            //TODO:Gestire generazione link multipli
                                            //strvalori+= '<a href="' + firstTag4Node[intLoop].getAttribute("value")+ '">link</a>';
                                            //Prendo i nodi "urls"
                                            var firstTag5Node = firstTag4Node[intLoop].getElements("urls");
                                            if (firstTag5Node.length >0 )
                                            {
                                                //Prendo i nodi "url"
                                                var firstTag6Node = firstTag5Node[0].getElements("url");
                                                for (intLoopUrl = 0; intLoopUrl < firstTag6Node.length; intLoopUrl++) {
                                                    if (intLoopUrl != 0)
                                                        strvalori += ',';
                                                    strvalori+= firstTag6Node[intLoopUrl].children[0].content;
                                                }
                                            }
                                        }
                                    }
                                
                                else
                                    {
                                        if (firstTag4Node[intLoop].getAttribute("value") != "" ) 
                                            strvalori+=firstTag4Node[intLoop].getAttribute("value");
                                        else
                                            strvalori+= "&nbsp;"; 
                                    }                            
                                }
                                else
                                {
                                    if (firstTag4Node[intLoop].getAttribute("value") != "" ) 
                                        strvalori+=firstTag4Node[intLoop].getAttribute("value");
                                    else
                                        strvalori+= "&nbsp;"; 
                                }
                                strvalori+='</td>';    
                            }
                            else {
                            	strsel='<td class="valoreAttrib" >';
                            	//alert(GetCoordinateByCampiById(ActiveLayerIndex,'FID',firstTag4Node[intLoop].getAttribute("value")));
                                if (firstTag2Node[intLoop].getAttribute("aliasname") == 'FeatureID')
                                {
                                    strsel+='<a href="#" onclick="javascript:'+winMappa+'.ZoomSelezioneSingolo('+extArray[0]+','+extArray[1]+','+extArray[2]+','+extArray[3]+',\''+firstTag4Node[intLoop].getAttribute("value")+'\'); return false;" ><img border="0" height="20" src="' + GLOPubblicatiComuni + '/images/lente.gif"/></a>';
                                    if (CampoFeatureSelezionata == "" ) CampoFeatureSelezionata=firstTag2Node[intLoop].getAttribute("aliasname");
                                    AggiungiSelezione(firstTag4Node[intLoop].getAttribute("value"));
                                }
                                if (firstTag2Node[intLoop].getAttribute("aliasname") == 'OBJECTID')
                                {
                                    strsel+='<a href="#" onclick="javascript:'+winMappa+'.ZoomSelezioneSingolo('+extArray[0]+','+extArray[1]+','+extArray[2]+','+extArray[3]+',\''+firstTag4Node[intLoop].getAttribute("value")+'\'); return false;" ><img border="0" height="20" src="' + GLOPubblicatiComuni + '/images/lente.gif"/></a>';
                                    if (CampoFeatureSelezionata == "" ) CampoFeatureSelezionata=firstTag2Node[intLoop].getAttribute("aliasname");
                                    AggiungiSelezione(firstTag4Node[intLoop].getAttribute("value"));
                                }
                                if (firstTag2Node[intLoop].getAttribute("aliasname") == '#ID#')
                                {
                                    strsel+='<a href="#" onclick="javascript:'+winMappa+'.ZoomSelezioneSingolo('+extArray[0]+','+extArray[1]+','+extArray[2]+','+extArray[3]+',\''+firstTag4Node[intLoop].getAttribute("value")+'\'); return false;" ><img border="0" height="20" src="' + GLOPubblicatiComuni + '/images/lente.gif"/></a>';
                                    if (CampoFeatureSelezionata == "" ) CampoFeatureSelezionata=firstTag2Node[intLoop].getAttribute("aliasname");
                                    AggiungiSelezione(firstTag4Node[intLoop].getAttribute("value"));
                                }
                                if (firstTag2Node[intLoop].getAttribute("aliasname") == 'IDXSHAPE')
                                {
                                    strsel+='<a href="#" onclick="javascript:'+winMappa+'.ZoomSelezioneSingolo('+extArray[0]+','+extArray[1]+','+extArray[2]+','+extArray[3]+',\''+firstTag4Node[intLoop].getAttribute("value")+'\'); return false;" ><img border="0" height="20" src="' + GLOPubblicatiComuni + '/images/lente.gif"/></a>';
                                    if (CampoFeatureSelezionata == "" ) CampoFeatureSelezionata=firstTag2Node[intLoop].getAttribute("aliasname");
                                    AggiungiSelezione(firstTag4Node[intLoop].getAttribute("value"));
                                }
                                if (firstTag2Node[intLoop].getAttribute("aliasname") == 'FID')
                                {
                                    strsel+='<a href="#" onclick="javascript:'+winMappa+'.ZoomSelezioneSingolo('+extArray[0]+','+extArray[1]+','+extArray[2]+','+extArray[3]+',\''+firstTag4Node[intLoop].getAttribute("value")+'\'); return false;" ><img border="0" height="20" src="' + GLOPubblicatiComuni + '/images/lente.gif"/></a>';
                                    if (CampoFeatureSelezionata == "" ) CampoFeatureSelezionata=firstTag2Node[intLoop].getAttribute("aliasname");
                                    AggiungiSelezione(firstTag4Node[intLoop].getAttribute("value"));
                                }
                                strsel+='<a href="#" onclick="javascript:alert('+winMappa+'.GetCoordinateByCampiById(\''+ActiveLayerIndex+'\',\''+firstTag2Node[intLoop].getAttribute("aliasname")+'\',\''+firstTag4Node[intLoop].getAttribute("value")+'\')); return false;" ><img border="0"  src="' + GLOPubblicatiComuni + '/images/selezionaOggetto.gif"/></a>';
                                
								strsel+='</td>';                              
                            }
                            
                        }
                        //GEOWEB
                        //str+=strzoom;
                        if (strsel != '')
                            str+=strsel;
                        else
                            str+='<td>&nbsp;</td>';
                        str+=strvalori;                            
                        str=str + '</tr>';
                    }
                    else
                        str='Nessun risultato';
                }
                //Se c'è una riga sola faccio lo zoom automatico all'oggetto trovato
                //zoomAutomatico
                if ( (zoomAutomatico == true) && (firstTag3Node.length == 1)) {
                        //alert('1 risultato');
                        if (firstTag3Node[0].getAttribute("estensione") != '')
                        {
                            extArray=firstTag3Node[0].getAttribute("estensione").split(" ");
                            setTimeout('ZoomSelezioneSingolo('+extArray[0]+','+extArray[1]+','+extArray[2]+','+extArray[3]+',\'\');',500);
                        }
                        
                }
                if ( (zoomAutomatico == true) && (firstTag3Node.length > 1)) {
                    if (domTree.getAttribute("estensione") != '')
                    {
                        extArray=domTree.getAttribute("estensione").split(" ");

                        setTimeout('ZoomSelezioneAll('+extArray[0]+','+extArray[1]+','+extArray[2]+','+extArray[3]+',\'\');',500);
                    }
                        
                }                
        }
        str=str + '</table>';
        //str=str + '</div>';
        str=str + '</body></html>';
        //document.getElementById("attributi").innerHTML=str;
        }
    }
    if (useAttribWindow)
    {
        Win1.document.close(); 
        Win1.document.open();     
        Win1.document.writeln(str);
        Win1.document.close();
    } 
    else
    {
        //alert(firstTag3Node.length);
        if (trovatoLink){
            if (chiudiTabellaAttribSeEsisteLink == false)
            {
                //Se ci sono risultati
                if ((trovatoRisultati == true) && (chiudiTabella == false))
                {
                    if (firstTag3Node.length >0)
                    {
                        var nomeDiv="risultDiv"+ Math.random();
                        new popUp(attrWinX,attrWinY,attrWinDimX,attrWinDimY,nomeDiv , "", "",str, "white", "black", " normal 12px verdana","Risultati" , "#3A6EA5", "white", "#dddddd", "gray", "black", false, true, true, true, false);
                        showbox(nomeDiv);
                    }
                }
                //Vecchia Versione con IFRAME nella pagina della mappa
                //var ifx = window.frames['ifattr']; //document.frames["ifattr"];
                //ifx.document.body.innerHTML=str;  
            }
        }
        else
        {
            if ((trovatoRisultati == true) && (chiudiTabella == false))
            {
                //Se ci sono risultati
                if (firstTag3Node.length >0)
                {
                    var nomeDiv="risultDiv"+ Math.random();
                    new popUp(attrWinX,attrWinY,attrWinDimX,attrWinDimY,nomeDiv , "", "",str, "white", "black", " normal 12px verdana","Risultati" , "#3A6EA5", "white", "#dddddd", "gray", "black", false, true, true, true, false);
                    showbox(nomeDiv);
                }
            }
        }
    } 
    
    if (trovatoRisultati == false)
    {
        alert('Nessun risultato.');
    }
    /*
    extArray=domTree.getAttribute("estensione").split(" ");
    ZoomSelezioneAll(extArray[0],extArray[1],extArray[2],extArray[3]); 
    */
    document.body.style.cursor = "default";
    return true;
}
//Estrae dalla selezione l'ID delle feature selezionate per evidenziarle
//e richiedere le coordinate
function CaricaDatiSelezione(xml)
{
    var xml;
    var numNodi=0;
    var intLoop;
    var str='';
    var extArray;
    var strsel='';
    var strvalori='';
    var strzoom='';
    var winMappa='';
    var strAllId='';
    var trovatoLink=false;
    var trovatoRisultati=false;
    var st='';
    
    AzzeraVariabiliSelezione();
    var objDom = new XMLDoc(xml);
    if (objDom.docNode)
    {
        //find the first TAG1 node
        var domTree = objDom.docNode;
        //Prendo il nodo "aliases" per il titolo della tabella
        var firstTag1Node = domTree.getElements("aliases");
        //Se ci sono delle righe
        if (firstTag1Node.length > 0 ) 
        {
            for (intNElements = 0;intNElements < firstTag1Node.length ; intNElements++){
                //Prendo i nodi "att"
                var firstTag2Node = firstTag1Node[intNElements].getElements("alias");
                numNodi=firstTag2Node.length;
                for (intLoop = 0; intLoop < numNodi; intLoop++) {
                    if (elencoCampiIdNascosti.indexOf(firstTag2Node[intLoop].getAttribute("name")) == -1){
                    }
                }
            }
            //Prendo il nodo "riga" per il titolo della tabella
            var firstTag3Node = domTree.getElements("riga");
            //Se ci sono delle righe
            if (firstTag3Node.length > 0 ) 
            {
                trovatoRisultati=true;
                for (intNElements = 0;intNElements < firstTag3Node.length ; intNElements++){
                    //Prendo i nodi "att"
                    var firstTag4Node = firstTag3Node[intNElements].getElements("att");
                    numNodi=firstTag4Node.length;
                    if (numNodi > 0 )
                    {
                        strsel='';
                        strvalori='';
                        IDFeatureSelezionata='';
                        for (intLoop = 0; intLoop < numNodi; intLoop++) {
                            if (elencoCampiIdNascosti.indexOf(firstTag2Node[intLoop].getAttribute("name")) != -1)
                                {
                                if (firstTag2Node[intLoop].getAttribute("aliasname") == 'FeatureID')
                                {
                                    if (CampoFeatureSelezionata == "" ) CampoFeatureSelezionata=firstTag2Node[intLoop].getAttribute("aliasname");
                                    AggiungiSelezione(firstTag4Node[intLoop].getAttribute("value"));
                                }
                                if (firstTag2Node[intLoop].getAttribute("aliasname") == 'OBJECTID')
                                {
                                    if (CampoFeatureSelezionata == "" ) CampoFeatureSelezionata=firstTag2Node[intLoop].getAttribute("aliasname");
                                    AggiungiSelezione(firstTag4Node[intLoop].getAttribute("value"));
                                }
                                if (firstTag2Node[intLoop].getAttribute("aliasname") == '#ID#')
                                {
                                    if (CampoFeatureSelezionata == "" ) CampoFeatureSelezionata=firstTag2Node[intLoop].getAttribute("aliasname");
                                    AggiungiSelezione(firstTag4Node[intLoop].getAttribute("value"));
                                }
                                if (firstTag2Node[intLoop].getAttribute("aliasname") == 'IDXSHAPE')
                                {
                                    if (CampoFeatureSelezionata == "" ) CampoFeatureSelezionata=firstTag2Node[intLoop].getAttribute("aliasname");
                                    AggiungiSelezione(firstTag4Node[intLoop].getAttribute("value"));
                                }
                                if (firstTag2Node[intLoop].getAttribute("aliasname") == 'FID')
                                {
                                    if (CampoFeatureSelezionata == "" ) CampoFeatureSelezionata=firstTag2Node[intLoop].getAttribute("aliasname");
                                    AggiungiSelezione(firstTag4Node[intLoop].getAttribute("value"));
                                }
                            }
                            if (CampoFeatureSelezionata != "" )
                            	IDFeatureSelezionata=firstTag4Node[intLoop].getAttribute("value");
                            	
                        }
		                //Se ho trovato un ID chiedo le coordinate al server
		                
                        //if (CampoFeatureSelezionata != "" )
			            //    globalCoordinateSelezione+=GetCoordinateByCampiById(ActiveLayerIndex,CampoFeatureSelezionata,IDFeatureSelezionata)+";";
                        
                    }
                    else
                        str='Nessun risultato';

                }
                
        	}
        }
    }

	//alert(globalCoordinateSelezione);
    document.body.style.cursor = "default";
    return true;
}
//Luca - Temi CDU
function getElencoTemiAnalisiPRGCDU(idSession,campoIdFt,fromdate,todate)
{

    var xmlurl='';
    xmlurl=gdManagerWS+'FW_GetElencoTemiAnalisiPRGCDU';
    var urlhost = xmlurl;
    var urlpara = 'GUIDSession='+idSession+'&TXT_NomeCampoIdFetaure='+campoIdFt+'&TXT_FromDate='+fromdate+'&TXT_ToDate='+todate;
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetElencoTemiAnalisiPRGCDU',urlpara); 
    xml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(xml);
    var objDom = new XMLDoc(xml);
    var i=0;
    var listaTemi = new Array(2);
    listaTemi[1] = "";
    if (objDom.docNode) {
        var domTree = objDom.docNode;
        var firstTag1Node = domTree.getElements("tema");
        for(i=0;i<firstTag1Node.length;i++) 
        {
           if(firstTag1Node[i].getAttribute("temaanalisi") == 'True')
               listaTemi[0] = firstTag1Node[i].getAttribute("name");
           else 
           {
            if(listaTemi[1] != "")
                    listaTemi[1] = listaTemi[1] +'@@@@@@@@@@'+ firstTag1Node[i].getAttribute("name");
            else
                    listaTemi[1] = firstTag1Node[i].getAttribute("name");
            }}}

     return listaTemi;
} 

//Estrae un elenco di valori dai risultati in base all'attributo indicato
//Gli attributi possono essere più di uno, separati da ','
function getArrayValori(xml,campi)
{
    var xml;
    var arrValori=new Array();
    var arrCampi;
    var numNodi=0;
    var numCampi=0;
    var intLoop;
    var str='';
    var extArray;
    var strsel='';
    var strvalori='';
    var strzoom='';
    var winMappa='';
    var strAllId='';
    var trovatoLink=false;
    var trovatoRisultati=false;
    var st='';
    var stlog='';
    var inizio;
    var fine;
    
    arrCampi=campi.split(',');
    numCampi=arrCampi.length;
    
    
    
    document.body.style.cursor = "wait";
    CampoFeatureSelezionata='';

    inizio=new Date().getTime();
    //stlog+="inizio="+inizio;
   
    var objDom = Sarissa.getDomDocument();
    var serializer = new XMLSerializer(); 
    
    var objDom = (new DOMParser()).parseFromString(xml, "text/xml");
        
    var aliasNodeList = objDom.selectNodes("/attributes/aliases/alias");
    var RigheNodeList = objDom.selectNodes("/attributes/riga");
    
    for (intNElements = 0;intNElements < RigheNodeList.length ; intNElements++){
    
        var rigaN = objDom.selectNodes("/attributes/riga["+(intNElements+1)+"]/att");
        var coord = objDom.selectNodes("/attributes/riga["+(intNElements+1)+"]");
        
        var coords = coord.item(0).getAttribute("estensione").split(" ");
        
        if (coords.length != 4 ) 
            alert(coords.length);
        else {
            winCDUSelezioneFP.aggiungiCoordinate(coords[0],coords[1],coords[2],coords[3]);        
        }       
 
        strvalori='';
                            
        //Ciclo sui valori degli attributi di questa riga
        if (rigaN.length>0)
        {
            for (var i=0; i<rigaN.length; i++)
            {
                //Ciclo per vedere se il campo è tra quelli che è stato richiesto
                for (intLoopCampi = 0; intLoopCampi < numCampi; intLoopCampi++)
                {                        	
                    if (aliasNodeList.item(i).getAttribute("name").toUpperCase() == arrCampi[intLoopCampi].toUpperCase())
                    {
                        if (strvalori == '')
                            strvalori=rigaN.item(i).getAttribute("value")
                        else
                            strvalori+=','+rigaN.item(i).getAttribute("value")
                    }
                }
            }
        }
        
        if (strvalori != '')
            arrValori.push(strvalori);
        
        //alert(strvalori);


/*var objDom2 = Sarissa.getDomDocument();
        var serializer2 = new XMLSerializer(); 
        objDom2 = (new DOMParser()).parseFromString(RigheNodeList.item(intNElements).outerXML, "text/xml");
        alert(objDom2);
        */
    }
    
    fine=new Date().getTime();
    /*
    alert(inizio);
    alert(fine);
    alert(inizio-fine);
    */
    
/*
    if (objNodeList.length >0)
    {
            for (intLoop = 0;intLoop < objNodeList.length ; intLoop++)
            {
		        retList +=','+objNodeList.item(intLoop).getAttribute("name");
            }
    }
    
        //find the first TAG1 node
        var domTree = objDom.docNode;
        //Prendo il nodo "aliases" per il titolo della tabella
        var firstTag1Node = domTree.getElements("aliases");
        //Se ci sono delle righe
        if (firstTag1Node.length > 0 ) 
        {
            for (intNElements = 0;intNElements < firstTag1Node.length ; intNElements++){
                //Prendo i nodi "alias"
                var firstTag2Node = firstTag1Node[intNElements].getElements("alias");
            }
			//Prendo il nodo "riga" per il titolo della tabella
            var firstTag3Node = domTree.getElements("riga");
            //Se ci sono delle righe
            if (firstTag3Node.length > 0 ) 
            {
                trovatoRisultati=true;
                for (intNElements = 0;intNElements < firstTag3Node.length ; intNElements++){
                    //Prendo i nodi "att"
                    strvalori='';
                    var firstTag4Node = firstTag3Node[intNElements].getElements("att");
                    numNodi=firstTag4Node.length;
                    if (numNodi > 0 )
                    {
                        //Ciclo sui valori degli attributi di questa riga
                        for (intLoop = 0; intLoop < numNodi; intLoop++) {
                        	//Ciclo per vedere se il campo è tra quelli che è stato richiesto
                        	for (intLoopCampi = 0; intLoopCampi < numCampi; intLoopCampi++)
                        	{                        	
								if (firstTag2Node[intLoop].getAttribute("aliasname") == arrCampi[intLoopCampi])
	                        	{
									if (strvalori == '')
										strvalori=firstTag4Node[intLoop].getAttribute("value");
									else
										strvalori+=','+firstTag4Node[intLoop].getAttribute("value");
								}
							}
                        	

						}
						arrValori.push(strvalori);

                	}	
                
        		}
			}

        }
    }
    */
    document.body.style.cursor = "default";
    return arrValori;
    
}

//Visualizza i tooltip restituiti aggiungendoli sulla mappa 
function VisualizzaTip(xml,rifMap)
{
    var xml;
    var numNodi=0;
    var intLoop;
    var str='';
    var extArray;
    var strsel='';
    var strvalori='';
    var strzoom='';
    var campoTip='';
    var tipX=0;
    var tipY=0;
    var valoreTip='';
    /*
    var xml2 = xml;
    xml2 = xml2.replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>","<?xml version=\"1.0\" encoding=\"utf-8\"?><?xml-stylesheet type=\"text/xsl\" href=\"http://gis-test/web%5FVenaria%5Fgdmanager_mscross/xsl/attributes.xsl\"?>");
    //var xml2 = xml.replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>","");
    var Win2 = open("","Dati","width=575,height=250,scrollbars=yes,resizable=yes");
    Win2.document.writeln(xml2);
    Win2.document.close();
    return true;
    */    
    document.body.style.cursor = "wait";
    var objDom = new XMLDoc(xml);
    if (objDom.docNode)
    {
        //find the first TAG1 node
        var domTree = objDom.docNode;
        //Prendo il nodo "aliases" per il titolo della tabella
        var firstTag1Node = domTree.getElements("aliases");
        //Se ci sono delle righe
        if (firstTag1Node.length > 0 ) 
        {
            //Recupero il nome del campo del tooltip
            for (intNElements = 0;intNElements < firstTag1Node.length ; intNElements++){
                //Prendo i nodi "att"
                var firstTag2Node = firstTag1Node[intNElements].getElements("alias");
                numNodi=firstTag2Node.length;
                for (intLoop = 0; intLoop < numNodi; intLoop++) {
                    campoTip=firstTag2Node[intLoop].getAttribute("aliasname");
                }
            }
           //Prendo il nodo "riga" per il titolo della tabella
            var firstTag3Node = domTree.getElements("riga");
            //Se ci sono delle righe
            if (firstTag3Node.length > 0 ) 
            {
                for (intNElements = 0;intNElements < firstTag3Node.length ; intNElements++){
                    //Prendo i nodi "att"
                    var firstTag4Node = firstTag3Node[intNElements].getElements("att");
                    numNodi=firstTag4Node.length;
                    if (numNodi > 0 )
                    {
                        str=str + '<tr>';
                        strsel='';
                        strvalori='';
                        if (firstTag3Node[intNElements].getAttribute("estensione"))
                        {
                            extArray=firstTag3Node[intNElements].getAttribute("estensione").split(" ");
                            tipX=(parseInt(extArray[0])+parseInt(extArray[2]))/2;
                            tipY=(parseInt(extArray[1])+parseInt(extArray[3]))/2;
                        }
                        else
                        {
                            tipX=0;
                            tipY=0;
                        }
                        IDFeatureSelezionata='';
                        for (intLoop = 0; intLoop < numNodi; intLoop++) {
                            //document.gdmanager.response.value=document.gdmanager.response.value+'||'+firstTag1Node[intLoop].getAttribute("name");
                            //AddToList(document.gdmanager.attributi,firstTag2Node[intLoop].getText(),firstTag2Node[intLoop].getText());
                            //AddToList(document.gdmanager.lista_attributi,firstTag2Node[intLoop].getAttribute("name"),firstTag2Node[intLoop].getAttribute("name") +" : " + firstTag2Node[intLoop].getAttribute("value"));
                            //MCS : Gestione dei campi di tipo Link 
                            //La Struttura può contenere uno o + link :
                            //Link Singolo: <att name="doc" value="Edificio.htm" link="yes" /> 
                            //Link Multiplo:
                            /*                             
                             * - <att name="formula_1" value="" link="yes">
                             * - <urls>
                             *   <url>004.pdf</url> 
                             *   <url>004.html</url> 
                             *   </urls>
                             *   </att>
                             */
                            if (firstTag4Node[intLoop].getAttribute("link") ) 
                            {
                                if (firstTag4Node[intLoop].getAttribute("link") == "yes" ) 
                                {
                                    if (firstTag4Node[intLoop].getAttribute("value") != "" ) 
                                    {
                                        //Link Singolo
                                        valoreTip= '<a href="' + firstTag4Node[intLoop].getAttribute("value")+ '" target="_blank">link</a>';
                                    }
                                    else
                                    {
                                        //Link MUltiplo
                                        /*                             
                                         * - <att name="formula_1" value="" link="yes">
                                         * - <urls>
                                         *   <url>004.pdf</url> 
                                         *   <url>004.html</url> 
                                         *   </urls>
                                         *   </att>
                                         */
                                        //TODO:Gestire generazione link multipli
                                        //strvalori+= '<a href="' + firstTag4Node[intLoop].getAttribute("value")+ '">link</a>';
                                        //Prendo i nodi "urls"
                                        var firstTag5Node = firstTag4Node[intLoop].getElements("urls");
                                        if (firstTag5Node.length >0 )
                                        {
                                            //Prendo i nodi "url"
                                            var firstTag6Node = firstTag5Node[0].getElements("url");
                                            for (intLoopUrl = 0; intLoopUrl < firstTag6Node.length; intLoopUrl++) {
                                                if (intLoopUrl != 0)
                                                    valoreTip += ',';
                                                valoreTip+= firstTag6Node[intLoopUrl].children[0].content;
                                            }
                                        }
                                    }
                                }
                            else
                                {
                                    if (firstTag4Node[intLoop].getAttribute("value") != "" ) 
                                        valoreTip=firstTag4Node[intLoop].getAttribute("value");
                                    else
                                        valoreTip= "&nbsp;"; 
                                }                               
                            }
                            else
                            {
                            
                                if (firstTag4Node[intLoop].getAttribute("value") != "" ) 
                                    valoreTip=firstTag4Node[intLoop].getAttribute("value");
                                else
                                    valoreTip= "&nbsp;"; 
                            }                            
                        }
                    }
                    else
                        str='Nessun risultato';
                    rifMap.addPunto(tipX,tipY,campoTip,valoreTip);                
                }
        }
        }
    }
    document.body.style.cursor = "default";
    return true;
}
//Visualizza gli attributi in una lista <select />
function GeneraFinestraLegenda()
{
 var Win1 = open("","LegendaWindow","width=300,height=500,scrollbars=yes,resizable=yes");
 Win1.document.writeln(GeneraTabellaLegenda(opener,true));
 Win1.close;
}
//Visualizza gli attributi in una lista <select />
function GeneraTabellaLegenda(finestraTree,soloNodiVisibili)
{
    var xml;
    var numNodi=0;
    var intLoop;
    var pubpathimmagini='';
   
	if (gdManagerWrapper != '')
		{
			var remotepathimm = window.frames['protoframe'].getremoteadd();	
			xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetOutputTreeImagesDir','');
			pubpathimmagini = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
			pubpathimmagini = remotepathimm + pubpathimmagini.substring(pubpathimmagini.indexOf("?>")+2,100000) + "/";
		}
	else
		{
		  	xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetOutputTreeImagesDir','');
			pubpathimmagini = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
			pubpathimmagini = 'http://' + document.location.host + pubpathimmagini.substring(pubpathimmagini.indexOf("?>")+2,100000) + "/";
		}
		
    var urlpara = 'GUIDSession=' + finestraTree.guidSession;
    
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetXMLActiveProject',urlpara);
	pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));

    var objDom = Sarissa.getDomDocument();
    var serializer = new XMLSerializer(); 
    objDom = (new DOMParser()).parseFromString(pubxml, "text/xml");
    
    var objNodeList = objDom.selectNodes("/tree/item");

    strHtmlLegenda='';
    strLayerAttiviLegenda=finestraTree.strLayerAttiviGLO; //"," + finestraTree.tree1.getAllChecked(); //Il tree è nella finestra da cui questa funzione è chiamata
    strLayerAttiviLegenda +=","; //Accodo la , per poi fare semplicemente le ricerche dell'ID nella stringa
    
    if (objNodeList.length >0)
    {
        strHtmlLegenda ='<table class="TabellaLegenda" border="0" width="100%">';
        GeneraLegenda(objNodeList.item(0),pubpathimmagini,soloNodiVisibili);
        strHtmlLegenda +='</table>';

    }


	
    return strHtmlLegenda;
}

function GeneraLegenda(nodo,pubpathimmagini,soloNodiVisibili)
{
    var i=0;
     //Prendo il noto "riga"
    var objNodeList = nodo.selectNodes("item");
    
    //Verifico se devo mettere in legenda il nodo solo se è visibile
    if (soloNodiVisibili) 
    {
        if (nodo.getAttribute("id").charAt(0) == "T"){
        	//alert(strLayerAttiviLegenda+'...'+nodo.getAttribute("IDFramework"));
            if (strLayerAttiviLegenda.indexOf(""+nodo.getAttribute("IDFramework")+"-V") > 0) {
                strHtmlLegenda += '<tr><td class="CellaTema" colspan="2"><b>'+nodo.getAttribute("text")+'</b></td></tr>';
			}
            else
                return true;
 		}
   }
    else
        //Genero la legenda di tutti i temi
        if (nodo.getAttribute("id").charAt(0) == "T")
            strHtmlLegenda += '<tr><td class="CellaTema" colspan="2"><b>'+nodo.getAttribute("text")+'</b></td></tr>';
    if (nodo.getAttribute("id").charAt(0) == "L")
        strHtmlLegenda += '<tr><td class="ImmagineLegenda"><img src="'+pubpathimmagini+'/'+nodo.getAttribute("im0")+'" /></td><td class="VoceLegenda">'+nodo.getAttribute("text")+'</td></tr>';
	//Procedo ricorsivamente solo se il nodo attuale è visibile
    if (nodo.getAttribute("visible") == "true"){
	   //Se ci sono delle righe
	    if (objNodeList.length > 0 ) 
	    {
	        for (i = 0;i < objNodeList.length ; i++){
	            GeneraLegenda(objNodeList.item(i),pubpathimmagini,soloNodiVisibili);        
	        }
	    }	
	}

    return true;
}
function DisegnaTabella()
   {
    //Prendo il nodo "aliases" per il titolo della tabella
    var firstTag1Node = xml.getElementsByTagName("aliases");
    if (firstTag1Node.length > 0 ) 
        {
            str='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
            str += '<html xmlns="http://www.w3.org/1999/xhtml">';
	        str +='<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />';
		    str +='<link media="screen" href="css/Info.css" type="text/css" rel="stylesheet" />';
		    str +='<title><%=Application("TITOLO")%></title>';
            str +='	</head> <body >';
            str+='<table border="1" cellpadding="0" cellspacing="0" >';
            for (intNElements = 0;intNElements < firstTag1Node.length ; intNElements++){
                //Prendo i nodi "att"
                var firstTag2Node = firstTag1Node[intNElements].getElementsByTagName("alias");
                numNodi=firstTag2Node.length;
                str=str + '<tr>';
                str+='<th>Zoom</th>';
                for (intLoop = 0; intLoop < numNodi; intLoop++) {
                    str=str + '<th>'
                    //document.gdmanager.response.value=document.gdmanager.response.value+'||'+firstTag1Node[intLoop].getAttribute("name");
                    //AddToList(document.gdmanager.attributi,firstTag2Node[intLoop].getText(),firstTag2Node[intLoop].getText());
                    //AddToList(document.gdmanager.lista_attributi,firstTag2Node[intLoop].getAttribute("name"),firstTag2Node[intLoop].getAttribute("name") +" : " + firstTag2Node[intLoop].getAttribute("value"));
                    str=str + firstTag2Node[intLoop].getAttribute("aliasname");
                    str=str + '</td>';
                }
                str=str + '</th>';
            }
           //Prendo il nodo "riga" per il titolo della tabella
            var firstTag3Node = xml.getElementsByTagName("riga");
            //Se ci sono delle righe
            if (firstTag3Node.length > 0 ) 
            {
                for (intNElements = 0;intNElements < firstTag3Node.length ; intNElements++){
                    var firstTag4Node = firstTag3Node[intNElements].getElementsByTagName("att");
                    numNodi=firstTag4Node.length;
                    if (numNodi > 0 )
                    {
                        str=str + '<tr>';
                        var extArray;
                        extArray=firstTag3Node[intNElements].getAttribute("estensione").split(" ");
                        str+='<td><a href="#" onclick="javascript:opener.myMap1.zoomExtent('+extArray[0]+','+extArray[1]+','+extArray[2]+','+extArray[3]+'); return false;" >Zoom</a></td>';
                        //str+='<td><a href="#" onclick="javascript:myMap1.zoomExtent('+extArray[0]+','+extArray[1]+','+extArray[2]+','+extArray[3]+');+'\');" >Zoom</a></td>';
                        for (intLoop = 0; intLoop < numNodi; intLoop++) {
                            str=str + '<td>'
                            //document.gdmanager.response.value=document.gdmanager.response.value+'||'+firstTag1Node[intLoop].getAttribute("name");
                            //AddToList(document.gdmanager.attributi,firstTag2Node[intLoop].getText(),firstTag2Node[intLoop].getText());
                            //AddToList(document.gdmanager.lista_attributi,firstTag2Node[intLoop].getAttribute("name"),firstTag2Node[intLoop].getAttribute("name") +" : " + firstTag2Node[intLoop].getAttribute("value"));
                            if (firstTag4Node[intLoop].getAttribute("value") != "" ) 
                                str=str + firstTag4Node[intLoop].getAttribute("value");
                            else
                                str=str+ "&nbsp;"; 
                            str=str + '</td>';
                        }
                        str=str + '</tr>';
                    }
                    else
                        str='Nessun risultato';
                }
        }
        str=str + '</table>';
        str +='	</body></html>';
        var Win1 = open("","DataWindow","width=575,height=250,scrollbars=yes,resizable=yes");
        Win1.document.writeln(str);
        Win1.document.close();
        }    return true;
   }
function ChiamaDisegnaTabellaIE()
   {
   if (xml.readyState == 4)
      DisegnaTabella();
   }
//Visualizza gli attributi in una tabella usando le funzioni JS getElementsByTagName
//Solo per IE. Non funzionano con Mozilla 1.5 per ora
function VisualizzaAttributiTabella(xmldoc,chiudiTabella)
{
    VisualizzaAttributiTabella_ClassicDom(xmldoc,chiudiTabella);
}
//Funzione di ricerca per un attributo e un valore solo
function CercaSemplice(valore,campo,idTema,useLike,doZoom)
{
    var xmlFields='';
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var thisdate=getDataUnivoca();
    var strLike='';
    var strDoZoom='0';
    
    	goPopup();

    if (useLike != null){
    	if (useLike == true)
    		strLike='LIKE';
	}
    if (doZoom != null){
    	if (doZoom == true)
    		strDoZoom='1';
	}
	
    if ((idTema == '' ) || (idTema == -1)) return false;
    xmlFields="<attrvalues><att name='"+campo+"' valore='"+valore+"' /></attrvalues>";
    xmlurl=gdManagerWS+"FW_IdentifyByFieldsValues?GUIDSession="+guidSession+"&IDFramework="+idTema+"&XMLFieldsValues="+xmlFields+"&searchlike="+strLike+"&dataora="+thisdate;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    gloUrlUltimaIdentify=urlpara;
    gloTipoUltimaIdentify='FW_IdentifyByFieldsValues';
    AzzeraVariabiliSelezione();
    
    //VisualizzaAttributiTabella(pubxml);

    if (attrWindowMode == 1)
    {
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByFieldsValues',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);

        //Visualizzo in un IFRAME il risultato della richiesta di identify
        //window.frames['datiframe'].document.location.href=xmlurl;
        //VisualizzaAttributi(pubxml);
    }
    else
    {
   
        if (useAttribWindow == true)
        {
            pubxml='';
            // 
            var nomeDiv="risultDiv"+ Math.random();
        new popUp(attrWinX,attrWinY,attrWinDimX,attrWinDimY,nomeDiv , "/gdproxy/attrib.aspx?comando=FW_IdentifyByFieldsValues&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames+"&dozoom="+strDoZoom , "","", "white", "black", " normal 12px verdana","Risultati" , "#3A6EA5", "white", "#dddddd", "gray", "black", false, true, true, true, false,attrWindowMode);
            showbox(nomeDiv);         
        }
        else
        {
            //Uso l'iframe che deve esistere nella finestra della mappa
            window.frames['ifattr'].document.location.href="/gdproxy/attrib.aspx?comando=FW_IdentifyByFieldsValues&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames+"&dozoom="+strDoZoom ;
        }    
    }
       
    try
    {
      onIdentify(pubxml);
    }
    catch(e)
    {}
    finally
    {}


}
//Funzione di ricerca: riceve in input un array di attributi e valori da cercare nel layer indicato
//doZoom vale 0,1
function CercaMultiplo(arrcampo,arrvalore,idTema,useLike,doZoom)
{
    var xmlFields='';
    var xmlurl='';
    var xmlLayer='';
    var strDoZoom='0';
    
   	goPopup();

    if ((idTema == '' ) || (idTema == -1)) return false;
    ActiveLayerIndex=idTema;
    var thisdate=getDataUnivoca();
    var strLike='';
    
    if (useLike != null){
    	if (useLike == true)
    		strLike='LIKE';
	}
    if (doZoom != null){
    	if (doZoom == true)
    		strDoZoom='1';
	}
    xmlFields="<attrvalues>";
    for (var j=0; j<arrcampo.length; j++) 
    {
        xmlFields += "<att name='"+arrcampo[j]+"' valore='"+arrvalore[j]+"' />";
    }
    xmlFields += "</attrvalues>";
    xmlurl=gdManagerWS+"FW_IdentifyByFieldsValues?GUIDSession="+guidSession+"&IDFramework="+idTema+"&XMLFieldsValues="+xmlFields+"&searchlike="+strLike+"&dataora="+thisdate;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    gloUrlUltimaIdentify=urlpara;
    gloTipoUltimaIdentify='FW_IdentifyByFieldsValues';
   
	AzzeraVariabiliSelezione();
	
    if (attrWindowMode == 1)
    {
        xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByFieldsValues',urlpara); 
        pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
        viewXMLLog(pubxml);
    }
    else
    {
        if (useAttribWindow == true)
        {
            pubxml='';
            var nomeDiv="risultDiv"+ Math.random();
            new popUp(attrWinX,attrWinY,attrWinDimX,attrWinDimY,nomeDiv , "/gdproxy/attrib.aspx?comando=FW_IdentifyByFieldsValues&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames+"&dozoom="+strDoZoom , "","", "white", "black", " normal 12px verdana","Risultati" , "#3A6EA5", "white", "#dddddd", "gray", "black", false, true, true, true, false,attrWindowMode);
			setCookie('ris_catasto', "/gdproxy/attrib.aspx?comando=FW_IdentifyByFieldsValues&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames, 864000);
            showbox(nomeDiv);     
            
            xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByFieldsValues',urlpara); 
            pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
            viewXMLLog(pubxml);    
        }
        else
        {
            //Uso l'iframe che deve esistere nella finestra della mappa
            window.frames['ifattr'].document.location.href="/gdproxy/attrib.aspx?comando=FW_IdentifyByFieldsValues&exp="+enableExport+"&"+urlpara+"&hideAttr="+hideAttrNames+"&dozoom="+strDoZoom ;
            pubxml='';
            xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_IdentifyByFieldsValues',urlpara); 
            pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
            viewXMLLog(pubxml);    
        }       
    }
    
       
    try
    {
      onIdentify(pubxml);
    }
    catch(e)
    {}
    finally
    {}
    
    nascondiPopup();

}
//Funzione di ricerca: riceve in input un array di attributi e valori da cercare nel layer indicato
function contaFeature(arrcampo,arrvalore,idTema,useLike)
{
    var xmlFields='';
    var xmlurl='';
    var xmlLayer='';
    if ((idTema == '' ) || (idTema == -1)) return false;
    ActiveLayerIndex=idTema;
    var thisdate=getDataUnivoca();
    var strLike='';
    
    if (useLike != null){
    	if (useLike == true)
    		strLike='LIKE';
	}

    xmlFields="<attrvalues>";
    for (var j=0; j<arrcampo.length; j++) 
    {
        xmlFields += "<att name='"+arrcampo[j]+"' valore='"+arrvalore[j]+"' />";
    }
    xmlFields += "</attrvalues>";
    xmlurl=gdManagerWS+"/gdproxy/nfeature.aspx?comando=FW_IdentifyByFieldsValues&GUIDSession="+guidSession+"&IDFramework="+idTema+"&XMLFieldsValues="+xmlFields+"&searchlike="+strLike+"&dataora="+thisdate;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    gloUrlUltimaIdentify=urlpara;
    gloTipoUltimaIdentify='/gdproxy/nfeature.aspx';
    xxx = window.frames['protoframe'].getAjaxRequestWrapper('/gdproxy/nfeature.aspx',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    pubxml = replaceExtChars(xxx.replace('<nfeature>',"").replace('</nfeature>',""));
    
    return pubxml;
    
}

function setCookie(sNome, sValore, iSecondi) {
  var dtOggi = new Date()
  var dtExpires = new Date();
  
  dtExpires.setTime(dtOggi.getTime() + iSecondi * 1000);
  
  document.cookie = sNome + "=" + escape(sValore) +
    "; expires=" + dtExpires.toGMTString();
    
}

function getCookie(Name){
    var search = Name;
    if (document.cookie.length> 0){
        offset = document.cookie.indexOf(search);
        if (offset != -1){
            offset += search.length;
            end = document.cookie.indexOf(";", offset);
            if (end == -1) {
                end = document.cookie.length;
            }
        return unescape(document.cookie.substring(offset, end));
        } else {
        return "";
        }
    } else {
        return "";
    }
}   
            

//funzione che è chiamata dall'albero e 
//visualizza il tema attivo
//imposta l'elenco dei campi ricercabili
//visualizza se il layer consente ricerche e/o tooltip
function AttivaTema(idTema)
{
    var temp;
    temp=parseInt(idTema);
    //MCS Se è un valore numerico allora è un layer e richiamo le funzioni di aggiornamento
	//degli attributi
	if (!isNaN(temp)){
		VisualizzaInfoTema(idTema);
    	if (document.getElementById("listaCampi")) CaricaElencoCampiVisibiliTree(idTema,document.gdmanager.listaCampi);
	}
}

function AttivaGruppo(idGruppo)
{
    if (idGruppo != '')
    {
        abilitaBottone("infmulti",true);
        abilitaBottone("analisibuffer",true);
    }
    else
    {
        abilitaBottone("infmulti",false); 
        abilitaBottone("analisibuffer",false);     
    }

}

function VisualizzaInfoTema(idTema)
{
    if (idTema > 0 )
        getInfoTemaProxy(idTema);
    else
        //Disattivo 
        AggiornaInfoTemaProxy('');
        
    return true;
    
    /* Vecchia soluzione con chiamate singole per le varie informazioni
    
    //alert(document.getElementById("txtTemaAttivo"));
	if (document.getElementById("txtTemaAttivo"))
        document.getElementById("txtTemaAttivo").innerHTML=ActiveLayerName;
    //alert(ActiveLayerName);
    var campi;
    
	AggiornaVisibilita(idTema);
    
    //TOOLTIP
    campi=getCampiTooltip(idTema);
    if (campi != ''){
        if (document.getElementById("imgTooltip"))
            document.getElementById("imgTooltip").src=GLOPubblicatiComuni + "/images/Tooltip_On.gif";
			document.getElementById("imgTooltip").title="ToolTip Attivi";
            abilitaBottone("tooltip",true);
        }
    else{
        if (document.getElementById("imgTooltip"))
            document.getElementById("imgTooltip").src=GLOPubblicatiComuni + "/images/Tooltip_Off.gif";
			document.getElementById("imgTooltip").title="ToolTip Disattivi";
            abilitaBottone("tooltip",false);            
    }

    //CAMPI DI RICERCA
    campi=getCampiRicerca(idTema);
    //escludo l'elenco dei campi fissi
    campi=campi.replace(",FID","");
    campi=campi.replace(",OBJECTID"+",","");
    campi=campi.replace(",IDXSHAPE"+",","");
    campi=campi.replace(",FEATUREID"+",","");
    if (campi != ''){
        if (document.getElementById("imgSearch"))
            document.getElementById("imgSearch").src=GLOPubblicatiComuni + "/images/Search_On.gif";
			document.getElementById("imgSearch").title="Ricerca Abilitata";
            abilitaBottone("find",true);
    }
    else{
        if (document.getElementById("imgSearch"))
            document.getElementById("imgSearch").src=GLOPubblicatiComuni + "/images/Search_Off.gif";
			document.getElementById("imgSearch").title="Ricerca Disabilitata";
            abilitaBottone("find",false);
    }
    if (document.getElementById("temi_di_analisi"))
        document.getElementById('temi_di_analisi').innerHTML='<b>'+ActiveLayerName+'</b>';
        
    //CAMPI DI DATO
    campi=getCampiVisibiliTema(idTema);
    if (campi != ''){
        abilitaBottone("inf",true);
        abilitaBottone("select",true); abilitaBottone("selectpoly",true);
        }
    else{
        abilitaBottone("inf",false);            
        abilitaBottone("select",false); abilitaBottone("selectpoly",false);            
    }
    */
}

//Riceve una stringa nel formato <INFO>VIS=0,TIP=1,INF=1,SEARCH=1</INFO>
function AggiornaInfoTemaProxy(strInfo)
{
    
    
    //alert(document.getElementById("txtTemaAttivo"));
	if (document.getElementById("txtTemaAttivo"))
        document.getElementById("txtTemaAttivo").innerHTML=ActiveLayerName;
    //alert(ActiveLayerName);
    var campi;
    
	//Sostituito dalla ricerca nella stringa info 
    //AggiornaVisibilita(idTema);

	if (document.getElementById("imgVisible")) {
	    if (strInfo.indexOf("VIS=1") >0){
	        document.getElementById("imgVisible").src=GLOPubblicatiComuni + "/images/Visible_On.gif";
			document.getElementById("imgVisible").title="Tema visibile alla scala attuale";
		}
		else {
	        document.getElementById("imgVisible").src=GLOPubblicatiComuni + "/images/Visible_Off.gif";
			document.getElementById("imgVisible").title="Tema non visibile alla scala attuale";
		}
	}
    //TOOLTIP
    //campi=getCampiTooltip(idTema);
    if (strInfo.indexOf("TIP=1") >0){
        if (document.getElementById("imgTooltip"))
            document.getElementById("imgTooltip").src=GLOPubblicatiComuni + "/images/Tooltip_On.gif";
			document.getElementById("imgTooltip").title="ToolTip Attivi";
            abilitaBottone("tooltip",true);
            abilitaBottone("analisibuffer",true);
        }
    else{
        if (document.getElementById("imgTooltip"))
            document.getElementById("imgTooltip").src=GLOPubblicatiComuni + "/images/Tooltip_Off.gif";
			document.getElementById("imgTooltip").title="ToolTip Disattivi";
            abilitaBottone("tooltip",false);         
            abilitaBottone("analisibuffer",false);   
    }

    //CAMPI DI RICERCA
    //campi=getCampiRicerca(idTema);
    //escludo l'elenco dei campi fissi
    /*
    campi=campi.replace(",FID","");
    campi=campi.replace(",OBJECTID"+",","");
    campi=campi.replace(",IDXSHAPE"+",","");
    campi=campi.replace(",FEATUREID"+",","");
    */
    if (strInfo.indexOf("SEARCH=1") >0){
        if (document.getElementById("imgSearch"))
            document.getElementById("imgSearch").src=GLOPubblicatiComuni + "/images/Search_On.gif";
			document.getElementById("imgSearch").title="Ricerca Abilitata";
            abilitaBottone("find",true);
            abilitaBottone("analisibuffer",true);
    }
    else{
        if (document.getElementById("imgSearch"))
            document.getElementById("imgSearch").src=GLOPubblicatiComuni + "/images/Search_Off.gif";
			document.getElementById("imgSearch").title="Ricerca Disabilitata";
            abilitaBottone("find",false);
            abilitaBottone("analisibuffer",false);
    }
    if (document.getElementById("temi_di_analisi"))
        document.getElementById('temi_di_analisi').innerHTML='<b>'+ActiveLayerName+'</b>';
        
    //CAMPI DI DATO
    //campi=getCampiVisibiliTema(idTema);
    if (strInfo.indexOf("INF=1") >0){
        abilitaBottone("inf",true);
        abilitaBottone("infpoly",true);
        abilitaBottone("select",true); 
        abilitaBottone("selectpoly",true);
        abilitaBottone("analisibuffer",true);
        }
    else{
        abilitaBottone("inf",false);            
        abilitaBottone("infpoly",false);            
        abilitaBottone("select",false);
        abilitaBottone("selectpoly",false);   
        abilitaBottone("analisibuffer",false);                
    }
}

function AggiornaVisibilita(idTema){
    //Visibilita tema alla scala attuale
	if (document.getElementById("imgVisible")) {
	    if (getTemaVisibile(idTema) == true){
	        document.getElementById("imgVisible").src=GLOPubblicatiComuni + "/images/Visible_On.gif";
			document.getElementById("imgVisible").title="Tema visibile alla scala attuale";
		}
		else {
	        document.getElementById("imgVisible").src=GLOPubblicatiComuni + "/images/Visible_Off.gif";
			document.getElementById("imgVisible").title="Tema non visibile alla scala attuale";
		}
	}
	return true;
}
//funzione che è chiamata dall'albero e popola l'elenco dei campi ricercabili
//sapendo in quale combobox agire
function CaricaElencoCampiVisibiliTree(idTema)
{
	CaricaElencoCampiVisibili(idTema,document.gdmanager.listaCampi);
}

//Funzione di per sapere se il tema ha dei tooltip
function getCampiTooltip(idTema)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var retList='';
    
    var thisdate=getDataUnivoca();
    xmlurl=gdManagerWS+"FW_ThemeFieldsTooltip?GUIDSession="+guidSession+"&IDFramework="+idTema+"&dataora="+thisdate;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_ThemeFieldsTooltip',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);
    
    var objDom = Sarissa.getDomDocument();
    var serializer = new XMLSerializer(); 
    objDom = (new DOMParser()).parseFromString(pubxml, "text/xml");
    
    var objNodeList = objDom.selectNodes("/themefields/field");
    
    if (objNodeList.length >0)
    {
            for (intLoop = 0;intLoop < objNodeList.length ; intLoop++)
            {
		        retList +=','+objNodeList.item(intLoop).getAttribute("name");
            }
    }
    
    return retList;
}

//Funzione di per sapere se il tema ha dei campi visibili
function getCampiVisibiliTema(idTema)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var retList='';
    
    var thisdate=getDataUnivoca();
    xmlurl=gdManagerWS+"FW_ThemeFieldsVisibles?GUIDSession="+guidSession+"&IDFramework="+idTema+"&dataora="+thisdate;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_ThemeFieldsVisibles',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);
    
    var objDom = Sarissa.getDomDocument();
    var serializer = new XMLSerializer(); 
    objDom = (new DOMParser()).parseFromString(pubxml, "text/xml");
    
    var objNodeList = objDom.selectNodes("/themefields/field");
    
    if (objNodeList.length >0)
    {
            for (intLoop = 0;intLoop < objNodeList.length ; intLoop++)
            {
		        retList +=','+objNodeList.item(intLoop).getAttribute("name");
            }
    }

    
    return retList;
}

//Funzione di per sapere se il tema ha dei tooltip
function getCampiRicerca(idTema)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var retList='';
    
    var thisdate=getDataUnivoca();
    xmlurl=gdManagerWS+"FW_ThemeFieldsSearchable?GUIDSession="+guidSession+"&IDFramework="+idTema+"&dataora="+thisdate;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_ThemeFieldsSearchable',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);
    
    var objDom = Sarissa.getDomDocument();
    var serializer = new XMLSerializer(); 
    objDom = (new DOMParser()).parseFromString(pubxml, "text/xml");
    
    var objNodeList = objDom.selectNodes("/themefields/field");   

    
    if (objNodeList.length >0)
    {
            for (intLoop = 0;intLoop < objNodeList.length ; intLoop++)
            {
		        retList +=','+objNodeList.item(intLoop).getAttribute("name");
            }
    }

    
    return retList;
}

//Funzione di per sapere se un tema è visibile alla scala attuale
function getTemaVisibile(idTema)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var extStr='';
    var extArray;
    ret='';
    var _xmin,_xmax,_ymin,_ymax;
    
    extStr=myMap1.getViewerExtent();
    extArray=extStr.split(" ");
    
    _xmin=extArray[0];
    _xmax=extArray[2];
    _ymin=extArray[1];
    _ymax=extArray[3];
    
    var thisdate=getDataUnivoca();
    xmlurl=gdManagerWS+"FW_GetThemeVisibleInMap?GUIDSession="+guidSession+"&XMIN="+_xmin+"&XMAX="+_xmax+"&YMIN="+_ymin+"&YMAX="+_ymax+"&IDFramework="+idTema+"&PixelsIMGX="+LarghezzaMappa+"&PixelsIMGY="+AltezzaMappa+"&dataora="+thisdate;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetThemeVisibleInMap',urlpara); 
    ret = ripulisciXml(xxx);
    viewXMLLog(pubxml);

	if (ret.indexOf('true') >0)    
    	return true;
    else
    	return false;
    	
}

//Funzione di per sapere se un tema è visibile alla scala attuale
function getInfoTemaProxy(idTema)
{	
    goPopup();
    
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var extStr='';
    var extArray;
    ret='';
    var _xmin,_xmax,_ymin,_ymax;
    
    extStr=myMap1.getViewerExtent();
    extArray=extStr.split(" ");
    
    _xmin=extArray[0];
    _xmax=extArray[2];
    _ymin=extArray[1];
    _ymax=extArray[3];
    
    var thisdate=getDataUnivoca();
    urlpara="GUIDSession="+guidSession+"&XMIN="+_xmin+"&XMAX="+_xmax+"&YMIN="+_ymin+"&YMAX="+_ymax+"&IDFramework="+idTema+"&PixelsIMGX="+LarghezzaMappa+"&PixelsIMGY="+AltezzaMappa+"&dataora="+thisdate;
    window.frames['protoframe'].getAjaxRequestWrapper_asincrono('/gdproxy/infotema.aspx',urlpara,AggiornaInfoTemaProxy); 
	
	 	
}


//Funzione di ricerca per un attributo e un valore solo
function CaricaElencoCampiVisibili(idTema,listBox)
{
    var xmlurl='';
    var xmlLayer='';
    var i=0;
    var thisdate=getDataUnivoca();
    xmlurl=gdManagerWS+"FW_ThemeFieldsSearchable?GUIDSession="+guidSession+"&IDFramework="+idTema+"&dataora="+thisdate;
    var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));
    var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_ThemeFieldsSearchable',urlpara); 
    pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
    viewXMLLog(pubxml);
    ClearList(listBox);

    var objDom = Sarissa.getDomDocument();
    var serializer = new XMLSerializer(); 
    objDom = (new DOMParser()).parseFromString(pubxml, "text/xml");
    
    var objNodeList = objDom.selectNodes("/themefields/field");   

    
    if (objNodeList.length >0)
    {
            for (intLoop = 0;intLoop < objNodeList.length ; intLoop++)
            {
		        //Se non è uno dei campi ID fissi lo visualizzo nell'elenco
                if (elencoCampiIdNascosti.indexOf(objNodeList.item(intLoop).getAttribute("name")) == -1)
		            AddToList(listBox,objNodeList.item(intLoop).getAttribute("name"),objNodeList.item(intLoop).getAttribute("aliasname"));
            }
    }
    
   
}
//Caricamento immagine mappa da XML tipo 
// <?xml version="1.0" encoding="utf-8"?>
// /GDManagerWS/output/c3a676ad-187a-492c-b09a-6899a8f0dbaa.jpg
function disegnadaXML()
{
    var imgUrl;
    
    imgUrl = ripulisciXml(pubxml);

    if (gdManagerWrapper != '')
    {
		var remotepathimm = window.frames['protoframe'].getremoteadd();	
		imgUrl = remotepathimm + imgUrl;
    }
    document.gdmanager.mappa.src=imgUrl;
    return true;
}
//Caricamento immagine mappa da XML tipo 
// <?xml version="1.0" encoding="utf-8"?>
// /GDManagerWS/output/c3a676ad-187a-492c-b09a-6899a8f0dbaa.jpg
function getImgUrldaXML()
{
    var imgUrl;
    imgUrl = ripulisciXml(pubxml);
    if (gdManagerWrapper != '')
    {
		var remotepathimm = window.frames['protoframe'].getremoteadd();	
		imgUrl = remotepathimm + imgUrl;
    }
    return imgUrl;
}

function initVar()
{
    if (document.getElementById("mappa"))
    {
     bordoDxMappa=1*(document.getElementById("mappa").style.left.replace("px","")); //findPosX("mappa");
     bordoTopMappa=1*(document.getElementById("mappa").style.top.replace("px","")); //findPosX("mappa");
   }
    // Find out if it is Netscape 5+
    var netscape = (document.layers) ? 1:0;
    var goodIE = (document.all) ? 1:0;
    var netscape6 = (document.getElementById && !document.all) ? 1:0;

    
    return true;
}
function setMouse()
{
    //set event handler to test for browser capabilities and initialize API
    document.getElementById("mappa").onmousemove = movemouse;
    document.getElementById("mappa").onmousedown = startmouse;
    return true;
}
function getImageXY(evt) {
    if (evt.x)
        mouseX=evt.x-bordoDxMappa;//document.gdmanager.coordextx.value=evt.screenX+",x="+evt.x;
    else
        mouseX=evt.layerX;//document.gdmanager.coordextx.value=evt.screenX+",lx="+evt.layerX;
    if (evt.y)
        mouseY=evt.y-bordoTopMappa;//document.gdmanager.coordexty.value=evt.screenY+",y="+evt.y;
    else
        mouseY=evt.layerY;//document.gdmanager.coordexty.value=evt.screenY+",ly="+evt.layerY;  
}
//ScreenX è la X a partire dal bordo dello schermo 
//x è la x a partire dal bordo della finestra
//Per mozilla uso evt.layerX che misura a partire dal bordo sx della finestra
//Per IE Uso evt.x
function movemouse(evt)
{
    var pixelX=0;
    var pixelY=0;
    evt = (evt) ? evt : event;
    //window.status=evt.screenX;
    getImageXY(evt);
    //mouseX=mouseX-bordoDxMappa;
    //mouseY=mouseY-bordoTopMappa;
    document.gdmanager.coordextx.value=mouseX;    
    document.gdmanager.coordexty.value=mouseY;    
    pixelX = (mapXmax-mapXmin) / LarghezzaMappa;
    document.gdmanager.coordextxmappa.value = (pixelX * mouseX) + (mapXmin*1.0);
    pixelY = (mapYmax-mapYmin) / AltezzaMappa;
    document.gdmanager.coordextymappa.value = (pixelY * (AltezzaMappa - mouseY)) + (mapYmin*1.0);
    return false;
}
// onmousedown event handler - initialize global variables
function startmouse(evt) {
    var zMouseButton;
    var diffX=0.0;
    var diffY=0.0;
    var XCenter=0.0;
    var YCenter=0.0;
    var pixelX=0.0;
    var pixelY=0.0;
	zMouseButton = (evt) ? evt.which : event.button
	evt = (evt) ? evt : event;
	if (zMouseButton == 1) {
        getImageXY(evt);
        diffX=parseInt((mapXmax-mapXmin)/4);
        diffY=parseInt((mapYmax-mapYmin)/4);
        switch(mouseTool) {
        case "DRAG":
            break;
        // Zooming functions
        case "ZOOMIN":
            //Centro della Mappa
            //XCenter=parseInt(mapXmin)+diffX+diffX;
            //YCenter=parseInt(mapYmin)+diffY+diffY;
            //Coordinate del Click del Mouse
            pixelX = (mapXmax-mapXmin) / LarghezzaMappa;
            XCenter = (pixelX * mouseX) + (mapXmin*1.0);
            pixelY = (mapYmax-mapYmin) / AltezzaMappa;
            YCenter = (pixelY * (AltezzaMappa - mouseY)) + (mapYmin*1.0);
            /*
            //ZOOM SUL CENTRO della mappa
            mapXmin=diffX+parseInt(mapXmin);
            mapXmax=parseInt(mapXmax)-diffX;
            mapYmin=diffY+parseInt(mapYmin);
            mapYmax=parseInt(mapYmax)-diffY;
            */
            //ZOOM SUL CENTRO del click
            mapXmin=XCenter-diffX;
            mapXmax=XCenter+diffX;
            mapYmin=YCenter-diffY;
            mapYmax=YCenter+diffY;
            getMappa(mapXmin,mapYmin,mapXmax,mapYmax);
            break;
        case "ZOOMOUT":
            //Centro della Mappa
            //XCenter=parseInt(mapXmin)+diffX+diffX;
            //YCenter=parseInt(mapYmin)+diffY+diffY;
            //Coordinate del Click del Mouse
            pixelX = (mapXmax-mapXmin) / LarghezzaMappa;
            XCenter = (pixelX * mouseX) + (mapXmin*1.0);
            pixelY = (mapYmax-mapYmin) / AltezzaMappa;
            YCenter = (pixelY * (AltezzaMappa - mouseY)) + (mapYmin*1.0);
            /*
            //ZOOM SUL CENTRO della mappa
            mapXmin=diffX+parseInt(mapXmin);
            mapXmax=parseInt(mapXmax)-diffX;
            mapYmin=diffY+parseInt(mapYmin);
            mapYmax=parseInt(mapYmax)-diffY;
            */
            //ZOOM SUL CENTRO del click
            mapXmin=mapXmin-diffX;
            mapXmax=mapXmax+diffX;
            mapYmin=mapYmin-diffY;
            mapYmax=mapYmax+diffY;
            getMappa(mapXmin,mapYmin,mapXmax,mapYmax);
            break;
        case "IDENTIFY":
            //Coordinate del Click del Mouse
            pixelX = (mapXmax-mapXmin) / LarghezzaMappa;
            XCenter = (pixelX * mouseX) + (mapXmin*1.0);     
            pixelY = (mapYmax-mapYmin) / AltezzaMappa;
            YCenter = (pixelY * (AltezzaMappa - mouseY)) + (mapYmin*1.0);
            doIdentifyPunto(XCenter,YCenter,ActiveLayerIndex);
            break;
        default:
        }
	} 
	return false;
}
function setAzione(azione)
{
 mouseTool=azione;
 return true;
}
function zoomAll()
{
 mapXmin=limitXmin;
 mapXmax=limitXmax;
 mapYmin=limitYmin;
 mapYmax=limitYmax;
 getMappa(mapXmin,mapYmin,mapXmax,mapYmax);
 //alert(8); 
 myMap1.redraw()
 //alert(9);
 return true;
}
function viewXMLLog(xml)
{
 if (abilitaLog)
  document.gdmanager.response.value=xml;
}
function getDataUnivoca()
{
 var thisdate = new Date();
 var st='';
 st = st + thisdate.getTime();
 st=st.replace(" ","");
 return st;
}
//FUNZIONI GENERALI PER LA PAGINA 
//ALBERO
//dhtmlXTree.js
//cambiato <?xml version='1.0' encoding='iso-8859-1'?> con <?xml version="1.0" encoding="utf-8" ?>  nel tree.xml
function dhtmlXTreeObject(htmlObject,width,height,rootId){
 if(typeof(htmlObject)!="object")
 this.parentObject=document.getElementById(htmlObject);
 else
 this.parentObject=htmlObject;
 this.xmlstate=0;
 this.mytype="tree";
 this.smcheck=true;
 this.width=width;
 this.height=height;
 this.rootId=rootId;
 this.childCalc=null;
 this.def_img_x="16px";
 this.def_img_y="16px";
 this.style_pointer="pointer";
 if(navigator.appName == 'Microsoft Internet Explorer')this.style_pointer="hand";
 this._aimgs=true;
 this.htmlcA=" [";
 this.htmlcB="]";
 this.lWin=window;
 this.cMenu=0;
 this.mlitems=0;
 this.dadmode=0;
 this.slowParse=false;
 this.autoScroll=true;
 this.hfMode=0;
 this.nodeCut=0;
 this.XMLsource=0;
 this.XMLloadingWarning=0;
 this._globalIdStorage=new Array();
 this.globalNodeStorage=new Array();
 this._globalIdStorageSize=0;
 this.treeLinesOn=true;
 this.checkFuncHandler=0;
 this.openFuncHandler=0;
 this.dblclickFuncHandler=0;
 this.tscheck=false;
 this.timgen=true;
 this.dpcpy=false;
 this.imPath="treeGfx/";
 this.checkArray=new Array("iconUnCheckAll.gif","iconCheckAll.gif","iconCheckGray.gif","iconUncheckDis.gif");
 this.lineArray=new Array("line2.gif","line3.gif","line4.gif","blank.gif","blank.gif");
 this.minusArray=new Array("minus2.gif","minus3.gif","minus4.gif","minus.gif","minus5.gif");
 this.plusArray=new Array("plus2.gif","plus3.gif","plus4.gif","plus.gif","plus5.gif");
 this.imageArray=new Array("leaf.gif","folderOpen2.gif","folderClosed2.gif");
 this.cutImg= new Array(0,0,0);
 this.cutImage="but_cut.gif";
 this.dragger= new dhtmlDragAndDropObject();
 this.htmlNode=new dhtmlXTreeItemObject(this.rootId,"",0,this,null,-1);
 this.htmlNode.htmlNode.childNodes[0].childNodes[0].style.display="none";
 this.htmlNode.htmlNode.childNodes[0].childNodes[0].childNodes[0].className="hiddenRow";
 this.allTree=this._createSelf();
 this.allTree.appendChild(this.htmlNode.htmlNode);
 this.allTree.onselectstart=new Function("return false;");
 this.XMLLoader=new dtmlXMLLoaderObject(this._parseXMLTree,this);
 this.selectionBar=document.createElement("DIV");
 this.selectionBar.className="selectionBar";
 this.selectionBar.innerHTML="&nbsp;";
 if(this.allTree.offsetWidth>20)this.selectionBar.style.width=this.allTree.offsetWidth-20;
 this.selectionBar.style.display="none";
 this.allTree.appendChild(this.selectionBar);
 return this;
};
function dhtmlXTreeItemObject(itemId,itemText,parentObject,treeObject,actionHandler,mode,itemIdFramework){
 this.htmlNode="";
 this.acolor="";
 this.scolor="";
 this.tr=0;
 this.childsCount=0;
 this.tempDOMM=0;
 this.tempDOMU=0;
 this.dragSpan=0;
 this.dragMove=0;
 this.span=0;
 this.closeble=1;
 this.childNodes=new Array();
 this.userData=new Object();
 this.IdFramework=itemIdFramework;
 this.checkstate=0;
 this.treeNod=treeObject;
 this.label=itemText;
 this.parentObject=parentObject;
 this.actionHandler=actionHandler;
 this.images=new Array(treeObject.imageArray[0],treeObject.imageArray[1],treeObject.imageArray[2]);
 this.id=treeObject._globalIdStorageAdd(itemId,this);
 if(this.treeNod.checkBoxOff)this.htmlNode=this.treeNod._createItem(1,this,mode);
 else this.htmlNode=this.treeNod._createItem(0,this,mode);
 this.htmlNode.objBelong=this;
 return this;
};
 dhtmlXTreeObject.prototype._globalIdStorageAdd=function(itemId,itemObject){
 if(this._globalIdStorageFind(itemId,1,1)){d=new Date();itemId=d.valueOf()+"_"+itemId;return this._globalIdStorageAdd(itemId,itemObject);}
 this._globalIdStorage[this._globalIdStorageSize]=itemId;
 this.globalNodeStorage[this._globalIdStorageSize]=itemObject;
 this._globalIdStorageSize++;
 return itemId;
};
 dhtmlXTreeObject.prototype._globalIdStorageSub=function(itemId){
 for(var i=0;i<this._globalIdStorageSize;i++)
 if(this._globalIdStorage[i]==itemId)
{
 this._globalIdStorage[i]=this._globalIdStorage[this._globalIdStorageSize-1];
 this.globalNodeStorage[i]=this.globalNodeStorage[this._globalIdStorageSize-1];
 this._globalIdStorageSize--;
 this._globalIdStorage[this._globalIdStorageSize]=0;
 this.globalNodeStorage[this._globalIdStorageSize]=0;
}
};
 dhtmlXTreeObject.prototype._globalIdStorageFind=function(itemId,skipXMLSearch,skipParsing){
 for(var i=0;i<this._globalIdStorageSize;i++)
 if(this._globalIdStorage[i]==itemId)
{
 return this.globalNodeStorage[i];
}
 return null;
};
 dhtmlXTreeObject.prototype._drawNewTr=function(htmlObject,node)
{
 var tr =document.createElement('tr');
 var td1=document.createElement('td');
 var td2=document.createElement('td');
 td1.appendChild(document.createTextNode(" "));
 td2.colSpan=3;
 td2.appendChild(htmlObject);
 tr.appendChild(td1);tr.appendChild(td2);
 return tr;
};
 dhtmlXTreeObject.prototype.loadXMLString=function(xmlString,afterCall){
 this.xmlstate=1;
 this.XMLLoader.loadXMLString(xmlString);this.waitCall=afterCall||0;};
 dhtmlXTreeObject.prototype.loadXML=function(file,afterCall){
 this.xmlstate=1;
 this.XMLLoader.loadXML(file);this.waitCall=afterCall||0;};
 dhtmlXTreeObject.prototype._attachChildNode=function(parentObject,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,childs,beforeNode,IdFramework){
 if(beforeNode)parentObject=beforeNode.parentObject;
 if(((parentObject.XMLload==0)&&(this.XMLsource))&&(!this.XMLloadingWarning))
{
 parentObject.XMLload=1; this.loadXML(this.XMLsource+getUrlSymbol(this.XMLsource)+"itemId="+escape(parentObject.id));
}
 var Count=parentObject.childsCount;
 var Nodes=parentObject.childNodes;
 if(beforeNode)
{
 var ik,jk;
 for(ik=0;ik<Count;ik++)
 if(Nodes[ik]==beforeNode)
{
 for(jk=Count;jk!=ik;jk--)
 Nodes[1+jk]=Nodes[jk];
 break;
}
 ik++;
 Count=ik;
}
 if((!itemActionHandler)&&(this.aFunc))itemActionHandler=this.aFunc;
 if(optionStr){
 var tempStr=optionStr.split(",");
 for(var i=0;i<tempStr.length;i++)
{
 switch(tempStr[i])
{
 case "TOP": if(parentObject.childsCount>0){beforeNode=new Object;beforeNode.tr=parentObject.childNodes[0].tr.previousSibling;}
 for(ik=0;ik<Count;ik++)
 Nodes[ik+Count]=Nodes[ik+Count-1];
 Count=0;
 break;
}};};
 Nodes[Count]=new dhtmlXTreeItemObject(itemId,itemText,parentObject,this,itemActionHandler,1,IdFramework);
 if(image1)Nodes[Count].images[0]=image1;
 if(image2)Nodes[Count].images[1]=image2;
 if(image3)Nodes[Count].images[2]=image3;
 parentObject.childsCount++;
 var tr=this._drawNewTr(Nodes[Count].htmlNode);
 if(this.XMLloadingWarning)
 Nodes[Count].htmlNode.parentNode.parentNode.style.display="none";
 if((beforeNode)&&(beforeNode.tr.nextSibling))
 parentObject.htmlNode.childNodes[0].insertBefore(tr,beforeNode.tr.nextSibling);
 else
 if((this.parsingOn)&&(this.parsingOn==parentObject.id))
{
 this.parsedArray[this.parsedArray.length]=tr;
}
 else 
 parentObject.htmlNode.childNodes[0].appendChild(tr);
 if((beforeNode)&&(!beforeNode.span))beforeNode=null;
 if(this.XMLsource)if((childs)&&(childs!=0))Nodes[Count].XMLload=0;else Nodes[Count].XMLload=1;
 Nodes[Count].tr=tr;
 tr.nodem=Nodes[Count];
 if(parentObject.itemId==0)
 tr.childNodes[0].className="hitemIddenRow";
 if(optionStr){
 var tempStr=optionStr.split(",");
 for(var i=0;i<tempStr.length;i++)
{
 switch(tempStr[i])
{
 case "SELECT": this.selectItem(itemId,false);break;
 case "CALL": this.selectItem(itemId,true);break;
 case "CHILD": Nodes[Count].XMLload=0;break;
 case "CHECKED": 
 if(this.XMLloadingWarning)
 this.setCheckList+=","+itemId;
 else
 this.setCheck(itemId,1);
 break;
 case "HCHECKED":
 this._setCheck(Nodes[Count],"notsure");
 break;
 case "OPEN": Nodes[Count].openMe=1;break;
}};};
 if(!this.XMLloadingWarning)
{
 if(this._getOpenState(parentObject)<0)
 this.openItem(parentObject.id);
 if(beforeNode)
{
 this._correctPlus(beforeNode);
 this._correctLine(beforeNode);
}
 this._correctPlus(parentObject);
 this._correctLine(parentObject);
 this._correctPlus(Nodes[Count]);
 if(parentObject.childsCount>=2)
{
 this._correctPlus(Nodes[parentObject.childsCount-2]);
 this._correctLine(Nodes[parentObject.childsCount-2]);
}
 if(parentObject.childsCount!=2)this._correctPlus(Nodes[0]);
 if(this.tscheck)this._correctCheckStates(parentObject);
}
 if(this.cMenu)this.cMenu.setContextZone(Nodes[Count].span,Nodes[Count].id);
 return Nodes[Count];
};
 dhtmlXTreeObject.prototype.insertNewItem=function(parentId,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,childs,IdFramework){
 var parentObject=this._globalIdStorageFind(parentId);
 if(!parentObject)return(-1);
 return this._attachChildNode(parentObject,itemId,itemText,itemActionHandler,image1,image2,image3,optionStr,childs,null,IdFramework);
};
 dhtmlXTreeObject.prototype._parseXMLTree=function(dhtmlObject,node,parentId,level){
 if(!dhtmlObject.parsCount)dhtmlObject.parsCount=1;else dhtmlObject.parsCount++;
 dhtmlObject.XMLloadingWarning=1;
 var nodeAskingCall="";
 if(!node){
 node=dhtmlObject.XMLLoader.getXMLTopNode("tree");
 parentId=node.getAttribute("id");
 dhtmlObject.parsingOn=parentId;
 dhtmlObject.parsedArray=new Array();
 dhtmlObject.setCheckList="";
}
 if(node.getAttribute("order"))
 dhtmlObject._reorderXMLBranch(node);
 for(var i=0;i<node.childNodes.length;i++)
{
 if((node.childNodes[i].nodeType==1)&&(node.childNodes[i].tagName == "item"))
{
 var nodx=node.childNodes[i];
 var name=nodx.getAttribute("text");
 var cId=nodx.getAttribute("id");
 if((!dhtmlObject.waitUpdateXML)||(dhtmlObject.waitUpdateXML.toString().search(","+cId+",")!=-1))
{
 var im0=nodx.getAttribute("im0");
 var im1=nodx.getAttribute("im1");
 var im2=nodx.getAttribute("im2");
 var aColor=nodx.getAttribute("aCol");
 var sColor=nodx.getAttribute("sCol");
 var chd=nodx.getAttribute("child");
 var IdFramework=nodx.getAttribute("IDFramework");
 var atop=nodx.getAttribute("top");
 var aopen=nodx.getAttribute("open");
 var aselect=nodx.getAttribute("select");
 var acall=nodx.getAttribute("call");
 var achecked=nodx.getAttribute("checked");
 var closeable=nodx.getAttribute("closeable");
 var tooltip = nodx.getAttribute("tooltip");
 var nocheckbox = nodx.getAttribute("nocheckbox");
 var style = nodx.getAttribute("style");
 var zST="";
 if(aselect)zST+=",SELECT";
 if(atop)zST+=",TOP";
 if(acall)nodeAskingCall=cId;
 if(achecked==-1)zST+=",HCHECKED";
 else if(achecked)zST+=",CHECKED";
 if(aopen)zST+=",OPEN";
 var temp=dhtmlObject._globalIdStorageFind(parentId);
 temp.XMLload=1;
 var newNode=dhtmlObject.insertNewItem(parentId,cId,name,0,im0,im1,im2,zST,chd,IdFramework);
 if(tooltip)newNode.span.parentNode.title=tooltip;
 if(style)newNode.span.style.cssText+=(";"+style);
 if(nocheckbox){
 newNode.span.parentNode.previousSibling.previousSibling.childNodes[0].style.display='none';
 newNode.nocheckbox=true;
}
 newNode._acc=chd||0;
 if(dhtmlObject.parserExtension)dhtmlObject.parserExtension._parseExtension(node.childNodes[i],dhtmlObject.parserExtension,cId,parentId);
 dhtmlObject.setItemColor(newNode,aColor,sColor);
 if((closeable=="0")||(closeable=="1"))dhtmlObject.setItemCloseable(newNode,closeable);
 var zcall="";
 if((!dhtmlObject.slowParse)||(dhtmlObject.waitUpdateXML))
{
 zcall=dhtmlObject._parseXMLTree(dhtmlObject,node.childNodes[i],cId,1);
}
 else{
 if(node.childNodes[i].childNodes.length>0){
 for(var a=0;a<node.childNodes[i].childNodes.length;a++)
 if(node.childNodes[i].childNodes[a].tagName=="item"){
 newNode.unParsed=node.childNodes[i];
 break;
}}}
 if(zcall!="")nodeAskingCall=zcall;
}
 else dhtmlObject._parseXMLTree(dhtmlObject,node.childNodes[i],cId,1);
}
 else
 if((node.childNodes[i].nodeType==1)&&(node.childNodes[i].tagName == "userdata"))
{
 var name=node.childNodes[i].getAttribute("name");
 if((name)&&(node.childNodes[i].childNodes[0])){
 if((!dhtmlObject.waitUpdateXML)||(dhtmlObject.waitUpdateXML.toString().search(","+parentId+",")!=-1))
 dhtmlObject.setUserData(parentId,name,node.childNodes[i].childNodes[0].data);
};};};
 if(!level){
 if(dhtmlObject.waitUpdateXML)
 dhtmlObject.waitUpdateXML="";
 else{
 var parsedNodeTop=dhtmlObject._globalIdStorageFind(dhtmlObject.parsingOn);
 for(var i=0;i<dhtmlObject.parsedArray.length;i++)
 parsedNodeTop.htmlNode.childNodes[0].appendChild(dhtmlObject.parsedArray[i]);
 dhtmlObject.parsingOn=0;
 dhtmlObject.lastLoadedXMLId=parentId;
 dhtmlObject.XMLloadingWarning=0;
 var chArr=dhtmlObject.setCheckList.split(",");
 for(var n=0;n<chArr.length;n++)
 if(chArr[n])dhtmlObject.setCheck(chArr[n],1);
 dhtmlObject._redrawFrom(dhtmlObject);
 if(nodeAskingCall!="")dhtmlObject.selectItem(nodeAskingCall,true);
 if(dhtmlObject.waitCall)dhtmlObject.waitCall();
}}
 if(dhtmlObject.parsCount==1){
 dhtmlObject.xmlstate=1;
}
 dhtmlObject.parsCount--;
 return nodeAskingCall;
};
 dhtmlXTreeObject.prototype._redrawFrom=function(dhtmlObject,itemObject){
 if(!itemObject){
 var tempx=dhtmlObject._globalIdStorageFind(dhtmlObject.lastLoadedXMLId);
 dhtmlObject.lastLoadedXMLId=-1;
 if(!tempx)return 0;
}
 else tempx=itemObject;
 var acc=0;
 for(var i=0;i<tempx.childsCount;i++)
{
 if(!itemObject)tempx.childNodes[i].htmlNode.parentNode.parentNode.style.display="";
 if(tempx.childNodes[i].openMe==1)
{
 this._openItem(tempx.childNodes[i]);
 tempx.childNodes[i].openMe=0;
}
 dhtmlObject._redrawFrom(dhtmlObject,tempx.childNodes[i]);
 if(this.childCalc!=null){
 if((tempx.childNodes[i].unParsed)||((!tempx.childNodes[i].XMLload)&&(this.XMLsource)))
{
 if(tempx.childNodes[i]._acc)
 tempx.childNodes[i].span.innerHTML=tempx.childNodes[i].label+this.htmlcA+tempx.childNodes[i]._acc+this.htmlcB;
 else 
 tempx.childNodes[i].span.innerHTML=tempx.childNodes[i].label;
}
 if((tempx.childNodes[i].childNodes.length)&&(this.childCalc))
{
 if(this.childCalc==1)
{
 tempx.childNodes[i].span.innerHTML=tempx.childNodes[i].label+this.htmlcA+tempx.childNodes[i].childsCount+this.htmlcB;
}
 if(this.childCalc==2)
{
 var zCount=tempx.childNodes[i].childsCount-(tempx.childNodes[i].pureChilds||0);
 if(zCount)
 tempx.childNodes[i].span.innerHTML=tempx.childNodes[i].label+this.htmlcA+zCount+this.htmlcB;
 if(tempx.pureChilds)tempx.pureChilds++;else tempx.pureChilds=1;
}
 if(this.childCalc==3)
{
 tempx.childNodes[i].span.innerHTML=tempx.childNodes[i].label+this.htmlcA+tempx.childNodes[i]._acc+this.htmlcB;
}
 if(this.childCalc==4)
{
 var zCount=tempx.childNodes[i]._acc;
 if(zCount)
 tempx.childNodes[i].span.innerHTML=tempx.childNodes[i].label+this.htmlcA+zCount+this.htmlcB;
}}
 else if(this.childCalc==4){
 acc++;
}
 acc+=tempx.childNodes[i]._acc;
 if(this.childCalc==3){
 acc++;
}}};
 if((!tempx.unParsed)&&((tempx.XMLload)||(!this.XMLsource)))
 tempx._acc=acc;
 dhtmlObject._correctLine(tempx);
 dhtmlObject._correctPlus(tempx);
};
 dhtmlXTreeObject.prototype._createSelf=function(){
 var div=document.createElement('div');
 div.className="containerTableStyle";
 div.style.width=this.width;
 div.style.height=this.height;
 this.parentObject.appendChild(div);
 return div;
};
 dhtmlXTreeObject.prototype._xcloseAll=function(itemObject)
{
 if(this.rootId!=itemObject.id)this._HideShow(itemObject,1);
 for(var i=0;i<itemObject.childsCount;i++)
 this._xcloseAll(itemObject.childNodes[i]);
};
 dhtmlXTreeObject.prototype._xopenAll=function(itemObject)
{
 this._HideShow(itemObject,2);
 for(var i=0;i<itemObject.childsCount;i++)
 this._xopenAll(itemObject.childNodes[i]);
};
 dhtmlXTreeObject.prototype._correctPlus=function(itemObject){
 var workArray=this.lineArray;
 if((this.XMLsource)&&(!itemObject.XMLload))
{
 var workArray=this.plusArray;
 itemObject.htmlNode.childNodes[0].childNodes[0].childNodes[2].childNodes[0].src=this.imPath+itemObject.images[2];
}
 else
 if((itemObject.childsCount)||(itemObject.unParsed))
{
 if((itemObject.htmlNode.childNodes[0].childNodes[1])&&(itemObject.htmlNode.childNodes[0].childNodes[1].style.display!="none"))
{
 if(!itemObject.wsign)var workArray=this.minusArray;
 itemObject.htmlNode.childNodes[0].childNodes[0].childNodes[2].childNodes[0].src=this.imPath+itemObject.images[1];
}
 else
{
 if(!itemObject.wsign)var workArray=this.plusArray;
 itemObject.htmlNode.childNodes[0].childNodes[0].childNodes[2].childNodes[0].src=this.imPath+itemObject.images[2];
}
}
 else
{
 itemObject.htmlNode.childNodes[0].childNodes[0].childNodes[2].childNodes[0].src=this.imPath+itemObject.images[0];
}
 var tempNum=2;
 if(!itemObject.treeNod.treeLinesOn)itemObject.htmlNode.childNodes[0].childNodes[0].childNodes[0].childNodes[0].src=this.imPath+workArray[3];
 else{
 if(itemObject.parentObject)tempNum=this._getCountStatus(itemObject.id,itemObject.parentObject);
 itemObject.htmlNode.childNodes[0].childNodes[0].childNodes[0].childNodes[0].src=this.imPath+workArray[tempNum];
}};
 dhtmlXTreeObject.prototype._correctLine=function(itemObject){
 var sNode=itemObject.parentObject;
 try{
 if(sNode)
 if((this._getLineStatus(itemObject.id,sNode)==0)||(!this.treeLinesOn))
{
 for(var i=1;i<=itemObject.childsCount;i++)
{
 itemObject.htmlNode.childNodes[0].childNodes[i].childNodes[0].style.backgroundImage="";
 itemObject.htmlNode.childNodes[0].childNodes[i].childNodes[0].style.backgroundRepeat="";
}}
 else
 for(var i=1;i<=itemObject.childsCount;i++)
{
 itemObject.htmlNode.childNodes[0].childNodes[i].childNodes[0].style.backgroundImage="url("+this.imPath+"line1.gif)";
 itemObject.htmlNode.childNodes[0].childNodes[i].childNodes[0].style.backgroundRepeat="repeat-y";
}}
 catch(e){};
};
 dhtmlXTreeObject.prototype._getCountStatus=function(itemId,itemObject){
 try{
 if(itemObject.childsCount<=1){if(itemObject.id==this.rootId)return 4;else return 0;}
 if(itemObject.htmlNode.childNodes[0].childNodes[1].nodem.id==itemId)if(!itemObject.id)return 2;else return 1;
 if(itemObject.htmlNode.childNodes[0].childNodes[itemObject.childsCount].nodem.id==itemId)return 0;
}
 catch(e){};
 return 1;
};
 dhtmlXTreeObject.prototype._getLineStatus =function(itemId,itemObject){
 if(itemObject.htmlNode.childNodes[0].childNodes[itemObject.childsCount].nodem.id==itemId)return 0;
 return 1;
}
 dhtmlXTreeObject.prototype._HideShow=function(itemObject,mode){
 if((this.XMLsource)&&(!itemObject.XMLload)){itemObject.XMLload=1;this.loadXML(this.XMLsource+getUrlSymbol(this.XMLsource)+"id="+escape(itemObject.id));return;};
 var Nodes=itemObject.htmlNode.childNodes[0].childNodes;var Count=Nodes.length;
 if(Count>1){
 if(((Nodes[1].style.display!="none")||(mode==1))&&(mode!=2)){
 this.allTree.childNodes[0].border = "1";
 this.allTree.childNodes[0].border = "0";
 nodestyle="none";
}
 else nodestyle="";
 for(var i=1;i<Count;i++)
 Nodes[i].style.display=nodestyle;
}
 this._correctPlus(itemObject);
}
 dhtmlXTreeObject.prototype._getOpenState=function(itemObject){
 if(!itemObject)return;
 var z=itemObject.htmlNode.childNodes[0].childNodes;
 if(z.length<=1)return 0;
 if(z[1].style.display!="none")return 1;
 else return -1;
}
 dhtmlXTreeObject.prototype.onRowClick2=function(){
 if(this.parentObject.treeNod.dblclickFuncHandler)if(!this.parentObject.treeNod.dblclickFuncHandler(this.parentObject.id))return 0;
 if((this.parentObject.closeble)&&(this.parentObject.closeble!="0"))
 this.parentObject.treeNod._HideShow(this.parentObject);
 else
 this.parentObject.treeNod._HideShow(this.parentObject,2);
};
 dhtmlXTreeObject.prototype.onRowClick=function(){
 if(this.parentObject.treeNod.openFuncHandler)if(!this.parentObject.treeNod.openFuncHandler(this.parentObject.id,this.parentObject.treeNod._getOpenState(this.parentObject)))return 0;
 if((this.parentObject.closeble)&&(this.parentObject.closeble!="0"))
 this.parentObject.treeNod._HideShow(this.parentObject);
 else
 this.parentObject.treeNod._HideShow(this.parentObject,2);
};
 dhtmlXTreeObject.prototype.onRowClickDown=function(){
 var that=this.parentObject.treeNod;
 that._selectItem(this.parentObject);
};
 dhtmlXTreeObject.prototype._selectItem=function(node){
 if(this.lastSelected){
 this._unselectItem(this.lastSelected.parentObject);
}
 var z=node.htmlNode.childNodes[0].childNodes[0].childNodes[3].childNodes[0];
 z.className="selectedTreeRow";
 this.lastSelected=z.parentNode;
}
 dhtmlXTreeObject.prototype._unselectItem=function(node){
 node.htmlNode.childNodes[0].childNodes[0].childNodes[3].childNodes[0].className="standartTreeRow";
}
 dhtmlXTreeObject.prototype.onRowSelect=function(e,htmlObject,mode){
 if(!htmlObject)htmlObject=this.parentObject.span.parentNode;
 htmlObject.parentObject.span.className="selectedTreeRow";
 if(htmlObject.parentObject.scolor)htmlObject.parentObject.span.style.color=htmlObject.parentObject.scolor;
 if((htmlObject.parentObject.treeNod.lastSelected)&&(htmlObject.parentObject.treeNod.lastSelected!=htmlObject))
{
 var lastId=htmlObject.parentObject.treeNod.lastSelected.parentObject.id;
 htmlObject.parentObject.treeNod.lastSelected.parentObject.span.className="standartTreeRow";
 if(htmlObject.parentObject.treeNod.lastSelected.parentObject.acolor)htmlObject.parentObject.treeNod.lastSelected.parentObject.span.style.color=htmlObject.parentObject.treeNod.lastSelected.parentObject.acolor;
}
 else var lastId="";
 htmlObject.parentObject.treeNod.lastSelected=htmlObject;
 if(!mode){
 if(window.event)e=event;
 if((e)&&(e.button==2)&&(htmlObject.parentObject.treeNod.arFunc))
{htmlObject.parentObject.treeNod.arFunc(htmlObject.parentObject.id);}
 if(htmlObject.parentObject.actionHandler)htmlObject.parentObject.actionHandler(htmlObject.parentObject.id,lastId);
}
};
dhtmlXTreeObject.prototype._correctCheckStates=function(dhtmlObject){
 if(!this.tscheck)return;
 if(dhtmlObject.id==this.rootId)return;
 var act=dhtmlObject.htmlNode.childNodes[0].childNodes;
 var flag1=0;var flag2=0;
 if(act.length<2)return;
 for(var i=1;i<act.length;i++)
 if(act[i].nodem.checkstate==0)flag1=1;
 else if(act[i].nodem.checkstate==1)flag2=1;
 else{flag1=1;flag2=1;break;}
 if((flag1)&&(flag2))this._setCheck(dhtmlObject,"notsure");
 else if(flag1)this._setCheck(dhtmlObject,false);
 else this._setCheck(dhtmlObject,true);
 this._correctCheckStates(dhtmlObject.parentObject);
}
// dhtmlXTreeObject.prototype.onCheckBoxClick=function(e){
// if(this.treeNod.tscheck)
// if(this.parentObject.checkstate==1)this.treeNod._setSubChecked(false,this.parentObject);
// else this.treeNod._setSubChecked(true,this.parentObject);
// else
// if(this.parentObject.checkstate==1)this.treeNod._setCheck(this.parentObject,false);
// else this.treeNod._setCheck(this.parentObject,true);
// this.treeNod._correctCheckStates(this.parentObject.parentObject);
// //MCS
// //Ridisegno la mappa ad ogni cambiamento di CheckBox
// //AGO//
// //2007-02-17 eliminato per gestione coda dei layer attivati
// //strLayerAttiviGLO = settavisono(this.parentObject.id,this.parentObject.checkstate);
// if (strCodaLayerCheck!='') strCodaLayerCheck+=";";
// strCodaLayerCheck+=this.parentObject.id+","+this.parentObject.checkstate;
// //AGO//
// if (AutoRedrawToc) myMap1.redraw();
// if(this.treeNod.checkFuncHandler)return(this.treeNod.checkFuncHandler(this.parentObject.id,this.parentObject.checkstate));
// else return true;
//};

//Luca - 080212
 dhtmlXTreeObject.prototype.onCheckBoxClick=function(e){
     if(this.treeNod.tscheck)
     
         if(this.parentObject.checkstate==1) {
            this.treeNod._setSubChecked(false,this.parentObject);
            alert("subuncheck");
         }   
         else {
            this.treeNod._setSubChecked(true,this.parentObject);
            alert("subcheck");
            }
         //else 
         
         if(this.parentObject.checkstate==1)
            this.treeNod._setCheck(this.parentObject,false);
         else { 
            this.treeNod._setCheck(this.parentObject,true);
            AccendiPadre(this.parentObject.id,1);
       //    alert(this.parentObject.checkstate);
            }
            
         this.treeNod._correctCheckStates(this.parentObject.parentObject);
         //MCS
         //Ridisegno la mappa ad ogni cambiamento di CheckBox
         //AGO//
         //2007-02-17 eliminato per gestione coda dei layer attivati
         //strLayerAttiviGLO = settavisono(this.parentObject.id,this.parentObject.checkstate);
         
         if (strCodaLayerCheck!='') strCodaLayerCheck+=";";
            strCodaLayerCheck+=this.parentObject.id+","+this.parentObject.checkstate;
         //AGO//
         if (AutoRedrawToc) 
            myMap1.redraw();
            if(this.treeNod.checkFuncHandler)
                return(this.treeNod.checkFuncHandler(this.parentObject.id,this.parentObject.checkstate));
     else 
     return true;
};

 dhtmlXTreeObject.prototype._createItem=function(acheck,itemObject,mode){
 var table=document.createElement('table');
 table.cellSpacing=0;table.cellPadding=0;
 table.border=0;
 if(this.hfMode)table.style.tableLayout="fixed";
 table.style.margin=0;table.style.padding=0;
 var tbody=document.createElement('tbody');
 var tr=document.createElement('tr');
 var td1=document.createElement('td');
 td1.className="standartTreeImage";
 var img0=document.createElement((itemObject.id==this.rootId)?"div":"img");
 img0.border="0";
 if(itemObject.id!=this.rootId)img0.align="absmiddle";
 td1.appendChild(img0);img0.style.padding=0;img0.style.margin=0;
 var td11=document.createElement('td');
 var inp=document.createElement((itemObject.id==this.rootId)?"div":"img");
 inp.checked=0;
 //ALESSANDRO per nodi legenda !
 var XXXXXX = new String(itemObject.id);
 if (XXXXXX.substring(0,1) != 'L')
	inp.src=this.imPath + this.checkArray[0];
 else
	inp.src = this.imPath + "nodolegenda.gif";
 //inp.src=this.imPath+this.checkArray[0];
 //ALESSANDRO
 inp.style.width="16px";inp.style.height="16px";
 if(!acheck)inp.style.display="none";
 td11.appendChild(inp);
 if(itemObject.id!=this.rootId)inp.align="absmiddle";
 inp.onclick=this.onCheckBoxClick;
 inp.treeNod=this;
 inp.parentObject=itemObject;
 td11.width="20px";
 var td12=document.createElement('td');
 td12.className="standartTreeImage";
 var img=document.createElement((itemObject.id==this.rootId)?"div":"img");img.onmousedown=this._preventNsDrag;img.ondragstart=this._preventNsDrag;
 img.border="0";
 if(this._aimgs){
 img.parentObject=itemObject;
 if(itemObject.id!=this.rootId)img.align="absmiddle";
 img.onclick=this.onRowSelect;}
 if(!mode)img.src=this.imPath+this.imageArray[0];
 td12.appendChild(img);img.style.padding=0;img.style.margin=0;
 if(this.timgen)
{img.style.width=this.def_img_x;img.style.height=this.def_img_y;}
 else
{img.style.width="0px";img.style.height="0px";}
 var td2=document.createElement('td');
 td2.className="standartTreeRow";
 itemObject.span=document.createElement('span');
 itemObject.span.className="standartTreeRow";
 if(this.mlitems)itemObject.span.style.width=this.mlitems;
 else td2.noWrap=true;
 td2.style.width="100%";
 itemObject.span.appendChild(document.createTextNode(itemObject.label));
 td2.appendChild(itemObject.span);
 td2.parentObject=itemObject;td1.parentObject=itemObject;
 td2.onclick=this.onRowSelect;td1.onclick=this.onRowClick;td2.ondblclick=this.onRowClick2;
 if(this.ettip)td2.title=itemObject.label;
 if(this.dragAndDropOff){
 if(this._aimgs){this.dragger.addDraggableItem(td12,this);td12.parentObject=itemObject;}
 this.dragger.addDraggableItem(td2,this);
}
 itemObject.span.style.paddingLeft="5px";itemObject.span.style.paddinRight="5px";td2.style.verticalAlign="";
 td2.style.fontSize="10pt";td2.style.cursor=this.style_pointer;
 tr.appendChild(td1);tr.appendChild(td11);tr.appendChild(td12);
 tr.appendChild(td2);
 tbody.appendChild(tr);
 table.appendChild(tbody);
 if(this.arFunc){
 tr.oncontextmenu=Function("this.childNodes[0].parentObject.treeNod.arFunc(this.childNodes[0].parentObject.id);return false;");
}
 return table;
};
 dhtmlXTreeObject.prototype.setImagePath=function(newPath){this.imPath=newPath;};
 dhtmlXTreeObject.prototype.setOnRightClickHandler=function(func){if(typeof(func)=="function")this.arFunc=func;else this.arFunc=eval(func);};
 dhtmlXTreeObject.prototype.setOnClickHandler=function(func){if(typeof(func)=="function")this.aFunc=func;else this.aFunc=eval(func);};
 dhtmlXTreeObject.prototype.setXMLAutoLoading=function(filePath){this.XMLsource=filePath;};
 dhtmlXTreeObject.prototype.setOnCheckHandler=function(func){if(typeof(func)=="function")this.checkFuncHandler=func;else this.checkFuncHandler=eval(func);};
 dhtmlXTreeObject.prototype.setOnOpenHandler=function(func){if(typeof(func)=="function")this.openFuncHandler=func;else this.openFuncHandler=eval(func);};
 dhtmlXTreeObject.prototype.setOnDblClickHandler=function(func){if(typeof(func)=="function")this.dblclickFuncHandler=func;else this.dblclickFuncHandler=eval(func);};
 dhtmlXTreeObject.prototype.openAllItems=function(itemId)
{
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 this._xopenAll(temp);
};
 dhtmlXTreeObject.prototype.getOpenState=function(itemId){
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return "";
 return this._getOpenState(temp);
};
 dhtmlXTreeObject.prototype.closeAllItems=function(itemId)
{
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 this._xcloseAll(temp);
};
 dhtmlXTreeObject.prototype.setUserData=function(itemId,name,value){
 var sNode=this._globalIdStorageFind(itemId);
 if(!sNode)return;
 if(name=="hint")sNode.htmlNode.childNodes[0].childNodes[0].title=value;
 sNode.userData["t_"+name]=value;
 if(!sNode._userdatalist)sNode._userdatalist=name;
 else sNode._userdatalist+=","+name;
};
 dhtmlXTreeObject.prototype.getUserData=function(itemId,name){
 var sNode=this._globalIdStorageFind(itemId);
 if(!sNode)return;
 return sNode.userData["t_"+name];
};
 dhtmlXTreeObject.prototype.getSelectedItemId=function()
{
 if(this.lastSelected)
 if(this._globalIdStorageFind(this.lastSelected.parentObject.id))
 return this.lastSelected.parentObject.id;
 return("");
};
 dhtmlXTreeObject.prototype.getItemColor=function(itemId)
{
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 var res= new Object();
 if(temp.acolor)res.acolor=temp.acolor;
 if(temp.acolor)res.scolor=temp.scolor;
 return res;
};
 dhtmlXTreeObject.prototype.getItemIdFramework=function(itemId)
{
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 var res= '';
 res=temp.IdFramework;
 return res;
};

// dhtmlXTreeObject.prototype.getItemNodeID=function(IDFramework, node)
//{
//    var i = 0;
//    var tmp = "";
//    if(node == 0)
//        node = this;
//        
//    //if(this.htmlNode.id != 0)
//    alert(node.htmlNode.childNodes[0].id);  
//    alert(node.htmlNode.childNodes[0].htmlNode.childNodes[0].id);           
//    
//    if (node.htmlNode.IDFramework == IDFramework)
//        return node.htmlNode.id;
//        
//    while (node.htmlNode.childNodes[i] != null) {  

// //       getItemNodeID(IDFramework ,node.htmlNode.childNodes[i]);
//        node._parseXMLTree (dhtmlObject,node.htmlNode.childNodes[i],node.htmlNode.id
//        i=i+1;
//    }
//   
//};

 dhtmlXTreeObject.prototype.setItemColor=function(itemId,defaultColor,selectedColor)
{
 if((itemId)&&(itemId.span))
 var temp=itemId;
 else
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 else{
 if((this.lastSelected)&&(temp.tr==this.lastSelected.parentObject.tr))
{if(selectedColor)temp.span.style.color=selectedColor;}
 else
{if(defaultColor)temp.span.style.color=defaultColor;}

 if(selectedColor)temp.scolor=selectedColor;
 if(defaultColor)temp.acolor=defaultColor;
}};
 dhtmlXTreeObject.prototype.getItemText=function(itemId)
{
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 return(temp.htmlNode.childNodes[0].childNodes[0].childNodes[3].childNodes[0].innerHTML);
};
 dhtmlXTreeObject.prototype.getParentId=function(itemId)
{
 var temp=this._globalIdStorageFind(itemId);
 if((!temp)||(!temp.parentObject))return "";
 return temp.parentObject.id;
};
 dhtmlXTreeObject.prototype.changeItemId=function(itemId,newItemId)
{
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 temp.id=newItemId;
 temp.span.contextMenuId=newItemId;
 for(var i=0;i<this._globalIdStorageSize;i++)
 if(this._globalIdStorage[i]==itemId)
{
 this._globalIdStorage[i]=newItemId;
}
};
 dhtmlXTreeObject.prototype.doCut=function(){
 if(this.nodeCut)this.clearCut();
 this.nodeCut=this.lastSelected;
 if(this.nodeCut)
{
 var tempa=this.nodeCut.parentObject;
 this.cutImg[0]=tempa.images[0];
 this.cutImg[1]=tempa.images[1];
 this.cutImg[2]=tempa.images[2];
 tempa.images[0]=tempa.images[1]=tempa.images[2]=this.cutImage;
 this._correctPlus(tempa);
}};
 dhtmlXTreeObject.prototype.doPaste=function(itemId){
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 if(this.nodeCut){
 if((!this._checkParenNodes(this.nodeCut.parentObject.id,temp))&&(id!=this.nodeCut.parentObject.parentObject.id))
 this._moveNode(temp,this.nodeCut.parentObject);
 this.clearCut();
}};
 dhtmlXTreeObject.prototype.clearCut=function(){
 if(this.nodeCut)
{
 var tempa=this.nodeCut.parentObject;
 tempa.images[0]=this.cutImg[0];
 tempa.images[1]=this.cutImg[1];
 tempa.images[2]=this.cutImg[2];
 if(tempa.parentObject)this._correctPlus(tempa);
 if(tempa.parentObject)this._correctLine(tempa);
 this.nodeCut=0;
}
};
 dhtmlXTreeObject.prototype._moveNode=function(itemObject,targetObject){
 var mode=this.dadmodec;
 if(mode==1)
{
 var z=targetObject;
 if(this.dadmodefix<0)
{
 while(true){
 z=this._getPrevNode(z);
 if((z==-1)){z=this.htmlNode;break;}
 if((z.tr.style.display=="")||(!z.parentObject))break;
}
 var nodeA=z;
 var nodeB=targetObject;
}
 else
{
 while(true){
 z=this._getNextNode(z);
 if((z==-1)){z=this.htmlNode;break;}
 if((z.tr.style.display=="")||(!z.parentObject))break;
}
 var nodeB=z;
 var nodeA=targetObject;
}
 if(this._getNodeLevel(nodeA,0)>this._getNodeLevel(nodeB,0))
{
 return this._moveNodeTo(itemObject,nodeA.parentObject);
}
 else
{
 return this._moveNodeTo(itemObject,nodeB.parentObject,nodeB);
}
}
 else return this._moveNodeTo(itemObject,targetObject);
}
dhtmlXTreeObject.prototype._fixNodesCollection=function(target,zParent){
 var flag=0;var icount=0;
 var Nodes=target.childNodes;
 var Count=target.childsCount-1;
 if(zParent==Nodes[Count])return;
 for(var i=0;i<Count;i++)
 if(Nodes[i]==Nodes[Count]){Nodes[i]=Nodes[i+1];Nodes[i+1]=Nodes[Count];}
 for(var i=0;i<Count+1;i++)
{
 if(flag){
 var temp=Nodes[i];
 Nodes[i]=flag;
 flag=temp;
}
 else 
 if(Nodes[i]==zParent){flag=Nodes[i];Nodes[i]=Nodes[Count];}
}};
 dhtmlXTreeObject.prototype._moveNodeTo=function(itemObject,targetObject,beforeNode){
 if(targetObject.mytype)
 var framesMove=(itemObject.treeNod.lWin!=targetObject.lWin);
 else
 var framesMove=(itemObject.treeNod.lWin!=targetObject.treeNod.lWin);
 if(this.dragFunc)if(!this.dragFunc(itemObject.id,targetObject.id,(beforeNode?beforeNode.id:null),itemObject.treeNod,targetObject.treeNod))return false;
 if((targetObject.XMLload==0)&&(this.XMLsource))
{
 targetObject.XMLload=1;this.loadXML(this.XMLsource+getUrlSymbol(this.XMLsource)+"id="+escape(targetObject.id));
}
 this.openItem(targetObject.id);
 var oldTree=itemObject.treeNod;
 var c=itemObject.parentObject.childsCount;
 var z=itemObject.parentObject;
 if((framesMove)||(oldTree.dpcpy))
 itemObject=this._recreateBranch(itemObject,targetObject,beforeNode);
 else
{
 var Count=targetObject.childsCount;var Nodes=targetObject.childNodes;
 Nodes[Count]=itemObject;
 itemObject.treeNod=targetObject.treeNod;
 targetObject.childsCount++;
 var tr=this._drawNewTr(Nodes[Count].htmlNode);
 if(!beforeNode)
{
 targetObject.htmlNode.childNodes[0].appendChild(tr);
 if(this.dadmode==1)this._fixNodesCollection(targetObject,beforeNode);
}
 else 
{
 targetObject.htmlNode.childNodes[0].insertBefore(tr,beforeNode.tr);
 this._fixNodesCollection(targetObject,beforeNode);
 Nodes=targetObject.childNodes;
}}
 if(!oldTree.dpcpy){
 itemObject.parentObject.htmlNode.childNodes[0].removeChild(itemObject.tr);
 if((!beforeNode)||(targetObject!=itemObject.parentObject)){
 for(var i=0;i<z.childsCount;i++){
 if(z.childNodes[i].id==itemObject.id){
 z.childNodes[i]=0;
 break;}}}
 else z.childNodes[z.childsCount-1]=0;
 oldTree._compressChildList(z.childsCount,z.childNodes);
 z.childsCount--;
}
 if((!framesMove)&&(!oldTree.dpcpy)){
 itemObject.tr=tr;
 tr.nodem=itemObject;
 itemObject.parentObject=targetObject;
 if(oldTree!=targetObject.treeNod){if(itemObject.treeNod._registerBranch(itemObject,oldTree))return;this._clearStyles(itemObject);this._redrawFrom(this,itemObject.parentObject);};
 this._correctPlus(targetObject);
 this._correctLine(targetObject);
 this._correctLine(itemObject);
 this._correctPlus(itemObject);
 if(beforeNode)
{
 this._correctPlus(beforeNode);
}
 else 
 if(targetObject.childsCount>=2)
{
 this._correctPlus(Nodes[targetObject.childsCount-2]);
 this._correctLine(Nodes[targetObject.childsCount-2]);
}
 this._correctPlus(Nodes[targetObject.childsCount-1]);
 if(this.tscheck)this._correctCheckStates(targetObject);
 if(oldTree.tscheck)oldTree._correctCheckStates(z);
}
 if(c>1){oldTree._correctPlus(z.childNodes[c-2]);
 oldTree._correctLine(z.childNodes[c-2]);
}
 oldTree._correctPlus(z);
 if(this.dropFunc)this.dropFunc(itemObject.id,targetObject.id,(beforeNode?beforeNode.id:null),itemObject.treeNod,targetObject.treeNod);
 return itemObject.id;
};
dhtmlXTreeObject.prototype._checkParenNodes=function(itemId,htmlObject,shtmlObject){
 if(shtmlObject){if(shtmlObject.parentObject.id==htmlObject.id)return 1;}
 if(htmlObject.id==itemId)return 1;
 if(htmlObject.parentObject)return this._checkParenNodes(itemId,htmlObject.parentObject);else return 0;
};
 dhtmlXTreeObject.prototype._clearStyles=function(itemObject){
 var td1=itemObject.htmlNode.childNodes[0].childNodes[0].childNodes[1];
 var td3=td1.nextSibling.nextSibling;
 itemObject.span.innerHTML=itemObject.label;
 if(this.checkBoxOff){td1.childNodes[0].style.display="";td1.childNodes[0].onclick=this.onCheckBoxClick;}
 else td1.childNodes[0].style.display="none";
 td1.childNodes[0].treeNod=this;
 this.dragger.removeDraggableItem(td3);
 if(this.dragAndDropOff)this.dragger.addDraggableItem(td3,this);
 td3.childNodes[0].className="standartTreeRow";
 td3.onclick=this.onRowSelect;td3.ondblclick=this.onRowClick2;
 td1.previousSibling.onclick=this.onRowClick;
 this._correctLine(itemObject);
 this._correctPlus(itemObject);
 for(var i=0;i<itemObject.childsCount;i++)this._clearStyles(itemObject.childNodes[i]);
};
 dhtmlXTreeObject.prototype._registerBranch=function(itemObject,oldTree){
 itemObject.id=this._globalIdStorageAdd(itemObject.id,itemObject);
 itemObject.treeNod=this;
 if(oldTree)oldTree._globalIdStorageSub(itemObject.id);
 for(var i=0;i<itemObject.childsCount;i++)
 this._registerBranch(itemObject.childNodes[i],oldTree);
 return 0;
};
 dhtmlXTreeObject.prototype.enableThreeStateCheckboxes=function(mode){this.tscheck=convertStringToBoolean(mode);};
 dhtmlXTreeObject.prototype.enableTreeImages=function(mode){this.timgen=convertStringToBoolean(mode);};
 dhtmlXTreeObject.prototype.enableFixedMode=function(mode){this.hfMode=convertStringToBoolean(mode);};
 dhtmlXTreeObject.prototype.enableCheckBoxes=function(mode){this.checkBoxOff=convertStringToBoolean(mode);};
 dhtmlXTreeObject.prototype.setStdImages=function(image1,image2,image3){
 this.imageArray[0]=image1;this.imageArray[1]=image2;this.imageArray[2]=image3;};
 dhtmlXTreeObject.prototype.enableTreeLines=function(mode){
 this.treeLinesOn=convertStringToBoolean(mode);
}
 dhtmlXTreeObject.prototype.setImageArrays=function(arrayName,image1,image2,image3,image4,image5){
 switch(arrayName){
 case "plus": this.plusArray[0]=image1;this.plusArray[1]=image2;this.plusArray[2]=image3;this.plusArray[3]=image4;this.plusArray[4]=image5;break;
 case "minus": this.minusArray[0]=image1;this.minusArray[1]=image2;this.minusArray[2]=image3;this.minusArray[3]=image4;this.minusArray[4]=image5;break;
}};
 dhtmlXTreeObject.prototype.openItem=function(itemId){
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 else return this._openItem(temp);
};
 dhtmlXTreeObject.prototype._openItem=function(item){
 this._HideShow(item,2);
 if((item.parentObject)&&(this._getOpenState(item.parentObject)<0))
 this._openItem(item.parentObject);
};
 dhtmlXTreeObject.prototype.closeItem=function(itemId){
 if(this.rootId==itemId)return 0;
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 if(temp.closeble)
 this._HideShow(temp,1);
};
 dhtmlXTreeObject.prototype.getLevel=function(itemId){
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 return this._getNodeLevel(temp,0);
};
 dhtmlXTreeObject.prototype.setItemCloseable=function(itemId,flag)
{
 flag=convertStringToBoolean(flag);
 if((itemId)&&(itemId.span))
 var temp=itemId;
 else 
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 temp.closeble=flag;
};
 dhtmlXTreeObject.prototype._getNodeLevel=function(itemObject,count){
 if(itemObject.parentObject)return this._getNodeLevel(itemObject.parentObject,count+1);
 return(count);
};
 dhtmlXTreeObject.prototype.hasChildren=function(itemId){
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 else 
{
 if((this.XMLsource)&&(!temp.XMLload))return true;
 else 
 return temp.childsCount;
};};
 dhtmlXTreeObject.prototype.setItemText=function(itemId,newLabel,newTooltip)
{
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 temp.label=newLabel;
 temp.span.innerHTML=newLabel;
 temp.span.parentNode.title=newTooltip||"";
};
 dhtmlXTreeObject.prototype.refreshItem=function(itemId){
 if(!itemId)itemId=this.rootId;
 var temp=this._globalIdStorageFind(itemId);
 this.deleteChildItems(itemId);
 this.loadXML(this.XMLsource+getUrlSymbol(this.XMLsource)+"id="+escape(itemId));
};
 dhtmlXTreeObject.prototype.setItemImage2=function(itemId,image1,image2,image3){
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 temp.images[1]=image2;
 temp.images[2]=image3;
 temp.images[0]=image1;
 this._correctPlus(temp);
};
 dhtmlXTreeObject.prototype.setItemImage=function(itemId,image1,image2)
{
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 if(image2)
{
 temp.images[1]=image1;
 temp.images[2]=image2;
}
 else temp.images[0]=image1;
 this._correctPlus(temp);
};
 dhtmlXTreeObject.prototype.getSubItems =function(itemId)
{
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;

 var z="";
 for(i=0;i<temp.childsCount;i++)
 if(!z)z=temp.childNodes[i].id;
 else z+=","+temp.childNodes[i].id;
 return z;
};
 dhtmlXTreeObject.prototype.getAllSubItems =function(itemId){
 return this._getAllSubItems(itemId);
}
 dhtmlXTreeObject.prototype._getAllSubItems =function(itemId,z,node)
{
 if(node)temp=node;
 else{
 var temp=this._globalIdStorageFind(itemId);
};
 if(!temp)return 0;
 z="";
 for(var i=0;i<temp.childsCount;i++)
{
 if(!z)z=temp.childNodes[i].id;
 else z+=","+temp.childNodes[i].id;
 var zb=this._getAllSubItems(0,z,temp.childNodes[i])
 if(zb)z+=","+zb;
}
 return z;
};
 dhtmlXTreeObject.prototype.selectItem=function(itemId,mode){
 mode=convertStringToBoolean(mode);
 var temp=this._globalIdStorageFind(itemId);
 if(!temp)return 0;
 if(this._getOpenState(temp.parentObject)==-1)
 this.openItem(itemId);
 if(mode)
 this.onRowSelect(0,temp.htmlNode.childNodes[0].childNodes[0].childNodes[3],false);
 else
 this.onRowSelect(0,temp.htmlNode.childNodes[0].childNodes[0].childNodes[3],true);
};
 dhtmlXTreeObject.prototype.getSelectedItemText=function()
{
 if(this.lastSelected)
 return this.lastSelected.parentObject.htmlNode.childNodes[0].childNodes[0].childNodes[3].childNodes[0].innerHTML;
 else return("");
};
 dhtmlXTreeObject.prototype._compressChildList=function(Count,Nodes)
{
 Count--;
 for(var i=0;i<Count;i++)
{
 if(Nodes[i]==0){Nodes[i]=Nodes[i+1];Nodes[i+1]=0;}
};
};
 dhtmlXTreeObject.prototype._deleteNode=function(itemId,htmlObject,skip){
 if(!skip){
 this._globalIdStorageRecSub(htmlObject);
}
 if((!htmlObject)||(!htmlObject.parentObject))return 0;
 var tempos=0;var tempos2=0;
 if(htmlObject.tr.nextSibling)tempos=htmlObject.tr.nextSibling.nodem;
 if(htmlObject.tr.previousSibling)tempos2=htmlObject.tr.previousSibling.nodem;
 var sN=htmlObject.parentObject;
 var Count=sN.childsCount;
 var Nodes=sN.childNodes;
 for(var i=0;i<Count;i++)
{
 if(Nodes[i].id==itemId){
 if(!skip)sN.htmlNode.childNodes[0].removeChild(Nodes[i].tr);
 Nodes[i]=0;
 break;
}}
 this._compressChildList(Count,Nodes);
 if(!skip){
 sN.childsCount--;
}
 if(tempos){
 this._correctPlus(tempos);
 this._correctLine(tempos);
}
 if(tempos2){
 this._correctPlus(tempos2);
 this._correctLine(tempos2);
}
 if(this.tscheck)this._correctCheckStates(sN);
};
 dhtmlXTreeObject.prototype.setCheck=function(itemId,state){
 state=convertStringToBoolean(state);
 var sNode=this._globalIdStorageFind(itemId);
 if(!sNode)return;
 if((this.tscheck)&&(this.smcheck))this._setSubChecked(state,sNode);
 else this._setCheck(sNode,state);
 if(this.smcheck)
 this._correctCheckStates(sNode.parentObject);
};
 dhtmlXTreeObject.prototype._setCheck=function(sNode,state){
 var z=sNode.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0];
 if(state=="notsure")sNode.checkstate=2;
 else if(state)sNode.checkstate=1;else sNode.checkstate=0;
 z.src=this.imPath+this.checkArray[sNode.checkstate];
};
dhtmlXTreeObject.prototype.setSubChecked=function(itemId,state){
 var sNode=this._globalIdStorageFind(itemId);
 this._setSubChecked(state,sNode);
 this._correctCheckStates(sNode.parentObject);
}
dhtmlXTreeObject.prototype._setSubCheckedXML=function(state,sNode){
 if(!sNode)return;
 for(var i=0;i<sNode.childNodes.length;i++){
 var tag=sNode.childNodes[i];
 if((tag)&&(tag.tagName=="item")){
 if(state)tag.setAttribute("checked",1);
 else tag.setAttribute("checked","");
 this._setSubCheckedXML(state,tag);
}}}
 dhtmlXTreeObject.prototype._setSubChecked=function(state,sNode){
//ALESSANDRO per nodi legenda !
var YYYYYY = new String(sNode.id);
if (YYYYYY.substring(0,1) == 'L')
	return;
//ALESSANDRO
 state=convertStringToBoolean(state);
 if(!sNode)return;
 if(sNode.unParsed)
 this._setSubCheckedXML(state,sNode.unParsed)
 for(var i=0;i<sNode.childsCount;i++)
{
 this._setSubChecked(state,sNode.childNodes[i]);
};
 var z=sNode.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0];
 if(state)sNode.checkstate=1;
 else sNode.checkstate=0;
 z.src=this.imPath+this.checkArray[sNode.checkstate];
};
 dhtmlXTreeObject.prototype.isItemChecked=function(itemId){
 var sNode=this._globalIdStorageFind(itemId);
 if(!sNode)return;
 return sNode.checkstate;
};
 dhtmlXTreeObject.prototype.getAllChecked=function(){
 return this._getAllChecked("","",1);
}
 
 dhtmlXTreeObject.prototype.getAllCheckedBranches=function(){
 return this._getAllChecked("","",0);
}
 dhtmlXTreeObject.prototype._getAllChecked=function(htmlNode,list,mode){
 if(!htmlNode)htmlNode=this.htmlNode;
 if(((mode)&&(htmlNode.checkstate==1))||((!mode)&&(htmlNode.checkstate>0)))
    //MCS if(!htmlNode.nocheckbox){if(list)list+=","+htmlNode.id;else list=htmlNode.id;}
    //Recupero l'IDFramework invece dell'ID 
     if(!htmlNode.nocheckbox){if(list)list+=","+htmlNode.IdFramework;else list=htmlNode.IdFramework;}
     //MCS Modifica per non fare il parsing dei rami il cui padre non è selezionato.
     if ((htmlNode.id == 0) || (htmlNode.id == 'PRIMONODO') || (((mode)&&(htmlNode.checkstate==1))||((!mode)&&(htmlNode.checkstate>0))))
     {
         var j=htmlNode.childsCount;
         
         for(var i=0;i<j;i++)
        {
         list=this._getAllChecked(htmlNode.childNodes[i],list,mode);
        };
         if(htmlNode.unParsed)
         list=this._getAllCheckedXML(htmlNode.unParsed,list,mode);
     }
 if(list)return list;else return "";
};
 dhtmlXTreeObject.prototype._getAllCheckedXML=function(htmlNode,list,mode){
 var j=htmlNode.childNodes.length;
 for(var i=0;i<j;i++)
{
 var tNode=htmlNode.childNodes[i];
 if(tNode.tagName=="item")
{
 var z=tNode.getAttribute("checked");
 if((z!=null)&&(z!="")&&(z!="0"))
 if(((z=="-1")&&(!mode))||(z!="-1"))
 if(list)list+=","+tNode.getAttribute("id");
 else list=htmlNode.id;
 list=this._getAllChecked(tNode,list,mode);
}
};
 if(list)return list;else return "";
};
 dhtmlXTreeObject.prototype.deleteChildItems=function(itemId)
{
 var sNode=this._globalIdStorageFind(itemId);
 if(!sNode)return;
 var j=sNode.childsCount;
 for(var i=0;i<j;i++)
{
 this._deleteNode(sNode.childNodes[0].id,sNode.childNodes[0]);
};};
dhtmlXTreeObject.prototype.deleteItem=function(itemId,selectParent){
 this._deleteItem(itemId,selectParent);
}
dhtmlXTreeObject.prototype._deleteItem=function(itemId,selectParent,skip){
 selectParent=convertStringToBoolean(selectParent);
 var sNode=this._globalIdStorageFind(itemId);
 if(!sNode)return;
 if(selectParent)this.selectItem(this.getParentId(this.getSelectedItemId()),1);
 else
 if(sNode==this.lastSelected.parentObject)
 this.lastSelected=null;
 if(!skip){
 this._globalIdStorageRecSub(sNode);
};
 var zTemp=sNode.parentObject;
 this._deleteNode(itemId,sNode,skip);
 this._correctPlus(zTemp);
 this._correctLine(zTemp);
 return zTemp;
};
 dhtmlXTreeObject.prototype._globalIdStorageRecSub=function(itemObject){
 for(var i=0;i<itemObject.childsCount;i++)
{
 this._globalIdStorageRecSub(itemObject.childNodes[i]);
 this._globalIdStorageSub(itemObject.childNodes[i].id);
};
 this._globalIdStorageSub(itemObject.id);
};
 dhtmlXTreeObject.prototype.insertNewNext=function(parentItemId,itemId,itemName,itemActionHandler,image1,image2,image3,optionStr,childs){
 var sNode=this._globalIdStorageFind(parentItemId);
 if((!sNode)||(!sNode.parentObject))return(0);
 this._attachChildNode(0,itemId,itemName,itemActionHandler,image1,image2,image3,optionStr,childs,sNode,-1);
};
 dhtmlXTreeObject.prototype.getItemIdByIndex=function(itemId,index){
 var z=this._globalIdStorageFind(itemId);
 if((!z)||(index>z.childsCount))return null;
 return z.childNodes[index].id;
};
 dhtmlXTreeObject.prototype.getChildItemIdByIndex=function(itemId,index){
 var z=this._globalIdStorageFind(itemId);
 if((!z)||(index>z.childsCount))return null;
 return z.childNodes[index].id;
};
 dhtmlXTreeObject.prototype.setDragHandler=function(func){if(typeof(func)=="function")this.dragFunc=func;else this.dragFunc=eval(func);};
 dhtmlXTreeObject.prototype._clearMove=function(htmlNode){
 if((htmlNode.parentObject)&&(htmlNode.parentObject.span)){
 htmlNode.parentObject.span.className='standartTreeRow';
 if(htmlNode.parentObject.acolor)htmlNode.parentObject.span.style.color=htmlNode.parentObject.acolor;
}
 this.selectionBar.style.display="none";
 this.allTree.className="containerTableStyle";
};
 dhtmlXTreeObject.prototype.enableDragAndDrop=function(mode){
 this.dragAndDropOff=convertStringToBoolean(mode);
 if(this.dragAndDropOff)this.dragger.addDragLanding(this.allTree,this);
};
 dhtmlXTreeObject.prototype._setMove=function(htmlNode,x,y){
 if(htmlNode.parentObject.span){
 var a1=getAbsoluteTop(htmlNode);
 var a2=getAbsoluteTop(this.allTree);
 this.dadmodec=this.dadmode;
 this.dadmodefix=0;
 if(this.dadmodec==0)
{
 htmlNode.parentObject.span.className='selectedTreeRow';
 if(htmlNode.parentObject.scolor)htmlNode.parentObject.span.style.color=htmlNode.parentObject.scolor;
}
 else{
 htmlNode.parentObject.span.className='standartTreeRow';
 if(htmlNode.parentObject.acolor)htmlNode.parentObject.span.style.color=htmlNode.parentObject.acolor;
 this.selectionBar.style.top=a1-a2+16+this.dadmodefix;
 this.selectionBar.style.left=5;
 this.selectionBar.style.display="";
}
 if(this.autoScroll)
{
 if((a1-a2-parseInt(this.allTree.scrollTop))>(parseInt(this.allTree.offsetHeight)-50))
 this.allTree.scrollTop=parseInt(this.allTree.scrollTop)+20;
 if((a1-a2)<(parseInt(this.allTree.scrollTop)+30))
 this.allTree.scrollTop=parseInt(this.allTree.scrollTop)-20;
}}};
dhtmlXTreeObject.prototype._createDragNode=function(htmlObject){
 dhtmlObject=htmlObject.parentObject;
 if(this.lastSelected)this._clearMove(this.lastSelected);
 var dragSpan=document.createElement('div');
 dragSpan.innerHTML=dhtmlObject.label;
 dragSpan.style.position="absolute";
 dragSpan.className="dragSpanDiv";
 return dragSpan;
}
dhtmlXTreeObject.prototype._preventNsDrag=function(e){
 if((e)&&(e.preventDefault)){e.preventDefault();return false;}
 return false;
}
dhtmlXTreeObject.prototype._drag=function(sourceHtmlObject,dhtmlObject,targetHtmlObject){
 if(this._autoOpenTimer)clearTimeout(this._autoOpenTimer);
 if(!targetHtmlObject.parentObject){
 targetHtmlObject=this.htmlNode.htmlNode.childNodes[0].childNodes[0].childNodes[1].childNodes[0];
 this.dadmodec=0;
}
 this._clearMove(targetHtmlObject);
 var z=targetHtmlObject.parentObject.treeNod;
 z._clearMove("");
 if((!this.dragMove)||(this.dragMove()))
{
 var newID=this._moveNode(sourceHtmlObject.parentObject,targetHtmlObject.parentObject);
 z.selectItem(newID);
}
 try{}
 catch(e){
 return;
}
}
dhtmlXTreeObject.prototype._dragIn=function(htmlObject,shtmlObject,x,y){
 if(!htmlObject.parentObject)
{
 this.allTree.className="containerTableStyle selectionBox";
 return htmlObject;
}
 if((!this._checkParenNodes(shtmlObject.parentObject.id,htmlObject.parentObject,shtmlObject.parentObject))&&(htmlObject.parentObject.id!=shtmlObject.parentObject.id))
{
 htmlObject.parentObject.span.parentNode.appendChild(this.selectionBar);
 this._setMove(htmlObject,x,y);
 if(this._getOpenState(htmlObject.parentObject)<0)
 this._autoOpenTimer=window.setTimeout(new callerFunction(this._autoOpenItem,this),1000);
 this._autoOpenId=htmlObject.parentObject.id;
 return htmlObject;
}
 else return 0;
}
dhtmlXTreeObject.prototype._autoOpenItem=function(e,treeObject){
 treeObject.openItem(treeObject._autoOpenId);
};
dhtmlXTreeObject.prototype._dragOut=function(htmlObject){
this._clearMove(htmlObject);
if(this._autoOpenTimer)clearTimeout(this._autoOpenTimer);
}
dhtmlXTreeObject.prototype._getNextNode=function(item,mode){
 if((!mode)&&(item.childsCount))return item.childNodes[0];
 if(item==this.htmlNode)
 return -1;
 if((item.tr)&&(item.tr.nextSibling)&&(item.tr.nextSibling.nodem))
 return item.tr.nextSibling.nodem;
 return this._getNextNode(item.parentObject,true);
};
dhtmlXTreeObject.prototype._lastChild=function(item){
 if(item.childsCount)
 return this._lastChild(item.childNodes[item.childsCount-1]);
 else return item;
};
dhtmlXTreeObject.prototype._getPrevNode=function(node,mode){
 if((node.tr)&&(node.tr.previousSibling)&&(node.tr.previousSibling.nodem))
 return this._lastChild(node.tr.previousSibling.nodem);
 if(node.parentObject)
 return node.parentObject;
 else return -1;
};
//dhtmlXTree.js
//dhtmlXCommon.js
function dtmlXMLLoaderObject(funcObject,dhtmlObject,async){
 this.xmlDoc="";
 if(arguments.length==2)
 this.async = true;
 else
 this.async=async;
 this.onloadAction=funcObject||null;
 this.mainObject=dhtmlObject||null;
 return this;
};
 dtmlXMLLoaderObject.prototype.waitLoadFunction=function(dhtmlObject){
 this.check=function(){
 if(dhtmlObject.onloadAction!=null){
 if(!dhtmlObject.xmlDoc.readyState)dhtmlObject.onloadAction(dhtmlObject.mainObject);
 else{
 if(dhtmlObject.xmlDoc.readyState != 4)return false;
 else dhtmlObject.onloadAction(dhtmlObject.mainObject);}
}
};
 return this.check;
};
 dtmlXMLLoaderObject.prototype.getXMLTopNode=function(tagName){
 if(this.xmlDoc.responseXML){var temp=this.xmlDoc.responseXML.getElementsByTagName(tagName);var z=temp[0];}
 else var z=this.xmlDoc.documentElement;
 if(z)return z;
 return document.createElement("DIV");
};
 dtmlXMLLoaderObject.prototype.loadXMLString=function(xmlString){
 try 
{
 var parser = new DOMParser();
 this.xmlDoc = parser.parseFromString(xmlString,"text/xml");
}
 catch(e)
{
 this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
 this.xmlDoc.async=this.async
 this.xmlDoc.loadXML(xmlString);
}
 this.onloadAction(this.mainObject);
}
 dtmlXMLLoaderObject.prototype.loadXML=function(filePath){
 try 
{
 this.xmlDoc = new XMLHttpRequest();
 this.xmlDoc.open("GET",filePath,this.async);
 this.xmlDoc.onreadystatechange = new this.waitLoadFunction(this);
 this.xmlDoc.send(null);
}
 catch(e){
 if(document.implementation && document.implementation.createDocument)
{
 this.xmlDoc = document.implementation.createDocument("","",null);
 this.xmlDoc.onload = new this.waitLoadFunction(this);
}
 else
{
 this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
 this.xmlDoc.async=this.async
 this.xmlDoc.onreadystatechange=new this.waitLoadFunction(this);
}
 this.xmlDoc.load(filePath);
}
};
function callerFunction(funcObject,dhtmlObject){
 this.handler=function(e){
 if(!e)e=event;
 funcObject(e,dhtmlObject);
 return true;
};
 return this.handler;
};
function getAbsoluteLeft(htmlObject){
 var xPos = htmlObject.offsetLeft;
 var temp = htmlObject.offsetParent;
 while(temp != null){
 xPos+= temp.offsetLeft;
 temp = temp.offsetParent;
}
 return xPos;
}
function getAbsoluteTop(htmlObject){
 var yPos = htmlObject.offsetTop;
 var temp = htmlObject.offsetParent;
 while(temp != null){
 yPos+= temp.offsetTop;
 temp = temp.offsetParent;
}
 return yPos;
}
function convertStringToBoolean(inputString){if(typeof(inputString)=="string")inputString=inputString.toLowerCase();
 switch(inputString){
 case "1":
 case "true":
 case "yes":
 case "y":
 case 1: 
 case true: 
 return true;
 break;
 default: return false;
}
}
function getUrlSymbol(str){
 if(str.indexOf("?")!=-1)
 return "&"
 else
 return "?"
}
function dhtmlDragAndDropObject(){
 this.lastLanding=0;
 this.dragNode=0;
 this.dragStartNode=0;
 this.dragStartObject=0;
 this.tempDOMU=null;
 this.tempDOMM=null;
 this.waitDrag=0;
 if(window.dhtmlDragAndDrop)return window.dhtmlDragAndDrop;
 window.dhtmlDragAndDrop=this;
 return this;
};
 dhtmlDragAndDropObject.prototype.removeDraggableItem=function(htmlNode){
 htmlNode.onmousedown=null;
 htmlNode.dragStarter=null;
 htmlNode.dragLanding=null;
}
 dhtmlDragAndDropObject.prototype.addDraggableItem=function(htmlNode,dhtmlObject){
 htmlNode.onmousedown=this.preCreateDragCopy;
 htmlNode.dragStarter=dhtmlObject;
 this.addDragLanding(htmlNode,dhtmlObject);
}
 dhtmlDragAndDropObject.prototype.addDragLanding=function(htmlNode,dhtmlObject){
 htmlNode.dragLanding=dhtmlObject;
}
 dhtmlDragAndDropObject.prototype.preCreateDragCopy=function(e)
{
 if(window.dhtmlDragAndDrop.waitDrag){
 window.dhtmlDragAndDrop.waitDrag=0;
 document.body.onmouseup=window.dhtmlDragAndDrop.tempDOMU;
 document.body.onmousemove=window.dhtmlDragAndDrop.tempDOMM;
 return false;
}
 window.dhtmlDragAndDrop.waitDrag=1;
 window.dhtmlDragAndDrop.tempDOMU=document.body.onmouseup;
 window.dhtmlDragAndDrop.tempDOMM=document.body.onmousemove;
 window.dhtmlDragAndDrop.dragStartNode=this;
 window.dhtmlDragAndDrop.dragStartObject=this.dragStarter;
 document.body.onmouseup=window.dhtmlDragAndDrop.preCreateDragCopy;
 document.body.onmousemove=window.dhtmlDragAndDrop.callDrag;
 if((e)&&(e.preventDefault)){e.preventDefault();return false;}
 return false;
};
 dhtmlDragAndDropObject.prototype.callDrag=function(e){
 if(!e)e=window.event;
 dragger=window.dhtmlDragAndDrop;
 if((e.button==0)&&(isIE()))return dragger.stopDrag();
 if(!dragger.dragNode){
 dragger.dragNode=dragger.dragStartObject._createDragNode(dragger.dragStartNode);
 if(!dragger.dragNode)return dragger.stopDrag();
 dragger.gldragNode=dragger.dragNode;
 document.body.appendChild(dragger.dragNode);
 document.body.onmouseup=dragger.stopDrag;
 dragger.waitDrag=0;
 dragger.dragNode.pWindow=window;
 dragger.initFrameRoute();
}
 if(dragger.dragNode.parentNode!=window.document.body){
 var grd=dragger.gldragNode;
 if(dragger.gldragNode.old)grd=dragger.gldragNode.old;
 grd.parentNode.removeChild(grd);
 var oldBody=dragger.dragNode.pWindow;
 if(isIE()){
 var div=document.createElement("Div");
 div.innerHTML=dragger.dragNode.outerHTML;
 dragger.dragNode=div.childNodes[0];}
 else dragger.dragNode=dragger.dragNode.cloneNode(true);
 dragger.dragNode.pWindow=window;
 dragger.gldragNode.old=dragger.dragNode;
 document.body.appendChild(dragger.dragNode);
 oldBody.dhtmlDragAndDrop.dragNode=dragger.dragNode;
}
 dragger.dragNode.style.left=e.clientX+15+(dragger.fx?dragger.fx*(-1):0)+document.body.scrollLeft+"px";
 dragger.dragNode.style.top=e.clientY+3+(dragger.fy?(-1)*dragger.fy:0)+document.body.scrollTop+"px";
 if(!e.srcElement)var z=e.target;else z=e.srcElement;
 dragger.checkLanding(z,e.clientX,e.clientY);
}
 dhtmlDragAndDropObject.prototype.calculateFramePosition=function(n){
 if(window.name){
 var el =parent.frames[window.name].frameElement.offsetParent;
 var fx=0;
 var fy=0;
 while(el){fx+= el.offsetLeft;fy+= el.offsetTop;el = el.offsetParent;}
 if((parent.dhtmlDragAndDrop)){var ls=parent.dhtmlDragAndDrop.calculateFramePosition(1);fx+=ls.split('_')[0]*1;fy+=ls.split('_')[1]*1;}
 if(n)return fx+"_"+fy;
 else this.fx=fx;this.fy=fy;
}
 return "0_0";
}
 dhtmlDragAndDropObject.prototype.checkLanding=function(htmlObject,x,y){

 if((htmlObject)&&(htmlObject.dragLanding)){if(this.lastLanding)this.lastLanding.dragLanding._dragOut(this.lastLanding);
 this.lastLanding=htmlObject;this.lastLanding=this.lastLanding.dragLanding._dragIn(this.lastLanding,this.dragStartNode,x,y);}
 else{
 if((htmlObject)&&(htmlObject.tagName!="BODY"))this.checkLanding(htmlObject.parentNode,x,y);
 else{if(this.lastLanding)this.lastLanding.dragLanding._dragOut(this.lastLanding,x,y);this.lastLanding=0;}
}
}
 dhtmlDragAndDropObject.prototype.stopDrag=function(e,mode){
 dragger=window.dhtmlDragAndDrop;
 if(!mode)
{
 dragger.stopFrameRoute();
 var temp=dragger.lastLanding;
 dragger.lastLanding=null;
 if(temp)temp.dragLanding._drag(dragger.dragStartNode,dragger.dragStartObject,temp);
}
 dragger.lastLanding=null;
 if((dragger.dragNode)&&(dragger.dragNode.parentNode==document.body))dragger.dragNode.parentNode.removeChild(dragger.dragNode);
 dragger.dragNode=0;
 dragger.gldragNode=0;
 dragger.fx=0;
 dragger.fy=0;
 dragger.dragStartNode=0;
 dragger.dragStartObject=0;
 document.body.onmouseup=dragger.tempDOMU;
 document.body.onmousemove=dragger.tempDOMM;
 dragger.tempDOMU=null;
 dragger.tempDOMM=null;
 dragger.waitDrag=0;
}
 dhtmlDragAndDropObject.prototype.stopFrameRoute=function(win){
 if(win)
 window.dhtmlDragAndDrop.stopDrag(1,1);
 for(var i=0;i<window.frames.length;i++)
 if((window.frames[i]!=win)&&(window.frames[i].dhtmlDragAndDrop))
 window.frames[i].dhtmlDragAndDrop.stopFrameRoute(window);
 if((parent.dhtmlDragAndDrop)&&(parent!=window)&&(parent!=win))
 parent.dhtmlDragAndDrop.stopFrameRoute(window);
}
 dhtmlDragAndDropObject.prototype.initFrameRoute=function(win,mode){
 if(win){
 window.dhtmlDragAndDrop.preCreateDragCopy();
 window.dhtmlDragAndDrop.dragStartNode=win.dhtmlDragAndDrop.dragStartNode;
 window.dhtmlDragAndDrop.dragStartObject=win.dhtmlDragAndDrop.dragStartObject;
 window.dhtmlDragAndDrop.dragNode=win.dhtmlDragAndDrop.dragNode;
 window.dhtmlDragAndDrop.gldragNode=win.dhtmlDragAndDrop.dragNode;
 window.document.body.onmouseup=window.dhtmlDragAndDrop.stopDrag;
 window.waitDrag=0;
 if((!isIE())&&(mode))window.dhtmlDragAndDrop.calculateFramePosition();
}
 if((parent.dhtmlDragAndDrop)&&(parent!=window)&&(parent!=win))
 parent.dhtmlDragAndDrop.initFrameRoute(window);
 for(var i=0;i<window.frames.length;i++)
 if((window.frames[i]!=win)&&(window.frames[i].dhtmlDragAndDrop))
 window.frames[i].dhtmlDragAndDrop.initFrameRoute(window,((!win||mode)?1:0));
}
function isIE(){
 if(navigator.appName.indexOf("Microsoft")!=-1)
 if(navigator.userAgent.indexOf('Opera')== -1)
 return true;
 return false;
}
dtmlXMLLoaderObject.prototype.doXPath = function(xpathExp,docObj){
 if(isIE())
 {
 if(arguments.length==1)
 {
 docObj = this.xmlDoc
 }
 return docObj.selectNodes(xpathExp);
 }
 else{
 var nodeObj = docObj;
 if(!docObj){
 if(!this.xmlDoc.nodeName){
 docObj = this.xmlDoc.responseXML
}else{
 docObj = this.xmlDoc;
}
}
 if(docObj.nodeName.indexOf("document")!=-1){
 nodeObj = docObj;
}else{
 nodeObj = docObj;
 docObj = docObj.ownerDocument;
}
 var rowsCol = new Array();
 var col = docObj.evaluate(xpathExp,nodeObj,null,XPathResult.ANY_TYPE,null);
 var thisColMemb = col.iterateNext();
 while(thisColMemb){
 rowsCol[rowsCol.length] = thisColMemb;
 thisColMemb = col.iterateNext();
}
 return rowsCol;
}
}
if(window.Node)
Node.prototype.removeNode = function(removeChildren)
{
 var self = this;
 if(Boolean(removeChildren))
{
 return this.parentNode.removeChild(self);
}
 else
{
 var range = document.createRange();
 range.selectNodeContents(self);
 return this.parentNode.replaceChild(range.extractContents(),self);
}
}
//dhtmlXCommon.js
document.write("<style type='text/css'>");
document.write(".defaultTreeTable{");
document.write("	margin : 0;");
document.write("	padding : 0;");
document.write("	border : 0;");
document.write("}");
document.write(".containerTableStyle { overflow : auto; font-size : 12px;}");
document.write(".standartTreeRow{	font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; 	font-size : 12px; -moz-user-select: none; }");
document.write(".selectedTreeRow{ background-color : navy; color:white; font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; 		font-size : 12px;  -moz-user-select: none;  }");
document.write(".standartTreeImage{ width:18px; height:18px;  overflow:hidden; border:0; padding:0; margin:0; }");
document.write(".hiddenRow { width:1px;   overflow:hidden;  }");
document.write(".dragSpanDiv{ 	font-size : 12px; 	border: thin solid 1 1 1 1; }");
document.write("</style>");
function caricatree(xmlurl)
{


    document.getElementById('alberotemi').innerHTML = "";
	var urlhost = xmlurl.substring(0,xmlurl.indexOf("?"));

    //var urlpara = xmlurl.substring(xmlurl.indexOf("?")+1,100000);
    //xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetXMLActiveProject',urlpara);
	//pubxml = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
	
    if (gdManagerWrapper != '')
		{
			var remotepathimm = window.frames['protoframe'].getremoteadd();	
			xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetOutputTreeImagesDir','');
			
			pubpathimmagini = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
			pubpathimmagini = remotepathimm + pubpathimmagini.substring(pubpathimmagini.indexOf("?>")+2,100000) + "/";
		}
	else
		{
			xxx = window.frames['protoframe'].getWSAjaxRequestWrapper('FW_GetOutputTreeImagesDir','');
			
			pubpathimmagini = replaceExtChars(xxx.replace('<string xmlns=\"GDManagerWS\">',"").replace('</string>',""));
			pubpathimmagini = 'http://' + document.location.host + pubpathimmagini.substring(pubpathimmagini.indexOf("?>")+2,100000) + "/";
		}
    
    caricatree_aux(xmlurl,urlhost);
}
function caricatree_aux(xmlurl,urlhost)
{
        //Genero l'albero dei temi
		tree1=new dhtmlXTreeObject(document.getElementById('alberotemi'),"100%","100%",0);
		tree1.setImagePath(pubpathimmagini);
		tree1.setDragHandler();
		tree1.enableCheckBoxes(true);
		tree1.enableThreeStateCheckboxes(false); //Abilita o no l'accensione di tutti i layer di un gruppo
		tree1.enableDragAndDrop(false);
        tree1.setOnClickHandler(onNodeSelect);

        //AGO// 
        var urlbase = xmlurl.replace('FW_GetXMLActiveProject','FW_GetXMLSessParziale');
        urlbase = urlbase + "@@@@@@@@@@nodocompreso=SI";
        if (gdManagerWrapper != '')
            urlbase = urlbase + "@@@@@@@@@@nodocompreso=SI@@@@@@@@@@usewrapper=SI";
        else
            urlbase = urlbase + "@@@@@@@@@@nodocompreso=SI@@@@@@@@@@usewrapper=NO";
        tree1.setXMLAutoLoading(GLOPubblicatiComuni + "/xml.asp?urlbase=" + urlbase);
        tree1.loadXML(GLOPubblicatiComuni + "/xml.asp?urlbase=" + urlbase + "@@@@@@@@@@id=PRIMONODO");
        
        //tree1.loadXMLString("<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?><tree id=\"0\"><item text='Piano Regolatore' id='G-102-3fd7fb19-1c10-45bf-9c64-703bc33a56c6' IDFramework='' checked='1' visible='true' estensione ='' estensioneINIZIALE='' child='1'></item><item text='Fasce Pai e Rii' id='G-37-e8743d45-8980-4f84-9584-5017a47ef97a' IDFramework='' visible='false' estensione='' estensioneINIZIALE='' child='1'></item><item text='Catasto' id='G-85-4cf58477-f93f-421a-994f-9719f59812aa' IDFramework='' visible='false' estensione='' estensioneINIZIALE='' child='1'></item><item text='Toponomastica' id='G-134-25c05cce-365c-432f-b0e0-8143a8021a0b' IDFramework='' checked='1' visible='true' estensione='' estensioneINIZIALE='' child='1'></item><item text='Carta Tec. Comunale' id='G-47-d17f0750-4d03-437c-9d96-89af7ac1e848' IDFramework='' checked='1' visible='true' estensione='' estensioneINIZIALE='' child='1'></item><item text='Foto Aeree' id='G-137-98d8289c-ac63-4fbe-8261-e61d74a422ad' IDFramework='' visible='false' estensione='' estensioneINIZIALE='' child='1'></item><item text='Cartografia di Base' id='G-104-f6e66b4d-ee8e-434a-b8ee-cc5db6e8699b' IDFramework='' checked='1' visible='true' estensione='' estensioneINIZIALE='' child='1'></item></tree>");
        //tree1.loadXMLString(pubxml); //per caricare albero in un colpo solo !
        //AGO// 
        
		/* 
           tree1.openAllItems(0);
           function preLoadImages(){
			var imSrcAr = new Array("line1.gif","line2.gif","line3.gif","line4.gif","minus2.gif","minus3.gif","minus4.gif","plus2.gif","plus3.gif","plus4.gif","book.gif","books_open.gif","books_close.gif","magazines_open.gif","magazines_close.gif","tombs.gif","tombs_mag.gif","book_titel.gif","iconCheckAll.gif")
			var imAr = new Array(0);
			for(var i=0;i<imSrcAr.length;i++){
				imAr[imAr.length] = new Image();
				imAr[imAr.length-1].src = "imgs/"+imSrcAr[i]
			}
		}
        */
        //Disegno la mappa con mscross

        //Reimposto lo zoom per evitare i problemi di calcolo automatico di mscross
        //myMap1.zoomExtent(parseInt(mapXmin),parseInt(mapYmin),parseInt(mapXmax),parseInt(mapYmax));
        //myMapOv.zoomExtent(parseInt(mapXmin),parseInt(mapYmin),parseInt(mapXmax),parseInt(mapYmax));
        //myMap1.redraw(false);
        //myMapOv.redraw(false);

}


function onNodeSelect(nodeId)
{
    var temp;
    temp=parseInt(tree1.getItemIdFramework(nodeId));
    //MCS Se è un valore numerico allora cambio il layer attivo altrimenti
    //mantengo il layer attuale perchè è stata cliccata una voce di legenda o un gruppo
    if (nodeId.substring(0,2) == 'T-')
    {
        ActiveGroupIndex='';
        //Ho selezionato un tema
        if (!isNaN(temp)){
            ActiveLayerIndex=tree1.getItemIdFramework(nodeId);
            ActiveLayerName=tree1.getItemText(nodeId);
            }
        else
            //Nell'ipotesi che abbia cliccato su una voce di legenda provo imposto come layer attivo il parent
            if(!isNaN(tree1.getItemIdFramework(tree1.getParentId(nodeId)))){
                ActiveLayerIndex=tree1.getItemIdFramework(tree1.getParentId(nodeId));
                ActiveLayerName=tree1.getItemText(tree1.getParentId(nodeId));
                }
        AttivaTema(ActiveLayerIndex);    
        AttivaGruppo(ActiveGroupIndex);    
    }
    if (nodeId.substring(0,2) == 'G-')
    {
        //Ho selezionato un gruppo
        //alert(nodeId);    
        ActiveGroupIndex=nodeId;
        ActiveLayerName='';
        ActiveLayerIndex=-1;
        AttivaTema(ActiveLayerIndex);    
        AttivaGruppo(ActiveGroupIndex);
    }

    AccendiPadre(nodeId);
}
//function AccendiPadre(nodeId)
//{
//    if (nodeId == 0 ) return true;
//    
//    tree1.setCheck(nodeId,1);
//    if (tree1.getParentId(nodeId) != null)
//    {
//        var parentId=tree1.getParentId(nodeId);
//        tree1.setCheck(parentId,1)
//        AccendiPadre(parentId);
//        //alert(tree1.getItemText(parentId));
//    }
//    return true;
//}

//Luca - 080212
function AccendiPadre(nodeId,bool)
{
    if (nodeId == 0 ) return true;
    tree1.setCheck(nodeId,1);
    if (tree1.getParentId(nodeId) != null)
    {
        var parentId=tree1.getParentId(nodeId);
        tree1.setCheck(parentId,1)

        if (strCodaLayerCheck!='') strCodaLayerCheck+=";";
            strCodaLayerCheck+=nodeId+","+bool;

        AccendiPadre(parentId,bool);
    }
    return true;
}

//ALBERO
// IE support
if (window.ActiveXObject && !window.XMLHttpRequest) {
  window.XMLHttpRequest = function() {
    var msxmls = new Array(
      'Msxml2.XMLHTTP.5.0',
      'Msxml2.XMLHTTP.4.0',
      'Msxml2.XMLHTTP.3.0',
      'Msxml2.XMLHTTP',
      'Microsoft.XMLHTTP');
    for (var i = 0; i < msxmls.length; i++) {
      try {
        return new ActiveXObject(msxmls[i]);
      } catch (e) {
      }
    }
    return null;
  };
}
// Gecko support // Opera support
if (window.opera && !window.XMLHttpRequest) {
  window.XMLHttpRequest = function() {
    this.readyState = 0; // 0=uninitialized,1=loading,2=loaded,3=interactive,4=complete
    this.status = 0; // HTTP status codes
    this.statusText = '';
    this._headers = [];
    this._aborted = false;
    this._async  = true;
    this._defaultCharset = 'ISO-8859-1';
    this._getCharset = function() {
      var charset = _defaultCharset;
      var contentType = this.getResponseHeader('Content-type').toUpperCase();
      val = contentType.indexOf('CHARSET=');
      if (val != -1) {
        charset = contentType.substring(val);
      }
      val = charset.indexOf(';');
      if (val != -1) {
        charset = charset.substring(0, val);
      }
      val = charset.indexOf(',');
      if (val != -1) {
        charset = charset.substring(0, val);
      }
      return charset;
    };
    this.abort = function() {
      this._aborted = true;
    };
    this.getAllResponseHeaders = function() {
      return this.getAllResponseHeader('*');
    };
    this.getAllResponseHeader = function(header) {
      var ret = '';
      for (var i = 0; i < this._headers.length; i++) {
        if (header == '*' || this._headers[i].h == header) {
          ret += this._headers[i].h + ': ' + this._headers[i].v + '\n';
        }
      }
      return ret;
    };
    this.getResponseHeader = function(header) {
      var ret = getAllResponseHeader(header);
      var i = ret.indexOf('\n');
      if (i != -1) {
        ret = ret.substring(0, i);
      }
      return ret;
    };
    this.setRequestHeader = function(header, value) {
      this._headers[this._headers.length] = {h:header, v:value};
    };
    this.open = function(method, url, async, user, password) {
      this.method = method;
      this.url = url;
      this._async = true;
      this._aborted = false;
      this._headers = [];
      if (arguments.length >= 3) {
        this._async = async;
      }
      if (arguments.length > 3) {
        opera.postError('XMLHttpRequest.open() - user/password not supported');
      }
      this.readyState = 1;
      if (this.onreadystatechange) {
        this.onreadystatechange();
      }
    };
    this.send = function(data) {
      if (!navigator.javaEnabled()) {
        alert("XMLHttpRequest.send() - Java must be installed and enabled.");
        return;
      }
      if (this._async) {
        setTimeout(this._sendasync, 0, this, data);
        // this is not really asynchronous and won't execute until the current execution context ends
      } else {
        this._sendsync(data);
      }
    }
    this._sendasync = function(req, data) {
      if (!req._aborted) {
        req._sendsync(data);
      }
    };
    this._sendsync = function(data) {
      this.readyState = 2;
      if (this.onreadystatechange) {
        this.onreadystatechange();
      }
      // open connection
      var url = new java.net.URL(new java.net.URL(window.location.href), this.url);
      var conn = url.openConnection();
      for (var i = 0; i < this._headers.length; i++) {
        conn.setRequestProperty(this._headers[i].h, this._headers[i].v);
      }
      this._headers = [];
      if (this.method == 'POST') {
        // POST data
        conn.setDoOutput(true);
        var wr = new java.io.OutputStreamWriter(conn.getOutputStream(), this._getCharset());
        wr.write(data);
        wr.flush();
        wr.close();
      }
      // read response headers NOTE: the getHeaderField() methods always return nulls for me :(
      var gotContentEncoding = false;
      var gotContentLength = false;
      var gotContentType = false;
      var gotDate = false;
      var gotExpiration = false;
      var gotLastModified = false;
      for (var i = 0; ; i++) {
        var hdrName = conn.getHeaderFieldKey(i);
        var hdrValue = conn.getHeaderField(i);
        if (hdrName == null && hdrValue == null) {
          break;
        }
        if (hdrName != null) {
          this._headers[this._headers.length] = {h:hdrName, v:hdrValue};
          switch (hdrName.toLowerCase()) {
            case 'content-encoding': gotContentEncoding = true; break;
            case 'content-length'  : gotContentLength   = true; break;
            case 'content-type'    : gotContentType     = true; break;
            case 'date'            : gotDate            = true; break;
            case 'expires'         : gotExpiration      = true; break;
            case 'last-modified'   : gotLastModified    = true; break;
          }
        }
      }
      // try to fill in any missing header information
      var val;
      val = conn.getContentEncoding();
      if (val != null && !gotContentEncoding) this._headers[this._headers.length] = {h:'Content-encoding', v:val};
      val = conn.getContentLength();
      if (val != -1 && !gotContentLength) this._headers[this._headers.length] = {h:'Content-length', v:val};
      val = conn.getContentType();
      if (val != null && !gotContentType) this._headers[this._headers.length] = {h:'Content-type', v:val};
      val = conn.getDate();
      if (val != 0 && !gotDate) this._headers[this._headers.length] = {h:'Date', v:(new Date(val)).toUTCString()};
      val = conn.getExpiration();
      if (val != 0 && !gotExpiration) this._headers[this._headers.length] = {h:'Expires', v:(new Date(val)).toUTCString()};
      val = conn.getLastModified();
      if (val != 0 && !gotLastModified) this._headers[this._headers.length] = {h:'Last-modified', v:(new Date(val)).toUTCString()};
      // read response data
      var reqdata = '';
      var stream = conn.getInputStream();
      if (stream) {
        var reader = new java.io.BufferedReader(new java.io.InputStreamReader(stream, this._getCharset()));
        var line;
        while ((line = reader.readLine()) != null) {
          if (this.readyState == 2) {
            this.readyState = 3;
            if (this.onreadystatechange) {
              this.onreadystatechange();
            }
          }
          reqdata += line + '\n';
        }
        reader.close();
        this.status = 200;
        this.statusText = 'OK';
        this.responseText = reqdata;
        this.readyState = 4;
        if (this.onreadystatechange) {
          this.onreadystatechange();
        }
        if (this.onload) {
          this.onload();
        }
      } else {
        // error
        this.status = 404;
        this.statusText = 'Not Found';
        this.responseText = '';
        this.readyState = 4;
        if (this.onreadystatechange) {
          this.onreadystatechange();
        }
        if (this.onerror) {
          this.onerror();
        }
      }
    };
  };
}
// ActiveXObject emulation
if (!window.ActiveXObject && window.XMLHttpRequest) {
  window.ActiveXObject = function(type) {
    switch (type.toLowerCase()) {
      case 'microsoft.xmlhttp':
      case 'msxml2.xmlhttp':
      case 'msxml2.xmlhttp.3.0':
      case 'msxml2.xmlhttp.4.0':
      case 'msxml2.xmlhttp.5.0':
        return new XMLHttpRequest();
    }
    return null;
  };
}
function replaceExtChars(text) 
{
//text = text.replace(eval('/&/g'), '&amp;');
//fromTo = new Array('&AElig;','Æ','&Aacute;','Á','&Acirc;','Â','&Agrave;','À','&Aring;','Å','&Atilde;', 'Ã','&Auml;','Ä','&Ccedil;','Ç','&ETH;','Ð','&Eacute;','É','&Ecirc;','Ê','&Egrave;','È ','&Euml;','Ë','&Iacute;','Í','&Icirc;','Î','&Igrave;','Ì','&Iuml;','Ï','&Ntilde;','Ñ', '&Oacute;','Ó','&Ocirc;','Ô','&Ograve;','Ò','&Oslash;','Ø','&Otilde;','Õ','&Ouml;','Ö','&THORN; ','Þ','&Uacute;','Ú','&Ucirc;','Û','&Ugrave;','Ù','&Uuml;','Ü','&Yacute;','Ý','&aacute;', 'á','&acirc;','â','&aelig;','æ','&agrave;','à','&aring;','å','&atilde;','ã','&auml;','ä ','&brvbar;','¦','&ccedil;','ç','&cent;','¢','&copy;','©','&deg;','°','&eacute;','é', '&ecirc;','ê','&egrave;','è','&eth;','ð','&euml;','ë','&frac12;','½','&frac14;','¼','&frac34; ','¾','&gt;','>','&gt','>','&iacute;','í','&icirc;','î','&iexcl;','¡','&igrave;','ì','&iquest;','¿','&iuml;','ï', '&laquo;','«','&lt;','<','&lt','<','&mdash;','—','&micro;','µ','&middot;','·','&ndash;','–','&not;','¬','&ntilde;','ñ', '&oacute;','ó','&ocirc;','ô','&ograve;','ò','&oslash;','ø','&otilde;','õ','&ouml;','ö','&para;','¶','&plusmn;','±','&pound;',' £','&quot;','\"','&raquo;','»','&reg;','®','&sect;','§','&shy;','*','&sup1;','¹','&sup2;','²', '&sup3;','³','&szlig;','ß','&thorn;','þ','&tilde;','˜','&trade;','™','&uacute;','ú','&ucirc; ','û','&ugrave;','ù','&uuml;','ü','&yacute;','ý','&yen;','¥','&yuml;','ÿ');
fromTo = new Array('&lt;','<','&gt;','>');
for (i=0; i < fromTo.length; i=i+2)
{
	text = text.replace(eval('/' + fromTo[i] + '/g') , fromTo[i+1]);
}
return (text);
}
function provaalert()
{
	alert(0);
}
function redrawmap()
{
}
//Funzioni di gestione di un Select Box
function SelectAllList(OptionList)
{
    for(var i = 0;i < OptionList.length;i++)
    {
        OptionList.options[i].selected = true;
    }
}
function DeselectAllList(OptionList)
{
    for(var i = 0;i < OptionList.length;i++)
    {
        OptionList.options[i].selected = false;
    }
}
function ClearList(OptionList)
{
    // Always clear an option list from the last entry to the first
    for (x = OptionList.length; x >= 0; x = x - 1)
    {
        OptionList[x] = null;
    }
}
function AddToList(OptionList, OptionValue, OptionText)
{
	try {
	    // Add option to the bottom of the list
	    OptionList[OptionList.length] = new Option(OptionText, OptionValue);
	}
	catch (e) {
	    //alert(e.message);
	}
}

