// restituisce vero se l'anno è bisestile
function leapYear( year )
{
	if( year % 4 == 0 )
		if( year % 100 == 0)
			if( year % 400 == 0)
				return true;
			else
				return false;
		else
			return true;
	else
		return false;
}

// restituisce il giorno massimo del mese richiesto
function dayInMonth( month, year )
{
	if( month == 2)
		if( leapYear( year ) )
			return 29;
		else
			return 28;
	else if( month == 4 || month == 6 || month == 9 || month == 11 )
		return 30;
	else
		return 31;
}

// ricostruisce la select giorni con i parametri passati
function rebuildDay( field, max, selected, abbr )
{
	var options = '<option value="-1">'+abbr+'</option>';
	for ( i = 1; i <= max; i++ )
	{
		if( selected == i )
			options += '<option value="'+ i +'" selected="selected" >'+ i +'</option>';
		else
			options += '<option value="'+ i +'">'+ i +'</option>';
	}
	field.html( options );
}

/*
 * id dei campi interessati
 * '#day' (select), '#month' (select), '#year' (select), '#day_max' (hidden)
*/



