/**
 * @author ability
 */
$('document').ready(function(){
	var date = new Date();
	var year = date.getFullYear();
	var month = date.getMonth()+1;
	var day = date.getDate();
	var span = 3;
	$('#year').css('width','55px');
	$('#month').css('width','40px');
	$('#day').css('width','40px');
	
	// 年
	for(i = 0; i < span; i++){
		$("#year").append($('<option>').attr({ value: year+i }).text(year+i));
	}
	
	// 月
	for(i = 1; i < 13; i++){
		$("#month").append($('<option>').attr({ value: i }).text(i));
	}
	
	// 日
	var days = getDays(year, month);
});

$(function(){
	$('#year').change(function(){
		getDays($('#year').val(), $('#month').val());
	});
	
	$('#month').change(function(){
		getDays($('#year').val(), $('#month').val());
	});
});

function getDays(year, month){
	var days = new Date(year,month,0).getDate();
	$('#day').children().remove();
	for(i = 0; i < days; i++){
		$("#day").append($('<option>').attr({ value: i+1 }).text(i+1));
	}
}