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("china", "", "China");
menu.addMenuItem("national.html", "National");
menu.addMenuItem("regional.html", "Regional");
menu.addMenuItem("taiwan_hk_macao.html", "Taiwan,HK,Macao");
menu.addMenuItem("odd_news.html", "Odd News");
menu.addMenuItem("newsmaker.html", "Newsmaker");
menu.addMenuItem("face.html", "Face to Face");
menu.addMenuItem("foreign_media.html", "Foreign Media on China");
menu.addMenuItem("http://www.chinadaily.com.cn/photo/china.html", "Photo Gallery");


menu = mainMenu.addMenu("bizchina", "", "BizChina"); 
menu.addMenuItem( "http://bizchina.chinadaily.com.cn/industry.shtml", "Industry Updates");
menu.addMenuItem( "overseas.html", "Overseas Investment");
menu.addMenuItem( "roundup.html", "Weekly Roundup");
menu.addMenuItem( "biz_who.html", "Biz Who's Who");
menu.addMenuItem( "http://bizchina.chinadaily.com.cn/event.shtml", "Biz Events");
menu.addMenuItem( "bizchina_guide.html", "Biz Guide");
menu.addMenuItem( "http://bizchina.chinadaily.com.cn/shop.shtml", "Biz Shop");
menu.addMenuItem( "http://bizchina.chinadaily.com.cn/service.shtml", "Services");
menu.addMenuItem( "http://www.chinadaily.com.cn/photo/bizchina.html", "Photo Gallery");

menu = mainMenu.addMenu("world", "", "World");
menu.addMenuItem( "asia_pacific.html", "Asia-Pacific");
menu.addMenuItem( "middle_east.html", "Middle East");
menu.addMenuItem( "europe.html", "Europe");
menu.addMenuItem( "america.html", "America");
menu.addMenuItem( "africa.html", "Africa");
menu.addMenuItem( "odd_news.html", "Odd News");
menu.addMenuItem( "newsmaker.html", "Newsmaker");
menu.addMenuItem( "special_coverage.html", "Special Coverage");
menu.addMenuItem( "health.html", "Health");
menu.addMenuItem( "http://www.chinadaily.com.cn/photo/world.html", "Photo Gallery");

menu = mainMenu.addMenu("opinion", "", "Opinion");
menu.addMenuItem( "commentary.html", "Commentary");
menu.addMenuItem( "columnists.html", "Columnists");
menu.addMenuItem( "china_watch.html", "China Watch");
menu.addMenuItem( "forum_digest.html", "Forum Digests");
menu.addMenuItem( "hot_talk.html", "Hot Talks");
menu.addMenuItem( "cartoons.html", "Cartoons");
menu.addMenuItem( "letters.html", "Letters");

menu = mainMenu.addMenu("sports", "", "Sports");
menu.addMenuItem( "china.html", "China");
menu.addMenuItem( "soccer.html", "Soccer");
menu.addMenuItem( "basketball.html", "Basketball");
menu.addMenuItem( "tennis.html", "Tennis");
menu.addMenuItem( "motor_racing.html", "Motor Racing");
menu.addMenuItem( "other_sports.html", "Other Sports");
menu.addMenuItem( "celebrity.html", "Celebrity");
menu.addMenuItem( "off_field.html", "Off the Field");
menu.addMenuItem( "newsmaker.html", "Newsmaker");
menu.addMenuItem( "feature_column.html", "Feature and Column");
menu.addMenuItem( "weekly_roundup.html", "Weekly Roundup");
menu.addMenuItem( "http://www.chinadaily.com.cn/photo/sports.html", "Photo Gallery");

menu = mainMenu.addMenu("http://www.chinadaily.com.cn/olympics/", "", "Olympics");

menu = mainMenu.addMenu("entertainment", "", "Entertainment");
menu.addMenuItem( "gossip.html", "Gossip");
menu.addMenuItem( "movie.html", "Movies");
menu.addMenuItem( "music.html", "Music");
menu.addMenuItem( "television.html", "Television");
menu.addMenuItem( "theater_arts.html", "Theater &amp; Arts");
menu.addMenuItem( "review.html", "Reviews");
menu.addMenuItem( "special_coverage.html", "Special Coverage");
menu.addMenuItem( "photo_gallery.html", "Photo Gallery");
menu.addMenuItem( "celebrities.html", "Celebrities");


menu = mainMenu.addMenu("lifestyle", "", "Lifestyle");
menu.addMenuItem( "trends.html", "Trends");
menu.addMenuItem( "fashion.html", "Fashion");
menu.addMenuItem( "health.html", "Health");
menu.addMenuItem( "foods.html", "Foods");
menu.addMenuItem( "newsmakers.html", "Newsmaker");
menu.addMenuItem( "special_coverage.html", "Special Coverage");
menu.addMenuItem( "photo_gallery.html", "Photo Gallery");
menu.addMenuItem( "http://www.chinadaily.com.cn/lifestyle/2006-03/15/content_539637.htm", "Horoscopes");

menu = mainMenu.addMenu("http://www.chinaculture.org/", "", "Culture");


menu = mainMenu.addMenu("citylife", "", "Citylife");
menu.addMenuItem( "odd_ends.html", "Odds &amp; Ends");
menu.addMenuItem( "hip_news.html", "Hip &amp; New");
menu.addMenuItem( "http://bbs.chinadaily.com.cn/index.php", "Forum");
menu.addMenuItem( "photo_gallery.html", "Photo Gallery");
menu.addMenuItem( "eating_out.html", "Eating Out");
menu.addMenuItem( "weekends_holiday.html", "Weekend &amp; Holiday");
menu.addMenuItem( "bars_cafes.html", "Bars & Cafes");
menu.addMenuItem( "shopping.html", "Shopping");
menu.addMenuItem( "what_on.html", "What's on");
menu.addMenuItem( "living_guide.html", "Living Guide");
menu.addMenuItem( "travel.html", "Travel");


menu = mainMenu.addMenu("photo", "", "Photo");
menu.addMenuItem( "china.html", "China");
menu.addMenuItem( "world.html", "World");
menu.addMenuItem( "sports.html", "Sports");
menu.addMenuItem( "entertainment.html", "Entertainment");
menu.addMenuItem( "lifestyle.html", "Lifestyle");
menu.addMenuItem( "bizchina.html", "BizChina");
menu.addMenuItem( "odd.html", "Odd");
menu.addMenuItem( "editor_pick.html", "Editor's pick");


menu = mainMenu.addMenu("http://bbs.chinadaily.com.cn/index.php", "", "Forum");

mainMenu.render();

