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 += "<div align='center' style='width:970px;height:30px;padding-top:8px;border-top-style: solid;border-top-color: #FFFFFF;border-top-width:2px;background-image:url(http://www.chinadaily.com.cn/npc2008_image/bgr_nevigationbar_2.jpg);background-repeat: repeat-x;background-position: left top'>";

//alert(this.selectedPath + '++ ' + menu.path + '#' +menu.menuItemCount);
		if (this.selectedPath == menu.path && menu.menuItemCount > 0)
		{
			for (j = 0; j < menu.menuItemCount; j++)
			{
				menuItem = menu.menuItems[j];
				if (menuItem.page.indexOf("http://") < 0)
					if(this.selectedPage == menuItem.page)
						content += "<span class='nev_visited'>" + menuItem.name + "</span>";
					else
						content += "<a class='nav' href='" + this.host + "/" + menu.path + "/" + menuItem.page + "'>" + menuItem.name + "</a>";
				else
					if(this.selectedPage == menuItem.page)
						content += "<span class='nev_visited'>" + menuItem.name + "</span>";
					else
						content += "<a class='nav' href='" + menuItem.page + "'>" + menuItem.name + "</a>";
			}
		}
		content += "</div>";
	}
//	alert(content);
	//document.writeln(content);
	document.writeln(content);
}

var mainMenu = new MainMenu("http://www.chinadaily.com.cn/china");

menu = mainMenu.addMenu("2008npc", "", "Npc2008");
menu.addMenuItem("index.html", "News");
menu.addMenuItem("govt.html", "Govt Reform");
menu.addMenuItem("key.html", "Key Reports");
menu.addMenuItem("conferences.html", "Press Conferences");
menu.addMenuItem("limelight.html", "In the Limelight");
menu.addMenuItem("discussion.html", "Panel Discussion");
menu.addMenuItem("newsmaker.html", "Newsmaker");
menu.addMenuItem("editorial.html", "Editorial");
menu.addMenuItem("backgrounder.html", "Backgrounder");
menu.addMenuItem("leadership.html", "Leadership");
menu.addMenuItem("streettalks.html", "New Faces");
menu.addMenuItem("forum.html", "Forum");
menu.addMenuItem("video.html", "Video");
menu.addMenuItem("photo.html", "Photo");
mainMenu.render();
