var dom=(document.getElementById)?true:false;
var ns5=((navigator.userAgent.indexOf("Gecko")>-1)&&dom)?true:false;
var ie5=((navigator.userAgent.indexOf("MSIE")>-1)&&dom)?true:false;
var ns4=(document.layers&&!dom)?true:false;
var ie4=(document.all&&!dom)?true:false;
var nodyn=(!ns5&&!ns4&&!ie4&&!ie5)?true:false;
var origWidth,origHeight;
if(ns4){
	origWidth=window.innerWidth;
	origHeight=window.innerHeight;
	window.onresize=function(){if(window.innerWidth!=origWidth||window.innerHeight!=origHeight)history.go(0);}
}
if(nodyn){event="nope"}
var theDiv,divCSS;
function initDiv(){
	if(nodyn)return;
	theDiv=(ns4)?document.imgDivb.document:(ie4)?document.all['imgDivb']:(ie5||ns5)?document.getElementById('imgDivb'):null;
	divCSS=(ns4)?document.imgDivb:theDiv.style;
	if (ie4||ie5||ns5) {
		divCSS.backgroundColor = "#ffffff";
		divCSS.borderWidth = "1px";
		divCSS.padding = "5px";
		divCSS.borderStyle = "ridge";
	}
	if(theDiv){
		if(ns4)document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove=trackMouse;
	}
}
window.onload=initDiv;
var t1,t2;
var imgOn=false;
function showImg(evt,theImg){
	if(!theDiv)return;
	if(t1)clearTimeout(t1);
	if(t2)clearTimeout(t2);
	imgOn=true;
	if(ns4){
		theDiv.write('<img src="'+theImg+'" border="1" width="454" />');
		theDiv.close();
	}else if(ie4||ie5||ns5){
		theDiv.innerHTML='<img src="'+theImg+'" border="1" width="454" />';
	}
	t1=setTimeout("divCSS.visibility='visible'",100);
}
function trackMouse(evt) {
	var mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
	var mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
	var tpWd = (ns4)? theDiv.width: (ie4||ie5)? theDiv.clientWidth: theDiv.offsetWidth;
	var tpHt = (ns4)? theDiv.height: (ie4||ie5)? theDiv.clientHeight: theDiv.offsetHeight;
	var winWd = (ns4||ns5)? window.innerWidth-20+window.pageXOffset: document.body.clientWidth+document.body.scrollLeft;
	var winHt = (ns4||ns5)? window.innerHeight-20+window.pageYOffset: document.body.clientHeight+document.body.scrollTop;
	if ((mouseX+20+tpWd)>winWd)
		divCSS.left = (ns4)? mouseX-(tpWd+20): mouseX-(tpWd+20)+"px";
	else divCSS.left = (ns4)? mouseX+20: mouseX+20+"px";
	if ((mouseY+12+tpHt)>winHt)
		divCSS.top = (ns4)? winHt-(tpHt+12): winHt-(tpHt+12)+"px";
	else divCSS.top = (ns4)? mouseY+12: mouseY+12+"px";
}
function hideImg(){
	if(!theDiv)return;
	t2=setTimeout("divCSS.visibility='hidden'",100);
	imgOn=false;
}
var popup = null;
function pop_up(pag) {
	var w = 410;
	var h = 600;
	var pw = Math.floor((screen.width - w) / 2);
	var ph = Math.floor((screen.height - h) / 2);
	
	// Crea il popup solo se non è già stato aperto
	if (!popup || popup.closed) 
	popup = window.open(pag, "help", "scrollbars=no, toolbar=no, width=" + w + ",height=" + h + ",top=" + ph + ",left=" + pw);
	
	// Attiva il popup (portalo in primo piano)
	if (popup) popup.focus();
}
