window.onerror=handleErr;
var PaginaInizializzata=0;
ArrayTabellaImmagini=false;
ArrayTabellaRighe=false;

if(document.getElementById('TableList')){
	ArrayTabellaRighe=document.getElementById('TableList').getElementsByTagName('tr');
	}

	
function EvidenziaImg(IdSql){
	
	if(document.getElementById('TableImmagini') && ArrayTabellaImmagini==false){
		ArrayTabellaImmagini=document.getElementById('TableImmagini').getElementsByTagName('a');
	}
	for(i=0; i<ArrayTabellaImmagini.length; i++){
		if(ArrayTabellaImmagini[i].getAttribute('id_sql')==IdSql){
			
			ArrayTabellaImmagini[i].className="Acceso";	
			};
		
		}
		EvidenziaRiga(IdSql)
	}
	
function ResettaImg(){
		for(i=0; i<ArrayTabellaImmagini.length; i++){
		ArrayTabellaImmagini[i].className="";
		}
	}

function EvidenziaRiga(IdSql){
	
	if(document.getElementById('TableList') && ArrayTabellaRighe==false){
		ArrayTabellaRighe=document.getElementById('TableList').getElementsByTagName('tr');
	}
	for(i=0; i<ArrayTabellaRighe.length; i++){
		if(ArrayTabellaRighe[i].getAttribute('id_sql')==IdSql){
			
			ArrayTabellaRighe[i].className="Acceso";	
			};
		
		}
	}
	
function ResettaRiga(){
	for(i=0; i<ArrayTabellaRighe.length; i++){
		ArrayTabellaRighe[i].className="";
		}
	}	

function handleErr(msg,url,l)
{
txt="There was an error on this page.\n\n"
txt+="Error: " + msg + "\n"
txt+="URL: " + url + "\n"
txt+="Line: " + l + "\n\n"
txt+="Click OK to continue.\n\n"
//alert(txt)
return true
}
function CaricaDescrizione(ObjHTML){
	_gb('BoxLista').style.display='none';
	_gb('BoxTornaLista').style.display='block';
	_gb('BoxDettaglioPeople').style.display='block';
	
	_gb('BoxDettaglioPeople').innerHTML=ObjHTML.parentNode.getElementsByTagName('div')[0].innerHTML
	}

function nulla() {
	return
	}
function trim(Stringa) {
	return Stringa.replace(/^\s+|\s+$/g,"")
	}
function CaricaImgBig(Elemento) {
	if(Elemento.getElementsByTagName('img')[0]){
	ImgElemento=Elemento.getElementsByTagName('img')[0];
	ImgBig=document.getElementById('BigImg')
	ImgBig.setAttribute('src',ImgElemento.getAttribute('src_big'))
	}
	}

function centra(){
		//alert("entra");
		if (parseInt(navigator.appVersion)>3) {
		 if (navigator.appName=="Netscape") {
		  winH = window.innerHeight;
		 }
		 else {
		  winH = document.documentElement.clientHeight;
		 }
		}

		temp=(winH-543)/2;
		document.getElementById('BoxTotale').style.top=temp+"px";
		document.getElementById('body').style.backgroundPosition="0px "+temp+"px ";
		document.getElementById('BoxTotale').style.visibility="visible";
	}	
	
function _gb(Id){
	return document.getElementById(Id);
	}

/* 
 * Cross-browser event handling, by Scott Andrew
 */
 
function addEvent(element, eventType, lamdaFunction, useCapture) {
    if (element.addEventListener) {
        element.addEventListener(eventType, lamdaFunction, useCapture);
        return true;
    } else if (element.attachEvent) {

		element.detachEvent('on' + eventType, lamdaFunction);
        var r = element.attachEvent('on' + eventType, lamdaFunction);
        return r;
    } else {
        return false;
    }
}

 


// JavaScript Document
function includeSwf(FlashVars,src,width,height,id)
{
	document.write(
    '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="'+id+'" align="middle">\n'+
      '<param name="FlashVars" value="'+FlashVars+'">\n'+
      '<param name="allowScriptAccess" value="always" />\n'+
      '<param name="movie" value="'+src+'" />\n'+
      '<param name="quality" value="high" />\n'+
      ' <param name="wmode" value="transparent" />\n'+
      '<embed src="'+src+'" wmode="transparent" quality="high" bgcolor="#000000" FlashVars="'+FlashVars+'" width="'+width+'" height="'+height+'" name="'+id+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n'+
    '</object>');
}
function ReturnSwf(FlashVars,src,width,height,id)
{
	var ReturnValue='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'" id="'+id+'" align="middle">\n'+
      '<param name="FlashVars" value="'+FlashVars+'">\n'+
      '<param name="allowScriptAccess" value="always" />\n'+
      '<param name="movie" value="'+src+'" />\n'+
      '<param name="quality" value="high" />\n'+
      ' <param name="wmode" value="transparent" />\n'+
      '<embed src="'+src+'" wmode="transparent" quality="high"  FlashVars="'+FlashVars+'" width="'+width+'" height="'+height+'" name="'+id+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n'+
    '</object>';
	return(ReturnValue)
}

function PaginaCaricata(){
		if(document.getElementById('Preloading')){
			document.getElementById('Preloading').style.display="block";
		}
	}

function InitPage(){

//alert(PaginaInizializzata+"PaginaInizializzata")
	if(PaginaInizializzata==0){
		
		if(document.getElementById('Preloading')){
				document.getElementById('Preloading').style.display="none";
		}
		
		//Sfondo random sulle pagine interne
		RandomPixel=Math.round(500*Math.random())-450;
		RandomSfondo=Math.round(6*Math.random());
		
		if(document.getElementById('BoxTotale').className.indexOf("Dettaglio")!=-1){
	
			if(RandomSfondo<2){
				document.getElementById('BoxFotoContainer').style.backgroundImage="url(images/sfondo1.gif)"
			}else if(RandomSfondo<4){
				document.getElementById('BoxFotoContainer').style.backgroundImage="url(images/sfondo2.gif)"
			}else{
				document.getElementById('BoxFotoContainer').style.backgroundImage="url(images/sfondo3.gif)"
				}		
	
		} else if(document.getElementById('BoxTotale').className=="Home"){
			if(RandomSfondo<2){
				document.getElementById('BoxTotale').style.backgroundImage="url(images/home-sfondo1.gif)"
			}else if(RandomSfondo<4){
				document.getElementById('BoxTotale').style.backgroundImage="url(images/home-sfondo2.gif)"
			}else{
				document.getElementById('BoxTotale').style.backgroundImage="url(images/home-sfondo3.gif)"
				}
		
		} else if(document.getElementById('BoxTotale').className!="Splash"){
	
			if(RandomSfondo<2){
				document.getElementById('BoxTotale').style.backgroundImage="url(images/sfondo1.gif)"
			}else if(RandomSfondo<4){
				document.getElementById('BoxTotale').style.backgroundImage="url(images/sfondo2.gif)"
			}else{
				document.getElementById('BoxTotale').style.backgroundImage="url(images/sfondo3.gif)"
				}
		
		}
		PaginaInizializzata=1;
		
		 ChangeFlash()
		 centra()
		}
	}

	
function ChangeFlash(){
	
	// ciclo sui LI
	var FlashWidth=235;
	var FlashHeight=21;
	var ArrayTag=document.getElementsByTagName('li');
	for (i=0;i<ArrayTag.length;i++){
		if(ArrayTag[i].getAttribute("flash_transform")){
			var FlashUrl=ArrayTag[i].getAttribute("flash_url");
			var FlashTxt=ArrayTag[i].getElementsByTagName('a')[0].innerHTML;
			var FlashVars="FlashTxt="+FlashTxt+"&FlashUrl="+FlashUrl;
			//alert(FlashVars)
			ArrayTag[i].innerHTML=ReturnSwf(FlashVars,"swf/titolo1.swf",FlashWidth,FlashHeight,"flash")+"";
			}
		}
	
	// ciclo sui H2
	var FlashWidth=235;
	var FlashHeight=120;
	var ArrayTag=document.getElementsByTagName('h2');
	for (i=0;i<ArrayTag.length;i++){
		if(ArrayTag[i].getAttribute("flash_transform")){
			var FlashUrl=ArrayTag[i].getAttribute("flash_url");
			var FlashTxt=ArrayTag[i].innerHTML;
			var FlashVars="FlashTxt="+FlashTxt+"&FlashUrl="+FlashUrl;
			ArrayTag[i].innerHTML=""+ReturnSwf(FlashVars,"swf/titolo2.swf",FlashWidth,FlashHeight,"flash")+"";
			}
		}

	// ciclo sui H3
	var FlashWidth=350;
	var FlashHeight=28;
	var ArrayTag=document.getElementsByTagName('h3');
	for (i=0;i<ArrayTag.length;i++){
		if(ArrayTag[i].getAttribute("flash_transform")){
			var FlashUrl=ArrayTag[i].getAttribute("flash_url");
			var FlashTxt=ArrayTag[i].innerHTML;
			var FlashVars="FlashTxt="+FlashTxt+"&FlashUrl="+FlashUrl;
			ArrayTag[i].innerHTML=""+ReturnSwf(FlashVars,"swf/titolo3.swf",FlashWidth,FlashHeight,"flash")+"";
			}
		}
		
	// ciclo sui H4
	var FlashWidth=350;
	var FlashHeight=28;
	var ArrayTag=document.getElementsByTagName('h4');
	for (i=0;i<ArrayTag.length;i++){
		if(ArrayTag[i].getAttribute("flash_transform")){
			var FlashUrl=ArrayTag[i].getAttribute("flash_url");
			var FlashTxt=ArrayTag[i].innerHTML;
			var FlashVars="FlashTxt="+FlashTxt+"&FlashUrl="+FlashUrl;
			ArrayTag[i].innerHTML=""+ReturnSwf(FlashVars,"swf/titolo4.swf",FlashWidth,FlashHeight,"flash")+"";
			}
		}

}

