//*******************************************************************************************
//*******************************************************************************************
//***** Apre Finestra Popup chiudendo la precedente e mantenendo Focus su Popup**************
//*******************************************************************************************

function popupWindow(path,name,height){  
	popup = window.open(path,name,"width=500,height=" + height + ",scrollbars=no,top=0,left=0");
	if ( popup.document.close() ) {
		popup.document.close()
	}
}

function popupWindow2(path,name,height){  
	popup = window.open(path,name,"width=780,height=" + height + ",scrollbars=no,top=0,left=0");
	if ( popup.document.close() ) {
		popup.document.close()
	}
}

function popupWindowScroll(path,name,height){  
	popup = window.open(path,name,"width=520,height=" + height + ",scrollbars=yes,top=0,left=0");
	if ( popup.document.close() ) {
		popup.document.close()
	}
}

function popupWindowScroll2(path,name,width){  
	popup = window.open(path,name,"width=" + width + ",height=620,scrollbars=yes,top=0,left=0");
	if ( popup.document.close() ) {
		popup.document.close()
	}
}

function popupWindowScroll3(path,name,width,height){  
	popup = window.open(path,name,"width=" + width + ",height=" + height + ",scrollbars=no,top=0,left=0");
	if ( popup.document.close() ) {
		popup.document.close()
	}
}


//*******************************************************************************************
//****** <a href="javascript:popupWindow('path_n.html','name','height')"> *******************
//*******************************************************************************************
//****** Da inserire nelle pag Popup: window.focus(); ***************************************
//*******************************************************************************************
//*******************************************************************************************


//*******************************************************************************************
//*******************************************************************************************
//*********************************** MENU' *************************************************
//*******************************************************************************************
//*******************************************************************************************

curlayer = 'none';
linkname = '';
thislinkname = '';
closeinterval = 0;
clientBrowser = '';

uAgnt = navigator.userAgent;
uVers = navigator.appVersion;
if (uAgnt.indexOf("MSIE") != -1 	&& uVers.substring(0,1) > 3) {
	clientBrowser = 'MSIE'; 
	closeInterval = window.setTimeout("",1);
} else if (uAgnt.indexOf("Gecko") != -1) {
	clientBrowser = 'Gecko'; 
	closeInterval = window.setInterval("",1);
} else if (uAgnt.indexOf("Mozilla/4") != -1) {
	clientBrowser = 'NS4';
	closeInterval = window.setInterval("",1);
} else {
	clientBrowser = 'unsupported';
} 

function Aprimenu(alayer){
	linkname = alayer+'link';
	if (clientBrowser == 'MSIE') {
		if (alayer != curlayer) {
			curlayer = alayer;
			ieChiudiTutto();
			ieAprimenu(alayer);
		}

	} else if (clientBrowser !='unsupported') {
		if (alayer != curlayer) {
			curlayer = alayer;
			nsChiudiTutto(alayer);
			nsAprimenu(alayer);
		}
	} else {
	}
}   

function nsAprimenu(alayer){
	if (clientBrowser == 'Gecko') {
		if (document.getElementById(alayer)) {
			document.getElementById(alayer).style.visibility='visible';
		}
	} else {
		if (document.layers[alayer]) {
			document.layers[alayer].visibility='visible';
		}
	}
	nsChiusuraAutomatica(900000);
}


function nsChiudiTutto() {
	dim = 0;
	while (dim <= (alayers.length - 1)) {
		thislayer = alayers[dim];
		if ( clientBrowser == 'Gecko') {
			document.getElementById(thislayer).style.visibility='hidden';
		} else {
			if (document.layers[thislayer]) {
				document.layers[thislayer].visibility='hide';
			}
		}
		dim++;
	}
	curlayer = '';
	nsChiusuraAutomatica(0);
}

function nsChiusuraAutomatica(interval){
	if (interval > 0) {
		closeInterval = window.setInterval("nsCloseall()",interval);
	} else {
		window.clearInterval(closeInterval);
	}
}

function ieAprimenu(alayer) {
	vis = 'visible';
	linkname = alayer+'link';
	if (document.all[alayer]) {
		document.all[linkname].className = "menuprincipaleaperto";
		document.all[alayer].style.visibility = vis;
	}
	ieChiusuraAutomatica(900000);
}

function ieChiudiTutto(alayer) {
	vis = 'hidden';
	linkname = alayer+'link';
	if (document.all[alayer]) {
		document.all[linkname].className = "menuprincipale";
		document.all[alayer].style.visibility = vis;
	}
	ieChiusuraAutomatica(0);
}

function ieChiudiTutto() {
	dim = 0;
	while (dim <= (alayers.length - 1)) {
		thislayer = alayers[dim];
		thislinkname = thislayer+'link';
		if (document.all[thislayer]) {
			document.all[thislayer].style.visibility = 'hidden'; 
			document.all[thislinkname].className = "menuprincipale";
		}
		dim++;
	}
	ieChiusuraAutomatica(0);
	curlayer = '';
}

function ieChiusuraAutomatica(interval){
	if (interval > 0) {
		closeInterval = window.setTimeout("ieCloseall()",interval);
	} else {
		if (closeInterval != 0)
			window.clearTimeout(closeInterval);
	}
}

   
function ieCambiaLayer(layername) {
	if (document.all[layername]) {
		if (document.all[layername].style.visibility == 'visible') {
			vis = 'hidden'; 
		} else {
			vis = 'visible';
		}
		document.all[layername].style.visibility = vis;
	}

}

function nsCambiaLayer(layername){
	if (clientBrowser == 'Gecko') {
		if (document.getElementById(layername)) {
			if (document.getElementById(layername).style.visibility=='visible') {
				document.getElementById(layername).style.visibility='hidden';
			} else {
				document.getElementById(layername).style.visibility='visible';
			}
		}
	} else {
		if (document.layers[layername]) {
			if (document.layers[layername].visibility=='visible') {
				document.layers[layername].visibility='hidden';
			} else {
				document.layers[layername].visibility='visible';
			}
		}
	}
}



//**********************************************************************************************************
//**********************************************************************************************************
//**************************************   Scroll   ********************************************************
//**********************************************************************************************************
//**********************************************************************************************************

function verifyCompatibleBrowser(){ 
    this.ver=navigator.appVersion; 
    this.dom=document.getElementById?1:0; 
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
    this.ie4=(document.all && !this.dom)?1:0; 
    this.ns5=(this.dom && parseInt(this.ver) >= 5)?1:0; 
    this.ns4=(document.layers && !this.dom)?1:0; 
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5); 
    return this;
} 
bw=new verifyCompatibleBrowser() 
 

var speed=30;
var loop; 
 
function ConstructObject(obj,nest){ 
    nest=(!nest) ? '':'document.'+nest+'.'; 
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
    this.scrollWidth=bw.ns4?this.css.document.width:this.el.offsetWidth; 
    this.clipWidth=bw.ns4?this.css.clip.width:this.el.offsetWidth; 

    ConstructObject.prototype.left=MoveAreaLeft;
	  ConstructObject.prototype.right=MoveAreaRight; 
    ConstructObject.prototype.MoveArea=MoveArea; 
	  this.x; 
	  this.y; 
    this.obj = obj + "Object"; 
    eval(this.obj + "=this"); 

    return this; 
} 

function MoveArea(x,y){ 
 this.x=x;
 this.y=y; 
 this.css.left=this.x; 
 this.css.top=this.y; 
PercPos = this.x/(objContainer.clipWidth - this.scrollWidth);
} 

function MoveAreaLeft(move){ 
	if(this.x>-this.scrollWidth+objContainer.clipWidth){ 
    this.MoveArea(this.x+move,0) 
    if(loop) 
		{setTimeout(this.obj+".left("+move+")",speed)}
	} 
} 

function MoveAreaRight(move){ 
	if(this.x<0){ 
    this.MoveArea(this.x+move,0) 
    if(loop) 
		{setTimeout(this.obj+".right("+move+")",speed)} 
	} 
} 

function PartiScroll(speed){ 
	if(initialised){ 
		loop=true; 
		if(speed>0)
		 {objScroller.right(speed)} 
		else 
		 {objScroller.left(speed)} 
	} 
} 

function FermaScroll(){ 
    loop=false;
} 

var initialised; 
function InitialiseScrollableArea(){ 
    objLayerPrincipale=new ConstructObject('LayerPrincipale'); 
    objContainer=new ConstructObject('LayerContenitore','LayerPrincipale'); 
    objWOL=new ConstructObject('LayerAttendi', 'LayerPrincipale'); 
    objScroller=new ConstructObject('LayerCorpo','LayerPrincipale.document.LayerContenitore'); 
    objLArrow=new ConstructObject('LayerMuoviSx','LayerPrincipale'); 
    objRArrow=new ConstructObject('LayerMuoviDx','LayerPrincipale'); 

    objScroller.MoveArea(0,0); 
    objContainer.css.visibility='visible'; 
    objScroller.css.visibility='visible'; 
    objWOL.css.visibility='hidden';
    initialised=true; 
} 
//**********************************************************************************************************
//**********************************************************************************************************
//**********************************************************************************************************
//**********************************************************************************************************
//**********************************************************************************************************

