function mostra_sottopagina(idEVSottoPagina,sottotitolo){
	new Request.HTML({method: 'get',
					url: 'getSottopagina.php?idEVSottoPagina='+idEVSottoPagina,
					update: $('content_bg'),
					async: false,
					onRequest: function() {
						$('content_bg').set('html','<img src="img/load.gif">');
					},
					onComplete: function(){
						allinea();
						$('sottotitolo').set('html',sottotitolo);
					}
	}).send();
}

function mostra_gallery(idFotoGalleria,prefix){

	if(prefix!=0)
		var url='getGallery.php?idFotoGalleria='+idFotoGalleria+'&prefix='+prefix;
	else
		var url='getGallery.php?annoFotogalleria='+idFotoGalleria;
	
	new Request.HTML({method: 'get',
					url: url,
					update: $('content_bg'),
					async: false,
					onRequest: function() {
						$('content_bg').set('html','<img src="img/load.gif">');
					},
					onComplete: function(){
						allinea();
					}
	}).send();
}

function mostra_sponsor(idEVEvento){
	new Request.HTML({method: 'get',
					url: 'getSponsor.php?idEVEvento='+idEVEvento,
					update: $('content_bg'),
					async: false,
					onRequest: function() {
						$('content_bg').set('html','<img src="img/load.gif">');
					},
					onComplete: function(){
						allinea();
						sponsor('sponsor_list','sponsor_link','#ff3131','white');
					}
	}).send();
}

function mostra_calendario(idCalendario,sottotitolo){
	var jsonRequest = new Request.JSON({
		url: 'getCalendario.php?idCalendario='+idCalendario,
		onSuccess: function(date){
			calendario.options.cEvents = date;
			calendario.gotEvents = true;
			$('loading').fade('out');
			calendario.loadCalEvents();
			allinea();
			$('sottotitolo').set('html',sottotitolo);
		}
	}).get();
}
function sponsor(classeTabella,classeTd,colorIn,colorOut){
	if($$('table.'+classeTabella)){
		var caselle = $$('td.'+classeTd);
		caselle.each( function(casella) {
			var innerHTML=casella.get('html');
			var div = casella.getElement('div');
			var img = casella.getElement('img');
			var titolo = img.getProperty('title');
			if (div!=null) var link = div.get('html');
			casella.addEvents({
				mouseenter: function(){
					this.setStyles({
							background: colorIn,
							color: 'white'
					}).set('html', titolo);
				},
				click: function(){
					if (div!=null) {
						this.setStyle('background-color',colorOut).set('html', innerHTML);
						window.open(link);
					}
				},
				mouseleave: function(){
					this.setStyle('background-color',colorOut).set('html', innerHTML);
				}
			});
		});
	}
}

function allinea(){
	if($('menu_accordion')){
		if($('menu_accordion').getStyle('height').toInt() > $('content').getStyle('height').toInt()-46){
		}else{
			$('colonnaDx_bg').setStyle('height',$('content').getStyle('height').toInt()-46);
		}
	}else{
		$('colonnaDx_bg').setStyle('height',$('content').getStyle('height').toInt()-46);
	}
}

function lista_accordion(toggler,accordion){
	var ac = new Fx.Accordion($$(toggler),$$(accordion),{
			alwaysHide: true,
			start : 'all-closed',
			height: true,
			duration: 500
		});
}

function tornaOggi(){
	calendario.calDate = new Date();
	calendario.initialize();
}