// INIZIO PNGHACK

if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
	document.writeln('<style type="text/css">img, input.image { visibility:hidden; } </style>');
	window.attachEvent("onload", fnLoadPngs);
}

function fnLoadPngs() {
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);

	for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) {
		if (itsAllGood && img.src.match(/\.png$/i) != null) {
			fnFixPng(img);
			img.attachEvent("onpropertychange", fnPropertyChanged);
		}
		img.style.visibility = "visible";
	}

	var nl = document.getElementsByTagName("INPUT");
	for (var i = nl.length - 1, e = null; (e = nl[i]); i--) {
		if (e.className && e.className.match(/\bimage\b/i) != null) {
			if (e.src.match(/\.png$/i) != null) {
				fnFixPng(e);
				e.attachEvent("onpropertychange", fnPropertyChanged);
			}
			e.style.visibility = "visible";
		}
	}
}

function fnPropertyChanged() {
	if (window.event.propertyName == "src") {
		var el = window.event.srcElement;
		if (!el.src.match(/x\.gif$/i)) {
			el.filters.item(0).src = el.src;
			el.src = "images/struttura/spacer.gif";
		}
	}
}

function fnFixPng(img) {
	var src = img.src;
	img.style.width = img.width + "px";
	img.style.height = img.height + "px";
	img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"
	img.src = "images/struttura/spacer.gif";
}
// FINE PNGHACK

// INIZIO POPUP
PositionX = 210;
PositionY = 210;
defaultWidth  = 100;
defaultHeight = 100;
var AutoClose = true;

//don't touch
function popImage(imageURL,imageTitle){
	var imgWin = window.open('','_blank','scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
	if( !imgWin ) { return true; } //popup blockers should not cause errors
	imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
		'function resizeWinTo() {\n'+
		'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
		'var oH = document.images[0].height, oW = document.images[0].width;\n'+
		'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
		'window.doneAlready = true;\n'+ //for Safari and Opera
		'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
		'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
		'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
		'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
		'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
		'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
		'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
		'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
		'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
		'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
		'}\n'+
		'<\/script>'+
		'<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+
		(document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;">'))+
		'<img src='+imageURL+' alt="Loading image ..." title="" onload="resizeWinTo();">'+
		(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	imgWin.document.close();
	if( imgWin.focus ) { imgWin.focus(); }
	return false;
}
// FINE POPUP

function myPopUp(url, myname, wd, ht, mytop, myleft, mn, to, lo, dr, st, sc, re, pos, siz) {
var mdbPopUp;
if(siz == "full") { 
 wd = screen.width;
 ht = screen.height;
}
if(siz == "qtr") { 
 wd = screen.width/2;
 ht = screen.height/2;
}
if(siz == "half") { 
 wd = (screen.width/4)*3;
 ht = (screen.height/4)*3;
}
if(siz == "3qtr") { 
 wd= (screen.width/8)*7;
 ht = (screen.height/8)*7;
}
if(pos == "cen") { 
 myleft = ((screen.width-wd)/2);
 mytop = ((screen.height-ht)/2);
}
if(pos == "tprt") { 
 myleft = ((screen.width-wd)-10);
 mytop = 0;
}
if(pos == "tplf") { 
 myleft = 0;
 mytop = 0;
}
if(pos == "tpctr") { 
 myleft = ((screen.width-wd)/2);
 mytop = 0;
}

settings="width=" + wd + ",height=" + ht + ",top=" + mytop + ",left=" + myleft + ",menubar=" + mn + ",toolbar=" + to + ",location=" + lo + ",directories=" + dr + ",status=" + st + ",scrollbars=" + sc + ",resizable=" + re;

mdbPopUp = window.open(url, myname, settings);
mdbPopUp.focus();
}

var ie4=document.all && !document.getElementById;
if(ie4) {
    document.getElementById = new Function('var expr = /^\\w[\\w\\d]*$/, elname=arguments[0]; if(!expr.test(elname)) { return null; } else if(eval("document.all."+elname)) { return eval("document.all."+elname); } else return null;')
}

var state = 'none';
function nascondino(layer_ref) {
		livello = document.getElementById(layer_ref);
		if (livello.style.display == "block"){livello.style.display =  "none";}
		else  {livello.style.display = "block";}
}

function submitformricerca()
{
  document.formricerca.submit();
}
