// Mortgage object for Marketing Department
function MKTG_Mortgage(option, lang) {
	this.option = option;
	this.aNodes = new Array();
	if (lang == 'eng') {
		this.aMonths = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
	} else {
		this.aMonths = new Array('一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月');
		/*
		this.aMonths = new Array('1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月');
		*/
	}
}

function MKTG_MortgageNode(year, month, hyperlink) {
	this.year = parseInt(year);
	this.month = month;
	this.hyperlink = hyperlink;
}

MKTG_MortgageNode.prototype.toString = function() {
	return (this.hyperlink ? '<tr align="top"><td width="95%" background="../../image/common/dots.gif"><a href="' + escape(this.hyperlink) + '" target="_blank">' + this.month + '</a></td><td width="5%"><a href="' + escape(this.hyperlink) + '" target="_blank"><img src="../../image/common/i_view.gif" border="0"></a></td></tr><tr><td colspan="2">&nbsp;</td></tr>' + "\n": '');
}

MKTG_Mortgage.prototype.add = function(year, month, hyperlink) {
	if (parseInt(month) < 1 || parseInt(month) > 12) {
		return false;
	} else {
		this.aNodes[this.aNodes.length] = new MKTG_MortgageNode(year, this.aMonths[month - 1], hyperlink);
		return true;
	}
}

MKTG_Mortgage.prototype.toString = function() {
	if (this.aNodes.length <= 0) return '';
	var y = parseInt(this.option);
	if (isNaN(y) || y <= 0) y = this.aNodes[0].year;
	var r = '<ul>' + "\n";
	for (var i = 0; i < this.aNodes.length; i++) if (y == this.aNodes[i].year) r += this.aNodes[i].toString();
	r += '</ul>' + "\n";
	return r;
}

MKTG_Mortgage.prototype.showTitle = function() {
	if (this.aNodes.length > 0 && !this.option) this.option = this.aNodes[0].year;
	if (!this.option) return;
	document.writeln(' ' + this.option);
}

MKTG_Mortgage.prototype.showMenu = function() {
	var r = '';
	var cy = 0;
	if (this.aNodes.length > 0 && !this.option) this.option = this.aNodes[0].year;
	for (var i = 0; i < this.aNodes.length; i++) {
		if (cy != this.aNodes[i].year) {
			cy = this.aNodes[i].year;
			if (r != '') r += ' | ';
			if (cy == this.option) {
				r += '<span style="color:#8b2942;font-size:24px;font-weight:bold;">' + cy + '</span>';
			} else {
				r += '<a href="?year=' + cy + '">' + cy + '</a>';
			}
		}
	}
	document.writeln(r);
}