/**
 * Rebuilds the amount of days by checking out what month and year is selected
 *
 * Usage:
 *      Put the function call onchange="selectDate(dayID, monthID, yearID)" in both
 *      the month and year selects, the function will do the rest.
 *
 **/
function selectDate(day, month, year) 
{
    daySelect = $(day);
    dayValue = $(day).options[$(day).selectedIndex].value;
    monthValue = $(month).options[$(month).selectedIndex].value;
    yearValue = $(year).options[$(year).selectedIndex].value;
    dd = new Date(yearValue, monthValue, 0);
    days = dd.getDate();
    if (dayValue > days) dayValue = days;
    $(daySelect).options.length = 0;
    for (i = 1; i <= days; i++) {
        isSelected = false;
        if (i == dayValue) isSelected = true;
        $(daySelect).options[i-1] = new Option(i, i, isSelected);
    }
}