
var $LstEv = {
	 sezione: /(^|[^-a-z])(sz-[-a-z0-9]+)/
	,sezione_on: /(^|[^-a-z])(sz-[-a-z0-9]+)-on($| |,)/
};

$(document).ready(function() {
	$('#lista-eventi li.ev')
	.mouseover(function(){
		var $this = $(this),
			sezione = $this.attr('class').match($LstEv.sezione);
		$this.addClass('ev-on');
		if (sezione) {
			$Msg.show(ev_show($this));
			sezione = sezione[2];
			if (!sezione.match($LstEv.sezione_on)) {
				$this.addClass(sezione + '-on').removeClass(sezione);
			}
		}
	}).mouseout(function(){
		var $this = $(this),
			sezione = $this.attr('class').match($LstEv.sezione_on);
		$this.removeClass('ev-on');
		$Msg.clear();
		if (sezione) {
			sezione = sezione[2];
			$this.addClass(sezione).removeClass(sezione + '-on');
		}
	}).click(function(){
		document.location = '?' + $(this).attr('ref');
	});
});

function ev_show($this) {
	var  info = $this.attr('i').split('|')
		,info_sez = info[0]
		,info_gratis = info[1]
		,info_interi = info[2]
		,info_ridotti = info[3]
		,id_evento = $this.attr('ref')
		,msg = ''
	;
	// id evento
	// msg += 'Evento n.' + id_evento + '<br />';
	
	// titolo
	// msg += '<span class="msg-titolo">' + $this.find('h1 a').last().text() + '</span>' + '<br />';
	
	// gratis
	if (info_gratis == 'y') {
		msg += '<span class="msg-gratis">GRATIS !</span><br />'; 
	}
	
	// sezione
	msg += 'Sezione: <span class="msg-sezione">';
	if (info_sez == 'c') {
		msg += 'Cinema';
	} else if (info_sez == 't') {
		msg += 'Teatro';
	} else if (info_sez == 'm') {
		msg += 'Musica';
	} else if (info_sez == 'k') {
		msg += 'Cultura';
	} else {
		msg += 'altro';
	}
	msg += '</span><br />';
	
	// prezzi "intero"
	if (info_interi.length > 0) {
		msg += 'Prezzo intero: <span class="msg-interi">' + info_interi.split("'").join(' o ') + '</span><br />';
	}
	
	// prezzi "ridotto"
	if (info_ridotti.length > 0) {
		msg += 'Prezzo ridotto: <span class="msg-ridotti">' + info_ridotti.split("'").join(' o ') + '</span><br />';
	}
	
	// fine
	return msg; // += '<br>' + info;
}



