var isNav, isIE, nVer = parseInt(navigator.appVersion.charAt(0));if (nVer >= 4) {isNav = (navigator.appName == "Netscape") ? 1 : 0;isIE = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;}var last = '';
function popup(c,p,id){larghezza = 3 * document.images["att"+p+"_"+id].width+10;altezza = 3 * document.images["att"+p+"_"+id].height+14;if ((isNav) && (nVer < 5)) altezza = altezza + 10;if (isNav) {altezza = altezza + 10;larghezza = larghezza + 15;}if (isIE) {altezza = altezza + 12;larghezza = larghezza + 15;}window.open('/detail.asp?c=' + c + '&p='+ p +'&id='+ id,'zoom','scrollbars=no,resizable=no,width='+larghezza+',height='+altezza+',top='+(screen.availHeight-altezza)/2+',left='+(screen.availWidth-larghezza)/2+',status=no,location=no,toolbar=no');}
function transac(nome,tipo){switch (tipo){case 0:if (nome!=last)  eval('document.'+nome+'.src=off'+nome+'.src');break;case 1:eval('document.'+nome+'.src=on'+nome+'.src');break;case 2:if ((nome!=last)&&(last!='')) eval('document.'+last+'.src=off'+last+'.src');eval('document.'+nome+'.src=on'+nome+'.src');last=nome;break;case 3:eval('document.'+last+'.src=off'+last+'.src');last='';break;default:alert("Errore!");}}
function s(str){window.open('/core/print/default.asp?'+str,'Print','scrollbars=yes,resizable=no,width=630,height=300,top='+(screen.availHeight-300)/2+',left='+(screen.availWidth-630)/2+',status=no,location=no,toolbar=no');}
function i(str){window.open('/core/print/default.asp?'+str,'Send','scrollbars=yes,resizable=no,width=300,height=300,top='+(screen.availHeight-300)/2+',left='+(screen.availWidth-300)/2+',status=no,location=no,toolbar=no');}

giorni = new Array('Domenica','Luned&igrave;','Marted&igrave;','Mercoled&igrave;','Gioved&igrave;','Venerd&igrave;','Sabato');
mesi = new Array('Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre');
function orologio()
{
 var ora = new Date();
 var aa = ora.getDate();
 var mm = ora.getMonth();
 var yy = ora.getFullYear();
 var oo = ora.getHours();
 var mn = ora.getMinutes();
 var sec = ora.getSeconds();
 var dd = ora.getDay();
 var aa2  = ((aa < 10) ? "0" : "");
 var oo2  = ((oo < 10) ? "0" : "");
 var mn2  = ((mn < 10) ? ":0" : ":");
 var sec2  = ((sec < 10) ? ":0" : ":");
 var Data = aa2 + aa +" "+ mesi[mm]  + " " + yy;
 var hh = oo2 + oo + mn2 + mn + sec2 + sec;
 if(document.all){ document.all.orario.innerHTML = giorni[dd] + " " + Data + " " + hh; }
 else if(document.getElementById){ document.getElementById('orario').innerHTML  = giorni[dd] + " " + Data + " " + hh; }
 else if(document.layers){ document.layers['orario'].document.write('<p id="orario" style="position:absolute; font-family:Verdana; font-size:10pt; font-weight:bold; color:#800000">'+ giorni[dd] + ' ' + Data + ' ' + hh + '</p>');
 document.layers['orario'].document.close()
 }
 window.setTimeout("orologio()",1000);
}

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;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
  orologio(); 
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
