//  DATA CREAZIONE: 01-07-2003;
//  DATA MODIFICA: 01-07-2003;
//  VERSIONE: 2003.1.0;
//  AUTORE: C.Lanza;

/* Variabile che definisce il tipo di browser
   va così utilizzata

      Netscape 4.x
      if (is.ns4) {

      Internet Explorer 4.x
      if (is.ie4) {

      Internet Explorer 5.x e 6.x
      if (is.ie5) {

      Netscape 6.x e 7.x
      if (is.ns6) {
*/
var is;

// Variabile per la visualizzazione del Menu di destra: 
// False (0) - versione semplificata
// True  (1) - versione completa
var menuDestraOK = 0;

// Posizione freccia menu superiore
var freccia_top;

// Inizializzazione - da chiamare in body come OnLoad
function init(tipo) {
  is = new browserCheck();

  if (tipo == 1) {
     freccia_top   = '37px';
  } else {
     freccia_top   = '37px';
  }


  return true;
}

// Determina il tipo di Brower, caricando la variabile is
function browserCheck() {
  this.ns4 = (document.layers);
  this.ns6 = (!document.all && document.getElementById);
  this.ie4 = (document.all && !document.getElementById);
  this.ie5 = (document.all && document.getElementById);
  return true;
}


// Rende visibile una DIV
function showObject(obj) {

  if (is == null) return true;

  if (is.ns4) {
    this.layer = window.document[obj];
    this.layer.visibility = "show";
  }

  if (is.ie4) {
    this.element = window.document.all[obj];
    this.style = this.element.style;
    this.style.visibility = "visible";
  }
  
  if (is.ns6 || is.ie5) {
    this.element = document.getElementById(obj);
    this.style = this.element.style;
    this.style.visibility = "visible";
  }

  return true;
}

// Nasconde una DIV
function hideObject(obj) {
  if (is == null) return true;

  if (is.ns4) {
    this.layer = window.document[obj];
    this.layer.visibility = "hide";
  }

  if (is.ie4) {
    this.element = window.document.all[obj];
    this.style = this.element.style;
    this.style.visibility = "hidden";
  }

  if (is.ns6 || is.ie5) {
    this.element = document.getElementById(obj);
    this.style = this.element.style;
    this.style.visibility = "hidden";
  }

  return true;
}


// modifica l'altezza di un oggetto
function resetObject(obj, val_height) {

  if (is == null) return true;

  if (is.ns4) {
    this.layer = window.document[obj];
    this.layer.height = val_height;
  }

  if (is.ie4) {
    this.element = window.document.all[obj];
    this.style = this.element.style;
    this.style.height = val_height;
  }

  if (is.ns6 || is.ie5) {
    this.element = document.getElementById(obj);
    this.style = this.element.style;
    this.style.height = val_height;
  }

  return true;
}


// modifica la posizione di un oggetto
function moveObject(obj, val_top, val_left) {

  if (is == null) return true;

  if (is.ns4) {
    this.layer = window.document[obj];
    this.layer.top = val_top;
    this.layer.left = val_left;
  }

  if (is.ie4) {
    this.element = window.document.all[obj];
    this.style = this.element.style;
    this.style.top = val_top;
    this.style.left = val_left;
  }

  if (is.ns6 || is.ie5) {
    this.element = document.getElementById(obj);
    this.style = this.element.style;
    this.style.top = val_top;
    this.style.left = val_left;
  }

  return true;
}

function setBody(obj,body) {

  if (is == null) return true;

  if (is.ns4) {
    this.layer = window.document[obj];
    for(var i = 0; i < body.length; i++) {
      this.layer.document.writeln(body[i]);
    }
    this.layer.document.close();
  }

  if (is.ie4) {
    this.element = window.document.all[obj];
    this.element.innerHTML = body;
  }

  if (is.ie5 || is.ns6) {
    this.element = document.getElementById(obj);
    this.element.innerHTML = body;
  }

  return true;  
}

function changeImage(imgName,imgObj) {
  if (is == null) return true;

  if (is.ns4) {
    eval('this.document.' + imgName + '.src = "' + imgObj + '"');
  }

  if (is.ie4) {
    document.images[imgName].src = imgObj;
  }

  if (is.ie5 || is.ns6) {
    document.images[imgName].src = imgObj;
  }

  return true; 
}

// Cambia il pointer in mano 
// NOTA : si può fare direttamente dal foglio stile (cursor:hand) salvo le solite incompatibilità...
function mouseMano(obj) {

  if (is == null) return true;

  if (is.ns4) {
    this.layer = window.document[obj];
    this.layer.cursor = "pointer";
  }

  if (is.ie4) {
    this.element = window.document.all[obj];
    this.style = this.element.style;
    this.style.cursor = "hand";
  }

  if (is.ie5) {
    this.element = document.getElementById(obj);
    this.style = this.element.style;
    this.style.cursor = "hand";
  }

  if (is.ns6) {
    this.element = document.getElementById(obj);
    this.style = this.element.style;
    this.style.cursor = "pointer";
  }

  return true;
}

// Cambia il pointer nel default (freccia verso l'alto)
function mouseDef(obj) {

  if (is == null) return true;

  if (is.ns4) {
    this.layer = window.document[obj];
    this.layer.cursor = "default";
  }

  if (is.ie4) {
    this.element = window.document.all[obj];
    this.style = this.element.style;
    this.style.cursor = "default";
  }

  if (is.ie5) {
    this.element = document.getElementById(obj);
    this.style = this.element.style;
    this.style.cursor = "default";
  }

  if (is.ns6) {
    this.element = document.getElementById(obj);
    this.style = this.element.style;
    this.style.cursor = "default";
  }

  return true;
}


// Cambia la classe di un oggetto
function Classe(obj, cl) {

  if (is == null) return true;


  if (is.ns4) {
    this.layer = window.document[obj];
    this.layer.className = cl;
  }

  if (is.ie4) {
    this.element = window.document.all[obj];
    this.element.className = cl;
  }

  if (is.ie5 || is.ns6) {
    this.element = document.getElementById(obj);
    this.element.className = cl;
  }

  return true;
}

// Cambia la URL della window (in pratica carica una nuova pagina)
function URLwindow(URL) {

  if (is == null) return true;

  if (is.ns4) {
    window.location.replace (URL);
  }

  if (is.ie4) {
    window.location.replace (URL);
  }

  if (is.ie5) {
    window.location.replace (URL);
  }

  if (is.ns6) {
    window.location.replace (URL);
  }

  return true;
}

// Cambia colore di un testo 
function changeColor (obj, idcolor) {

  if (is == null) return true;

  if (is.ns4) {
    this.layer = window.document[obj];
    this.layer.color = idcolor;
  }

  if (is.ie4) {
    this.element = window.document.all[obj];
    this.style = this.element.style;
    this.style.color = idcolor;
  }

  if (is.ie5) {
    this.element = document.getElementById(obj);
    this.style = this.element.style;
    this.style.color = idcolor;
  }

  if (is.ns6) {
    this.element = document.getElementById(obj);
    this.style = this.element.style;
    this.style.color = idcolor;
  }

  return true;
}

// Verifica la presenza del plugin di Flash
// NOTA: per I.E. viene utilizzata una function scritta in VB che deve essere presente nella head
function checkFlash () {

  PluginFlash = false;

  var MM_contentVersion = 6;
  var MM_PluginVersion; 

  if (navigator.plugins && navigator.plugins.length >0) {
    if(navigator.plugins["Shockwave Flash"]) {
      var words = navigator.plugins["Shockwave Flash"].description.split(" ");
      for (var i = 0; i < words.length; ++i) {
        if (isNaN(parseInt(words[i]))) continue;
        MM_PluginVersion = words[i]; 
      }
      PluginFlash = MM_PluginVersion >= MM_contentVersion;
    }
  } else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0  &&
            (navigator.appVersion.indexOf("Win") != -1)) {

    detectActiveXControl(MM_contentVersion);
  }

/* Commentare o scommentare per simulare la presenza o meno del plugin di flash 
  (oppure forzare a true o false) */
//  PluginFlash = false;

  return true; 
}

// Determina sistema operativo, tipo di browser e versione 
// in vista della visualizzaizone del Menu di destra
function sniffaMenu () {

  // Determino il sistema operativo (Windows o Mac)
  var SOWIN = (navigator.userAgent.toLowerCase().indexOf("win") > -1) ? 1: 0;
  if(navigator.userAgent.toLowerCase().indexOf("opera") > -1) SOWIN = 0;
  var SOMAC = (navigator.userAgent.toLowerCase().indexOf("mac") > -1) ? 1: 0;

  // Ipotesi di lavoro - il menu completo è solo per 
  // Windows con Internet Explorer 5.5 o superiori, oppure Netscape 6.0 o superiori
  menuDestraOK = 0;
  var versione;
  if (SOWIN) {
     var ind = navigator.userAgent.indexOf("MSIE");  
     if (ind > -1 &&
         navigator.userAgent.indexOf("Opera") == -1) {
       // Internet Explorer
       versione = parseInt(navigator.userAgent.substr(ind+5));
       if(versione >= 5) menuDestraOK = 1;

     } else if (navigator.appName.indexOf("Netscape") > -1) {
       // Netscape
       versione = parseInt(navigator.appVersion);
       if(versione > 4) menuDestraOK = 1;
     } 
  }

  return true; 
}

// Muove la freccia del menu di navigazione (div frecciamobile)
function moveArrow(id) {
  var base  =  126;
  var delta =   90;
  var l = base + ((id-1) * delta) + (delta / 2);
  var val_left = l + 'px';
  moveObject('frecciamobile', freccia_top, val_left);
  showObject('frecciamobile');
  return true;
}

function hideArrow() {	
  hideObject('frecciamobile');
  return true;
}

function fissaArrow(id) {
  var base  =  126;
  var delta =   90;
  var l = base + ((id-1) * delta) + (delta / 2);
  var val_left = l + 'px';
  moveObject('frecciafissa', freccia_top, val_left);
  showObject('frecciafissa');
  return true;
}

// Attivano i vari form che aprono le pagine cadmiche
function eseguiText (pagina) {
  document.FormText._page.value = pagina;
  document.FormText.submit();
}

function eseguiList (pagina) {
  document.FormList._page.value = pagina;
  document.FormList.submit();
}

