function datePickerUpdateDays(yearId, monthId, dayId) {
	var daysInMonth = 0;
	var daySelect = document.getElementById(dayId);
	var monthSelect = document.getElementById(monthId);
	var yearSelect = document.getElementById(yearId);
	var offset = 1;

	
	if ( daySelect.options[0].value == "" )
		offset = 1;
		
	var prevDaysInMonth = daySelect.length - offset;
	
	var d = parseInt(daySelect.options[daySelect.selectedIndex].value);
	var m = parseInt(monthSelect.options[monthSelect.selectedIndex].value);
	var y = parseInt(yearSelect.options[yearSelect.selectedIndex].value);
	
	if ( isNaN( m ) )
		m = 0;
	
	switch ( m ) {
	
		case 0:;
		case 1 :;
		case 3 :;
		case 5 :;
		case 7 :;
		case 8 :;
		case 10 :;
		case 12 :
				daysInMonth = 31;
				break;
		case 2 :
				if ( ( y % 4 == 0 ) && ( ( y % 100 != 0 ) || ( y % 400 == 0 ) ) ) 
					daysInMonth = 29;
				else
					daysInMonth = 28;
				break;
		case 4 :;
		case 6 :;
		case 9 :;
		case 11 : 
				daysInMonth = 30;
			
	}
		
	if ( daySelect.selectedIndex >= daysInMonth + offset )
		daySelect.selectedIndex = daysInMonth + offset - 1;
	
	if ( prevDaysInMonth > daysInMonth )
		daySelect.length = daysInMonth + offset;
	
	for ( var i = prevDaysInMonth + 1; i <= daysInMonth; i++ ) {
		var newOption = new Option();
		newOption.value = i;
		newOption.text = i;
		daySelect[i-1+offset] = newOption;
	}

}
