﻿// ------------------------------------------------------------- Start of Menu Variable Setting -----------------------------------------
var mainMenuImgId = new Array();
mainMenuImgId[0]  = 'Image45';									//Home
mainMenuImgId[1]  = 'Image46';									//What's New
mainMenuImgId[2]  = 'Image47';									//About Urban Renewal
mainMenuImgId[3]  = 'Image48';									//Review Process
mainMenuImgId[4]  = 'Image49';									//Public Engagement
mainMenuImgId[5]  = 'Image26';									//Streering Committee
mainMenuImgId[6]  = 'Image27';									//Related Studies and Reports
mainMenuImgId[7]  = 'Image28';									//Publications And Related Documents
<!--mainMenuImgId[8]  = 'Image29';	-->								//Have Your Say
mainMenuImgId[8]  = 'Image30';									//Gallery
mainMenuImgId[9]  = 'Image31';									//Contact Us
mainMenuImgId[10] = 'Image32';									//Links
//mainMenuImgId[11] = 'Image32';									//Online Game

var mainMenuImgPath1 = new Array();
mainMenuImgPath1[0]  = 'images/menu/home.jpg';					//Home
mainMenuImgPath1[1]  = 'images/menu/new.jpg';					//What's New
mainMenuImgPath1[2]  = 'images/menu/about.jpg';					//About Urban Renewal
mainMenuImgPath1[3]  = 'images/menu/review.jpg';				//Review Process
mainMenuImgPath1[4]  = 'images/menu/publicEng.jpg';				//Public Engagement
mainMenuImgPath1[5]  = 'images/menu/steer.jpg';					//Streering Committee
mainMenuImgPath1[6]  = 'images/menu/related_studies.jpg';			//Related Studies and Reports
mainMenuImgPath1[7]  = 'images/menu/public.jpg';				//Publications And Related Documents
<!--mainMenuImgPath1[8]  = 'images/menu/have.jpg';	-->				//Have Your Say
mainMenuImgPath1[8]  = 'images/menu/gallery.jpg';				//Gallery
mainMenuImgPath1[9]  = 'images/menu/contact.jpg';				//Contact Us
mainMenuImgPath1[10] = 'images/menu/links.jpg';					//Links
//mainMenuImgPath1[11] = 'images/menu/online_game.jpg';			//Online Game

var mainMenuImgPath2 = new Array();
mainMenuImgPath2[0]  = 'images/menu/home_o.jpg';				//Home
mainMenuImgPath2[1]  = 'images/menu/new_o.jpg';					//What's New
mainMenuImgPath2[2]  = 'images/menu/about_o.jpg';				//About Urban Renewal
mainMenuImgPath2[3]  = 'images/menu/review_o.jpg';				//Review Process
mainMenuImgPath2[4]  = 'images/menu/publicEng_o.jpg';			//Public Engagement
mainMenuImgPath2[5]  = 'images/menu/steer_o.jpg';				//Streering Committee
mainMenuImgPath2[6]  = 'images/menu/related_studies_o.jpg';		//Related Studies and Reports
mainMenuImgPath2[7]  = 'images/menu/public_o.jpg';				//Publications And Related Documents
<!--mainMenuImgPath2[8]  = 'images/menu/have_o.jpg';	-->			//Have Your Say
mainMenuImgPath2[8]  = 'images/menu/gallery_o.jpg';				//Gallery
mainMenuImgPath2[9]  = 'images/menu/contact_o.jpg';				//Contact Us
mainMenuImgPath2[10] = 'images/menu/links_o.jpg';				//Links
//mainMenuImgPath2[11] = 'images/menu/online_game_o.jpg';			//Online Game

var mainMenuImgPath3 = new Array();
mainMenuImgPath3[0]  = 'images/menu/home_s.jpg';				//Home
mainMenuImgPath3[1]  = 'images/menu/new_s.jpg';					//What's New
mainMenuImgPath3[2]  = 'images/menu/about_s.jpg';				//About Urban Renewal
mainMenuImgPath3[3]  = 'images/menu/review_s.jpg';				//Review Process
mainMenuImgPath3[4]  = 'images/menu/publicEng_s.jpg';			//Public Engagement
mainMenuImgPath3[5]  = 'images/menu/steer_s.jpg';				//Streering Committee
mainMenuImgPath3[6]  = 'images/menu/related_studies_s.jpg';		//Related Studies and Reports
mainMenuImgPath3[7]  = 'images/menu/public_s.jpg';				//Publications And Related Documents
<!--mainMenuImgPath3[8]  = 'images/menu/have_s.jpg'; -->				//Have Your Say
mainMenuImgPath3[8]  = 'images/menu/gallery_s.jpg';				//Gallery
mainMenuImgPath3[9]  = 'images/menu/contact_s.jpg';				//Contact Us
mainMenuImgPath3[10] = 'images/menu/links_s.jpg';				//Links
//mainMenuImgPath3[11] = 'images/menu/online_game_s.jpg';			//Online Game

var mainMenuLink = new Array();
mainMenuLink[0]  = 'home.html';									//Home
mainMenuLink[1]  = 'news.do?action=list';						//What's New
mainMenuLink[2]  = 'about.html';								//About Urban Renewal
mainMenuLink[3]  = 'process.html';								//Review Process
mainMenuLink[4]  = 'public_engagement.html';					//Public Engagement
mainMenuLink[5]  = 'steering.html';								//Streering Committee
mainMenuLink[6]  = 'related_studies_reports.html';				//Related Studies and Reports 
mainMenuLink[7]  = 'publication.html';							//Publications And Related Documents
<!--mainMenuLink[8]  = 'say.html';	-->								//Have Your Say
mainMenuLink[8]  = 'gallery.html';								//Gallery
mainMenuLink[9]  = 'contact.html';								//Contact Us
mainMenuLink[10] = 'links.html';								//Links
//mainMenuLink[11] = 'online_game.html';							//Online Game

var currentMainMenuIndex = -1;
if (location.href.toString().search('home') != -1) currentMainMenuIndex = 0;
if (location.href.toString().search('ews') != -1) currentMainMenuIndex = 1;
if (location.href.toString().search('about') != -1) currentMainMenuIndex = 2;
if (location.href.toString().search('process') != -1) currentMainMenuIndex = 3;
if (location.href.toString().search('public') != -1) currentMainMenuIndex = 4;
if (location.href.toString().search('steering') != -1) currentMainMenuIndex = 5;
if (location.href.toString().search('related_studies') != -1) currentMainMenuIndex = 6;
if (location.href.toString().search('publication') != -1) currentMainMenuIndex = 7;
<!--if (location.href.toString().search('say') != -1) currentMainMenuIndex = 8;
if (location.href.toString().search('gallery') != -1) currentMainMenuIndex = 8;
if (location.href.toString().search('contact') != -1) currentMainMenuIndex = 9;
if (location.href.toString().search('links') != -1) currentMainMenuIndex = 10;
//if (location.href.toString().search('online_game') != -1) currentMainMenuIndex = 11;

var activeSubMenuId = -1;
var isShowSubMenu = false;
// ------------------------------------------------------------- End of Menu Variable Setting -----------------------------------------


function getDim(el){
	for (var lx=0,ly=0;el!=null;
		lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
	return {x:lx,y:ly}
}


//generate the left side menu
function getLeftMenu() {
	var scriptBuffer = '';
	var imgPath = '';
	var imgHeight = 25;

	scriptBuffer += '<div id="LeftMenu" name="LeftMenu">';
	for (var i in mainMenuImgId) {
		//set image source path
		if (currentMainMenuIndex == i) {
			imgPath = mainMenuImgPath3[i];
		} else {
			imgPath = mainMenuImgPath1[i];
		}

		//set image height
		if (i == 0) {
			imgHeight = 25;
		} 
		else {
			imgHeight = 25;
		}
		
		if ((i == 1) ||(i == 4) || (i == 5) || (i == 8)) {
			scriptBuffer += '<a onmouseout="leftMenuMouseOut('+i+')" onmouseover="leftMenuMouseOver('+i+')">';
		} else {
			scriptBuffer += '<a href="'+mainMenuLink[i]+'" onmouseout="leftMenuMouseOut('+i+')" onmouseover="leftMenuMouseOver('+i+')">';
		}
		scriptBuffer += '<img src="'+imgPath+'" id="'+mainMenuImgId[i]+'" name="'+mainMenuImgId[i]+'" width="154" height="'+imgHeight+'" border="0" />';
		scriptBuffer += '</a>';
	}
	scriptBuffer += '</div>';

	return scriptBuffer;
}



//generate the sub side menu
function doShowSubMenu(i){
	if ((isShowSubMenu) && (activeSubMenuId != i)) {
		var scriptBuffer = '';
		var leftOffset = 0;
		var topOffset = 0;
	
		if (i == 1) {
			scriptBuffer += '<table border="1" cellpadding="1" cellspacing="0" bordercolor="#F3E641">';
			scriptBuffer += '<tr>';
			scriptBuffer += '<td bgcolor="#F8F46C"><a href="newsEvent.do?action=list" class="submenu" onmouseout="subMenuMouseOut('+i+')" onmouseover="subMenuMouseOver('+i+')">最新消息</a></td>';
			scriptBuffer += '</tr>';
			scriptBuffer += '<tr>';
			scriptBuffer += '<td bgcolor="#F8F46C"><a href="eventNews.do?action=list" class="submenu" onmouseout="subMenuMouseOut('+i+')" onmouseover="subMenuMouseOver('+i+')">活动</a></td>';
			scriptBuffer += '</tr>';
			scriptBuffer += '</table>';
	
		}else if (i == 4) {
			scriptBuffer += '<table border="1" cellpadding="1" cellspacing="0" bordercolor="#F3E641">';
			scriptBuffer += '<tr>';
			scriptBuffer += '<td bgcolor="#F8F46C"><a href="public_envision.html" class="submenu" onmouseout="subMenuMouseOut('+i+')" onmouseover="subMenuMouseOver('+i+')">「构想」阶段</a></td>';
			scriptBuffer += '</tr>';
			scriptBuffer += '<tr>';
			scriptBuffer += '<td bgcolor="#F8F46C"><a href="public_engagement.html" class="submenu" onmouseout="subMenuMouseOut('+i+')" onmouseover="subMenuMouseOver('+i+')">「公众参与」阶段    </a></td>';
			scriptBuffer += '</tr>';
			scriptBuffer += '<tr>';
			scriptBuffer += '<td bgcolor="#F8F46C"><a href="public_consensus.html" class="submenu" onmouseout="subMenuMouseOut('+i+')" onmouseover="subMenuMouseOver('+i+')">「建立共识」阶段</a></td>';
			scriptBuffer += '</tr>';
			scriptBuffer += '</table>';
	
		} else if (i == 5) {
			scriptBuffer += '<table border="1" cellpadding="1" cellspacing="0" bordercolor="#F3E641">';
			scriptBuffer += '<tr>';
			scriptBuffer += '<td bgcolor="#F8F46C"><a href="steering_membership.html" class="submenu" onmouseout="subMenuMouseOut('+i+')" onmouseover="subMenuMouseOver('+i+')">成员</a></td>';
			scriptBuffer += '</tr>';
			scriptBuffer += '<tr>';
			scriptBuffer += '<td bgcolor="#F8F46C"><a href="steering_terms.html" class="submenu" onmouseout="subMenuMouseOut('+i+')" onmouseover="subMenuMouseOver('+i+')">职权范围    </a></td>';
			scriptBuffer += '</tr>';
			scriptBuffer += '<tr>';
			scriptBuffer += '<td bgcolor="#F8F46C"><a href="steering_meet.html" class="submenu" onmouseout="subMenuMouseOut('+i+')" onmouseover="subMenuMouseOver('+i+')">会议</a></td>';
			scriptBuffer += '</tr>';
			scriptBuffer += '</table>';
			
		} else if (i == 8) {
			scriptBuffer += '<table border="1" cellpadding="1" cellspacing="0" bordercolor="#F3E641">';
			scriptBuffer += '<tr>';
			scriptBuffer += '<td bgcolor="#F8F46C"><a href="gallery_photo.html" class="submenu" onmouseout="subMenuMouseOut('+i+')" onmouseover="subMenuMouseOver('+i+')">摄影集</a></td>';
			scriptBuffer += '</tr>';
			scriptBuffer += '<tr>';
			scriptBuffer += '<td bgcolor="#F8F46C"><a href="gallery_av.html" class="submenu" onmouseout="subMenuMouseOut('+i+')" onmouseover="subMenuMouseOver('+i+')">影音集</a></td>';
			scriptBuffer += '</tr>';
			scriptBuffer += '</table>';
		}
	
		leftOffset = getDim(document.images[mainMenuImgId[i]]).x + 156;
		topOffset = getDim(document.images[mainMenuImgId[i]]).y + 5;
		
		document.getElementById("SubMenu").innerHTML = scriptBuffer;
		document.getElementById("SubMenu").style.visibility = "visible";
		document.getElementById("SubMenu").style.left = leftOffset + "px";
		document.getElementById("SubMenu").style.top = topOffset + "px";
	}
}


//hide sub menu
function doHideSubMenu() {
	if (!isShowSubMenu) {
		document.getElementById("SubMenu").innerHTML = '';
		document.getElementById("SubMenu").style.visibility = "hidden";
		activeSubMenuId = -1;
	}
}


//
function leftMenuMouseOut(i) {
	MM_swapImgRestore();
	
	if (isShowSubMenu) {
		isShowSubMenu = false;
		setTimeout("doHideSubMenu()", 500);
	}
}


//
function leftMenuMouseOver(i) {
	//set swamp image
	if (currentMainMenuIndex == i) {
		MM_swapImage(mainMenuImgId[i], '', mainMenuImgPath3[i], 1);
	} else {
		if ((i == 1) ||(i == 4) || (i == 5) || (i == 8)) {
			//
		} else {
			MM_swapImage(mainMenuImgId[i], '', mainMenuImgPath2[i], 1);
		}
	}

	if ((i == 1) ||(i == 4) || (i == 5) || (i == 8)) {
		isShowSubMenu = true;
		doShowSubMenu(i);
		activeSubMenuId = i;
	}
}


//
function subMenuMouseOut(i) {
	if (isShowSubMenu) {
		isShowSubMenu = false;
		setTimeout("doHideSubMenu()", 500);
	}
}


//
function subMenuMouseOver(i) {
	isShowSubMenu = true;
	doShowSubMenu(i);
}

