// (c) 2008 mauro gallo web creations
var xmlhttp = false;


function updClock() {
	var orologio = document.getElementById("orologio");
	var datario = document.getElementById("datario");
	var orario = new Date();
	var ore = orario.getHours().toString();
	if (ore.length == 1)
		ore = "0" + ore;
	var minuti = orario.getMinutes().toString();
	if (minuti.length == 1)
		minuti = "0" + minuti;
	var giorno = orario.getDate().toString();
	if (giorno.length == 1)
		giorno = "0" + giorno;
	var mese = (orario.getMonth() + 1).toString();
	if (mese.length == 1)
		mese = "0" + mese;
	orologio.innerHTML = ore + " : " + minuti;
	datario.innerHTML = giorno + "." + mese + "." + orario.getFullYear();
	setTimeout("updClock()", 1000);
}

function initXmlHttp() {
	// inizializzazione xmlhttp
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
	}
	else {
		var msXHR = ["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp", "Microsoft.XMLHttp"];
		for (var i = 0; i < msXHR.length; i++) {
			try {
				xmlhttp = new ActiveXObject(msXHR[i]);
				break;
			} catch (e) {}
		}
	}
}

function updCounter() {
	if (xmlhttp) {
		xmlhttp.open("GET", "readCounter.php", true);
		xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				//if (xmlhttp.readyState == 4) {
					var counter = document.getElementById("counter");
					counter.innerHTML = xmlhttp.responseText + " visitatori";
				}
			}
		xmlhttp.send(null);
	}
	else {
		alert("Sorry, your browser seems to be not Ajax-Ready...");
	}
}

function liveMenu(youAreHere) {
	var menuItems = new Array();
	menuItems[0] = new Array("home", document.getElementById("home"), function () {document.getElementById("home").src = "pix/homeOvr.gif";}, function () {document.getElementById("home").src = "pix/home.gif";});
	menuItems[1] = new Array("chi", document.getElementById("chi"), function () {document.getElementById("chi").src = "pix/chiOvr.gif";}, function () {document.getElementById("chi").src = "pix/chi.gif";});
	menuItems[2] = new Array("storia", document.getElementById("storia"), function () {document.getElementById("storia").src = "pix/storiaOvr.gif";}, function () {document.getElementById("storia").src = "pix/storia.gif";});
	menuItems[3] = new Array("eventi", document.getElementById("eventi"), function () {document.getElementById("eventi").src = "pix/eventiOvr.gif";}, function () {document.getElementById("eventi").src = "pix/eventi.gif";});
	menuItems[4] = new Array("contatti", document.getElementById("contatti"), function () {document.getElementById("contatti").src = "pix/contactsOvr.gif";}, function () {document.getElementById("contatti").src = "pix/contacts.gif";});
	menuItems[5] = new Array("foto", document.getElementById("foto"), function () {document.getElementById("foto").src = "pix/picturesOvr.gif";}, function () {document.getElementById("foto").src = "pix/pictures.gif";});
	menuItems[6] = new Array("sponsor", document.getElementById("sponsor"), function () {document.getElementById("sponsor").src = "pix/sponsorOvr.gif";}, function () {document.getElementById("sponsor").src = "pix/sponsor.gif";});
	menuItems[7] = new Array("amici", document.getElementById("amici"), function () {document.getElementById("amici").src = "pix/amiciOvr.gif";}, function () {document.getElementById("amici").src = "pix/amici.gif";});
	for (var i = 0; i < menuItems.length; i++) {
		if (menuItems[i][0] != youAreHere) {
			menuItems[i][1].onmouseover = menuItems[i][2];
			menuItems[i][1].onmouseout = menuItems[i][3];
		}
	}
}