// attiva un suono (.wav) e dopo delay millisecondi cambia la 
// location dell'oggetto corrente. Se il parametro newlocation 
// non viene specificato, la location non viene cambiata. 
// Tale suono viene inserito nel documento HTML utilizzando: 
// <EMBED SCR=... NAME="nomeobj>
// NS4 utilizza il plugin LiveAudio mentre IEXPLORER4: utilizza
// il controllo ActiveX ActiveMovie 
// @s document.nomeobj, nomeobj=valore attributo NAME del tag EMBED
// @newlocation nuovo file htm
// @delay ritardo in millisecondi
function playclick(s,newlocation,delay)
{
var Plugin, Type;
if(ie4)
{
	if(s.issoundcardenabled())				// Check if soundcard is enabled
	{								
		if ( s.readyState >= 3 )			// Check if the ActiveMovie Control is ready
		{

			s.Stop();				// Stop any currently playing sounds
			s.Run();		  		// Play the new sound object specified by s
		}
	}
}
else 
{						// For Netscape (use LiveAudio plugin)
	Plugin = navigator.plugins["LiveAudio"];		
	Type = Plugin["audio/wav"];						
	// Check if LiveAudio is available and configured for wav
	if (Plugin["audio/wav"] && Plugin["audio/wav"].enabledPlugin == navigator.plugins["LiveAudio"] )	
	{
		if (s.IsReady())	
		{						// Check if the LiveAudio plugin is ready
			s.stop();					// Stop any currently playing sounds
			s.play(false);					// Play the new sound
		}
		else
		{
			return;
		}
	}
}
if ((newlocation)&&(delay))	
{ 
	var str="setTimeout(\"go('"+newlocation+"')\","+delay+");"
	eval(str);
}
}



// attiva un suono (.wav) e dopo delay millisecondi chiama la funzione specificata in input 
// NS4 utilizza il plugin LiveAudio mentre IEXPLORER4: utilizza
// il controllo ActiveX ActiveMovie 
// @s document.nomeobj, nomeobj=valore attributo NAME del tag EMBED
// @functionstr stringa che viene inserita come argomento della funzione setTimeout
// @delay ritardo in millisecondi
function playstrclick(s,functionstr,delay)
{
var Plugin, Type;
if(ie4)
{								// For IE (use ActiveMovie Control)
	if(s.issoundcardenabled())				// Check if soundcard is enabled
	{								
		if ( s.readyState >= 3 )			// Check if the ActiveMovie Control is ready
		{
			s.Stop();				// Stop any currently playing sounds
			s.Run();		  		// Play the new sound object specified by s
		}
	}
}
else 
{
						// For Netscape (use LiveAudio plugin)
	Plugin = navigator.plugins["LiveAudio"];		
	Type = Plugin["audio/wav"];						
	// Check if LiveAudio is available and configured for wav
	if (Plugin["audio/wav"] && Plugin["audio/wav"].enabledPlugin == navigator.plugins["LiveAudio"] )	
	{
		if (s.IsReady())	
		{						// Check if the LiveAudio plugin is ready
			s.stop();					// Stop any currently playing sounds
			s.play(false);					// Play the new sound
		}
		else
		{
			return;
		}
	}
}
setTimeout(functionstr,delay);
}


function stopallsounds(soundstr)
{
var s=eval(soundstr);
s.StopAll();
}


// cambia la proprietà location della window corrente
// @newloc nome del nuovo documento html
function go(newloc)
{
if (newloc && newloc!='')
	window.document.location.href=newloc;
}




// *** generica funzione per il movimento di un layer  ***
// @objname id del layer
// @dx incremento orizzontale
// @dy incremento verticale
function movelayerdxdy(objname,dx,dy)
{	
	if(ie4)
		var objp=eval("document.all['"+objname+"'].style");
	else
		var objp=eval("document.layers['"+objname+"']");
        var dimtmp=(ie4)? parseInt(objp.left.split("px")[0]):objp.left;
	dimtmp+=dx;
	objp.left=(ie4)? dimtmp+"px":dimtmp;
        dimtmp=(ie4)? parseInt(objp.top.split("px")[0]):objp.top;
	dimtmp+=dy;
	objp.top=(ie4)? dimtmp+"px":dimtmp;
}



// *** generica funzione per il movimento di un layer  ***
// @objname id del layer
// @dx incremento orizzontale
// @dy incremento verticale
function movelayerxy(objname,x,y)
{	
	if(ie4)
		var objp=eval("document.all['"+objname+"'].style");
	else
		var objp=eval("document.layers['"+objname+"']");
        var dimtmp=(ie4)? parseInt(objp.left.split("px")[0]):objp.left;
	dimtmp=x;
	objp.left=(ie4)? dimtmp+"px":dimtmp;
        dimtmp=(ie4)? parseInt(objp.top.split("px")[0]):objp.top;
	dimtmp=y;
	objp.top=(ie4)? dimtmp+"px":dimtmp;
}






// ritorna la proprietà di un layer
// @objname id del layer
// @propstr proprietà da analizzare
// @return il valore della proprietà richiesta
function getlayerproperty(objname,propstr)
{
	if (ie4)
	{
		var objp=eval("document.all['"+objname+"']");
		if (propstr == 'width') return objp.scrollWidth;
		else if (propstr == 'height') return objp.scrollHeight;
		else if (propstr == 'left') return objp.style.pixelLeft;
		else if (propstr == 'top') return objp.style.pixelTop;
		else if (propstr == 'visibility') return (objp.style.visibility=="visible");
		else if (propstr == 'HTML') return objp.innerHTML;
		else if (propstr == 'backgroundcolor') objp.style.backgroundColor;
		else if (propstr == 'clip') return objp.style.clip;
		else if (propstr == 'clipleft') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			return parseInt(clipv[3]);
		}
		else if (propstr == 'cliptop') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			return parseInt(clipv[0]);
		}
		else if (propstr == 'clipbottom') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			return parseInt(clipv[2]);
		}
		else if (propstr == 'clipright') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			return parseInt(clipv[1]);
		}
	}	
	else
	{
		var objp=eval("document.layers['"+objname+"']");
		if (propstr == 'width') return objp.document.width;
		else if (propstr == 'height') return objp.document.height;
		else if (propstr == 'left') return objp.left;
		else if (propstr == 'top') return objp.top;
		else if (propstr == 'visibility') return (objp.visibility=="show");
		else if (propstr == 'backgroundcolor') return objp.bgColor;
		else if (propstr == 'clipleft') return objp.clip.left;
		else if (propstr == 'cliptop') return objp.clip.top;
		else if (propstr == 'clipbottom') return objp.clip.bottom;
		else if (propstr == 'clipright') return objp.clip.right;
	}	
}




// ritorna la proprietà di un layer
// @objstr stringa da valuare per ottenere il layer
// @propstr proprietà da analizzare
// @return il valore della proprietà richiesta
function getlayerstrproperty(objstr,propstr)
{
	var objp=eval(objstr);
	if (ie4)
	{
		if (propstr == 'width') return objp.scrollWidth;
		else if (propstr == 'height') return objp.scrollHeight;
		else if (propstr == 'left') return objp.style.pixelLeft;
		else if (propstr == 'top') return objp.style.pixelTop;
		else if (propstr == 'visibility') return (objp.style.visibility=="visible");
		else if (propstr == 'HTML') return objp.innerHTML;
		else if (propstr == 'backgroundcolor') objp.style.backgroundColor;
		else if (propstr == 'clip') return objp.style.clip;
		else if (propstr == 'clipleft') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			return parseInt(clipv[3]);
		}
		else if (propstr == 'cliptop') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			return parseInt(clipv[0]);
		}
		else if (propstr == 'clipbottom') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			return parseInt(clipv[2]);
		}
		else if (propstr == 'clipright') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			return parseInt(clipv[1]);
		}
	}	
	else
	{
		if (propstr == 'width') return objp.document.width;
		else if (propstr == 'height') return objp.document.height;
		else if (propstr == 'left') return objp.left;
		else if (propstr == 'top') return objp.top;
		else if (propstr == 'visibility') return (objp.visibility=="show");
		else if (propstr == 'backgroundcolor') return objp.bgColor;
		else if (propstr == 'clipleft') return objp.clip.left;
		else if (propstr == 'cliptop') return objp.clip.top;
		else if (propstr == 'clipbottom') return objp.clip.bottom;
		else if (propstr == 'clipright') return objp.clip.right;
	}	
}



// modifica la proprietà di un layer
// @objname id del layer
// @propstr proprietà da modificare
// NOTA: nel caso in cui propstr='visibility' newvalue=valore booleano (=true,false)
function setlayerproperty(objname,propstr,newvalue)
{
	if (ie4)
	{
		var objp=eval("document.all['"+objname+"']");
		if (propstr == 'width') objp.style.width=newvalue;
		else if (propstr == 'height') objp.style.height=newvalue;
		else if (propstr == 'left') objp.style.left=newvalue+"px";
		else if (propstr == 'top') objp.style.top=newvalue+"px";
		else if (propstr == 'onmousemove') eval("objp.onmousemove="+newvalue);
		else if (propstr == 'onmouseover') eval("objp.onmouseover="+newvalue);
		else if (propstr == 'onmouseout') eval("objp.onmouseout="+newvalue);
		else if (propstr == 'visibility') 
			if (newvalue == true)
				objp.style.visibility="visible";
			else
				objp.style.visibility="hidden";
		else if (propstr == 'HTML') objp.innerHTML=newvalue;
		else if (propstr == 'backgroundcolor') objp.style.backgroundColor=newvalue;
		else if (propstr == 'clip') 
			objp.style.clip=newvalue;
		else if (propstr == 'clipright') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			tt=parseInt(clipv[0]);
			rr=parseInt(clipv[1]);
			bb=parseInt(clipv[2]);
			ll=parseInt(clipv[3]);
			objp.style.clip="rect("+tt+"px "+newvalue+"px "+bb+"px "+ll+"px)";
		}
		else if (propstr == 'clipleft') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			tt=parseInt(clipv[0]);
			rr=parseInt(clipv[1]);
			bb=parseInt(clipv[2]);
			ll=parseInt(clipv[3]);
			objp.style.clip="rect("+tt+"px "+rr+"px "+bb+"px "+newvalue+"px)";
		}
		else if (propstr == 'clipbottom') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			tt=parseInt(clipv[0]);
			rr=parseInt(clipv[1]);
			bb=parseInt(clipv[2]);
			ll=parseInt(clipv[3]);
			objp.style.clip="rect("+tt+"px "+rr+"px "+newvalue+"px "+ll+"px)";
		}
		else if (propstr == 'cliptop') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			tt=parseInt(clipv[0]);
			rr=parseInt(clipv[1]);
			bb=parseInt(clipv[2]);
			ll=parseInt(clipv[3]);
			objp.style.clip="rect("+newvalue+"px "+rr+"px "+bb+"px "+ll+"px)";
		}
		else // aggiunge una nuova proprietà 
			eval("document.all['"+objname+"']."+propstr+"="+newvalue);
	}	
	else
	{
		var objp=eval("document.layers['"+objname+"']");
		if (propstr == 'width') objp.width=newvalue;
		else if (propstr == 'height') objp.height=newvalue;
		else if (propstr == 'left') objp.left=newvalue;
		else if (propstr == 'top') objp.top=newvalue;
		else if (propstr == 'onmousemove') eval("objp.onmousemove="+newvalue);
		else if (propstr == 'onmouseover') eval("objp.onmouseover="+newvalue);
		else if (propstr == 'onmouseout') eval("objp.onmouseout="+newvalue);
		else if (propstr == 'visibility')
			if (newvalue == true)
				objp.visibility="show";
			else
				objp.visibility="hide";
		else if (propstr == 'HTML') 
		{			
			objp.document.open();
			objp.document.write(newvalue);
			objp.document.close();
		}
		else if (propstr == 'backgroundcolor') objp.bgColor=newvalue;
		else if (propstr == 'clipright') 
			objp.clip.right=newvalue;
		else if (propstr == 'clipleft') 
			objp.clip.left=newvalue;
		else if (propstr == 'clipbottom') 
			objp.clip.bottom=newvalue;
		else if (propstr == 'cliptop') 
			objp.clip.top=newvalue;
		else // aggiunge una nuova proprietà 
			eval("document.layers['"+objname+"']."+propstr+"="+newvalue);
	}	
}





// modifica la proprietà di un layer
// @objstr stringa da vlutare per ottenere un riferimento al layer
// @propstr proprietà da modificare
// NOTA: nel caso in cui propstr='visibility' newvalue=valore booleano (=true,false)
function setlayerstrproperty(objstr,propstr,newvalue)
{
	var objp=eval(objstr);
	if (ie4)
	{
		if (propstr == 'width') objp.style.width=newvalue;
		else if (propstr == 'height') objp.style.height=newvalue;
		else if (propstr == 'left') objp.style.left=newvalue+"px";
		else if (propstr == 'top') objp.style.top=newvalue+"px";
		else if (propstr == 'onmousemove') eval("objp.onmousemove="+newvalue);
		else if (propstr == 'onmouseover') eval("objp.onmouseover="+newvalue);
		else if (propstr == 'onmouseout') eval("objp.onmouseout="+newvalue);
		else if (propstr == 'visibility') 
			if (newvalue == true)
				objp.style.visibility="visible";
			else
				objp.style.visibility="hidden";
		else if (propstr == 'HTML') objp.innerHTML=newvalue;
		else if (propstr == 'backgroundcolor') objp.style.backgroundColor=newvalue;
		else if (propstr == 'clip') 
			objp.style.clip=newvalue;
		else if (propstr == 'clipright') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			tt=parseInt(clipv[0]);
			rr=parseInt(clipv[1]);
			bb=parseInt(clipv[2]);
			ll=parseInt(clipv[3]);
			objp.style.clip="rect("+tt+"px "+newvalue+"px "+bb+"px "+ll+"px)";
		}
		else if (propstr == 'clipleft') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			tt=parseInt(clipv[0]);
			rr=parseInt(clipv[1]);
			bb=parseInt(clipv[2]);
			ll=parseInt(clipv[3]);
			objp.style.clip="rect("+tt+"px "+rr+"px "+bb+"px "+newvalue+"px)";
		}
		else if (propstr == 'clipbottom') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			tt=parseInt(clipv[0]);
			rr=parseInt(clipv[1]);
			bb=parseInt(clipv[2]);
			ll=parseInt(clipv[3]);
			objp.style.clip="rect("+tt+"px "+rr+"px "+newvalue+"px "+ll+"px)";
		}
		else if (propstr == 'cliptop') 
		{
			var clipv = objp.style.clip.split("rect(")[1].split(")")[0].split("px");
			tt=parseInt(clipv[0]);
			rr=parseInt(clipv[1]);
			bb=parseInt(clipv[2]);
			ll=parseInt(clipv[3]);
			objp.style.clip="rect("+newvalue+"px "+rr+"px "+bb+"px "+ll+"px)";
		}
		else // aggiunge una nuova proprietà 
			eval(objstr+"."+propstr+"="+newvalue);
	}	
	else
	{
		if (propstr == 'width') objp.height=newvalue;
		else if (propstr == 'height') objp.width=newvalue;
		else if (propstr == 'left') objp.left=newvalue;
		else if (propstr == 'top') objp.top=newvalue;
		else if (propstr == 'onmousemove') eval("objp.onmousemove="+newvalue);
		else if (propstr == 'onmouseover') eval("objp.onmouseover="+newvalue);
		else if (propstr == 'onmouseout') eval("objp.onmouseout="+newvalue);
		else if (propstr == 'visibility')
			if (newvalue == true)
				objp.visibility="show";
			else
				objp.visibility="hide";
		else if (propstr == 'HTML') 
		{			
			objp.document.open();
			objp.document.write(newvalue);
			objp.document.close();
		}
		else if (propstr == 'backgroundcolor') objp.bgColor=newvalue;
		else if (propstr == 'clipright') 
			objp.clip.right=newvalue;
		else if (propstr == 'clipleft') 
			objp.clip.left=newvalue;
		else if (propstr == 'clipbottom') 
			objp.clip.bottom=newvalue;
		else if (propstr == 'cliptop') 
			objp.clip.top=newvalue;
		else // aggiunge una nuova proprietà 
			eval(objstr+"."+propstr+"="+newvalue);
	}	
}




// resituisce l'oggetto associato all'immagine specificata in input
// @objname nome dell'eventuale layer che contiene l'immagine ("" <-> ha come 
// contenitore window.document
// @imagename nome dell'immagine.    null <-> container.images[0]
function loadimage(objname, imagename)
{
if ((!objname)||(objname==""))
	return document.images[imagename];
if (imagename)
(ie4)?eval("var toreturn=document.images['"+imagename+"']"):eval("var toreturn=document."+objname+".document.images['"+imagename+"']");
else
(ie4)?eval("var toreturn=document.images['"+imagename+"']"):eval("var toreturn=document."+objname+".document.images[0]");
return toreturn;
}

// resituisce l'oggetto associato all'immagine specificata in input
// @objstr stringa da valutare per ottenere il layer che contiene l'immagine 
// @imagename nome dell'immagine.    null <-> container.images[0]
function loadstrimage(objstr, imagename)
{
if (imagename)
(ie4)?eval("var toreturn=document.images['"+imagename+"']"):eval("var toreturn="+objstr+".document.images['"+imagename+"']");
else
(ie4)?eval("var toreturn=document.images['"+imagename+"']"):eval("var toreturn="+objstr+".document.images[0]");
return toreturn;
}


// effetto rollover su un'immagine
// @imagename nome dell'immagine (attributo NAME del tag <IMAGE>)
// @newimageobj nome dell'oggetto image contenente la nuova immagine 
// che sostituira' la vecchia
// @divname nome dell'eventuale layer che contiene l'immagine
function rollover(imagename,newimageobj,divname)
{
var oldimageobj=loadimage(divname,imagename);
var img=eval(newimageobj);
oldimageobj.src=img.src;
}


// effetto rollover su un'immagine
// @imagename nome dell'immagine (attributo NAME del tag <IMAGE>)
// @newimageobj nome dell'oggetto image contenente la nuova immagine 
// che sostituira' la vecchia
// @divstr stringa da valutare per ottenere l'eventuale oggetto layer 
// contenente l'immagine
function rolloverstr(imagename,newimageobj,divstr)
{
var oldimageobj=loadstrimage(divstr,imagename);
var img=eval(newimageobj);
oldimageobj.src=img.src;
}


// apre una nuova istanza del browser
// @url url da caricare nel documento della nuova pagina 
// @windowname nome della nuova window, che servirà a referenziarla via Javascript
// @windowfeatures stringa di caratteristiche
// s scrollbars presenti
// ...
// esempio: smrw=123,h=1,l=0,t=0
function openwindow(url,windowname,windowfeatures)
{
var features="";
if (windowfeatures.search('s')!=-1)
	features+="scrollbars=yes,";
else
	features+="scrollbars=no,";
if (windowfeatures.search('m')!=-1)
	features+="menubar=yes,";
else
	features+="menubar=no,";
if (windowfeatures.search('r')!=-1)
	features+="resizable=yes,";
else
	features+="resizable=no,";
if (windowfeatures.search('w')!=-1)
{
	features+="width=";
	index1=windowfeatures.search('w');
	var str=windowfeatures.substr(index1+2,windowfeatures.length);
	index2=str.search(',');
	if (index2==-1)
		index2=str.length;
	var num=parseInt(windowfeatures.substr(index1+2,index2));	
	if (num!='NaN')
	{
		features+=num;
		features+=",";
	}
}
if (windowfeatures.search('h')!=-1)
{
	features+="height=";
	index1=windowfeatures.search('h');
	var str=windowfeatures.substr(index1+2,windowfeatures.length);
	index2=str.search(',');
	if (index2==-1)
		index2=str.length;
	var num=parseInt(windowfeatures.substr(index1+2,index2));	
	if (num!='NaN')
	{
		features+=num;
		features+=",";
	}
}
if (windowfeatures.search('t')!=-1)
{
	features+="top=";
	index1=windowfeatures.search('t');
	var str=windowfeatures.substr(index1+2,windowfeatures.length);
	index2=str.search(',');
	if (index2==-1)
		index2=str.length;
	var num=parseInt(windowfeatures.substr(index1+2,index2));	
	if (num!='NaN')
	{
		features+=num;
		features+=",";
	}
}
if (windowfeatures.search('l')!=-1)
{
	features+="left=";
	index1=windowfeatures.search('l');
	var str=windowfeatures.substr(index1+2,windowfeatures.length);
	index2=str.search(',');
	if (index2==-1)
		index2=str.length;
	var num=parseInt(windowfeatures.substr(index1+2,index2));	
	if (num!='NaN')
	{
		features+=num;
		features+=",";
	}
}
features=features.substr(0,features.length-1);
var toret=window.open(url,windowname,features);
//var toret=window.open(url,windowname,"scrollbars=yes,menubar=no,width=792,height=599,top=0,left=0");
return toret;
}




// effetto click su una IMAGE
// @imgname nome dell'immagine (attributo NAME del tag IMAGE)
// @imageobjon oggetto Image contenente l'immagine a pulsante cliccato
// @imageobjoff oggetto Image contenente l'immagine a pulsante non cliccato
// @delay ritardo del cambio immagine sul click (in ms)
// @divname nome dell'eventuale div contenente l'immagine
function buttonclick(imgname,imageobjon,imageobjoff,delay,divname)
{
if (!divname)
{
	eval("changeimagesrc('"+imgname+"','"+imageobjon+"')");
	setTimeout("changeimagesrc('"+imgname+"','"+imageobjoff+"')",delay);
}
else
{
	eval("changeimagesrc('"+imgname+"','"+imageobjon+"','"+divname+"')");
	setTimeout("changeimagesrc('"+imgname+"','"+imageobjoff+"','"+divname+"')",delay);
}
}

// cambia l'attributo SRC di una IMAGE 
// @imgname nome dell'immagine (attributo NAME del tag IMAGE)
// @newimageobjsrc oggetto Image contenente la nuova immagine 
// @divname  nome dell'eventuale div contenente l'immagine
function changeimagesrc(imgname,newimageobjsrc,divname)
{
if (divname)
{
	(!document.all)? eval("var obj=document.layers['"+divname+"'].document.images['"+imgname+"']"):eval("var obj=document.images['"+imgname+"']");
	var imgobj=eval(newimageobjsrc);
	eval("obj.src=imgobj.src");
}
else
	eval("document.images['"+imgname+"'].src="+newimageobjsrc+".src");
}

