function countdown() {
	var dataOdierna = new Date();
	var dataScadenza = new Date(2011, 9, 28, 14, 30, 00);
	var dataMancante = new Date(dataScadenza.valueOf() - dataOdierna.valueOf());

	var mesi = dataScadenza.getMonth() - dataOdierna.getMonth();
	var giorni = ((mesi * 30) - dataOdierna.getDate()-2) + '<span style="color:#999">gg </span>';
	var ore = dataMancante.getHours() + '<span style="color:#999">hh </span>';
	var minuti = dataMancante.getMinutes() + '<span style="color:#999">mm </span>';
	var secondi = dataMancante.getSeconds() + '<span style="color:#999">ss</span>';

	$(".timer").html("- " + giorni + ore + minuti + secondi);

	window.setTimeout("countdown()", 1000);
}

/****************************************************************
*   Funzioni di registrazione eventi
****************************************************************/
function getEvent(evento,id) {
	var clientWidth = $(window).width();
	var clientHeight = $(window).height();

	var sfondo = $('<div id="popUpBackGround" />');
	sfondo.height((document.documentElement.scrollHeight ? document.documentElement.scrollHeight : document.body.scrollHeight) + 'px');
	sfondo.width((document.documentElement.scrollWidth ? document.documentElement.scrollWidth : document.body.scrollWidth) + 'px');
	sfondo.appendTo(document.body);

	var registerEvent = $("#registerEvent");
	registerEvent.addClass("popUpBody");
	registerEvent.css("left", ((clientWidth / 2) - (registerEvent.width() / 2) - 10 + 'px'));
	registerEvent.css("top", ((clientHeight / 2) - (registerEvent.height() / 2) - 10 + 'px'));
	registerEvent.show();

	$("#titoloEvento").html(evento);
	$("#ct100_hfEventoNome").attr('value', evento);
	$("#ctl00_hfEventoId").attr('value', id);

	window.onresize = function () {
		sfondo.height((document.documentElement.scrollHeight ? document.documentElement.scrollHeight : document.body.scrollHeight) + 'px');
		sfondo.width((document.documentElement.scrollWidth ? document.documentElement.scrollWidth : document.body.scrollWidth) + 'px');
		var clientWidth = $(window).width();
		var clientHeight = $(window).height();
		var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
		var scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
		registerEvent.css("left", ((clientWidth / 2) - (registerEvent.width() / 2) - 10 + 'px'));
		registerEvent.css("top", ((clientHeight / 2) - (registerEvent.height() / 2) - 10 + 'px'));
	}
}

function hideEvent() {
	$('#popUpBackGround').remove();
	var registerEvent = $("#registerEvent");
	registerEvent.removeClass("popUpBody");
	registerEvent.hide();

	window.onresize = null;
}

// funzioni per l'apertura di popUp
function popUP(page){
	w = 505;
	h = 710;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+w+',height='+h+',left='+LeftPosition+', top='+TopPosition+',screenX='+LeftPosition+',screenY='+TopPosition+'';
	pg = window.open(page,'page',settings)
}
