var isNS=document.layers?true:false;
var isIE=(document.all!=null)&&(navigator.appName.toLowerCase().indexOf('microsoft internet explorer')!=-1);
var isDom2=document.getElementById;
var fVers=parseFloat(navigator.appVersion);
var NavOs=navigator.platform.toLowerCase();
var isWin=(NavOs.indexOf('win')!=-1);
if ((isNS && fVers<4)||(isIE && fVers<4))
    alert('Your browser is very old. Please upgrade if you want to see this page correctly.');
function getLayer(n) {var o;if (isDom2) return document.getElementById(n);if (isNS) return document.layers[n];if (isIE) return document.all(n);if (o=eval('document.'+n)) return o;return null;}
function unHide(n){var o=getLayer(n);o.style.visibility='visible';}
function Hide(n){var o=getLayer(n);o.style.visibility='hidden';}

var sfumaIndex=1;
var sfumaRevIndex=0;
function sfumaConX(nm){
						sfumaIndex-=0.01;
					var tm="sfumaConX(\""+nm+"\")";
				var o=getLayer(nm);
				if(sfumaIndex>=0.3&&sfumaIndex<1)	{	o.style.filter='Gray(grayScale=0,opacity='+sfumaIndex+')'; setTimeout(tm,100);}
					  	if(sfumaIndex>0&&sfumaIndex<0.3) { o.style.filter='Gray(XRay=1,opacity='+sfumaIndex+')'; setTimeout(tm,100);}
					if(sfumaIndex<=0){sfumaIndex=1;}
						}

function sfuma(nm){
				sfumaIndex-=0.1;
				var tm="sfuma(\""+nm+"\")";
				var o=getLayer(nm);
				
				if(sfumaIndex>=0&&sfumaIndex<1)	{	o.style.filter='Gray(grayScale=0,opacity='+sfumaIndex+')'; setTimeout(tm,1);}
				else{sfumaIndex=1;}	  	
						}
 function sfumaRev(nm){
				sfumaRevIndex+=0.1;
				var tm="sfumaRev(\""+nm+"\")";
				var o=getLayer(nm);
				
				if(sfumaRevIndex>=0&&sfumaRevIndex<1)	{	o.style.filter='Gray(grayScale=0,opacity='+sfumaRevIndex+')'; setTimeout(tm,1);}
				else{sfumaRevIndex=0;}	  	
						}
						
function animazione(id1,id2,tm,inizio){
	if(inizio==1){
		Hide(id2);
		unHide(id1);
		setTimeout("animazione(\'"+id1+"\',\'"+id2+"\',"+tm+","+0+")",tm);
	}
	else{
		Hide(id1);
		unHide(id2);
		setTimeout("animazione(\'"+id1+"\',\'"+id2+"\',"+tm+","+1+")",tm);
	}
}
						
function load(file,tm){

	setTimeout("html(\""+file+"\")",tm);
	
	}
	
function html(file){
	document.location=file;
	}

function opa(nm,num){
	var o=getLayer(nm);
	o.style.filter='Gray(grayScale=0,opacity='+num+')';
	}
	
	function  resize(Img,xsize){
		 Img.style.width=xsize+'px';
        
         }
var foto=new Array();
var srcs= new Array();
var indexC=0;
var stop=0;
function carica(lfoto,f,n,tm)
{
	var i=0;
	srcs=lfoto.split(";");
	var fotos=eval(f);
	var tmo;
	var to="carica(\'"+lfoto+"\',\'"+f+"\',\'"+n+"\',\'"+tm+"\')";
	
	for( indexC; indexC<srcs.length&&!stop;indexC++)
	{
	if(indexC==0){
		fotos[indexC]= new Image();         
		fotos[indexC].src=srcs[indexC];
		tmo=setTimeout(to,tm);
	}
	else;
	fotos[indexC]= new Image();         
	fotos[indexC].src=srcs[indexC];
	i++;
	}
}





var lsFoto=new Array();
var SRCs
var IndexI=0;
function loadFoto(inFoto,tm){
	SRCs=inFoto.split(";");
	tm=tm*1000;
	//for(i;i<srcs.length;i++){
	setTimeout("lF(\'"+tm+"\',\'"+0+"\')",tm);
	//}	
}
function CountLF(tm,i){
	var j=parseInt(i)+1;
	//alert("i="+IndexI);
	lF(tm,j);
}

function lF(tm,i){
	
	if(parseInt(i)<SRCs.length && (!stop)){	
		//alert("Sto salvando:"+SRCs[parseInt(i)]);
		lsFoto[parseInt(i)]=new Image();
		lsFoto[parseInt(i)].src=SRCs[parseInt(i)];
		
		setTimeout("CountLF(\'"+tm+"\',\'"+i+"\')",tm);

	}
	else{};

}

function stopLoad(){stop=1;}
/*
function carica(lfoto,f,n,tm)
{
	var i=0;
	srcs=lfoto.split(";");
	var fotos=eval(f);
	var tmo;
	fotos=lsFoto;
	setTimeout("loadFoto(\'"+lfoto+"\',"+tm+")",n);	

}

*/	
var first=true;
var findex=0;
var GalbumStop=false;
function album(id,f,tm,dopo){
	var fun="album(\'"+id+"\',\'"+f+"\',\'"+tm+"\',\'"+dopo+"\')";
	if(GalbumStop){return 0;}
	if(first){first=false; setTimeout(fun,dopo);}
	else{
		var o=getLayer(id);
		var fotos=eval(f);
		
		sfuma(id);
		sfumaRev(id);
      	findex++;
        	if(findex>=(fotos.length)){findex=0;}
		else{}
		o.src=fotos[findex].src;
		if(!GalbumStop){setTimeout(fun,tm);}
	}
 }

function altroAlbum(id,f,m){
	if(m=='-1'){findex=findex-1;}
	else {findex+=1;}
	
	 
	 var o=getLayer(id);
	 var fotos=eval(f);
	 if(findex>=fotos.length){findex=0;}
	 else;
	  if(findex<0){findex=(fotos.length-1);}
	  else;
	
	o.src=fotos[findex].src;
	
	
	
	}
	
function change(id,inSrc){var o=getLayer(id);o.src=inSrc;}
var w,h;
w=screen.width;
h=screen.height;
orgW=w;
orgH=h;    
w-=10;
h-=70;

function newWin(fileDesc){
var descWin=window.open(fileDesc,'Desc','width='+w+',height='+h+',Resizable=yes,left=0,top=0,scrollbars=yes');
descWin.focus();
}

 function close(){parent.window.focus();}


function center(id,size){
	var top=Math.round((h/2)-(size/2));
	var o=getLayer(id);
	o.style.top=top+"px";
	}	



function freshIm(o,x,y){
	o.style.top=y;
	o.style.left=x;
	}

function cGroup(idN,inX,inY){
	this.id=idN;
	this.x=inX;
	this.y=inY;
	
}


function group(pId,list){
	var inx,iny,ox=0,oy=0,o,i=0;
	o=getLayer(pId);
	inx=parseInt(o.style.left);
	iny=parseInt(o.style.top);
	var oi;
	for(i;i<list.length;i++){
		oi=getLayer(list[i].id);
		ox=inx+list[i].x;
		oy=iny+list[i].y;
		//alert("id="+list[i].id+" , x="+ox+" , y="+oy);
		oi.style.left=ox+"px";
		oi.style.top=oy+"px";
	}
}

function middle(id,width,height){
	center(id,height);
	var left=Math.round((w-width-23)/2);
	var o=getLayer(id);
	o.style.left=left+"px";
	}
	
	
function fotoCh(id,foto){
	o1=getLayer(id);
	o1.src=foto;
}	
	
function addattaNew(id,inH){
	var o1=getLayer(id);
	var left=Math.round((orgW/100)*8);
	var o2=getLayer("line3");
	var right=parseInt(o2.style.right);
	o2=getLayer("line5");
	var top=parseInt(o2.style.top);
	o2=getLayer("line1");
	var bottomT=parseInt(o2.style.top);
	var H=bottomT-top;
	var W=orgW-left-right;
	//alert("H="+H+":"+W+"\nleft="+left+":"+right+"\ntop="+top+":"+bottomT+"\norgH="+orgH+":"+orgW);
	//o1==getLayer(id);
	//alert(o1.innerText+"\n"+id+o1.style.fontSize);
	return (addattaScrittaAL(H-inH,W,"",id));			//alert(grandezza);
}		

function addatta(id){
	var o1=getLayer(id);
	var grandezza=parseInt(o1.style.fontSize);
	var larg=1024-10;
	var line;
		//alert(grandezza);
	if(w>larg){
			grandezza=(parseInt(grandezza*(w/larg))-1);
			//line=grandezza-1;
			o1.style.lineHeight=grandezza+"px";
	}
	else{ if(w<larg){
			grandezza=20;
			line=grandezza-1;
			o1.style.lineHeight=line+"px";
		}
		else{}

	}
	/*if(!isIE){
		grandezza-=9;
		//alert(grandezza);
	}*/
	o1.style.fontSize=grandezza+"px";
	
}		

function addattaAlt(id){
	//alert(id+"\nALT");

	var o1=getLayer(id);
	var grandezza=parseInt(o1.style.top);//if(id=='menu'){alert(id+"\n"+grandezza);}

	var larg=768-70;
	var linea;
	//alert(grandezza);
	grandezza=parseInt(grandezza*(h/larg));
	/*if(h>larg){
		grandezza=linea+grandezza;
	}
	else{
		grandezza=grandezza-linea;
	}*/
	o1.style.top=grandezza+"px";
	//if(id=='menu'){alert(id+"\n"+grandezza);}
	if(id=='foto'&& larg>h){o1.style.top="0px";
				o1.style.left="0px";
	}
}

function addattaLar(id){
	//alert(id+"\nALT");

	var o1=getLayer(id);
	var grandezza=parseInt(o1.style.left);//if(id=='menu'){alert(id+"\n"+grandezza);}

	var larg=1024-10;
	var linea;
	//alert(grandezza);
	grandezza=parseInt(grandezza*(w/larg));
	/*if(h>larg){
		grandezza=linea+grandezza;
	}
	else{
		grandezza=grandezza-linea;
	}*/
	o1.style.left=grandezza+"px";
	//if(id=='menu'){alert(id+"\n"+grandezza);}

}
function addattaWid(id){
	var o1=getLayer(id);
	var grandezza=parseInt(o1.style.width);
	var larg=1024-10;
	
	//alert(id);
	grandezza=parseInt(grandezza*(w/larg));
	o1.style.width=grandezza+"px";
	//alert(id+"\n"+grandezza);
}
function addattaHei(id){
	var o1=getLayer(id);
	var grandezza=parseInt(o1.style.height);
	var larg=768-70;
	//alert(grandezza);
	grandezza=parseInt(grandezza*(h/larg));
	o1.style.height=grandezza+"px";
	//alert(id+"\n"+grandezza);
}
function addattaRig(id){
	var o1=getLayer(id);
	var grandezza=parseInt(o1.style.right);
	var larg=1024-70;
	//alert(grandezza);
	grandezza=parseInt(grandezza*(w/larg));
	o1.style.right=grandezza+"px";
	//alert(grandezza);
}
function addattaHeiWid(id){
	if(w<1014){
		//alert(id);
		addattaHei(id);
		addattaWid(id);
	}
}

function cHtml(id,str,htm){
	var o1=getLayer(id);
	
	//alert("id="+id+"\nstr="+str);
	if(!htm){
		if(isNS){
			o1.document.write(str);
		}
		else{
			o1.innerText=str;
		}
	}
	else{
		if(isNS){
			o1.document.write(str);
		}
		else{
			
			o1.innerHTML=str;
			//alert(str);
			
		}
	}
}

function addHtml(id,str,htm){
	var o1=getLayer(id);	

	if(!htm){
		if(isNS){
			o1.document.write(str);
		}
		else{
			o1.innerText+=str;
		}
	}
	else{
		if(isNS){
			o1.document.write(str);
		}
		else{
			
			o1.innerHTML+=str;
			//alert(str);
			
		}
	}

}


function chkControll(){
	var o1;
	var ind=0;
	var cond=-1;

	for(ind;ind<isHOpen.length;ind++){
		o1=getLayer('chk'+ind);
		//alert(o1.checked);
		if((o1.checked=="checked"||o1.checked==true) &&cond==-1){cond=ind;}
		else if((o1.checked=="checked"||o1.checked==true) && cond>-1){
			return -2;
		}
	}
	//alert(cond);
	return cond;
}

function chkFalse(){
	var o1;
	var ind=0;

	for(ind;ind<isHOpen.length;ind++){
		o1=getLayer('chk'+ind);
		if(o1.checked==false||o1.checked==true){
			o1.checked=false;
		}
		else{
			o1.checked="";
		}	
	}
}



function escChar(str){
	
	str=str.replace(/ ?<br\/>/g,"\n");
	str=str.replace(/<\/br>/g,"\n");
	str=str.replace(/&nbsp;/g," ");
	
	str=str.replace(/&#38;/g,"&");
	str=str.replace(/&#60;/g,"<");
	str=str.replace(/&#62;/g,">");
	str=str.replace(/&#39;/g,"'");
	str=str.replace(/&#34;/g,"\"");
	str=str.replace(/&#44;/g,",");
	return str;
	}

var indEventi=0;

function altroTit(sgn){
    stopScorr=true;
   // clearTimeout(inTimer);
    
	
     var tot=inTitolo.length;
		var pr;
		if(tot==(indEventi+1)&&sgn=='+'){indEventi=0;}
		else{
			if(indEventi==0&&sgn=='-'){indEventi=tot-1;}
			else{
				if(sgn=='-'){indEventi--;}
				else{indEventi++;}
			}
		}
  setTimeout("stopScorr=false",200);
  setTimeout("altroTitScorr(\""+sgn+"\",\"#\",0,1)",200);
/*	//sfumaRev("menuScritta");
	pr=indEventi+1;
	//Evento("+pr+"/"+tot+")</
	//cHtml('menuScritta',,1);	
	cHtml('menuScritta',"<span style=\'position: relative;top:0px;width: 180px;text-align: center;font-size: 28px;font-family: Arial;color:rgb(248,217,99);\'> 31<span style=\"font-size:20px;\"><br/>Aprile 2009</span></span>"+inTitolo[indEventi],1);
	*/
}
var numTotGiri=2;
var tuttiMesi=["Jennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"];
var stopScorr=false;
var inTimer;
function altroTitScorr(sgn,str,numGiri,tm){
		var tot=inTitolo.length;
		var pr;
		
      if(numGiri==numTotGiri){
			//altroTitScorr("+","#",0,tm);
			sgn="+";
			str="#";
			numGiri=0;
			if(tot==(indEventi+1)&&sgn=='+'){indEventi=0;}
			else{
				if(indEventi==0&&sgn=='-'){indEventi=tot-1;}
				else{
					if(sgn=='-'){indEventi--;}
					else{indEventi++;}
				}
			}
		}
    if(stopScorr){cHtml('menuScritta',"");/*alert("ciao");*/return 0;}
	//sfumaRev("menuScritta");
	pr=indEventi+1;
	//Evento("+pr+"/"+tot+")</
	//cHtml('menuScritta',,1);
	var str2="";
	var str3="";
	if(str=="#"){
		str2="               "+inTitolo[indEventi];
	}
	else{
		
		str2=str.substr(1,str.length);
	}
	str3=str2.substr(0,15);
	str3=str3.replace(/ /g,"&nbsp;");
	inDtA=inData[indEventi].split("/");
	
	cHtml('menuScritta',"<span style=\'position: relative;top:2px;width: 180px;text-align: center;font-size: 42px;font-family: French Script MT,Script;color:#bdb76c/*rgb(248,217,99)*/;\'>"+inDtA[0]+"<span style=\"font-size:35px;\"><br/>"+tuttiMesi[inDtA[1]-1]+" "+inDtA[2]+"<br/></span></span><span style=\"margin-top: 10px;text-align:left;width: 180px;height: 30px;\">"+str3+"</span>",1);
	if(str.length==0){
		numGiri++;
		str2="#";
		//alert("ciao");
	}
	//alert(indEventi);
	inTimer=setTimeout("altroTitScorr(\""+sgn+"\",\""+str2+"\","+numGiri+","+tm+")",200);
	//return 0;
	
}


function chEventi(){
	
	cHtml('titolo',inTitolo[indEventi],1);
	var gma=inData[indEventi].split("/");
	cHtml('titData',gma[0]+" "+tuttiMesi[gma[1]-1]+" "+gma[2],1);
	cHtml('menuCh',inMenu[indEventi],1);
	cHtml('desc',inDesc[indEventi],1);
	var obj=getLayer("line5");
	var wd=parseInt(obj.style.width)+20;
	var prima=parseInt(obj.style.top);
	obj=getLayer("line2");
	var sec=parseInt(obj.style.top);
	
	addattaScrittaAL(sec-prima-120,wd,inDesc[indEventi],'scritta');
	//addattaScrittaAL(120,180,inTitolo[indEventi],"menuScritta");
	addattaScrittaAL(320,600,inMenu[indEventi],"scritta2");
	}

function albumEventi(tm){
		setTimeout("timeAltroTit("+tm+")",tm);
}	

function timeAltroTit(tm){
	altroTitScorr("+","#",0,200);
	//altroTit('+');
	//setTimeout("timeAltroTit("+tm+")",tm);
}	

function addattaScrittaAL(H,W,scr,id){
	var obj=getLayer(id);
	 
	var sz;
	sz=addattaAltS2(obj,H)+1;
	obj.style.lineHeight=sz+"px";
	return sz;	
	
}	

function addattaAltS2(objIn,altIn){
	var szC=35;//parseInt(objIn.style.fontSize);
	var altOut=altIn+1;//objIn.offsetHeight;
	while(altOut>altIn){
		szC--;
		objIn.style.fontSize=szC+"px";
		objIn.style.lineHeight=szC+"px";
		altOut=objIn.offsetHeight;
			//alert(altIn+"\nH:"+altOut);
	//alert(szC);
	}
	
	return szC;
}

function addattaMenu(objIn,menu){
	var altOut=objIn.offsetHeight;
	//altOut+=30;
	menu.style.height=altOut+"px";
}

function centerMenu(o,W){
	var left=parseInt(w*0.08);
	var right=250;
	var ag=0;
	if(w==(1024-10)){ag+=59}
	
	var tmp=(((w-250)-W+ag)/2);
	o.style.left=tmp+"px";
	
}

	

