function refreshFrame(iframeName) {
	var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
 	if ( iframeEl && iframeWin ) {		
    iframeEl.contentWindow.location.reload(true);
		  window.defaultStatus = "This is the status bar - " + iframeName + " RELOADED!";
  }
  else {
	  window.defaultStatus = "This is the status bar - " + iframeName + " not releaded";
  }
}

function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}

function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + 30 + "px";
  }
	//else {	
	//	alert('Frame not found=' + iframeName);
	//}
}

function setIframeHeightTop(iframeName) {
  var iframeWin = top.window.frames[iframeName];
  var iframeEl = top.document.getElementById? top.document.getElementById(iframeName): top.document.all? top.document.all[iframeName]: null;
 	if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + 30 + "px";
  }
	//else {	
	//	alert('Frame not found=' + iframeName);
	//}
}

function setIframeHeightPrecise(iframeName, pad) {
	var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
		//alert(docHt);
    if (docHt) iframeEl.style.height = docHt + pad + "px";
		////alert(docHt);
  }
	else {	
		alert('Frame not found=' + iframeName);
	}
}

function resizeIframe() {
	var fHeight = 0;
	var html = "";
	if (navigator.appName.toLowerCase() == "netscape") {
		fHeight = document.getElementById("content").contentDocument.height + 15;
		html = document.getElementById("content").contentDocument.body.innerHTML;
	}
	else {
		fHeight = document.frames("content").document.body.scrollHeight + 15;
		html = document.frames['content'].document.body.innerHTML;
	}
	if (fHeight <= 200) fHeight = 200;
	document.getElementById("content").style.height = fHeight;
}

function checkFrameIsSelf() {
  if (self.location.href != top.location.href) {
    top.location.href = self.location.href;
  }
}

function ShowHide(id,tag) {
    obj = document.getElementsByTagName(tag);
    if (obj[id].style.visibility == 'visible'){
    obj[id].style.visibility = 'hidden';
    }
    else {
    obj[id].style.visibility = 'visible';
    }
}

function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'none')
e.style.display = 'block';
else
e.style.display = 'none';
}

function set_visibility(id,visibility) {
var e = document.getElementById(id);
if(visibility == 'on')
e.style.display = 'block';
else
e.style.display = 'none';
}

function returnDate() {
    var this_month = new Array(12);
    this_month[0]  = "Gennaio";
    this_month[1]  = "Febbraio";
    this_month[2]  = "Marzo";
    this_month[3]  = "Aprile";
    this_month[4]  = "Maggio";
    this_month[5]  = "Giugno";
    this_month[6]  = "Luglio";
    this_month[7]  = "Agosto";
    this_month[8]  = "Settembre";
    this_month[9]  = "Ottobre";
    this_month[10] = "Novembre";
    this_month[11] = "Dicembre";

    var this_day = new Array(7);
    this_day[0]  = "Domenica";
    this_day[1]  = "Lunedi";
    this_day[2]  = "Martedi";
    this_day[3]  = "Mercoledi";
    this_day[4]  = "Giovedi";
    this_day[5]  = "Venerdi";
    this_day[6]  = "Sabato";

    var today = new Date();
    var day   = today.getDate();
    var month = today.getMonth();
    var year  = today.getYear();
    var weekday = today.getDay();
    if (year< 1900) 
      year += 1900;
    SrcStr = (this_day[weekday]+", "+day+" "+this_month[month]+", "+year);
    document.write(SrcStr);	  
}

function lastUpdated() {
	document.write(document.lastModified);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Browser Detection
isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
NS4 = (document.layers) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IE4plus = (document.all) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
IE = ((document.all)&&(navigator.appVersion.indexOf("MSIE")!=-1)) ? true : false;
ver4 = (NS4 || IE4plus) ? true : false;
NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;

// Body onload utility (supports multiple onload functions)
function chainWindowFunc( funcname, newfunc ) {
	var oldfunc = window[ funcname ];
	if( oldfunc ) {
		window[ funcname ] = function() { oldfunc(); newfunc(); };
	}
	else {
		window[ funcname ] = newfunc;
	}
}

window.addOnLoad   = function( func ) { chainWindowFunc( "onload",   func ); };
window.addOnUnload = function( func ) { chainWindowFunc( "onunload", func ); };

