try
{
  var esiste = GLOPubblicatiComuni;
}
catch(e)
{
    GLOPubblicatiComuni = '/PubblicatiComuni';  
}
finally
{
  
}


/*
function gd_addPulsante (p_container, p_id, p_title, p_function, p_icon, p_icon_off, p_tooltip)
{
    var tool  = document.createElement('img');
    tool.oncontextmenu = function(){return false;};
    tool.onmousedown = function(){return false;};  // Disable drag'n drop
    tool.onmouseout = function(){ Change(p_id,p_id+"_off");};  // Disable drag'n drop
    add_event(tool, 'click', p_function );
    tool.title = p_title;
    tool.id=p_id;
    tool.src=p_icon_off;
    
    tool.style.display = '';
    tool.style.cursor='pointer';
    
    if (p_tooltip != '' )
    {
        tool.onmouseover = function(){ Change(p_id,p_id+"_on"); return escape(p_tooltip)}; 
    }
    else
        tool.onmouseover = function(){ Change(p_id,p_id+"_on");};  // Disable drag'n drop

    p_container.appendChild(tool);

    return true;
}

function gd_add_event(obj, event_id, func)
{
  if (obj.addEventListener)
  {
    obj.addEventListener( event_id, func, false )
  } else if(obj.attachEvent)
  {
    event_id = 'on'+event_id;
    obj.attachEvent( event_id, func )
  } else
  { obj[event_id] = func; }
}
*/
////////////////////
//Gestione Comandi
////////////////////

//Global Variables
var azione	= 'drag';
var tasto	= 'damappa';
			
//PANNING
pan_on		= new Image();
pan_off		= new Image();
pan_on.src	= GLOPubblicatiComuni + "/imgbottoni/Pan_ON.GIF";
pan_off.src = GLOPubblicatiComuni + "/imgbottoni/Pan_OFF.GIF";

//BACK ZOOM
bzoom_off 		= new Image();
bzoom_on  		= new Image();
bzoom_on.src	= GLOPubblicatiComuni + "/imgbottoni/bzoom_on.GIF";
bzoom_off.src	= GLOPubblicatiComuni + "/imgbottoni/bzoom_off.GIF";

//SLIDER
slider_brown_off		= new Image();
slider_brown_on			= new Image();
slider_brown_on.src		= GLOPubblicatiComuni +"/images/cellaSlider_brown.JPG";
slider_brown_off.src	= GLOPubblicatiComuni +"/images/cellaSlider_brown_light.JPG";

//SLIDER
slider_off		= new Image();
slider_on		= new Image();
slider_on.src	= GLOPubblicatiComuni +"/images/cellaSlider_green.GIF";
slider_off.src	= GLOPubblicatiComuni +"/images/cellaSlider.GIF";

//ZOOM ALL
zoomall_off		= new Image();
zoomall_on		= new Image();
zoomall_on.src	= GLOPubblicatiComuni + "/imgbottoni/zoomall_on.gif";
zoomall_off.src	= GLOPubblicatiComuni + "/imgbottoni/zoomall_off.gif";

//DRAG
drag_off		= new Image();
drag_on			= new Image();
drag_on.src		= GLOPubblicatiComuni + "/imgbottoni/drag_on.gif";
drag_off.src	= GLOPubblicatiComuni +  "/imgbottoni/drag_off.gif";

//ZOOM MENO
mzoom_off		= new Image();
mzoom_on		= new Image();
mzoom_on.src	= GLOPubblicatiComuni + "/imgbottoni/mzoom_OFF.GIF";
mzoom_off.src	= GLOPubblicatiComuni +  "/imgbottoni/mzoom_OFF.GIF";

//ZOOM PIU'
pzoom_off		= new Image();
pzoom_on		= new Image();
pzoom_on.src	= GLOPubblicatiComuni +  "/imgbottoni/pzoom_OFF.GIF";
pzoom_off.src	= GLOPubblicatiComuni +  "/imgbottoni/pzoom_OFF.GIF";

//ZOOM MENO NEW
nnzoom_off		= new Image();
nnzoom_on		= new Image();
nnzoom_on.src	= GLOPubblicatiComuni +"/imgbottoni/zoom05_neg1.GIF";
nnzoom_off.src	= GLOPubblicatiComuni +"/imgbottoni/zoom05_neg0.GIF";

//ZOOM PIU' NEW
npzoom_off		= new Image();
npzoom_on		= new Image();
npzoom_on.src	= GLOPubblicatiComuni +"/imgbottoni/zoom05_pos1.GIF";
npzoom_off.src	= GLOPubblicatiComuni +"/imgbottoni/zoom05_pos0.GIF";


//INFO
inf_off			= new Image();
inf_on			= new Image();
inf_on.src		= GLOPubblicatiComuni +  "/imgbottoni/Info_ON.gif";
inf_off.src		= GLOPubblicatiComuni +  "/imgbottoni/Info_OFF.gif";

//HELP
help_off			= new Image();
help_on				= new Image();
help_on.src			= GLOPubblicatiComuni +  "/imgbottoni/help_on.gif";
help_off.src		= GLOPubblicatiComuni +  "/imgbottoni/help_off.gif";

//MEASURE
measure_off			= new Image();
measure_on			= new Image();
measure_on.src		= GLOPubblicatiComuni +  "/imgbottoni/measure_on.gif";
measure_off.src		= GLOPubblicatiComuni +  "/imgbottoni/measure_off.gif";

//INFO
infpoly_off			= new Image();
infpoly_on			= new Image();
infpoly_on.src		= GLOPubblicatiComuni +  "/imgbottoni/infpoly_on.gif";
infpoly_off.src		= GLOPubblicatiComuni +  "/imgbottoni/infpoly_off.gif";

//DRILL DOWN
infmulti_off		= new Image();
infmulti_on			= new Image();
infmulti_on.src		= GLOPubblicatiComuni +  "/imgbottoni/infmulti_on.gif";
infmulti_off.src	= GLOPubblicatiComuni +  "/imgbottoni/infmulti_off.gif";

//STAMPA
print_off		= new Image();
print_on		= new Image();
print_on.src	= GLOPubblicatiComuni +  "/imgbottoni/print_ON.GIF";
print_off.src	= GLOPubblicatiComuni +  "/imgbottoni/print_OFF.GIF";


//STAMPA
stampa_off		= new Image();
stampa_on		= new Image();
stampa_on.src	= GLOPubblicatiComuni +  "/imgbottoni/print_ON.GIF";
stampa_off.src	= GLOPubblicatiComuni +  "/imgbottoni/print_OFF.GIF";

//SALVA
save_off		= new Image();
save_on			= new Image();
save_on.src		= GLOPubblicatiComuni +  "/imgbottoni/save_on.GIF";
save_off.src	= GLOPubblicatiComuni +  "/imgbottoni/save_off.GIF";

//TEMI
zoomtema_off	    = new Image();
zoomtema_on		    = new Image();
zoomtema_on.src	    = GLOPubblicatiComuni +  "/imgbottoni/Temi_ON.GIF";
zoomtema_off.src	= GLOPubblicatiComuni +  "/imgbottoni/Temi_OFF.GIF";

//STAMPA
//print1000_off		= new Image();
//print1000_on		= new Image();
//print1000_on.src	= GLOPubblicatiComuni +  "/imgbottoni/Stampa1000_ON.GIF";
//print1000_off.src	= GLOPubblicatiComuni +  "/imgbottoni/Stampa1000_OFF.GIF";

//SELEZIONE
select_off		= new Image();
select_on		= new Image();
select_on.src	= GLOPubblicatiComuni +  "/imgbottoni/Select_ON.GIF";
select_off.src	= GLOPubblicatiComuni +  "/imgbottoni/Select_OFF.GIF";

//SELEZIONE
selectpoly_off		= new Image();
selectpoly_on		= new Image();
selectpoly_on.src	= GLOPubblicatiComuni +  "/imgbottoni/selectpoly_on.gif";
selectpoly_off.src	= GLOPubblicatiComuni +  "/imgbottoni/selectpoly_off.gif";

//SELEZIONE
analisibuffer_off		= new Image();
analisibuffer_on		= new Image();
analisibuffer_on.src	= GLOPubblicatiComuni +  "/imgbottoni/analisibuffer_on.gif";
analisibuffer_off.src	= GLOPubblicatiComuni +  "/imgbottoni/analisibuffer_off.gif";

//REDLINE
redline_off		= new Image();
redline_on		= new Image();
redline_on.src	= GLOPubblicatiComuni +  "/imgbottoni/Redline_ON.GIF";
redline_off.src	= GLOPubblicatiComuni +  "/imgbottoni/Redline_OFF.GIF";

//CLEAR
clear_off		= new Image();
clear_on		= new Image();
clear_on.src	= GLOPubblicatiComuni +  "/imgbottoni/clear_ON.GIF";
clear_off.src	= GLOPubblicatiComuni + "/imgbottoni/clear_OFF.GIF";

//CLEAR
percorsiidentify_off		= new Image();
percorsiidentify_on			= new Image();
percorsiidentify_on.src		= GLOPubblicatiComuni +  "/imgbottoni/percorsiidentify_ON.jpg";
percorsiidentify_off.src	= GLOPubblicatiComuni + "/imgbottoni/percorsiidentify_OFF.jpg";

//CLEARDRAW
cleardraw_off		= new Image();
cleardraw_on		= new Image();
cleardraw_on.src	= GLOPubblicatiComuni + "/imgbottoni/ClearDraw_ON.GIF";
cleardraw_off.src	= GLOPubblicatiComuni + "/imgbottoni/ClearDraw_OFF.GIF";

//TOOLTIP
tooltip_off			= new Image();
tooltip_on			= new Image();
tooltip_on.src      = GLOPubblicatiComuni + "/imgbottoni/tooltip_on.gif";
tooltip_off.src     = GLOPubblicatiComuni + "/imgbottoni/tooltip_off.gif";

//LEGENDA
legend_off			= new Image();
legend_on			= new Image();
legend_on.src		= GLOPubblicatiComuni + "/imgbottoni/Legend_ON.gif";
legend_off.src		= GLOPubblicatiComuni + "/imgbottoni/Legend_OFF.gif";

//RICERCA
find_off			= new Image();
find_on			= new Image();
find_on.src		= GLOPubblicatiComuni + "/imgbottoni/Find_ON.gif";
find_off.src	= GLOPubblicatiComuni + "/imgbottoni/Find_OFF.gif";

//INFO CATASTO
infpt_off			= new Image();
infpt_on			= new Image();
infpt_on.src		= GLOPubblicatiComuni + "/imgbottoni/infopt_ON.gif";
infpt_off.src	    = GLOPubblicatiComuni + "/imgbottoni/infopt_OFF.gif";


//Funzioni di gestione delle immagini e dei click

var last_action = "";
var new_action = "";

function Change(x,y) {

    if(last_action != "" && document.images[last_action] != null) 
		document.images[last_action].src=eval(last_action +'_off.src'); 
    
    if (azione != x) {
		if(x == "infpoly" || x == "find" || x == "inf" || x == "selectpoly" || x == "legend" || x == "select" ) {
			if (document.getElementById("b_" + x) != null)
				document.images[x].src=eval(y+'.src'); 		
		}
		else {
			if (document.getElementById(x) != null)
				document.images[x].src=eval(y+'.src'); 
	    }
	    last_action = x;
	}
	else {
		new_action = x;
		if(document.images[new_action] != null) 
			document.images[new_action].src=eval(new_action +'_on.src'); 
	}
}


function resetChange(x,y) { 

    if (document.getElementById(x) != null)
        document.images[x].src=eval(y+'.src'); 
}

function resetImages() {
    resetChange('pan','pan_off');	
	resetChange('zoomall','zoomall_off');
	resetChange('drag','drag_off');
	resetChange('bzoom','bzoom_off');
    resetChange('mzoom','mzoom_off');
    resetChange('pzoom','pzoom_off');
    resetChange('print','print_off');
    resetChange('clear','clear_off');
    resetChange('measure','measure_off');
    resetChange('help','help_off'); 
    resetChange('inf','inf_off');    
    resetChange('infpoly','infpoly_off');    
    resetChange('tooltip','tooltip_off');    
    resetChange('find','find_off');    
    resetChange('selectpoly','selectpoly_off');
    resetChange('infmulti','infmulti_off');
}

function gdAfterRedraw(){
	if ((ActiveLayerIndex != '') && (ActiveLayerIndex != '-1') )
		AggiornaVisibilita(ActiveLayerIndex);
    
    mostraScala();
	return true;
}
////////////////////
//FUNZIONI APPLET
////////////////////
function InteractPanning() { 
			    
    azione='pan';
    fineDisegno();
    myMap1.setActionPan();
}

function PercorsiIdentify() {	

	azione='percorsiidentify';
	myMap1.setActionPercorsiIdentify();
}
	
function ZoomAll() { 
    
    azione='zoomall';
    fineDisegno();
    //myMap1.fullExtent();
    myMap1.zoomExtent(parseInt(mapXmin),parseInt(mapYmin),parseInt(mapXmax),parseInt(mapYmax));
    //setTimeout("myMap1.redraw();",1000)
    
}

function InteractZoomRectOut() {
    
    azione='drag';
//    Perché cancellare linee/percorsi solo selezionando il pulsante? lo fa con il redraw
//    ripulisciDrawLayer();
    myMap1.setActionZoombox();
}

function PrelevaCoordinate() {
    
	if(azione != 'tick') {
		azione='tick';
		myMap1.setActionTick();
    }
    else{
		azione='drag';
		myMap1.setActionZoombox();
    }
  
}

function ZoomOut2X() { 
    
    azione='mzoom';
    fineDisegno();
    myMap1.setActionZoomOut();
    //setTimeout("myMap1.redraw();",1000)
}



function ZoomIn2X() { 
    
    azione='pzoom';
    /*
    setTimeout("zoom(LarghezzaMappa,AltezzaMappa,'imgmappa2','in',myMap1.getImg());",100)
    setTimeout("zoom(LarghezzaMappa,AltezzaMappa,'imgmappa2','in',myMap1.getImg());",200)
    setTimeout("zoom(LarghezzaMappa,AltezzaMappa,'imgmappa2','in',myMap1.getImg());",300)
    setTimeout("zoom(LarghezzaMappa,AltezzaMappa,'imgmappa2','in',myMap1.getImg());",400)
    setTimeout("zoom(LarghezzaMappa,AltezzaMappa,'imgmappa2','in',myMap1.getImg());",500)
    */
    fineDisegno();
    myMap1.setActionZoomIn(); 
    //setTimeout("myMap1.redraw();",1000)
}

function ZoomBack() { 
    
	azione='bzoom';
    ZoomLast();
    myMap1.setActionNone();
}

function InteractIdentify() { 
    
    myMap1.setActionIdentifyPunto();
    azione='inf';
}

function InteractIdentifyMulti() { 
    
    myMap1.setActionIdentifyPuntoMulti();
    azione='infmulti';
}

function InteractIdentifyMultiPoly() { 
    
    myMap1.setActionIdentifyPuntoMultiPoly();
    azione='infmulti';
}



function InteractIdentifyPoly() { 
    
    myMap1.setActionIdentify();
    azione='infpoly';
}

function InteractMeasure() { 

    azione='meas';
    document.Viewer.Execute("InteractMeasure"); 
}


function InteractSelect() { 

    azione='select';
    myMap1.setActionSelect();   
}


function InteractSelectPoly() { 

    azione='selectpoly';
    myMap1.setActionSelezionaPoligono();   
}

function AvviaAnalisiBuffer() {
	
	azione = 'analisibuffer';
	if(document.getElementById ("AnalisiSpaziale")) {
        document.getElementById ("AnalisiSpaziale").src = 'Include_ASP/analisi_spaziale2.asp';
	    if(document.getElementById ("AnalisiSpaziale").style.display == "") {
	        document.getElementById ("AnalisiSpaziale").style.display = "none";
	        window.frames['AnalisiSpaziale'].chiudi();
	    }
	    else 
	        document.getElementById ("AnalisiSpaziale").style.display = "";
	}
	else
	    apri_div_pop('analisi_spaziale','Analisi Spaziale','Include_ASP/analisi_spaziale2.asp','',450,350);
    if (attrWindowMode == 1) {
        setTimeout('document.getElementById(\'temi_di_analisi\').innerHTML=\'<b>'+ActiveLayerName+'</b>\';',300);
    }
}

function AvviaRicerca() {

    //myMap1.goPopup();
    
    var nomeDiv="risultDiv"+ Math.random();
    new popUp(attrWinX,attrWinY,attrWinDimX,attrWinDimY,nomeDiv,"RicercaGenerica.asp", "","", "white", "black", " normal 12px verdana","Risultati" , "#3A6EA5", "white", "#dddddd", "gray", "black", false, true, true, true, false,attrWindowMode);
    showbox(nomeDiv);  
    
//    apri_div_pop('ricerca_pop','Ricerca','RicercaGenerica.asp','',400,270);

    if (attrWindowMode == 1) {
        setTimeout('document.getElementById(\'tema_di_ricerca\').innerHTML=\'<b>'+ActiveLayerName+'</b>\';',200);
        setTimeout('CaricaElencoCampiVisibili(\''+ActiveLayerIndex+'\',document.getElementById(\'listaCampi_pop\'));',300);
    }

}

function avviaAnalisiCDU() {

    /* Versione con finestra pop che ha problemi in caso di post del form che contiene */
	/*
	apri_div_pop('cdu_pop','Analisi CDU','CDUSelezioneFP.asp','',500,600);
    setTimeout('caricaElencoTemi(document.getElementById(\'listatemiCDU\'));',300);
	*/
	winCDUSelezioneFP=window.open('CDUSelezioneFP.asp?SessionID='+MySessione,'AnalisiCDU','toolbar=no,directiores=no,resizable=yes,scrollbars=no,width=500,height=500');
}

function avviaAnalisiCDU2() {

	winCDUSelezioneFP=window.open('CDUSelezioneFP_new.asp?SessionID='+MySessione,'AnalisiCDU','toolbar=no,directiores=no,resizable=yes,scrollbars=no,width=500,height=500');
}


//Buffer dato il centro e il valore del raggio
function BufferCircolare ()
{ 
           
    ripulisciDrawLayer();
    
    // Luca 
    myMap1.ClearPunti();
    myMap1.setActionBufferCircolare();
    //
    
    var winPop;
    if(document.getElementById ("AnalisiSpaziale"))
	    winPop = window.frames['AnalisiSpaziale'].document;
    else
        winPop=getDocumentPopup('analisi_spaziale');
        
    winPop.getElementById('lunghezzaAnalisi').style.display="none"; 
    
    if(winPop.getElementById('info_varieAnalisi')){
            winPop.getElementById('info_varieAnalisi').style.display="";
            winPop.getElementById('info_varieAnalisi').innerHTML="Clicca sulla mappa per inserire il centro della circonferenza di analisi. <br> Per aumentare la dimensione del buffer, modificare il raggio e poi cliccare sulla mappa.";
 
        }    
}

//Buffer dato il centro e il valore del raggio
function BufferSegmento ()
{ 

    ripulisciDrawLayer();
    myMap1.setActionBufferSegmento();
    var winPop;
        
    winPop=getDocumentPopup('analisi_spaziale');
    lunghezza = 0;
    lunghezza_ultimo_segmento = 0
    
    if(winPop.getElementById('info_varieAnalisi')){

        winPop.getElementById('info_varieAnalisi').style.display="";
        winPop.getElementById('info_varieAnalisi').innerHTML="Clicca sulla mappa per iniziare a tracciare il segmento, evitando di far intersecare la spezzata. Clicca con il tasto destro per concludere il disegno.";
    }    

}

function BufferArea ()
{ 

    ripulisciDrawLayer();
    myMap1.setActionBufferArea();
    var winPop;
        
    winPop=getDocumentPopup('analisi_spaziale');
    lunghezza = 0;
    lunghezza_ultimo_segmento = 0
    
    if(winPop.getElementById('info_varieAnalisi')){

        winPop.getElementById('info_varieAnalisi').style.display="";
        winPop.getElementById('info_varieAnalisi').innerHTML="Clicca sulla mappa per iniziare a tracciare il poligono. Clicca con il tasto destro per concludere il disegno.";
    }    

}

//Buffer dato il click del centro e il click per il raggio
function BufferCircolare2Punti ()
{ 
    if ((ActiveLayerIndex != -1) || (LayerTmp != -1))
    {
        ripulisciDrawLayer();
        
        myMap1.setActionBufferCircolare2Punti();
    /*
    if(document.getElementById('mostra_buffer'))
        document.getElementById('mostra_buffer').style.display="none";
    alert("Clicca sulla mappa per inserire il centro della circonferenza da esaminare.");
    */
    if(document.getElementById('info_varieAnalisi')){

            document.getElementById('info_varieAnalisi').style.display="";
            document.getElementById('info_varieAnalisi').innerHTML="Clicca sulla mappa per inserire il centro della circonferenza di analisi e poi per definire il raggio.";
        }    
    }
    else
    {
        alert("Nessun Tema selezionato");
    }
}

function BufferGeometriaConSelezione()
{

    
    if ((ActiveLayerIndex != -1) || (LayerTmp != -1))
    {
        ripulisciDrawLayer();
        myMap1.setActionBufferGeometriaEsistente();
        if(document.getElementById('info_varieAnalisi')){

            document.getElementById('info_varieAnalisi').style.display="";
            document.getElementById('info_varieAnalisi').innerHTML="Clicca sulla mappa per selezionare un oggetto da usare per il buffer.";
        }          
        
        /*
        if((LayerTmp != '') && (LayerTmp != -1))
            var ID_FW=LayerTmp;
        else
            var ID_FW=ActiveLayerIndex; 
            
        if (IDALLFeatureSelezionate == '')
            alert('Nessun oggetto selezionato, usare il tool di selezione con poligono');
        else
        {
            //alert(globalCoordinateSelezione);
            arrSel=IDALLFeatureSelezionate.split(",");
            globalCoordinateSelezione='';
            //alert(CampoFeatureSelezionata);
            for (var i=0; i<arrSel.length; i++)
            {
                if (CampoFeatureSelezionata != "" )
                    if (globalCoordinateSelezione != '')
                        globalCoordinateSelezione &=";"
                    globalCoordinateSelezione+=GetCoordinateByCampiById(ID_FW,CampoFeatureSelezionata,arrSel[i]);

            }
            doIdentifyGeometria(globalCoordinateSelezione,ID_FW,bufferSize);
            //alert(globalCoordinateSelezione);
        }
        */
   
    }
    else
    {
        alert("Nessun Tema selezionato");
    }    
}


function ClearSelect() { 

    //MCS Ripulisco la variabile di selezione globale.
	AzzeraVariabiliSelezione();
 
    fineDisegno();
    //myMap1.ClearPunti();
    myMap1.setActionNone();

    delBufferDisegnoServer();
}

function PanNord() { 
    
    azione='pannord';
    fineDisegno();
    myMap1.setActionSposta('N');  
}

function PanSud() { 
    
    azione='pansud';
    fineDisegno();
    myMap1.setActionSposta('S');  
}

function PanEst() { 
    
    azione='panest';
    fineDisegno();
    myMap1.setActionSposta('E');  
}

function PanWest() { 
    
    azione='panwest';
    fineDisegno();
    myMap1.setActionSposta('W');  
}

function PanNordWest() { 
    
    azione='pannw';
    fineDisegno();
    myMap1.setActionSposta('NW');  
}

function PanSudWest() { 
    
    azione='pansw';
    fineDisegno();
    myMap1.setActionSposta('SW');  
}

function PanNordEst() { 
    
    azione='panne';
    fineDisegno();
    myMap1.setActionSposta('NE');  
}

function PanSudEst() { 
    
    azione='panse';
    fineDisegno();
    myMap1.setActionSposta('SE');  
}

function InteractTooltip() { 
    
    azione='tooltip';
    myMap1.setActionTooltip();
}

function ZoomScala(scala) { 
    
    //azione='scalezoom';
    fineDisegno();
    myMap1.setActionZoomScala(scala);  
    
}

function nessunaAzione() { 
 
    myMap1.setActionNone();
}

function ScaricaImg(file){

    file=file.replace('?','$$');
    window.open("getfile.asp?file="+file,"_blank","toolbar=no,directiores=no,resizable=no,scrollbars=no,width=100,height=100");

}

function StampaConMisure(){
	document.getElementById("testata").style.display="none";
	document.getElementById("colonnadx").style.display="none";
	document.getElementById("scalebar").style.display="none";
	window.print();
}

function mostraScala() {
    var dimx=0;
    
    dimx=parseInt(myMap1.wPixel2real(300));
    
    
    if (document.getElementById("txtscala"))
        document.getElementById("txtscala").value=myMap1.GetScala();
    
    if (document.getElementById("scale5"))
    {
        //Scrivo i valori nella scalebar che misura 300 px;
        document.getElementById("scale5").innerHTML=dimx+'m';
        document.getElementById("scale4").innerHTML=parseInt((dimx/4)*3);
        document.getElementById("scale3").innerHTML=parseInt((dimx/4)*2);
        document.getElementById("scale2").innerHTML=parseInt((dimx/4));    
    }

    
}

function ExportDati()
{
 //window.alert("OnSelectionChangedJS");
    var  theForm = document.forms[0];
    window.open("EsportaDati.asp?SID="+parent.document.Viewer.m_SessionID+"&Tema="+ActiveLayerName+"&progetto="+NomeProgetto,'Tematizzazione','toolbar=no,directiores=no,resizable=no,scrollbars=no,width=500,height=500');
    
}

//window.open('certificazione/certificazione.asp','Tematizzazione','toolbar=no,directiores=no,resizable=no,scrollbars=no,width=500,height=700');
function ApriCertificazione()
{
 //window.alert("OnSelectionChangedJS");
    var  theForm = document.forms[0];
    if (ActiveLayerName == 'Particelle' )
        window.open("certificazione/Certificazione.asp?SID="+parent.document.Viewer.m_SessionID+"&Tema="+ActiveLayerName+"&progetto="+NomeProgetto,'Tematizzazione','toolbar=no,directiores=no,resizable=no,scrollbars=no,width=700,height=500');
    else
        alert("Selezionare le particelle interessate");
    
}

//StringURL = document.Viewer.MailShotCreate();                     
function GeneraStampa(IDProgetto,IDSessione) { 

    azione='print';
    
    var show='';
    var ext;

    //Recupero l'elenco dei temi attivi
    show=getXMLLayerAttivi(guidSession);
    
    ext=myMap1.getViewerExtent().split(" ");
    //alert(show);
    //alert(document.getElementById("legenda").innerHTML);
    //alert(myMap1.getViewerExtent());
    //, _ext_Xmax, _ext_Ymin, _ext_Ymax
    window.open("PrintForm.asp?SessionID="+IDSessione+"&IDProg="+IDProgetto+"&show=" + show +"&xMin=" + parseInt(ext[0]) + "&yMin=" + parseInt(ext[1]) + "&xMax=" + parseInt(ext[2])+ "&yMax=" + parseInt(ext[3]),"","width=575,height=500,scrollbars status=yes resizable=yes,toolbar=yes" );

}

//apre la finestra dei temi
function Temi() {	
	
	//window.open("test.asp","","toolbar=no,directories=no,scrollbars=yes,menubar=no,width=250,height=450" );
}

//Apre la finestra della legenda
function VisualizzaLegenda(IDProgetto,IDSessione){
	window.open("Legenda.asp?SessionID="+IDSessione+"&IDProg="+IDProgetto,"","toolbar=no,directories=no,scrollbars=yes,menubar=no,width=250,height=450" );

}

function Disegna(){
	//myMap1.addDraw();
    //var drawLayer = new jsGraphics("mappa");
    azione='draw';
    myMap1.setActionDisegna();    
  /*
  drawLayer.setColor("#00ff00"); // green
  drawLayer.fillEllipse(100, 200, 100, 180); // co-ordinates related to the document
  drawLayer.setColor("maroon");
  drawLayer.drawPolyline(new Array(50, 10, 120), new Array(10, 50, 70));
  drawLayer.paint(); // draws, in this case, directly into the document

  drawLayer.setColor("#ff0000"); // red
  drawLayer.drawLine(10, 113, 220, 55); // co-ordinates related to "myCanvas"
  drawLayer.setColor("#0000ff"); // blue
  drawLayer.fillRect(110, 120, 30, 60);
  drawLayer.paint();
  */

}

/*
function ridimensionaMappa(dim)
{
    var larg=0;
    var alt=0;
    var arr;
    
    if (dim.value != "-")
    {
        arr=dim.value.split(",");
        
        //alert('http://'+document.location.host+document.location.pathname+'?IDProgetto='+idProgetto+'&SessionID='+sessionId+'&qualedb='+qualedb);
        document.location.href='http://'+document.location.host+document.location.pathname+'?IDProgetto='+idProgetto+'&IDVista='+idVista+'&SessionID='+sessionId+'&qualedb='+qualedb+'&largmappa='+arr[0]+'&altmappa='+arr[1];
    }
}
*/
// Aggiunta Coiro
function ridimensiona_mappa(w,h){
	
	var ext;
	var um;
	var urla;

   
    ext=myMap1.getViewerExtent().split(" ");
	document.getElementById("mappa").style.height=h+"px";
	document.getElementById("mappa").style.width=w+"px";
	urla=getUrlMappaWS(parseInt(ext[0]),parseInt(ext[1]),parseInt(ext[2]),parseInt(ext[3]),w,h,1);
	myMap1.setWidth(w);
	myMap1.setHeight(h);
	myMap1.redraw();
	myMap1.ridimensiona_mappa(w,h);
	
	myMap1.setDimensioniImage(w,h);
	myMap1.setMapImage(urla);
}

//Cerco un TAG href con id  a_idObj e tolgo l'attributi href
//Cambio il colore del pulsante e lo metto grigio
function abilitaBottone(idObj,abilita)
{
    var obj=document.getElementById("a_"+idObj);
    var obj_immagine=document.getElementById("b_"+idObj);
    
    if (obj == null)
        return true;
      
    if (abilita)
    {	
        obj.setAttribute("href","javascript:void(0)");
        //obj.className='hrefbottoneComando'; //Con IE non va
        obj_immagine.className='bottoneComando';
        var onclick = obj.getAttribute("onclick_bak");
        if(onclick && onclick != "" && onclick != null){
            obj.setAttribute('onclick', onclick);
        }
    }
    else
    {		
        obj.removeAttribute('href');
        //obj.className='hrefbottoneComando_OFF'; //Con IE non va
        obj_immagine.className='bottoneComando_OFF';
        var onclick = obj.getAttribute("onclick");
        if(onclick && onclick != "" && onclick != null){
            obj.setAttribute('onclick_bak', onclick);
            //obj.removeAttribute('onclick'); //Con IE non va
            obj.setAttribute('onclick','');
        }
    }
    
    return true;
}

