/* Funzione per ricavare l'URL della pagina corrente */
function baseUrlCalendario(modulo, azione){
	var base_url = window.location.pathname;
	
	base_url = base_url.split('/');
	var new_base_url = '';
	for(var i = 0; i < (base_url.length); i++){
		new_base_url += base_url[i] + '/';
		if( ( base_url[i] == 'frontend_dev.php' ) || ( base_url[i] == 'frontend.php' ) ||
			( base_url[i] == 'backend_dev.php' ) || ( base_url[i] == 'backend.php' ) || 
			( base_url[i] == 'shop_dev.php' ) ) break;	//mi fermo sempre quando trovo frontend_dev.php
														//oppure backend_dev.php
														//oppure shop_dev.php
	}
	
	new_base_url = window.location.protocol + '//' + window.location.host + new_base_url + modulo + '/' + azione;
	return new_base_url;
}

/**
 *	
 */
function getEventiPerData( data )
{	
	var urlDest = baseUrlCalendario( 'calendario', 'getEventiPerData' );
	$('#lista_eventi #loading_events').show();
	$.ajax({
		type: 'POST',
		url: urlDest,
		data: 'data='+data,
		success: function( msg ){
			$('#lista_eventi').html( msg );
			$('#lista_eventi #loading_events').hide();	//nascondo il loading
		}
	});
	
}
/**
 * Metto lo 0 davanti al numero se è minore di 10, serve per i confronti
 */
function normalizzaNumero( numero ){
	if( eval(numero) < 10 ){
		return '0' + numero;
	} else {
		return numero;
	}
}



function showDialogAvvisi( )
{
	$( '#finestrina' ).dialog({
		autoOpen: true,
		modal: true,
		width: 500,
		/*height:300,*/
		/*title: 'Avvisi per il giorno ' + giorno,*/
		/*buttons: { 
			"Chiudi": function() { 
				$(this).dialog("close");
				$(this).html(''); // svuoto il div
				$(this).remove(); // elimino completamente il div
				setTimeout('', 500); // attesa per IE
			} 
		}*/
		close: function(event, ui) { 
			$(this).html(''); // svuoto il div
			$(this).remove(); // elimino completamente il div
			setTimeout('', 500); // attesa per IE
		}
	});
}
