function MainMenu(host) {
	this.host = host;
	this.menus = new Array();
	this.menuCount = 0;
}

function Menu(path, page, name) {
	this.path = path;
	this.page = page;
	this.name = name;
	this.selectedPath = null;
	this.selectedPage = null;
	this.menuItems = new Array();
	this.menuItemCount = 0;
}

function MenuItem(page, name) {
	this.page = page;
	this.name = name;
}

MainMenu.prototype.addMenu = function(path, page, name) {
	menu = new Menu(path, page, name);
	this.menus[this.menuCount] = menu;
	this.menuCount++;
	return menu;
}

Menu.prototype.addMenuItem = function(page, name) {
	menuItem = new MenuItem(page, name);
	this.menuItems[this.menuItemCount] = menuItem;
	this.menuItemCount++;
}

MainMenu.prototype.getSlectedPathAndPage = function() {
	domainValues = window.location.pathname.split("/");
	this.selectedPath = domainValues[domainValues.length - 2];
	this.selectedPage = domainValues[domainValues.length - 1];
}

MainMenu.prototype.render = function() {
	this.getSlectedPathAndPage();
	content = "";
	for (i = 0; i < this.menuCount; i++)
	{
		menu = this.menus[i];
		content += "<table border='0' cellpadding='0' cellspacing='0' >";
		if (menu.page == "" && menu.path.indexOf("http://") >= 0)
			content += "<tr><td class='navigitionleft1'><span><a href='" + menu.path + "' target='_blank' class='www' style='padding: 4px 0px 4px 5px;width:120px'>" + menu.name + "</a></span>";
		else
			content += "<tr><td class='navigitionleft1'><span><a href='" + this.host + "/" + menu.path + "/" + menu.page + "' class='www' style='padding: 4px 0px 4px 5px;width:120px'>" + menu.name + "</a></span>";
		if (this.selectedPath == menu.path) content += "<span><img src='http://www.chinadaily.com.cn/image_e/dot_cursor.gif' width='4' height='12' style='margin-bottom:4px;'></span>";
		content += "</td></tr>";
		if (this.selectedPath == menu.path && menu.menuItemCount > 0)
		{
			content += "<tr><td><table border='0' cellpadding='0' cellspacing='0'>";
			for (j = 0; j < menu.menuItemCount; j++)
			{
				menuItem = menu.menuItems[j];
				if (menuItem.page.indexOf("http://") < 0)
					content += "<tr><td class='navigitionleft2'><a href='" + this.host + "/" + menu.path + "/" + menuItem.page + "' class='chinamenu' style='width:127px;height:20px;padding: 3px 0px 3px 10px;" + (this.selectedPage == menuItem.page ? "background-color: #2E82AB" : "") + "'" + (this.selectedPage != menuItem.page ? " onmouseover=\"this.style.backgroundColor='#2E82AB'\" onmouseout=\"this.style.backgroundColor=''\"" : "") + ">" + menuItem.name + "</a></td></tr>";
				else
					content += "<tr><td class='navigitionleft2'><a href='" + menuItem.page + "' class='chinamenu' style='width:127px;height:20px;padding: 3px 0px 3px 10px;" + (this.selectedPage == menuItem.page ? "background-color: #2E82AB" : "") + "'" + (this.selectedPage != menuItem.page ? " onmouseover=\"this.style.backgroundColor='#2E82AB'\" onmouseout=\"this.style.backgroundColor=''\"" : "") + ">" + menuItem.name + "</a></td></tr>";
			}
			content += "</table></td></tr>";
		}
		content += "</table>";
	}
	document.writeln(content);
}

var mainMenu = new MainMenu("http://www.chinadaily.com.cn");


menu = mainMenu.addMenu("hqgj", "", "时政"); 
menu.addMenuItem( "zbyt.html", "周边亚太");
menu.addMenuItem( "meiou.html", "美欧");
menu.addMenuItem( "zdzy.html", "中东中亚");
menu.addMenuItem( "fzlm.html", "非洲拉美国际组织");

menu = mainMenu.addMenu("hqpl", "", "评论");
menu.addMenuItem( "bwsd.html", "本网视点");
menu.addMenuItem( "xwmh_hqpl.html", "新闻漫画");
menu.addMenuItem( "tzlj_hqpl.html", "谈政论经");
menu.addMenuItem( "jrzl_hqpl.html", "今日专栏");
menu.addMenuItem( "sxzm_hqpl.html", "思想之门");
menu.addMenuItem( "ycjr_hqpl.html", "语出惊人");
menu.addMenuItem( "gjsp.html", "国际焦点");
menu.addMenuItem( "bwzl_hqpl.html", "本网专栏");
menu.addMenuItem( "tjyd_hqpl.html", "推荐阅读");

menu = mainMenu.addMenu("hqbl", "", "博览");
menu.addMenuItem( "jchd.html", "精彩互动");
menu.addMenuItem( "tjlm_hqbl.html", "特别推荐");
menu.addMenuItem( "chuanqi.html", "传奇");
menu.addMenuItem( "renwu.html", "人物");
menu.addMenuItem( "wsfy.html", "王室");
menu.addMenuItem( "qwqs.html", "奇闻轶事");
menu.addMenuItem( "fengqing.html", "风情");
menu.addMenuItem( "xmqy.html", "星梦·奇缘");



menu = mainMenu.addMenu("hqsj", "", "视觉");
menu.addMenuItem( "hqrd_hqsj.html", "环球热点");
menu.addMenuItem( "hqfq.html", "环球风情");
menu.addMenuItem( "rwdx_hqsj.html", "人物斗秀");
menu.addMenuItem( "sjsy.html", "视觉盛宴");
menu.addMenuItem( "ssmt_hqsj.html", "时尚美图");
menu.addMenuItem( "diancang.html", "典藏");





menu = mainMenu.addMenu("hqcj", "", "财经");
menu.addMenuItem( "sdjd_hqcj.html", "深度解读");
menu.addMenuItem( "yhzg_hqcj.html", "洋化中国");
menu.addMenuItem( "tscj_hqcj.html", "图说财经");
menu.addMenuItem( "spqy_hqcj.html", "深评浅议");
menu.addMenuItem( "lc_hqcj.html", "理财投资");
menu.addMenuItem( "xf_hqcj.html", "消费生活");
menu.addMenuItem( "xqjj_hqcj.html", "新奇经济");
menu.addMenuItem( "cfrw_hqcj.html", "财富人物");
menu.addMenuItem( "cfb_hqcj.html", "财富榜");




menu = mainMenu.addMenu("hqyl", "", "娱乐");



menu = mainMenu.addMenu("hqss", "", "时尚");


menu = mainMenu.addMenu("http://cbbs.chinadaily.com.cn/", "", "论坛");


menu = mainMenu.addMenu("http://cblog.chinadaily.com.cn/", "", "博客");



mainMenu.render();

