//---------------------------------------------------------------
// dbgtData.js
// Copyright (C) 2002 David Bollinger (davebollinger@hotmail.com)
//
// Support code for the "dbGroupToc" modification - A grouped
// table of contents for ArcIMS 3.1 HTML viewer sites.
//
// Notice:   This code may be freely distributed, used and
//           modified provided that this comment remains intact.
//---------------------------------------------------------------


//
// create the global resource object
//
tocResource = new RESOURCE("");
tocResource.stringTitle = "LAYER";                     // text to display as title of toc
tocResource.imageWidth = 23;                            // width in pixels of icons/swatches
tocResource.imageHeight = 18;                           // height in pixels of icons/swatches
tocResource.groupSpacing = 10;                           // height in pixels of blank space between groups

tocResource.iconPath = "images/";                   // path to icon images

tocResource.iconPixel = "icon_pixel.gif";               // single transparent pixel
tocResource.iconBlank = "icon_blank.gif";               // all transparent placeholder
tocResource.iconClosed = "icon_closed.gif";             // closed group folder
tocResource.iconOpened = "icon_opened.gif";             // opened group folder
tocResource.iconChild = "icon_child.gif";               // connecting line to child layer
tocResource.iconChildLast = "icon_childlast.gif";        // connecting line to child layer for the last layer of group
//tocResource.iconOrphan = "icon_orphan.gif";             // non-connecting line to an orphan ("only child") layer
tocResource.iconHidden = "icon_hidden.gif";             // layer not visible, unselected checkbox
tocResource.iconVisible = "icon_visible.gif";           // layer visible, selected checkbox
tocResource.iconVisscale = "icon_visscale.gif";         // layer visible, but not at this scale
tocResource.iconTristate = "icon_tristate.gif";         // tri-state checkbox, some layers visible
tocResource.iconActive = "icon_active.gif";             // selected radio
tocResource.iconInactive = "icon_inactive.gif";         // unselected radio
//tocResource.iconInfo = "icon_info.gif";                 // for displayLayerInfoButton
//tocResource.iconHelp = "icon_help.gif";                 // not currently used

//INIZIO Profilazione TOC - PTO
//Funzione che permette la visibilità di un determinato gruppo all'interno della TOC
//Viene gestita anche la visibilità dei layer presenti all'interno dell'AXL e settati
//per default a false (e cioè non visibili)
function getCommandGroupParams(cmdString,groupName,verifica)
    {
     var bTrovato = false;
     if (verifica)
      {

       var startpos = 0;
       var endpos = 0;

       var cmdString2 = unescape(cmdString.toUpperCase());
        pos = cmdString2.indexOf("GROUP=");
       if (pos!=-1)
          {
          startpos = pos + 6;
          endpos = cmdString.indexOf("&",startpos);
          if (endpos==-1) endpos = cmdString.length;

          var escGroup = unescape(cmdString.substring(startpos,endpos));
          var separator="|";
          var arrayOfStrings = escGroup.split(separator);

          var indice = 0;

          while (indice<arrayOfStrings.length && bTrovato==false)
                {
//alert("arrayOfStrings[indice]= " + arrayOfStrings[indice] + "\ngroupName.slice(9)= " + groupName.slice(9));
                    if ( arrayOfStrings[indice] == groupName.slice(9) )
                    {
                        bTrovato=true;
                    }
                    indice++;
                }

          return bTrovato    //Il Gruppo deve essere visualizzato nella TOC
          }
      }
      else
        {
        bTrovato = true;
        return bTrovato;
        }
    }
//FINE Profilazione TOC - PTO

//=======================================================================================

//Inizio NewToc : NTO
// Gestione array di toc
//var toc = new TOC("Toc_modificata");
var toc = new Array()
toc[0] = new TOC("Toc_modificata");
toc[1] = new TOC("Toc Secondaria");
var toc_csi_tocIndex=0;
//Fine NewToc : NTO


/* #################################################
##                                                ##
##  INSERIMENTO DELLA TOC                         ##
##                                                ##
##  L'ORDINE DI INSERIMENTO NELL'ARRAY            ##
##    E' LO STESSO DI QUELLO                      ##
##    DI VISUALIZZAZIONE                          ##
##                                                ##
##################################################*/
// NOTA: il nome delle variabili GRPx non é importante;
// é importante che non siano definite 2 volte,
// ma possono essere inserite nell'array in qualsiasi ordine




// ----------------------------------------------------------
// add a group to the toc
// usage reminder:  GROUP( name_of_group, startup_opened )
// ----------------------------------------------------------
if ( getCommandGroupParams(webParams,"CTR Raster",false) ){
var grp0 = toc[0].addGroup( new GROUP("CTR Raster",false) );

//
// add layers to the group
// usage reminder:  LAYER( name_of_layer)
//
if ( getCommandGroupParams(webParams,"CTR Raster",false) )
        grp0.addLayer(     new LAYER("CTR Raster") );
}







// ----------------------------------------------------------
// add a group to the toc
// usage reminder:  GROUP( name_of_group, startup_opened )
// ----------------------------------------------------------
if ( getCommandGroupParams(webParams,"Contesto territoriale",false) ){
var grp1 = toc[0].addGroup(new GROUP("Contesto territoriale",false) );
//
// add layers to the group
// usage reminder:  LAYER( name_of_layer)
//

if ( getCommandGroupParams(webParams,"Regione",false) )
        grp1.addLayer(     new LAYER("Regione") );

if ( getCommandGroupParams(webParams,"Province",false) )
        grp1.addLayer(     new LAYER("Province") );

if ( getCommandGroupParams(webParams,"Comuni",false) )
        grp1.addLayer(     new LAYER("Comuni") );

if ( getCommandGroupParams(webParams,"Toponimi comunali",false) )
        grp1.addLayer(     new LAYER("Toponimi comunali") );

}








// ----------------------------------------------------------
// add a group to the toc
// usage reminder:  GROUP( name_of_group, startup_opened )
// ----------------------------------------------------------
if ( getCommandGroupParams(webParams,"Viabilità",false) ){
var grp2 = toc[0].addGroup(new GROUP("Viabilità",false) );
//
// add layers to the group
// usage reminder:  LAYER( name_of_layer)
//

if ( getCommandGroupParams(webParams,"Autostrade",false) )
        grp2.addLayer(     new LAYER("Autostrade") );

if ( getCommandGroupParams(webParams,"Ferrovie",false) )
        grp2.addLayer(     new LAYER("Ferrovie") );

if ( getCommandGroupParams(webParams,"Stazioni ferroviarie",false) )
        grp2.addLayer(     new LAYER("Stazioni ferroviarie") );

if ( getCommandGroupParams(webParams,"Strade statali",false) )
        grp2.addLayer(     new LAYER("Strade statali") );

if ( getCommandGroupParams(webParams,"Strade provinciali",false) )
        grp2.addLayer(     new LAYER("Strade provinciali") );

if ( getCommandGroupParams(webParams,"Strade comunali",false) )
        grp2.addLayer(     new LAYER("Strade comunali") );

}




// ----------------------------------------------------------
// add a group to the toc
// usage reminder:  GROUP( name_of_group, startup_opened )
// ----------------------------------------------------------
if ( getCommandGroupParams(webParams,"Idrografia",false) ){
var grp3 = toc[0].addGroup( new GROUP("Idrografia",false) );
//
// add layers to the group
// usage reminder:  LAYER( name_of_layer)
//
if ( getCommandGroupParams(webParams,"Fiumi",false) )
            grp3.addLayer( new LAYER("Fiumi") );

/* CANALI NON DISP A RISOL 10.000 E GIA' INCLUSI IN FIUMI10
if ( getCommandGroupParams(webParams,"Canali",false) )
            grp3.addLayer( new LAYER("Canali") );
*/
if ( getCommandGroupParams(webParams,"Laghi",false) )
            grp3.addLayer( new LAYER("Laghi") );
if ( getCommandGroupParams(webParams,"Idrografia areale",false) )
            grp3.addLayer( new LAYER("Idrografia areale") );

}








// ----------------------------------------------------------
// add a group to the toc
// usage reminder:  GROUP( name_of_group, startup_opened )
// ----------------------------------------------------------
if ( getCommandGroupParams(webParams,"Mosaicatura PRG",false) ){
var grp4 = toc[0].addGroup(new GROUP("Mosaicatura PRG",false) );
//
// add layers to the group
// usage reminder:  LAYER( name_of_layer)
//

if ( getCommandGroupParams(webParams,"Limiti comunali da PRG",false) )
        grp4.addLayer(     new LAYER("Limiti comunali da PRG") );

if ( getCommandGroupParams(webParams,"Destinazioni d'uso prevalenti",false) )
        grp4.addLayer(     new LAYER("Destinazioni d'uso prevalenti") );

if ( getCommandGroupParams(webParams,"Modalita' di intervento",false) )
        grp4.addLayer(     new LAYER("Modalita' di intervento") );

if ( getCommandGroupParams(webParams,"Lotti edificabili",false) )
        grp4.addLayer(     new LAYER("Lotti edificabili") );

if ( getCommandGroupParams(webParams,"Servizi compresi in altre aree",false) )
        grp4.addLayer(     new LAYER("Servizi compresi in altre aree") );

}






// ----------------------------------------------------------
// add a group to the toc
// usage reminder:  GROUP( name_of_group, startup_opened )
// ----------------------------------------------------------
if ( getCommandGroupParams(webParams,"Mosaicatura PRG - Elementi primari di piano",false) ){
var grp5 = toc[0].addGroup( new GROUP("Mosaicatura PRG - Elementi primari di piano",false) );
//
// add layers to the group
// usage reminder:  LAYER( name_of_layer)
//

if ( getCommandGroupParams(webParams,"Aree residenziali",false) )
            grp5.addLayer( new LAYER("Aree residenziali") );
if ( getCommandGroupParams(webParams,"Aree produttive",false) )
            grp5.addLayer( new LAYER("Aree produttive") );
if ( getCommandGroupParams(webParams,"Aree terziarie",false) )
            grp5.addLayer( new LAYER("Aree terziarie") );
if ( getCommandGroupParams(webParams,"Aree polifunzionali",false) )
            grp5.addLayer( new LAYER("Aree polifunzionali") );
if ( getCommandGroupParams(webParams,"Aree ricettivo-turistiche",false) )
            grp5.addLayer( new LAYER("Aree ricettivo-turistiche") );
if ( getCommandGroupParams(webParams,"Aree per servizi L.56/77 art.21",false) )
            grp5.addLayer( new LAYER("Aree per servizi L.56/77 art.21") );
if ( getCommandGroupParams(webParams,"Aree per servizi L.56/77 art.22",false) )
            grp5.addLayer( new LAYER("Aree per servizi L.56/77 art.22") );
if ( getCommandGroupParams(webParams,"Aree per servizi: altre aree di interesse generale",false) )
            grp5.addLayer( new LAYER("Aree per servizi: altre aree di interesse generale") );
if ( getCommandGroupParams(webParams,"Aree per servizi generiche",false) )
            grp5.addLayer( new LAYER("Aree per servizi generiche") );
if ( getCommandGroupParams(webParams,"Piste da sci",false) )
            grp5.addLayer( new LAYER("Piste da sci") );
if ( getCommandGroupParams(webParams,"Viabilita' in progetto",false) )
            grp5.addLayer( new LAYER("Viabilita' in progetto") );
if ( getCommandGroupParams(webParams,"Aree agricole",false) )
            grp5.addLayer( new LAYER("Aree agricole") );
if ( getCommandGroupParams(webParams,"Aree di pregio naturale",false) )
            grp5.addLayer( new LAYER("Aree di pregio naturale") );
if ( getCommandGroupParams(webParams,"Aree per attivita' estrattive",false) )
            grp5.addLayer( new LAYER("Aree per attivita' estrattive") );
}





// ----------------------------------------------------------
// add a group to the toc
// usage reminder:  GROUP( name_of_group, startup_opened )
// ----------------------------------------------------------
if ( getCommandGroupParams(webParams,"Mosaicatura PRG - Altre caratterizzazioni d'area",false) ){
var grp6 = toc[0].addGroup( new GROUP("Mosaicatura PRG - Altre caratterizzazioni d'area",false) );
//
// add layers to the group
// usage reminder:  LAYER( name_of_layer)
//

if ( getCommandGroupParams(webParams,"Centri storici/nuclei minori",false) )
            grp6.addLayer( new LAYER("Centri storici/nuclei minori") );
if ( getCommandGroupParams(webParams,"Altre aree urbanizzate di pregio",false) )
            grp6.addLayer( new LAYER("Altre aree urbanizzate di pregio") );
if ( getCommandGroupParams(webParams,"Piste da sci e bacini sciistici",false) )
            grp6.addLayer( new LAYER("Piste da sci e bacini sciistici") );
if ( getCommandGroupParams(webParams,"Campeggi",false) )
            grp6.addLayer( new LAYER("Campeggi") );
if ( getCommandGroupParams(webParams,"Opere di difesa",false) )
            grp6.addLayer( new LAYER("Opere di difesa") );
if ( getCommandGroupParams(webParams,"Attivita' inquinanti",false) )
            grp6.addLayer( new LAYER("Attivita' inquinanti") );
}






// ----------------------------------------------------------
// add a group to the toc
// usage reminder:  GROUP( name_of_group, startup_opened )
// ----------------------------------------------------------
if ( getCommandGroupParams(webParams,"Mosaicatura PRG - Vincoli",false) ){
var grp7 = toc[0].addGroup( new GROUP("Mosaicatura PRG - Vincoli",false) );
//
// add layers to the group
// usage reminder:  LAYER( name_of_layer)
//

if ( getCommandGroupParams(webParams,"Vincoli antropici",false) )
            grp7.addLayer( new LAYER("Vincoli antropici") );
if ( getCommandGroupParams(webParams,"Vincoli di tutela ambientale culturale",false) )
            grp7.addLayer( new LAYER("Vincoli di tutela ambientale culturale") );
if ( getCommandGroupParams(webParams,"Limitazioni e vincoli idrogeologici",false) )
            grp7.addLayer( new LAYER("Limitazioni e vincoli idrogeologici") );
if ( getCommandGroupParams(webParams,"Aree inedificabili",false) )
            grp7.addLayer( new LAYER("Aree inedificabili") );
if ( getCommandGroupParams(webParams,"Abitato da consolidare",false) )
            grp7.addLayer( new LAYER("Abitato da consolidare") );
if ( getCommandGroupParams(webParams,"Abitati da trasferire",false) )
            grp7.addLayer( new LAYER("Abitati da trasferire") );
}








if ( getCommandGroupParams(webParams,"Piano Provinciale - Infrastrutture Novara",false) ){
var grp8 = toc[0].addGroup(new GROUP("Piano Provinciale - Infrastrutture Novara",false) );
//
// add layers to the group
// usage reminder:  LAYER( name_of_layer)
//

if ( getCommandGroupParams(webParams,"Alta capacita PP-NO",false) )
        grp8.addLayer(     new LAYER("Alta capacita PP-NO") );

if ( getCommandGroupParams(webParams,"Autostrade PP-NO",false) )
        grp8.addLayer(     new LAYER("Autostrade PP-NO") );

if ( getCommandGroupParams(webParams,"Nodi PP-NO",false) )
        grp8.addLayer(     new LAYER("Nodi PP-NO") );

if ( getCommandGroupParams(webParams,"Ferrovie PP-NO",false) )
        grp8.addLayer(     new LAYER("Ferrovie PP-NO") );

if ( getCommandGroupParams(webParams,"Strade provinciali PP-NO",false) )
        grp8.addLayer(     new LAYER("Strade provinciali PP-NO") );
        
if ( getCommandGroupParams(webParams,"Strade statali PP-NO",false) )
        grp8.addLayer(     new LAYER("Strade statali PP-NO") );

if ( getCommandGroupParams(webParams,"Viabilita PP-NO",false) )
        grp8.addLayer(     new LAYER("Viabilita PP-NO") );

if ( getCommandGroupParams(webParams,"Cimitero PP-NO",false) )
        grp8.addLayer(     new LAYER("Cimitero PP-NO") );

}



if ( getCommandGroupParams(webParams,"Piano Provinciale - Infrastrutture Alessandria",false) ){
var grp9 = toc[0].addGroup(new GROUP("Piano Provinciale - Infrastrutture Alessandria",false) );
//
// add layers to the group
// usage reminder:  LAYER( name_of_layer)
//

if ( getCommandGroupParams(webParams,"Caselli autostradali PP-AL",false) )
        grp9.addLayer(     new LAYER("Caselli autostradali PP-AL") );

if ( getCommandGroupParams(webParams,"Autostrade PP-AL",false) )
        grp9.addLayer(     new LAYER("Autostrade PP-AL") );

if ( getCommandGroupParams(webParams,"Centri intermodali PP-AL",false) )
        grp9.addLayer(     new LAYER("Centri intermodali PP-AL") );

if ( getCommandGroupParams(webParams,"Ferrovie PP-AL",false) )
        grp9.addLayer(     new LAYER("Ferrovie PP-AL") );

if ( getCommandGroupParams(webParams,"Strade statali PP-AL",false) )
        grp9.addLayer(     new LAYER("Strade statali PP-AL") );
        
if ( getCommandGroupParams(webParams,"Strade provinciali PP-AL",false) )
        grp9.addLayer(     new LAYER("Strade provinciali PP-AL") );

if ( getCommandGroupParams(webParams,"Strade comunali PP-AL",false) )
        grp9.addLayer(     new LAYER("Strade comunali PP-AL") );
}



// ----------------------------------------------------------

/////////////////////////////////////////////////////MAD; + [AP]



