//年
function YearActionEventConstruct() {
	this.referenceHTMLObject;
	this.parentActionEvent;
	this.startYear = 1981;
	this.endYear = 0;
	this.build = function() {
		this.referenceHTMLObject.options[0] = new Option("-----", "");
		for(var i=this.startYear;i<=this.endYear;i++) {
			this.referenceHTMLObject.options[this.referenceHTMLObject.options.length] = new Option(i, i);
		}
	}

}
function YearActionEvent(HTMLObject) {
	temp = new YearActionEventConstruct();
	HTMLObject.actionEvent = temp;
	temp.referenceHTMLObject = HTMLObject;
	return temp;
}

//月
function MonthActionEventConstruct() {
	this.item = new Array();
	this.monthMapping = new Array("","01","02","03","04","05","06","07","08","09","10","11","12");
	this.referenceHTMLObject;
	this.parentActionEvent;
	this.startMonth = 1;
	this.endMonth = 12;
	this.addActionListener = function(listener) {
		listener.parentActionEvent = this;
		this.item[this.item.length] = listener;
	}
	this.change = function() {
		for(var i=0;i<this.item.length;i++) {
			this.item[i].notify();
		}
	}
	this.build = function() {
		this.referenceHTMLObject.options[0] = new Option("-----", "");
		for(var i=this.startMonth;i<=this.endMonth;i++) {
			this.referenceHTMLObject.options[this.referenceHTMLObject.options.length] = new Option(this.monthMapping[i], this.monthMapping[i]);
		}
	}

}
function MonthActionEvent(HTMLObject) {
	temp = new MonthActionEventConstruct();
	HTMLObject.actionEvent = temp;
	temp.referenceHTMLObject = HTMLObject;
	return temp;
}

//日
function DayActionEventConstruct() {
	this.item = new Array();
	//查詢是屬於範圍這邊可以不管閏年
	this.maxDay = new Array(0,31,29,31,30,31,30,31,31,30,31,30,31);
	this.referenceHTMLObject;
	this.parentActionEvent;
	this.notify = function() {
		parentHTMLObject = this.parentActionEvent.referenceHTMLObject;
		//取得點選的索引
		var tempIndex = parseInt(parentHTMLObject.options[parentHTMLObject.selectedIndex].value, 10);
		if(tempIndex == 0) return;
		this.referenceHTMLObject.options.length = 0;
		this.referenceHTMLObject.options[0] = new Option("-----", "");
		for(var i=1;i<=this.maxDay[tempIndex];i++) {
			this.referenceHTMLObject.options[this.referenceHTMLObject.options.length] = new Option((i<10?"0":"")+i, (i<10?"0":"")+i);
		}
	}

}
function DayActionEvent(HTMLObject) {
	temp = new DayActionEventConstruct();
	HTMLObject.actionEvent = temp;
	temp.referenceHTMLObject = HTMLObject;
	return temp;
}