 var docu=document;
 var nAgt=navigator.userAgent;
 var browserName=navigator.appName;
 var nameOffset,verOffset;
 if((verOffset=nAgt.indexOf("MSIE"))!=-1){browserName="MSIE"}else
 if((verOffset=nAgt.indexOf("Opera"))!=-1){browserName="Opera"}else
 if((verOffset=nAgt.indexOf("Chrome"))!=-1){browserName="Chrome"}else
 if((verOffset=nAgt.indexOf("Safari"))!=-1){browserName="Safari"}else
 if((verOffset=nAgt.indexOf("Firefox"))!=-1){browserName="Firefox"}else
 if((nameOffset=nAgt.lastIndexOf(' ')+1)<(verOffset=nAgt.lastIndexOf('/'))){
  browserName=nAgt.substring(nameOffset,verOffset);
  if(browserName.toLowerCase()==browserName.toUpperCase())browserName=navigator.appName;
 }
 var ns=(browserName=="Netscape");
 with(new Date()){var sxm=getSeconds()*getMinutes()}
 var info='w='+screen.width+'&h='+screen.height+'&c='+(ns?screen.pixelDepth:screen.colorDepth)+'&r='+escape(document.referrer)+'&u='+escape(document.URL)+'&fs='+window.screen.fontSmoothingEnabled+'&b='+browserName+'&x='+sxm;
 function f_detType(n_win,n_docel,n_body){
  var n_result=n_win?n_win:0;
  if(n_docel&&(!n_result||(n_result>n_docel)))n_result=n_docel;
  if(n_body&&(!n_result||(n_result>n_body)))n_result=n_body;
  if(n_result==n_body)return 1;
  else if(n_result==n_docel)return 0;
  else return -1;
 }
 function f_testHeight(){
  return f_detType(window.innerHeight?window.innerHeight:0,
   document.documentElement?document.documentElement.clientHeight:0,
   document.body?document.body.clientHeight:0);
 }
 function scrollMenus(){
  var menusxObj=document.getElementById?document.getElementById('menusx'):document.all?document.all['menusx']:document.layers['menusx'];
  if(menusxObj){
   if(document.layers)menusxObj.style=menusxObj;
   menusxObj.y=+(menusxObj.style.top.split('px'))[0];
   var menusxstartY=menusxObj.y;
   var menusxOffset=0;
//provvisorio
if(menusxstartY==120||menusxstartY==130)menusxstartY=135;
//provvisorio
   if(menusxstartY<135)menusxOffset=135-menusxstartY;
   if(menusxObj.offsetHeight)menusxObj.h=menusxObj.offsetHeight;
   else if(menusxObj.style.pixelHeight)menusxObj.h=menusxObj.style.pixelHeight;
  }
//per liquid layout
  var colmid=document.getElementById?document.getElementById('colmid'):document.all?document.all['colmid']:document.layers['colmid'];
  if(colmid){
    var colleft=document.getElementById?document.getElementById('colleft'):document.all?document.all['colleft']:document.layers['colleft'];
    var colright=document.getElementById?document.getElementById('colright'):document.all?document.all['colright']:document.layers['colright'];
    if(colmid.offsetHeight){
     colleft.style.height=colmid.offsetHeight+"px";
     colright.style.height=colmid.offsetHeight+"px";
    } else if(colmid.style.pixelHeight){
     colleft.style.height=colmid.style.pixelHeight+"px";
     colright.style.height=colmid.style.pixelHeight+"px";
    }
  }
//per liquid layout
  var menudxObj=document.getElementById?document.getElementById('menudx'):document.all?document.all['menudx']:document.layers['menudx'];
  var menudxFra=window.frames['framedx'];
  if(menudxFra){
   var menudxTornasu=document.getElementById?menudxFra.document.getElementById('tornasu'):document.all?menudxFra.document.all['tornasu']:menudxFra.document.layers['tornasu'];
   menudxFra=document.getElementsByName('framedx')[0];
   if(menudxFra)menudxFra.style.height=menudxFra.contentWindow.document.body.scrollHeight+"px";
  }else{
//per pagina indice.html (e altre senza iframe?)
   var menudxTornasu=document.getElementById?document.getElementById('tornasu'):document.all?document.all['tornasu']:document.layers['tornasu'];
  }
  if(menudxObj){
   if(document.layers)menudxObj.style=menudxObj;
   menudxObj.y=+(menudxObj.style.top.split('px'))[0];
   var menudxstartY=menudxObj.y;
   var menudxOffset=0;
   if(menudxstartY<135)menudxOffset=135-menudxstartY;
   if(menudxObj.offsetHeight)menudxObj.h=menudxObj.offsetHeight;
   else if(menudxObj.style.pixelHeight)menudxObj.h=menudxObj.style.pixelHeight;
  }
  window.scrollInnerHeight=function(){
   var psY=window.pageYOffset-menusxOffset;
   psY=psY>menusxstartY?psY:menusxstartY;
   var fermo;
   with(menusxObj){
    if(h>window.innerHeight){
     fermo=true;
     style.top=menusxstartY;
    }else if(psY==y){
     fermo=true;
    }else{
     fermo=false;
     y+=Math.round((psY-y)/4);
     if(y<psY-300)y=psY-300;
     else if(y>psY+300)y=psY+300;
     style.top=y;
    }
   }
   psY=window.pageYOffset-menudxOffset;
   psY=(psY>menudxstartY)?psY:menudxstartY;
   with(menudxObj){
    if(h>window.innerHeight){
     fermo=true;
     style.top=menudxstartY;
    }else if(psY!=y){
     fermo=false;
     y+=Math.round((psY-y)/4);
     if(y<psY-300)y=psY-300;
     else if(y>psY+300)y=psY+300;
     style.top=y;
    }
   }
   if(fermo)setTimeout("scrollInnerHeight()",100);
   else{
    setTimeout("scrollInnerHeight()",20);
    if(menudxTornasu){
     with(menudxTornasu.style){
      if(psY>menudxstartY+50){
       if(display!='block'){
        display='block';
        if(menudxFra)menudxFra.style.height=menudxFra.contentWindow.document.body.scrollHeight+"px";
       }
      }else{
       if(display!='none'){
        display='none';
        if(menudxFra)menudxFra.style.height=menudxFra.contentWindow.document.body.scrollHeight+"px";
       }
      }
     }
    }
   }
  }
  window.scrollDocuHeight=function(){
   var psY=document.documentElement.scrollTop-menusxOffset;
   psY=psY>menusxstartY?psY:menusxstartY;
   var fermo;
   with(menusxObj){
    if(h>document.documentElement.clientHeight){
     fermo=true;
     style.top=menusxstartY;
    }else if(psY==y){
     fermo=true;
    }else{
     fermo=false;
     y+=Math.round((psY-y)/4);
     if(y<psY-300)y=psY-300;
     else if(y>psY+300)y=psY+300;
     style.top=y;
    }
   }
   psY=document.documentElement.scrollTop-menudxOffset;
   psY=(psY>menudxstartY)?psY:menudxstartY;
   with(menudxObj){
    if(h>document.documentElement.clientHeight){
     fermo=true;
     style.top=menudxstartY;
    }else if(psY!=y){
     fermo=false;
     y+=Math.round((psY-y)/4);
     if(y<psY-300)y=psY-300;
     else if(y>psY+300)y=psY+300;
     style.top=y;
    }
   }
   if(fermo)setTimeout("scrollDocuHeight()",100);
   else{
    setTimeout("scrollDocuHeight()",20);
    if(menudxTornasu){
     with(menudxTornasu.style){
      if(psY>menudxstartY+50){
       if(display!='block'){
        display='block';
        if(menudxFra)menudxFra.style.height=menudxFra.contentWindow.document.body.scrollHeight+"px";
       }
      }else{
       if(display!='none'){
        display='none';
        if(menudxFra)menudxFra.style.height=menudxFra.contentWindow.document.body.scrollHeight+"px";
       }
      }
     }
    }
   }
  }
  window.scrollBodyHeight=function(){
   var psY=document.body.scrollTop-menusxOffset;
   psY=psY>menusxstartY?psY:menusxstartY;
   var fermo;
   with(menusxObj){
    if(h>document.body.clientHeight){
     fermo=true;
     style.top=menusxstartY;
    }else if(psY==y){
     fermo=true;
    }else{
     fermo=false;
     y+=Math.round((psY-y)/4);
     if(y<psY-300)y=psY-300;
     else if(y>psY+300)y=psY+300;
     style.top=y;
    }
   }
   psY=document.body.scrollTop-menudxOffset;
   psY=(psY>menudxstartY)?psY:menudxstartY;
   with(menudxObj){
    if(h>document.body.clientHeight){
     fermo=true;
     style.top=menudxstartY;
    }else if(psY!=y){
     fermo=false;
     y+=Math.round((psY-y)/4);
     if(y<psY-300)y=psY-300;
     else if(y>psY+300)y=psY+300;
     style.top=y;
    }
   }
   if(fermo)setTimeout("scrollBodyHeight()",100);
   else{
    setTimeout("scrollBodyHeight()",20);
    if(menudxTornasu){
     with(menudxTornasu.style){
      if(psY>menudxstartY+50){
       if(display!='block'){
        display='block';
        if(menudxFra)menudxFra.style.height=menudxFra.contentWindow.document.body.scrollHeight+"px";
       }
      }else{
       if(display!='none'){
        display='none';
        if(menudxFra)menudxFra.style.height=menudxFra.contentWindow.document.body.scrollHeight+"px";
       }
      }
     }
    }
   }
  }
  var tipo=f_testHeight();
//alert(tipo);
  if(tipo<0)scrollInnerHeight();
  else if(tipo>0)scrollBodyHeight();
  else scrollDocuHeight();
 }
//per liquid layout
function MakeLayout(id,maxw){
 if(browserName!="MSIE")return;
 if(document.getElementById){
  SetWidth(id,maxw);
  window.onresize=function(){SetWidth(id,maxw)}
 }
}
function SetWidth(id,a){
 var w=getBrowserWidth();
 if(w==0) return;
 var d=document.getElementById(id).style;
 if(w<=a) d.width=w+"px";
 else d.width=a+"px";
}
function getBrowserWidth(){
 if (window.innerWidth) return window.innerWidth;
 else if (document.documentElement && document.documentElement.clientWidth!=0)
  return document.documentElement.clientWidth;
 else if (document.body) return document.body.clientWidth;
 return 0;
}
//per liquid layout
//controllo lingua
function f_detLingua(){
  if(navigator.language)return navigator.language.substring(0,2);
  if(navigator.userLanguage)return navigator.userLanguage.substring(0,2);
  if(navigator.browserLanguage)return navigator.browserLanguage.substring(0,2);
  if(navigator.systemLanguage)return navigator.systemLanguage.substring(0,2);
}
function f_test_it(lin){
//ritorna 1 se lin è it o es o pt, in tutti gli altri casi 0
  if(!lin)return 0;
  if(lin=='it')return 1;
  if(lin=='es')return 1;
  if(lin=='pt')return 1;
  return 0;
}
function f_elabora_lin(lin){
//elabora la stringa lin di 2 lettere:se it|es|pt ritorna it altrimenti en
  if(!lin)return'en';
  if(lin=='it')return'it';
  if(lin=='es')return'it';
  if(lin=='pt')return'it';
  return'en';
}
function Cambia_Lingua(lin){
//setta il cookie e ricarica il foglio omologo dell'attuale con lingua lin ('it' per it!)
//se cookies not enabled forza il caricamento settando il parametro l=
 Set_Cookie('Lingua',lin);
 if(Get_Cookie('Lingua')){
  f_ricarica_lin(lin);
 }else{
  f_ricarica_lin(lin,true);
 }
}
function Cambia_Lingua_Se(){
//ricarica il foglio omologo dell'attuale con la lingua di sistema salvo che...
 if(Get_Cookie('Lingua')==f_get_lin())return;
 if(window.location.search.length>0)return;
 f_ricarica_lin(f_elabora_lin(f_detLingua()));
}
function f_ricarica_lin(lin,forza){
//ricarica il foglio omologo dell'attuale con lingua lin ('it' per it!)
//se forza = true definisce il parametro l= per forzare
 var l=f_get_lin();
 if(l==lin)return;
 var h=window.location.pathname.toLowerCase();
 if(lin=='it'){
  h=h.replace(/_\w\w\.htm/,'.htm');
 }else if(l=='it'){
  h=h.replace(/\.htm/,'_'+lin+'.htm');
 }else{
  h=h.replace(/_\w\w\.htm/,'_'+lin+'.htm');
 }
 if(forza)h+='?l='+lin;
 window.location=h;
}
function f_get_lin(){
//determina la lingua del foglio attualmente caricato
//esegue solo per le lingue possibili (en al momento) e ritorna it negli altri casi
 var h=window.location.pathname.toLowerCase();
 if(h.match(/_en\.html?$/))return'en';
 return'it';
}
function Set_Cookie(name,value){
    // funzione semplificata: expire non è definito, quindi cookie di sessione, e path è root
  document.cookie=name+"="+escape(value)+";path=/";
}
function Get_Cookie(check_name){
    // first we'll split this cookie up into name/value pairs
    // note: document.cookie only returns name=value, not the other components
  var a_all_cookies=document.cookie.split(';');
  var a_temp_cookie='';
  var cookie_name='';
  var cookie_value='';
  var b_cookie_found=false;
  for(i=0;i<a_all_cookies.length;i++){
      // now we'll split apart each name=value pair
    a_temp_cookie=a_all_cookies[i].split('=');
      // and trim left/right whitespace while we're at it
    cookie_name=a_temp_cookie[0].replace(/^\s+|\s+$/g,'');
      // if the extracted name matches passed check_name
    if(cookie_name==check_name){
      b_cookie_found=true;
        // we need to handle case where cookie has no value but exists (no = sign, that is):
      if(a_temp_cookie.length>1)cookie_value=unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g,''));
        // note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
    }
    a_temp_cookie=null;
    cookie_name='';
  }
  if(!b_cookie_found)return null;
}

