function initArray()
 { 
  this.length = initArray.arguments.length
  for (var i = 0; i < this.length; i++)
  this[i+1] = initArray.arguments[i]
 }
var giorno=new initArray("domenica","lunedė","martedė","mercoledė","giovedė","venerdė","sabato")
var day=new initArray("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var mese=new initArray("Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre")
var month=new initArray("January","February","March","April","May","June","July","August","September","October","November","December")
var ultimamodifica = new Date(document.lastModified)
loc=unescape(window.location)
loceff=loc.split("#")
loc=loceff[0]
l=loc.length
floc=loc.slice(l-1,l)
if (floc=='l')
 {
  loc=loc.slice(0,l-1)
  l=l-1
  v='l'
  floc=''
  testo='Italiano'
  gif='italiana'
 }
else
 {
  v=''
  floc='l'
  testo='English'
  gif='inglese'
  }
if (loc.slice(l-9,l)!='testo.htm')
 {
  a='<TABLE BORDER=0 WIDTH=100%><TR><TD WIDTH=65%><BR><FONT FACE="arial" SIZE=2 COLOR="#505050"><P ALIGN=left>'
  if (floc=="l")
   {a=a+'Ultima modifica '+giorno[(ultimamodifica.getDay()+1)]+" "+ultimamodifica.getDate()+" "+mese[(ultimamodifica.getMonth()+1)]+" "}
  else
   {a=a+'Last modified '+day[(ultimamodifica.getDay()+1)]+", "+month[(ultimamodifica.getMonth()+1)]+" "+ultimamodifica.getDate()+" "}
  a=a+ultimamodifica.getFullYear()+"   h. "
  if (ultimamodifica.getHours()<10) {a=a+'0'}
  a=a+ultimamodifica.getHours()+"."
  if (ultimamodifica.getMinutes()<10) {a=a+'0'}
  a=a+ultimamodifica.getMinutes()+'</TD><TD WIDTH=35%><FONT FACE="arial" SIZE=4 COLOR="#0000FF"><P ALIGN=right><A HREF="'
document.write(a,loc+floc+'">'+testo+' <IMG SRC="bandiera'+gif+'.gif" BORDER=0></A></TD></TR></TABLE>')
 }

function leggecookie()
 {
  cookies=document.cookie
  inizio=cookies.indexOf("download=");
  if (inizio>-1)
   {
    fine=inizio+"download=".length
    download=cookies.slice(fine,fine+1)
    download=parseInt(download,16)
    url=''
    while (cookies.slice(fine+1,fine+2)!='')
     {  
      fine++
      url=url+cookies.slice(fine,fine+1);
     }
    pag=download & 14
    download=download & 1   
   }
  else
   {
    download=0
    pag=0
    url=''
   }
 }
function scrivecookie(download0,pag0,url0,al)
 {
  download0=download0|pag0
  cifre = "0123456789ABCDEF"
  download0 = ""+cifre.charAt(download0)
  scadenza=new Date();
  traunora=scadenza.getHours()+1;
  scadenza.setHours(traunora);
  scadenza=scadenza.toUTCString();
  document.cookie="download="+download0+url0+"; path=/; expires="+scadenza;
    if (cookies.indexOf("download=")==-1)
     {
      if (al!='') {alert("Attenzione! Per effettuare il download dei files musicali devi abilitare l'accettazione dei cookie!")} 
     }
 }

function right(e)
 {
  if (navigator.appName == 'Netscape' && 
  (e.which == 3 || e.which == 2))
  return false;
  else if (navigator.appName == 'Microsoft Internet Explorer' && 
  (event.button == 2 || event.button == 3))
   {
    mes="Il tasto destro del mouse č disabilitato."
    if (floc=='') 
     {mes="The rigth mouse button is disabled."}
    alert(mes)
    return false;
   }
  return true;
 }

function apre(livello)
 {

if (livello==2) {window.name="composizioni"}
  window.focus()
  document.onmousedown=right;
  if (document.layers) window.captureEvents(Event.MOUSEDOWN);
  window.onmousedown=right;
  leggecookie()
  if ((pag&livello)==livello)
   {
    if (livello==2)
     {
      mes1="sulle mie composizioni"
      mes2="on my compositions"
     }
    else 
     {
      mes1="sui temi dell'armonia e dell'acustica"
      mes2="on themes of harmony and acoustics"
     }
    mes="Risulta ancora aperta un'altra finestra "+mes1+";\nqualche link potrebbe non funzionare correttamente."
    if (floc=='')
     {mes="Another window "+mes2+" still result open;\nsome links would not be able to correctly work."}
    if (navigator.userAgent.indexOf("MSIE")!==-1 && !window.opera) {/*alert(mes)*/}
   } 
  pag=pag|livello
  scrivecookie(download,pag,url,'')
 }

function chiude(livello)
 {
  leggecookie()
  pag=(pag&(15-livello))
  if ((pag&6)==0) {
//alert("Chiudo il livello 8!")
   pag=pag&7}
  scrivecookie(download,pag,url,'')
 }

function accetta(i)
 {
  leggecookie()
  download=i
  scrivecookie(i,pag,'','!')
  url0=url
  if (url0=='') {url0='composizioni.htm'+v}
  url0='location.href= \''+url0+'\''
  var timeID = setTimeout(url0, 1)
 }

function carica(str)
 {
est=str.slice(str.length-4,str.length)
i=-1
if (est=='.MUS') {i='0'}
if (est=='.pdf') {i='1'}
if ((est=='.MID')|(est=='.mp3')) {i='2'}
if (i<0) {alert('Messaggio per il webmaster: attenzione! tipo di file errato')}
  if (download==0)
   {
    str='condizioni.htm'+v
    url=window.location
    scrivecookie(download,pag,url,'!')
   }
  else
   {
    nstr=''
    inizio=str.slice(0,str.length-4)
    fine=str.slice(str.length-4,str.length)
    j2=(fine.charCodeAt(1)+fine.charCodeAt(2)+fine.charCodeAt(3))&127
     for (j=0; j<inizio.length; j++)
      {
       j1=inizio.length+j+inizio.charCodeAt(inizio.length-1)
       c=String.fromCharCode(inizio.charCodeAt(j))

       if ((i<2)|(est=='.mp3'))
        {

       c=String.fromCharCode(((((inizio.charCodeAt(j)+j1)^j2)|96)&127)+1)
       if (c=='|') {c='!'}
       if (c.charCodeAt(0)==128) {c='_'}
       if (c.charCodeAt(0)==127) {c='-'}

      }

       nstr=nstr+c
      }
     str=nstr+fine
    }
  url0='location.href= \''+str+'\''
  if ((download==1) && (i==2)) {url0='top.'+url0}
  if ((download==1) && (i==1))
   {
    win = window.open(str,'pdf','scrollbars=yes,resizable=yes,status=yes,location=yes,toolbar=yes')
    win.focus()
   }
  else {var timeID = setTimeout(url0, 1)}
 }

function torna(str)
 {
  leggecookie()
  if ((pag&2)==0) 
   {
    window.opener=self
  win = window.open(str,'composizioni','scrollbars=yes,resizable=yes,status=yes,location=yes,toolbar=yes');
win.focus()
   }
  self.close()
 }

function pagina(str)
 {
  leggecookie()
  if (((pag&2)==0)|((pag&8)==8))
   {
    pag=pag|8
    scrivecookie(download,pag,'','')
    win = window.open(str,'composizioni','scrollbars=yes,resizable=yes,status=yes,location=yes,toolbar=yes');
    win.focus()
   }
  else
   {
window.opener.location=str
window.opener.focus()
   }
 }

function help(pagina)
 {
  x=event.screenX
  y=event.screenY
  if (x>270) {x=x-270} else {x=x+70}
  if (y>100) {y=y-100} else {y=y+20}
  dimx=screen.width
  dimy=screen.height
  if (y>dimy-200) {y=y-130}
  settings ='resizable=yes,width=200,height=175,status=no,location=no,toolbar=no,left='+x+',top='+y
        searchWin = window.open(pagina,'help',settings);
 }
