function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);
var winW, winH, dimH;

function detect() {
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		winW = document.body.offsetWidth;
		winH = document.body.offsetHeight;
		die = 20;
	} else {
		winW = window.innerWidth;
		winH = window.innerHeight;
		die = 0;
	}
}

function setObj(c) {
	if(ns4) o = document.layers[c];
	else if(ie4) o = document.all[c];
	else if(ie5 || ns6) o = document.getElementById(c);
	return(o);
}

function testDiv(div) {
	detect();
	d = 50;
	objA = setObj(div);
	objAHeight = objA.offsetHeight + objA.offsetTop + die + d;
	objB = setObj("bbasso");
	objBHeight = objB.offsetHeight + objB.offsetTop + die + d;

	objT = setObj("maindiv");

	objMHeight = (Math.max(objAHeight,objBHeight));

	if(objMHeight > winH) {
		objT.style.height = objMHeight + "px";
	} else {
		objT.style.height = winH + "px";
	}
}

var popup = null;

function popimage(w,h,n){
(navigator.appName.indexOf('Microsoft')==-1) ? diff = 5 : diff = 0;
var width = w;
var height = h + diff;
prop = 'toolbar=no,location=no,directories=no,status=no,resizable,scrollbars=no,menubar=no,top=100,left=50,width=' + width + ',height=' + height;
if(popup && !popup.closed) popup.close();
popup = window.open('', '', prop);
docx = popup.document;
docx.open("text/html","replace");
docx.write("<html><head><title>A.T.L. Agenzia</title></head>");
docx.write("<body style=\"margin:0px; padding:0px; background-color:#000;\">");
docx.write("<div id=\"pics\" style=\"position:absolute; margin:0px; padding:0px;\">");
docx.write("<a href=\"#\" onclick=\"self.close();\"><img name=\"pix\" src=\"" + n + "\" alt=\"Clicca per chiudere.\" width=\"" + w + "\" height=\"" + h +"\" border=\"0\" /></a>");
docx.write("</div></body></html>");
//setTimeout("if (popup) popup.focus();",300);
docx.close();
}

var popage = null;

function popupage(w,h,p) {
(navigator.appName.indexOf('Microsoft')==-1) ? diff = 5 : diff = 0;
var width = w;
var height = h + diff;
prop = 'toolbar=no,location=no,directories=no,status=no,resizable,scrollbars=no,menubar=no,top=100,left=50,width=' + width + ',height=' + height;
if(popage && !popage.closed) popage.close();
popage = window.open(p, '', prop);
}

var popmovie = null;

function popMovie(w,h,p) {
(navigator.appName.indexOf('Microsoft')==-1) ? diff = 5 : diff = 0;
var width = w;
var height = h + diff;
prop = 'toolbar=no,location=no,directories=no,status=no,resizable,scrollbars=no,menubar=no,top=100,left=50,width=' + width + ',height=' + height;
if(popmovie && !popmovie.closed) popmovie.close();
popmovie = window.open('/media/movie.php?m='+p+'&w='+w+'&h='+h, '', prop);
}