
	var gReferer = null;

	function getReferer() {
		// Es.: da http://www.dinamica-fp.it/centri/bo/default.cfm ritorna /centri/bo/default.cfm
		var winloc = window.location + '';
		return winloc.substring(25);
	}

	function getWindowHeight() {
		var windowHeight = 0;
		if (typeof(window.innerHeight) == 'number') {
			windowHeight = window.innerHeight;
		}
		else {
			if (document.documentElement && document.documentElement.clientHeight) {
				windowHeight = document.documentElement.clientHeight;
			}
			else {
				if (document.body && document.body.clientHeight) {
					windowHeight = document.body.clientHeight;
				}
			}
		}
		return windowHeight;
	}

	function setFooter() {
		var contentHeight;
		var footerElement;
		var footerHeight;
		if (document.getElementById) {
			var windowHeight = getWindowHeight();
			if (windowHeight > 0) {
				switch(gReferer){
					// Gestione utenti.
					case '/riservata/users/users.cfm':
						contentHeight = (windowHeight - $('top').offsetHeight - $('exfooter').offsetHeight - 3);
						var menuh = 30;
						$('exleftpanelist').style.height = (contentHeight - menuh) + 'px';
						$('exdetails').style.height = (contentHeight - menuh) + 'px';
						break
				}
			}
		}
	}

	// Modifica le tabelle di classe borderTable in modo che presentino le righe
	// con colore di sfondo alternato.
	function ex_alterTable() {

		// Colori.
		var evenColor = "#fff";
		var oddColor = "#eee";

		// Ottiene i riferimenti a tutte le tabelle di classe borderTable presenti nella pagina.
		var objList = $$('table.borderTable');

		// Per tutte le tabelle di classe borderTable...
		for (var t=0; t < objList.length; t++) {
			var table = objList[t];
			var even = false;
			// Le tabelle possono avere più di un elemento tbody...
			// Ottiene tutti i tbody della tabella corrente...
			var tbodies = table.getElementsByTagName("tbody");
			// ... e li traversa tutti.
			for (var h = 0; h < tbodies.length; h++) {
				// Trova tutti i tag <tr>. 
				var trs = tbodies[h].getElementsByTagName("tr");
				// ... e li traversa tutti.
				for (var i = 0; i < trs.length; i++) {
					// Evita le righe per le quali è specificato un attributo di classe
					// o di stile del colore di background.
					//if (! hasClass(trs[i]) && ! trs[i].style.backgroundColor) {
						// Imposta l'attributo vertical-align della riga.
						trs[i].style.verticalAlign = 'top';
						// Ottiene tutte le celle della riga.
						var tds = trs[i].getElementsByTagName("td");
						// e le traversa tutte.
						for (var j = 0; j < tds.length; j++) {
							var mytd = tds[j];
							// Evita le celle per le quali è specificato un attributo di classe
							// o di stile del colore di background.
							//if (! hasClass(mytd) &&	! mytd.style.backgroundColor) {
								mytd.style.backgroundColor = even ? evenColor : oddColor;
							//}
						}
					//}
					// Alterna da even a odd.
					even =  ! even;
				}
			}
		}
	}

	/* background a righe alterne per le tabelle di classe borderTable */
	function AlternateRowTable(e) {
		var evens = $$('table.AlternateRowTable tr:nth-child(odd)');
		if(evens) {
			evens.each(function(tr) {
				tr.addClassName('oddRow');
			});
		}
	}

	function showHideArea(divId) {
		if ($(divId).style.display == 'none') {
			$(divId).style.display = 'block';
		}else{
			$(divId).style.display = 'none';
		}
		return;
	}

	function OpenWindow(url) {
		window.open (url, 'MZ', 'width=500,height=350,status=no,menubar=yes,location=no,scrollbars=yes');
		return false;
	}

	Event.observe(window, 'load', function() {
		gReferer = getReferer();
		if (gReferer == '/' || gReferer == '/default.cfm') {
			RotabInit();
			RotabStart();
		}
		AlternateRowTable();
	});
