Event.observe(window,'load',setTime);baseR=[0,0,0,0,0,0,146,178,152,131,131,132,149,172,193,206,220,204,129,68,0,0,0,0]
baseG=[0,0,0,0,0,61,146,178,154,131,131,131,149,172,192,206,220,204,136,68,0,0,0,0]
baseB=[32,32,32,32,32,125,209,255,255,255,255,255,255,255,255,242,230,210,158,11,32,32,32,32]
function setSize(){var cnt=$('container').getWidth();var midl=$('midl').getWidth();var midr=$('midr')?$('midr').getWidth():0;var hg=(document.viewport.getHeight()-230);$('midm').setStyle('width:'+(cnt-midl-midr-2)+'px;height:'+hg+'px');$('midl').setStyle('height:'+hg+'px');$('midr').setStyle('height:'+hg+'px');}
xTime=0
function setTime(mode){if(mode=='run'){if(xTime==storeTime)xTime=0;xTime+=1000;if(xTime<(23*3600))setTimeout('setTime(\'run\')',50)
else xTime=storeTime;setSky(xTime)}
else{var d=new Date();xTime=d.getHours()*3600+d.getMinutes()+d.getSeconds()
storeTime=xTime;if((xTime>(5*3600))&&(xTime<20*3600))setTimeout('flyBird()',1000)
setSky(xTime)}}
function setSky(){var timePosition=xTime/(24*3600)
var hour=parseInt(xTime/3600)
red=baseR[hour-1]
green=baseG[hour-1]
blue=baseB[hour-1]
var percSin=100*(Math.sin(Math.PI*timePosition))
$('header').setStyle('opacity:'+((percSin-15)/100))
if(!isSei)$$('#header img')[0].setStyle('top:-'+(-10+percSin)+'%;left:'+80*(timePosition)+'%');else $('header').update('');$('top').setStyle('background:rgb('+red+','+green+','+blue+')')
$('topMenu').setStyle('background:rgb('+red+','+green+','+blue+')')
setTimeout('menuColors('+red+','+green+','+blue+')',20)
if((parseInt(red)+parseInt(green)+parseInt(blue))<300)topMenuBackground='#fff';else topMenuBackground='#000';for(var x=0;x<$$('#topMenu a').length;x++)
$$('#topMenu a')[x].setStyle('color:'+topMenuBackground)
$('bot').setStyle('background:rgb('+red+','+green+','+blue+')')
for(var x=0;x<$$('#topMenu a').length;x++)
$$('#bot a')[x].setStyle('color:'+topMenuBackground)
if($$('p.loginLink').length>0){$$('p.loginLink')[0].setStyle('background:rgb('+red+','+green+','+blue+')')
$$('p.loginLink a')[0].setStyle('color:'+topMenuBackground)}
if($$('p.homeBoxTit').length>0){$$('p.homeBoxTit')[0].setStyle('background:rgb('+red+','+green+','+blue+')')
$$('p.homeBoxTit')[0].setStyle('color:'+topMenuBackground)}
if($$('p.homeBoxItemTit').length>0){for(var x=0;x<$$('p.homeBoxItemTit').length;x++){$$('p.homeBoxItemTit')[x].setStyle('background:rgb('+red+','+green+','+blue+')')
$$('p.homeBoxItemTit')[x].setStyle('color:'+topMenuBackground)}}}
function menuColors(){for(var x=0;x<($$('p.articoli').length);x++)$$('p.articoli')[x].setStyle('background-color:rgb('+red+','+green+','+blue+')')
for(var x=0;x<($$('p.sottorubriche').length);x++)$$('p.sottorubriche')[x].setStyle('background-color:rgb('+red+','+green+','+blue+')')
for(var x=0;x<($$('.sottorubriche.enh').length);x++)$$('.sottorubriche.enh')[x].setStyle('background-color:#f00')
for(var x=0;x<($$('.articoli.enh').length);x++)$$('.articoli.enh')[x].setStyle('background-color:#f00')}
function flyBird(){birdX=0;if(!$('bird')){var a=document.createElement('IMG')
a.setAttribute('id','bird')
var b=parseInt(3*Math.random())
if(b==2)bird='supp/bird2.gif'
else bird='supp/bird.gif'
a.setAttribute('src',bird)
$('top').appendChild(a)
$('bird').setStyle('position:absolute;left:0;top:0')
birdX=0;}
moveBird()
setTimeout('flyBird()',90000*Math.random())}
function moveBird(){$('bird').setStyle('display:block')
birdX=birdX+1;$('bird').setStyle('left:'+birdX+'%');if(birdX<90)setTimeout('moveBird()',10+60*Math.random())
else $('bird').setStyle('display:none')}
function checkData(x){new Ajax.Request('?',{parameters:{ajax:'ajax.html',1:'text',2:$$('div.testoit')[0].innerHTML},onSuccess:function(transport){showTerms(transport.responseText)}});}
function showTerms(tr){$$('div.testoit')[0].innerHTML=tr;for(var x=0;x<$$('span.subst').length;x++){createDiv('label_'+x,'rightBar','labels')
$('label_'+x).innerHTML=$$('span.subst')[x].innerHTML
$('label_'+x).setStyle('top:'+px($$('span.subst')[x].cumulativeOffset()[1]-130))}}
function buildRightBar(){createDiv('rightBar','midm','bar')
$('rightBar').setStyle('position:absolute;top:'+px($('top').getHeight()+30)+';height:'+px($('midm').getHeight())+';right:0px;width:5px;background:#efefff;border:1px solid #ddd')
Event.observe('rightBar','click',function(){setLabels()})}
function setLabels(){$('rightBar').morph('width:70px')
checkData();}
function buildRelaxLink(){var a=$$('.titolo')
$(a[0]).innerHTML='<span class=relax><a title="versione amica degli occhi" href=javascript:relax()><img src="supp/eye.jpg"></a></span>'+$(a[0]).innerHTML}
relax_flag=0;function relax(){if(relax_flag==0){relax_flag++;var a=['midl','top','bot','topMenu','rightBar','bio_relations','midm']
for(var x=0;x<a.length;x++){setTimeout('new Effect.Fade(\''+a[x]+'\')',Math.random()*1000)}
setTimeout('new Effect.Appear(\'midm\')',2000);setTimeout('new Effect.Morph(\'midm\',{style:\'width:95%;font-size:1.6em\'})',1000);}
else{relax_flag--;new Effect.Fade('midm')
var a=['midl','top','bot','topMenu','rightBar','bio_relations','midm']
for(var x=0;x<a.length;x++){setTimeout('new Effect.Appear(\''+a[x]+'\')',Math.random()*1000)}
setTimeout('new Effect.Appear(\'midm\')',2000);setTimeout('new Effect.Morph(\'midm\',{style:\'width:75%;font-size:1em\'})',1000);}}
