function refresh_days(y_id,m_id,d_id)
{

	var y=document.getElementById(y_id);
	var m=document.getElementById(m_id);
	var d=document.getElementById(d_id);

	if(y && m && d)
	{
		var year=parseInt(y.value);
		var month=parseInt(m.value);
		var day;
		switch (month)
		{
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:
				day=31; break;
			case 2:
				if ((year%4==0 && year%100!=0) || year%400==0)
					day=29;
				else
					day=28;
				break;
			default:
				day=30;
				break;
		}
		
		if (d.options.length>day)	//裁减掉多余日期
		{
			if(d.options.selectedIndex+1>day) d.options.selectedIndex=day-1;
			d.options.length=day;
		}
		else	//补足日期
		{
			for(var i=d.options.length+1;i<=day;i++)
			{
				d.options[d.options.length]=new Option(i,i,false,false);
			}
		}
		
	}
}

function hook_dropdate(y_id,m_id,d_id)
{
	var y=document.getElementById(y_id);
	var m=document.getElementById(m_id);
	
	y.onchange=function() {refresh_days(y_id,m_id,d_id);}
	m.onchange=function() {refresh_days(y_id,m_id,d_id);}
	
	refresh_days(y_id,m_id,d_id);

}