var viewall = false;
var currYear = -1;
// now at the begin of the day
var now = new Date();
now.setHours(0);
now.setMinutes(0);
now.setSeconds(0);
now.setMilliseconds(0);

var maxLiveNbr = -1;
var counter = 0;

var Month = new Array();
Month[0] = "Gen";
Month[1] = "Feb";
Month[2] = "Mar";
Month[3] = "Apr";
Month[4] = "Mag";
Month[5] = "Giu";
Month[6] = "Lug";
Month[7] = "Ago";
Month[8] = "Set";
Month[9] = "Ott";
Month[10] = "Nov";
Month[11] = "Dic";

var WeekDay = new Array();
WeekDay[0] = "Dom";
WeekDay[1] = "Lun";
WeekDay[2] = "Mar";
WeekDay[3] = "Mer";
WeekDay[4] = "Gio";
WeekDay[5] = "Ven";
WeekDay[6] = "Sab";

function isFuture(date) { return (date.getTime() >= now.getTime()); }

function addYear(year) {
	document.write("<tr>");
	document.write("<td class='LiveYear' colspan='4'>");
	document.write(year);
	document.write("</td");
	document.write("</tr>");
}

function addLive(date, where, text, text2) {
	if (maxLiveNbr != -1) {
		if (counter >= maxLiveNbr) return;
	}

	day = date.getDate();
	if (day < 10) day = "0" + day;
	month = date.getMonth();
	weekday = date.getDay();
	year = date.getFullYear();

	future = isFuture(date);

	if (! viewall)
		if ( future) return;

	counter++;
	document.write("<tr>");
	document.write("<td width='100'>");
	document.write("<b>");
		document.write(day);
	document.write(" ");
		document.write(Month[month]);
	document.write(" ");
			document.write(year);
	document.write("</b>");
	document.write("</td>");
	document.write("<td>");
		document.write(where);
	document.write("</td>");
	document.write("<td>");
		document.write(text);
		document.write("<br>");
		document.write(text2);
	document.write("</td>");
	document.write("</tr>");

	document.write("<tr>");
	document.write("<td colspan='4'><br></td>");
	document.write("</tr>");
}
