function showMenuObj(){
	var menuObjID;

	if(Selected_ID==1)
		menuObjID=1;
	else if(Selected_ID==2)
		menuObjID=2;
	else if(Selected_ID==3)
		menuObjID=3;
	else if(Selected_ID==4)
		menuObjID=4;
	else if(Selected_ID==14)
		menuObjID=5;	
	else if(Selected_ID==5)
		menuObjID=6;
	else if(Selected_ID==15)
		menuObjID=7;
	else if(Selected_ID==16)
		menuObjID=8;
	else if(Selected_ID==17)
		menuObjID=9;
	else if(Selected_ID==6)
		menuObjID=10;
	else if(Selected_ID==7)
		menuObjID=11;
	else if(Selected_ID==8)
		menuObjID=12;
	else if(Selected_ID==9)
		menuObjID=13;
	else if(Selected_ID==10)
		menuObjID=14;
	else if(Selected_ID==11)
		menuObjID=15;
	else if(Selected_ID==12)
		menuObjID=16;
	else if(Selected_ID==13)
		menuObjID=17;

	return menuObjID;
}

//function for check current Path
function getLocationPath(){
	var locPath=location.href.toString();
	var subPath='';

	if(location.href.toString().search('test2.westcomzivo.com/devbh')!=-1){
		if(location.href.toString().search('/gb/')!=-1)
		{
			subPath="ht"+"tp://common.westcomzivo.com/gb/test2.westcomzivo.com/devbh"
		}
		else
		{
			subPath="ht"+"tp://test2.westcomzivo.com/devbh"
		}
		HomePath="test2.westcomzivo.com/devbh"
	}
	
	else if(location.href.toString().search('wwwt.heritage.gov.hk')!=-1){
		if(location.href.toString().search('/gb/')!=-1)
		{
			subPath="ht"+"tp://210.184.14.62/gb/wwwt.heritage.gov.hk"
		}
		else
		{
			subPath="ht"+"tp://wwwt.heritage.gov.hk"
		}
		HomePath="wwwt.heritage.gov.hk"
	}
	
	else{
		if(location.href.toString().search('/gb/')!=-1)
		{
			subPath="ht"+"tp://210.184.14.62/gb/www.heritage.gov.hk"
		}
		else
		{
			subPath="ht"+"tp://www.heritage.gov.hk"
		}
		HomePath="www.heritage.gov.hk"
	}

	if(subPath==''){
		var lastSlash=location.href.toString().lastIndexOf('/');
		subPath=location.href.toString().substring(0, lastSlash);
	}

	locationPath=subPath;

	//for Search Template
/*	if(location.href.toString().search('westcomzivo')!=-1){
		locationPath=prodURL;
	}*/
}

//function for Draw Print Button
function genPrintButton(){

	if(langID==1){ var altText='Print'; }else{ var altText='列印'; }

	document.writeln('<p><table border=0 cellspacing=0 cellpadding=0 width=100%>');
//	document.writeln('<tr valign=top><td align=right><a href="javascript:PrintDocument();"><img src="'+imagePath+'images/but_print.gif" border=0 align=top alt="'+altText+'"></a></td></tr>');
	if(!isText){
		document.writeln('<tr valign=top><td align=right><a href="javascript:PrintDocument();"><img src="'+imagePath+'images/but_print.gif" border=0 align=top alt="'+altText+'"></a></td></tr>');
	}else{
		document.writeln('<tr valign=top><td align=right><a href="javascript:PrintDocument();">'+altText+'</a></td></tr>');
	}
	document.writeln('');
	document.writeln('</table>');
}

//function for Print Function
function PrintDocument(){
	window.open(document.URL,'PrintPage','top=10,left=10,height=500,width=650,scrollbars=1');
}

//function for mouse over effect on left menu
function overTopMenu(obj)
{
      if (document.images){
		eval("document.images." + obj + ".src = '"+imagePath+"images/" + obj + "_f2.gif'");
      }
}

//function for mouse out effect on left menu
function outTopMenu(obj)
{
      if (document.images){
		eval("document.images." + obj + ".src = '"+imagePath+"images/" + obj + ".gif'");
      }
}

//function for switching image
function simg(obj,src)
{
      if (document.images){
              obj.src = src;
      }
}

function getAcrobat(){
	var linkUrl='<a class="Link" href="http://www.adobe.com/products/acrobat/acrrwhatsnew.html" target="_blank">';
	var StrText='Please download the'+linkUrl+' Acrobat Reader</a><br>and <a class="Link" href="http://www.adobe.com/products/acrobat/cjkfontpack.html" target="_blank">Asian Font Packs</a> to view the documents.';
	if(langID==2){
		linkUrl='<a class="Link" href="http://www.chinese-t.adobe.com/products/acrobat/readstep2.html" target="_blank">';
		StrText='如想觀看以上文件，請下載'+linkUrl+'Acrobat Reader</a> 。';
	}
	var StrImg='<img src="'+locationPath+'/images/acrobat.gif" border=0 align=top alt="Acrobat Reader">';
		
	document.writeln('<p><table border=0 cellspacing=0 cellpadding=2 width=565><tr valign=top>');
	if(!isText)
		document.writeln('<td width=1%>'+linkUrl+StrImg+'</a></td>');
	document.writeln('<td class="maincontent" width=99%>'+StrText+'</td>');
	document.writeln('</tr></table>');
}

function getRealPlayer(){
	var StrText='You can use RealPlayer to view the videos in Real Media format. RealPlayer is available free at <a class="text_link" href="javascript:externalLink(\'http://www.real.com/\');">www.real.com</a>.';
	if(langID==2) StrText='以上短片須使用RealPlayer觀看, 此軟件可於<a class="text_link" href="javascript:externalLink(\'http://www.real.com/\');">www.real.com</a>免費下載:';
	var StrImg='<img src="'+locationPath+'/images/realplayer.gif" border=0 align=top alt="RealPlayer">';
		
	document.writeln('<p><table border=0 cellspacing=0 cellpadding=2 width=565><tr valign=top>');
	if(!isText)
		document.writeln('<td width=1%><a href="javascript:externalLink(\'http://www.real.com/\');">'+StrImg+'</a></td>');
	document.writeln('<td width=99%>'+StrText+'</td>');
	document.writeln('</tr></table>');
}

function addMenu(sectionID, caption, chi_caption,url,offPic,overPic,onPic,hasChild,sitemap,navigationMenu)
{
	menuObj[x] = new Object();
	menuObj[x].id = sectionID;
	menuObj[x].caption = caption;
	menuObj[x].chiCaption = chi_caption;
	if(url.search('http://')!=-1){
		menuObj[x].url = url;
		menuObj[x].popup = ' target="_blank"'
	}else{
		menuObj[x].url = locationPath+langPath+url;
		menuObj[x].popup = ''
	}
	menuObj[x].onPic = imagePath + "images/menu/" + onPic;
	menuObj[x].offPic = imagePath + "images/menu/" + offPic;
	menuObj[x].overPic = imagePath + "images/menu/" + overPic;
	menuObj[x].offPicIndex = imagePath + "images/index/index_" + offPic;
	menuObj[x].overPicIndex = imagePath + "images/index/index_" + overPic;
	menuObj[x].hasChild = hasChild;
	menuObj[x].sitemap = sitemap;
	menuObj[x].navigationMenu = navigationMenu;
	x++;
}

function addSubMenu(menuID, subSectionID, caption, chi_caption,url,sitemap,navigationMenu)
{
	subMenuObj[y] = new Object();
	subMenuObj[y].id = subSectionID;
	subMenuObj[y].menuID = menuID;
	subMenuObj[y].caption = caption;
	subMenuObj[y].chiCaption = chi_caption;
	if(url.search('http://')!=-1){
		subMenuObj[y].url = url;
		subMenuObj[y].popup = ' target="_blank"'
	}else if(url.search('.pdf')!=-1){
		subMenuObj[y].url = url;
		subMenuObj[y].popup = ' target="_blank"'
	}else if(url.search('javascript:')!=-1){
		subMenuObj[y].url = url;
		subMenuObj[y].popup = ''
	}else{
		subMenuObj[y].url = locationPath+langPath+url;
		subMenuObj[y].popup = ''
	}
	subMenuObj[y].sitemap = sitemap;
	subMenuObj[y].navigationMenu = navigationMenu;
	y++;
}

function addHomeIcon(ID, caption, chi_caption, url, chi_url, Pic)
{
	HomeIconObj[z] = new Object();
	HomeIconObj[z].id = ID;
	HomeIconObj[z].caption = caption;
	HomeIconObj[z].chiCaption = chi_caption;
	if(url.search('javascript:')!=-1){
		HomeIconObj[z].url = url;
		HomeIconObj[z].popup = ''
	}else{
		HomeIconObj[z].url = url;
		HomeIconObj[z].popup = ' target="_blank"'
	}
	HomeIconObj[z].chi_url = chi_url;
	HomeIconObj[z].pic = Pic;
	z++;
}

function getheaderHTML(){
	var topMenuBG;
	var gicSearchForm;
	
	gicSearchForm='<form name="frmSearch" action="'+arClfTopMenu[langID][1]+'" method="get" onsubmit="if( document.frmSearch.query.value.length == 0 ) {alert(\''+arClfTopMenu[langID][28]+'\');}  else { document.frmSearch.submit();} return false;">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="exact_q" type="hidden" value="">';
	gicSearchForm=gicSearchForm+'<INPUT name="any_q" type="hidden" value="">';
	gicSearchForm=gicSearchForm+'<INPUT name="none_q" type="hidden" value="">';
	gicSearchForm=gicSearchForm+'<INPUT name="gp0" type="hidden" value="heritage_home">';
	gicSearchForm=gicSearchForm+'<INPUT name="gp1" type="hidden" value="heritage_home">';
	gicSearchForm=gicSearchForm+'<INPUT name="p_size" type="hidden" value="10">';
	gicSearchForm=gicSearchForm+'<INPUT name="doc_type" type="hidden" value="all">';
	gicSearchForm=gicSearchForm+'<INPUT name="last_mod" type="hidden" value="#-1">';
	gicSearchForm=gicSearchForm+'<INPUT name="ui_lang" type="hidden" value="'+arClfTopMenu[langID][26]+'">';
	gicSearchForm=gicSearchForm+'<INPUT name="r_lang" type="hidden" value="all">';
	gicSearchForm=gicSearchForm+'<INPUT name="ui_charset" type="hidden" value="'+arClfTopMenu[langID][27]+'">';
	gicSearchForm=gicSearchForm+'<INPUT name="tpl_id" type="hidden" value="heritage">';
	gicSearchForm=gicSearchForm+'<INPUT name="a_submit" type="hidden" value="false">';
	gicSearchForm=gicSearchForm+'<INPUT name="web" type="hidden" value="this">';
	if(location.href.toString().search('/text/')!=-1){
		gicSearchForm=gicSearchForm+'<INPUT name="txtonly" type="hidden" value="1">';
	}
	else
	{
		gicSearchForm=gicSearchForm+'<INPUT name="txtonly" type="hidden" value="0">';
	}
	
	if(Selected_ID == 1)
		if(Selected_Sub == 1)
			topMenuBG = "top_pic_01";
		else
			topMenuBG = "top_pic_03";
	else if(Selected_ID == 6 || Selected_ID == 7 || Selected_ID == 9 || Selected_ID == 10 || Selected_ID == 11 || Selected_ID == 12 || Selected_ID == 13)
		topMenuBG = "top_pic_02";
	else if(Selected_ID == 2 || Selected_ID == 4 || Selected_ID == 5 || Selected_ID == 16 || Selected_ID == 17)
		topMenuBG = "top_pic_03";
	else if(Selected_ID == 3 || Selected_ID == 8 || Selected_ID == 14 || Selected_ID == 15)
		topMenuBG = "top_pic_04";
		
	if(Selected_ID>=10){
		var bg=Selected_ID;
	}else{
		var bg="0"+Selected_ID;
	}
	if(!isText){
		document.writeln('<table width="1003" border="0" cellpadding="0" cellspacing="0">');
		document.writeln('<tr>');
		document.writeln('	<td>');
		document.writeln('		<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('		<tr>');
		document.writeln('			<td background="'+imagePath+'images/top_bg.jpg">');
		document.writeln('				<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('				<tr>');
		document.writeln('					<td><a href="'+locationPath+langPath+'index.htm"><img src="'+imagePath+'images/logo.jpg" border="0"></a></td>');
		document.writeln('					<td align="right">');
		document.writeln('						<table border="0" cellspacing="0" cellpadding="0">');
		document.writeln(gicSearchForm);
		document.writeln('						<tr>');
		document.writeln('							<td><a href="'+locationPath+langPath+'contact/index.htm" onmouseover="MM_swapImage(\'btn_contact1\',\'\',\''+imagePath+'images/btn_contactus_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="'+imagePath+'images/btn_contactus.gif" name="btn_contact1" id="btn_contact1" border="0" alt="'+arClfTopMenu[langID][19]+'"></a></td>');
		document.writeln('							<td><a href="'+locationPath+langPath+'sitemap/index.htm" onmouseover="MM_swapImage(\'btn_site1\',\'\',\''+imagePath+'images/btn_sitemap_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="'+imagePath+'images/btn_sitemap.gif" name="btn_site1" id="btn_site1" border="0" alt="'+arClfTopMenu[langID][18]+'"></a></td>');
		document.writeln('							<td><img src="'+imagePath+'images/btn_top_spacer.gif" width="11" height="40"></td>');
		//document.writeln('							<td><img src="'+imagePath+'images/btn_search_blank.gif" border="0" width="60" height="40"></td>');
		//document.writeln('							<td><a href="#" onmouseover="MM_swapImage(\'btn_search1\',\'\',\''+imagePath+'images/btn_search_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="'+imagePath+'images/btn_search.gif" name="btn_search1" id="btn_search1" border="0" alt="'+arClfTopMenu[langID][17]+'"></a></td>');
		document.writeln('							<td><input type="text" name="query" size="'+arClfTopMenu[langID][4]+'" class="search"></td>');
		document.writeln('							<td><a href="#" onclick="if (document.frmSearch.query.value.length == 0 ) {alert(\''+arClfTopMenu[langID][28]+'\');}  else { document.frmSearch.submit(); }; return false" onmouseover="MM_swapImage(\'btn_search_pic\',\'\',\''+imagePath+'images/btn_search_pic_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="'+imagePath+'images/btn_search_pic.gif" name="btn_search_pic" id="btn_search_pic" border="0" alt="'+arClfTopMenu[langID][17]+'"></a></td>');
//		document.writeln('							<td><img src="'+imagePath+'images/btn_top_spacer.gif" width="11" height="40"></td>');
		document.writeln('							<td><a href="javascript:changeLanguage(\''+arClfTopMenu[langID][12]+'\')" onmouseover="MM_swapImage(\''+arClfTopMenu[langID][24]+'1\',\'\',\''+imagePath+'images/'+arClfTopMenu[langID][24]+'_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="'+imagePath+'images/'+arClfTopMenu[langID][24]+'.gif" name="'+arClfTopMenu[langID][24]+'1" border="0" alt="'+arClfTopMenu[langID][13]+'"></a></td>');
		document.writeln('							<td><a href="javascript:changeLanguage(\''+arClfTopMenu[langID][15]+'\')" onmouseover="MM_swapImage(\''+arClfTopMenu[langID][25]+'1\',\'\',\''+imagePath+'images/'+arClfTopMenu[langID][25]+'_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="'+imagePath+'images/'+arClfTopMenu[langID][25]+'.gif" name="'+arClfTopMenu[langID][25]+'1" border="0" alt="'+arClfTopMenu[langID][16]+'"></a></td>');
		document.writeln('						</tr>');
		document.writeln('						<tr>');
		document.writeln('							<td colspan="7" align="right"><img src="'+imagePath+'images/'+topMenuBG+'a.gif" border="0"></td>');
		document.writeln('						</tr>');
		document.writeln('</form>');
		document.writeln('						</table>');
		document.writeln('					</td>');
		document.writeln('				</tr>');
		document.writeln('				</table>');
		document.writeln('			</td>');
		document.writeln('		</tr>');
		document.writeln('		<tr>');
		document.writeln('			<td>');
		getTopMenu();
		document.writeln('			</td>');
		document.writeln('		</tr>');
		document.writeln('		</table>');
		document.writeln('	</td>');
		document.writeln('</tr>');
		document.writeln('<tr>');
		document.writeln('	<td>');
		document.writeln('		<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('		<tr>');
		document.writeln('	        <td width="180" valign="top"><img src="'+imagePath+'images/spacer.gif" width="180" height="50"><br>');
		getLeftMenu();
		document.writeln('			</td>');
		document.writeln('			<td valign="top">');
		document.writeln('				<table width="100" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('				<tr>');
		getTopic();
		//document.writeln('					<td><img src="'+imagePath+'images/hd_06_01.gif" width="823" height="70" /></td>');
		document.writeln('				</tr>');
		document.writeln('				<tr>');
		document.writeln('					<td>');
		document.writeln('						<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('						<tr>');
		document.writeln('							<td width="10"><img src="'+imagePath+'images/spacer.gif" width="10" height="10" /></td>');
		document.writeln('							<td><br>');
	}else{
		document.writeln('<table border=0 cellspacing=0 cellpadding=0>');
		if(printPage!=1){ getTopMenu();	}
		document.writeln('<tr valign=top>');
		if(printPage!=1){ getLeftMenu(); }
		document.writeln('</tr>');
		document.writeln('<tr valign=top>');
		document.writeln('	<td>');
		getTopic();
		document.writeln('	</td>');
		document.writeln('</tr>');
		document.writeln('<tr valign=top>');
		document.writeln('	<td>');
	}
}

function getfooterHTML(){
	if(!isText){
		document.writeln('							</td>');
		if(Selected_ID == 1 && Selected_Sub == 1)
		{
			document.writeln('							<td width="162" align="right" valign="top"><img src="'+imagePath+'images/top_pic_01c.gif"></td>');
		}
/*		else
		{
			document.writeln('							<td width="10"><img src="'+imagePath+'images/spacer.gif" width="10" height="10"></td>');
		}*/
		document.writeln('						</tr>');
		document.writeln('						</table>');
		document.writeln('					</td>');
		document.writeln('				</tr>');
//space
		document.writeln('				<tr>');
		document.writeln('					<td>&nbsp;</td>');
		document.writeln('				</tr>');
//space
		document.writeln('				<tr>');
		document.writeln('					<td>');
		getFooter();
		document.writeln('					</td>');
		document.writeln('				</tr>');
		document.writeln('				</table>');
		document.writeln('			</td>');
		document.writeln('		</tr>');
		document.writeln('		</table>');
		document.writeln('	</td>');
		document.writeln('</tr>');
		document.writeln('</table>');
	}else{
		document.writeln('	</td>');
		document.writeln('</tr>');
		if(Selected_ID==1){
			getHomeIcon();
		}
		document.writeln('<tr valign=top>');
		document.writeln('	<td>');
		getFooter();
		document.writeln('	</td>');
		document.writeln('</tr>');
		document.writeln('</table>');
	}
}

function getHomeIcon(){
	var rows=0;

	document.writeln('<tr valign=top>');
	document.writeln('	<td>');
	document.writeln('		<!-- Home Icon Area -->');
	document.writeln('		<p>');
	document.writeln('		<table border=0 cellspacing=2 cellpadding=2 align=center>');
	document.writeln('		<tr valign=top>');
	if(!isText){
		for(var i=1;i<z;i++){
			if(langID==1){
				document.writeln('			<td align=center><a href="'+HomeIconObj[i].url+'"'+HomeIconObj[i].popup+'><img src="'+imagePath+'images/icon/'+HomeIconObj[i].pic+'" border=0 align=top alt="'+HomeIconObj[i].caption+'"></a></td>');
			}else{
				document.writeln('			<td align=center><a href="'+HomeIconObj[i].chi_url+'"'+HomeIconObj[i].popup+'><img src="'+imagePath+'images/icon/'+HomeIconObj[i].pic+'" border=0 align=top alt="'+HomeIconObj[i].chiCaption+'"></a></td>');
			}
			rows++;
			if(rows>=6){
				document.writeln('		</tr>');
				document.writeln('		<tr valign=top>');
				rows=0;
			}
		}
	}else{
		for(var i=1;i<z;i++){
			if(langID==1){
				document.writeln('			<td><a href="'+HomeIconObj[i].url+'" target="_blank">'+HomeIconObj[i].caption+'</a></td>');
			}else{
				document.writeln('			<td><a href="'+HomeIconObj[i].chi_url+'" target="_blank">'+HomeIconObj[i].chiCaption+'</a></td>');
			}
			rows++;
			if(rows>=6){
				document.writeln('		</tr>');
				document.writeln('		<tr valign=top>');
				rows=0;
			}
		}
	}
	document.writeln('		</tr>');
	document.writeln('		</table>');
	document.writeln('		<!-- Home Icon Area -->		');
	document.writeln('	</td>');
	document.writeln('</tr>');
}

//function for generating the top menu
function getTopMenu(){
	var topMenuBG;
	var rows=0;
	var rows2=0;
	var rowsNumber;
	
	if(langID==1 && Selected_ID==5)
		rowsNumber = 5;
	if(langID==1 && Selected_ID==6)
		rowsNumber = 4;
	if(langID==1 && Selected_ID==17)
		rowsNumber = 2;
	if(langID==1 && Selected_ID==4)
		rowsNumber = 3;
	if(langID==2 && Selected_ID==5)
		rowsNumber = 6;

	if(Selected_ID == 1)
		if(Selected_Sub == 1)
			topMenuBG = "top_pic_01";
		else
			topMenuBG = "top_pic_03";
	else if(Selected_ID == 6 || Selected_ID == 7 || Selected_ID == 9 || Selected_ID == 10 || Selected_ID == 11 || Selected_ID == 12 || Selected_ID == 13)
		topMenuBG = "top_pic_02";
	else if(Selected_ID == 2 || Selected_ID == 4 || Selected_ID == 5 || Selected_ID == 16 || Selected_ID == 17)
		topMenuBG = "top_pic_03";
	else if(Selected_ID == 3 || Selected_ID == 8 || Selected_ID == 14 || Selected_ID == 15)
		topMenuBG = "top_pic_04";

	document.writeln('<table width="100%" height="46" border="0" cellpadding="0" cellspacing="0" background="'+imagePath+'images/'+topMenuBG+'b.gif">');
	document.writeln('<tr>');
	document.writeln('	<td width="180" rowspan="2"><img src="'+imagePath+'images/spacer.gif" width="180" height="46"></td>');
	if(!((langID==1 && (Selected_ID==5 || Selected_ID==6 || Selected_ID==4 || Selected_ID==17 ))||(langID==2 && Selected_ID==5)))
	{
		document.writeln('	<td>&nbsp;</td>');
		document.writeln('</tr>');
		document.writeln('<tr>');
	}
		document.writeln('	<td>');
	for(var j=1;j<y;j++){
		if (subMenuObj[j].menuID==Selected_ID)
		{
			if(subMenuObj[j].id==Selected_Sub)
			{
				var over = "_over";
			}
			else
			{
				var over = "";
			}
			if(subMenuObj[j].menuID>9)
			{
				var nav_h_prefix = "nav_h_";
			}
			else
			{
				var nav_h_prefix = "nav_h_0";
			}
			
			document.write('<a href="'+subMenuObj[j].url+'"'+subMenuObj[j].popup+'" onmouseover="MM_swapImage(\''+nav_h_prefix+subMenuObj[j].menuID+'_0'+subMenuObj[j].id+'\',\'\',\''+imagePath+'images/'+nav_h_prefix+subMenuObj[j].menuID+'_0'+subMenuObj[j].id+'_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="'+imagePath+'images/'+nav_h_prefix+subMenuObj[j].menuID+'_0'+subMenuObj[j].id+over+'.gif" name="'+nav_h_prefix+subMenuObj[j].menuID+'_0'+subMenuObj[j].id+'" alt="'+getCaption('subMenuObj', j)+'" border="0"></a>');
			rows++;
			//if((langID==1 && (Selected_ID==4 || Selected_ID==5 || Selected_ID==6 || Selected_ID==17))||(langID==2 && Selected_ID==5)){
			if((langID==1 && (Selected_ID==4 || Selected_ID==5 || Selected_ID==6 || Selected_ID==17 ))||(langID==2 && Selected_ID==5)){
				if(rows>=rowsNumber){
					if(rows2<1){
						document.writeln('</td>');
						document.writeln('</tr>');
						document.writeln('<tr valign=top>');
						document.writeln('	<td>');
						rows=0;
					}
					rows2++;
				}
			}
		}
	}
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('</table>');
}

function changeLanguage(switchLang){
	var currentPath=location.href.toString();
	var switchTc='/tc/';
	var switchEn='/en/';

	var urlVars=document.location.search;

//	alert(urlVars);

	switch (switchLang){
		case '/graphics/':
			currentPath=currentPath.replace(switchGraphic, "");
//			currentPath=currentPath.replace(switchTc, switchText+switchTc);
			break;
		case '/text/':
			currentPath=currentPath.replace(switchEn, switchText+switchEn);
			currentPath=currentPath.replace(switchTc, switchText+switchTc);
			break;
		case '/gb/':
//			currentPath='http://'+gb_urlPath+locationPath.substring(7, locationPath.length)+switchTc;
			if (currentPath.indexOf("/rhbtp/febs")>0||currentPath.indexOf("/rhbtp/virtual")>0||currentPath.indexOf("/games/game1")>0||currentPath.indexOf("/games/game2")>0) {
			//if (currentPath.indexOf("/rhbtp/febs")>0||currentPath.indexOf("/rhbtp/virtual")>0) {
				currentPath=currentPath.replace(".htm","_gb.htm");
				currentPath=currentPath.replace(switchEn, switchTc);
				currentPath=currentPath.replace(gb_urlPath, "");
			} else {
				currentPath=currentPath.replace('http://', 'http://'+gb_urlPath);
				currentPath=currentPath.replace(switchEn, switchTc);
			}
			break;
		case '/en/':
			currentPath=currentPath.replace(switchTc, switchEn);
			currentPath=currentPath.replace(gb_urlPath, "");
			break;
		case '/tc/':
			currentPath=currentPath.replace(switchEn, switchTc);
			currentPath=currentPath.replace(gb_urlPath, "");
			break;
		default:
	}
	document.location=currentPath;

//	alert(currentPath);
}

function getCaption(menu, i){
	var showAlt;

	if(langID==1)
		eval('showAlt='+menu+'['+i+'].caption');
	else
		eval('showAlt='+menu+'['+i+'].chiCaption');
	return showAlt;
}

function getLeftMenu(){
	menuObjID=showMenuObj();
	if(!isText){
		document.writeln('<table border=0 cellspacing=0 cellpadding=0>');
		for(var i=1;i<x;i++){
			if(menuObj[i]){
				if(menuObj[i].navigationMenu=="Y"){
					if (Selected_ID==menuObj[i].id){
						var pic = menuObj[i].onPic;
					}else{
						var pic = menuObj[i].offPic;
					}
					var outAction = "onMouseOut=\"simg(pic"+menuObj[i].id+", '"+pic+"');";
					var overAction = " onMouseOver=\"simg(pic"+menuObj[i].id+", '"+menuObj[i].overPic+"');";

					if (menuObj[i].hasChild =="Y"){
						outAction = outAction + "MM_showHideLayers('LeftLayer_"+menuObj[i].id+"','','hidden',"+menuObj[i].id+"); return true;";
						overAction = overAction + "MM_showHideLayers('LeftLayer_"+menuObj[i].id+"','','show',"+menuObj[i].id+"); return true;";
					}
					outAction = outAction + "\""
					overAction = overAction + "\" "

					if(menuObj[i].hasChild=="Y"){
						document.writeln('<tr><td><img '+ outAction + overAction + menuObj[i].popup+ ' name="pic'+menuObj[i].id+'" id="pic'+menuObj[i].id+'" src="' + pic +  '" alt="'+getCaption("menuObj", i)+'" border=0></td></tr>');
					}else{
						document.writeln('<tr><td><a href="'+menuObj[i].url+'"'+ outAction + overAction + menuObj[i].popup+ '><img name="pic'+menuObj[i].id+'" id="pic'+menuObj[i].id+'" src="' + pic +  '" alt="'+getCaption("menuObj", i)+'" border=0></a></td></tr>');
					}
				}
			}
		}
		document.writeln('</table>');
	}else{
		document.writeln('<table border=0 cellspacing=0 cellpadding=1 width=100%><tr valign=top><tr valign=top><td>');
		for(var i=1;i<x;i++){
			if(menuObj[i]){
				if(menuObj[i].navigationMenu=="Y"){
					if(menuObj[i].id!=Selected_ID){
						document.writeln('[ <a href="'+menuObj[i].url+'"'+ menuObj[i].popup+ '>'+getCaption("menuObj", i)+'</a> ]&nbsp;');
					}else{
						document.writeln('[ <b><a href="'+menuObj[i].url+'"'+ menuObj[i].popup+ '>'+getCaption("menuObj", i)+'</a></b> ]&nbsp;');
					}
				}
			}
		}
		document.writeln('</td></tr>');
		document.writeln('<tr valign=top>');
		document.writeln('	<td colspan=100><hr width=100%></td>');
		document.writeln('</tr>');
		if(menuObj[menuObjID].hasChild=="Y"){
			getSubMenu();
		}
		document.writeln('</table>');
	}
}

function getIndexTopMenu(){
	var gicSearchForm;
	
	gicSearchForm='<form name="frmSearch" action="'+arClfTopMenu[langID][1]+'" method="get" onsubmit="if( document.frmSearch.query.value.length == 0 ) {alert(\''+arClfTopMenu[langID][28]+'\');}  else { document.frmSearch.submit();} return false;">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="exact_q" type="hidden" value="">';
	gicSearchForm=gicSearchForm+'<INPUT name="any_q" type="hidden" value="">';
	gicSearchForm=gicSearchForm+'<INPUT name="none_q" type="hidden" value="">';
	gicSearchForm=gicSearchForm+'<INPUT name="gp0" type="hidden" value="heritage_home">';
	gicSearchForm=gicSearchForm+'<INPUT name="gp1" type="hidden" value="heritage_home">';
	gicSearchForm=gicSearchForm+'<INPUT name="p_size" type="hidden" value="10">';
	gicSearchForm=gicSearchForm+'<INPUT name="doc_type" type="hidden" value="all">';
	gicSearchForm=gicSearchForm+'<INPUT name="last_mod" type="hidden" value="#-1">';
	gicSearchForm=gicSearchForm+'<INPUT name="ui_lang" type="hidden" value="'+arClfTopMenu[langID][26]+'">';
	gicSearchForm=gicSearchForm+'<INPUT name="r_lang" type="hidden" value="all">';
	gicSearchForm=gicSearchForm+'<INPUT name="ui_charset" type="hidden" value="'+arClfTopMenu[langID][27]+'">';
	gicSearchForm=gicSearchForm+'<INPUT name="tpl_id" type="hidden" value="heritage">';
	gicSearchForm=gicSearchForm+'<INPUT name="a_submit" type="hidden" value="false">';
	gicSearchForm=gicSearchForm+'<INPUT name="web" type="hidden" value="this">';
	if(location.href.toString().search('/text/')!=-1){
		gicSearchForm=gicSearchForm+'<INPUT name="txtonly" type="hidden" value="1">';
	}
	else
	{
		gicSearchForm=gicSearchForm+'<INPUT name="txtonly" type="hidden" value="0">';
	}
	
	document.writeln('						<table border="0" cellspacing="0" cellpadding="0">');
	document.writeln(gicSearchForm);
	document.writeln('						<tr>');
	document.writeln('							<td><a href="'+locationPath+langPath+'contact/index.htm" onmouseover="MM_swapImage(\'btn_contact1\',\'\',\''+imagePath+'images/index/btn_contactus_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="'+imagePath+'images/index/btn_contactus.gif" name="btn_contact1" id="btn_contact1" border="0" alt="'+arClfTopMenu[langID][19]+'"></a></td>');
	document.writeln('							<td><a href="'+locationPath+langPath+'sitemap/index.htm" onmouseover="MM_swapImage(\'btn_site1\',\'\',\''+imagePath+'images/index/btn_sitemap_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="'+imagePath+'images/index/btn_sitemap.gif" name="btn_site1" id="btn_site1" border="0" alt="'+arClfTopMenu[langID][18]+'"></a></td>');
	document.writeln('							<td><img src="'+imagePath+'images/index/spacer.gif" width="11" height="40"></td>');
//	document.writeln('							<td><img src="'+imagePath+'images/spacer.gif" width="59" height="40" border="0"></td>');
	//document.writeln('							<td><a href="#" onmouseover="MM_swapImage(\'btn_search1\',\'\',\''+imagePath+'images/index/btn_search_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="'+imagePath+'images/index/btn_search.gif" name="btn_search1" id="btn_search1" border="0" alt="'+arClfTopMenu[langID][17]+'"></a></td>');
	document.writeln('							<td><input type="text" name="query" size="'+arClfTopMenu[langID][4]+'" class="search"></td>');
	document.writeln('							<td><a href="#" onclick="if (document.frmSearch.query.value.length == 0 ) {alert(\''+arClfTopMenu[langID][28]+'\');}  else { document.frmSearch.submit(); }; return false" onmouseover="MM_swapImage(\'btn_search_pic\',\'\',\''+imagePath+'images/btn_search_pic_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="'+imagePath+'images/btn_search_pic.gif" name="btn_search_pic" id="btn_search_pic" border="0" alt="'+arClfTopMenu[langID][17]+'"></a></td>');
//	document.writeln('							<td><img src="'+imagePath+'images/index/spacer.gif" width="11" height="40"></td>');
	document.writeln('							<td><a href="javascript:changeLanguage(\''+arClfTopMenu[langID][12]+'\')" onmouseover="MM_swapImage(\''+arClfTopMenu[langID][24]+'1\',\'\',\''+imagePath+'images/index/'+arClfTopMenu[langID][24]+'_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="'+imagePath+'images/index/'+arClfTopMenu[langID][24]+'.gif" name="'+arClfTopMenu[langID][24]+'1" border="0" alt="'+arClfTopMenu[langID][13]+'"></a></td>');
	document.writeln('							<td><img src="'+imagePath+'images/index/btn_line.gif" width="1" height="40"></td>');
	document.writeln('							<td><a href="javascript:changeLanguage(\''+arClfTopMenu[langID][15]+'\')" onmouseover="MM_swapImage(\''+arClfTopMenu[langID][25]+'1\',\'\',\''+imagePath+'images/index/'+arClfTopMenu[langID][25]+'_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="'+imagePath+'images/index/'+arClfTopMenu[langID][25]+'.gif" name="'+arClfTopMenu[langID][25]+'1" border="0" alt="'+arClfTopMenu[langID][16]+'"></a></td>');
	document.writeln('						</tr>');
	document.writeln('</form>');
	document.writeln('						</table>');
}

function getIndexLeftMenu(){
	document.writeln('<table border=0 cellspacing=0 cellpadding=0>');
	for(var i=1;i<x;i++){
		if(menuObj[i]){
			if(menuObj[i].navigationMenu=="Y"){
				var pic = menuObj[i].offPicIndex;
				
				var outAction = "onMouseOut=\"simg(pic"+i+", '"+menuObj[i].offPicIndex+"');";
				var overAction = " onMouseOver=\"simg(pic"+i+", '"+menuObj[i].overPicIndex+"');";

				/*if (menuObj[i].hasChild =="Y"){
					outAction = outAction + "MM_showHideLayers('LeftLayer_"+i+"','','hidden',"+i+"); return true;";
					overAction = overAction + "MM_showHideLayers('LeftLayer_"+i+"','','show',"+i+"); return true;";
				}*/
				outAction = outAction + "\""
				overAction = overAction + "\" "
				document.writeln('<tr><td><a href="'+menuObj[i].url+'"'+ outAction + overAction + menuObj[i].popup+ '><img name="pic'+i+'" id="pic'+i+'" src="' + pic +  '" alt="'+getCaption("menuObj", i)+'" border=0></a></td></tr>');
			}
		}
	}
	document.writeln('</table>');
}

function getSubMenu(){
	var nextLine=0;
	for(var i=1;i<y;i++){
		if (subMenuObj[i])
		{
			if (subMenuObj[i].menuID==Selected_ID){
				if(nextLine==0){
					document.writeln('<tr>');
					document.writeln('	<td>');
				}
				nextLine++;
	
				if (subMenuObj[i].id != Selected_Sub){
					document.writeln("[ <a href='"+subMenuObj[i].url+"'>"+getCaption('subMenuObj', i)+"</a> ]&nbsp;&nbsp;");
				}else{
					document.writeln("[ <b>"+getCaption('subMenuObj', i)+"</b> ]&nbsp;&nbsp;");
				}
			}
		}
	}
	
	document.writeln('<tr valign=top>');
	document.writeln('	<td><hr width=100%></td>');
	document.writeln('</tr>');
}

function getMenuPath(ID, sub_ID, showlink){
	menuObjID=showMenuObj();
	
	var strText;
	
	if(showlink)
		strText = "<a href='"+menuObj[menuObjID].url+"' class='path_link'>"+getCaption('menuObj', ID)+"</a>"
	else
		strText = getCaption('menuObj', ID)
	
	return strText;
}

function getSubMenuPath(ID, sub_ID, showlink){
	var strText;
	var langText;
	
	if(langID==1)
		langText=".caption";
	else
		langText=".chiCaption";
	for(var i=1;i<y;i++){
		if (subMenuObj[i])
		{
			if (subMenuObj[i].menuID==ID){
				if (subMenuObj[i].id == sub_ID){
					if(showlink)
						strText = "<a href='"+subMenuObj[i].url+"'"+subMenuObj[i].popup+" class='path_link'>"+eval('subMenuObj[i]'+langText)+"</a>";
					else
						strText = eval('subMenuObj[i]'+langText);
				}
			}
		}
	}

	return strText;
}

function getTopic(){
	menuObjID=showMenuObj();
	
	var showPath;
	if(exLink!=null)
		showPath = exLink;
	var checkList = new Array()
		checkList[0] = "Selected_Sub"
		checkList[1] = "Selected_ID"
	var functionList = new Array()
		functionList[0] ="getSubMenuPath" 
		functionList[1] ="getMenuPath" 
	
	for (var i in checkList){
		if(eval(checkList[i]) > 0){
			if(showPath==null){
				showPath = eval(eval("functionList["+i+"]")+"("+menuObjID+", "+Selected_Sub+", false)");
			}else{
				showPath = eval(eval("functionList["+i+"]")+"("+menuObjID+", "+Selected_Sub+", true)") + "<span class='path_arrow'> > </span>" + showPath;
			}
		}
	}
	showPath = "<span class='path_arrow'> > </span>" + showPath;

	var functionNum;
	functionNum = 1;
	if(Selected_ID<10)
		var titleNum="0"+Selected_ID;
	else
		var titleNum=Selected_ID;
	
	if(Selected_Sub>0){
		functionNum = 0;
		if(Selected_Sub<10){
			titleNum=titleNum+"_0"+Selected_Sub;
		}else{
			titleNum=titleNum+"_"+Selected_Sub;
		}
	}
	
	if(!isText){		
		/*document.writeln('<table border=0 cellspacing=0 cellpadding=0 width=612 background="'+imagePath+'images/spacer.gif">');
		document.writeln('<tr><td width=12><img src="'+imagePath+'images/spacer.gif" border=0 align=top alt="" width=12 height=24></td><td width=600 class="path_higlight">'+showPath+'</td></tr>');
		document.writeln('<tr><td colspan=2 background="'+locationPath+'/images/path_line.gif"><img src="'+imagePath+'images/spacer.gif" border=0 align=top alt="" width=1 height=5></td></tr>');
		document.writeln('<tr><td colspan=2><img src="'+imagePath+'images/title/heading_'+titleNum+'.gif" border=0 align=top alt="'+eval(eval("functionList["+functionNum+"]")+"("+Selected_ID+", "+Selected_Sub+", false)")+'"></td></tr>');
		document.writeln('</table>');*/
		if(functionNum==1)
		{
			document.writeln('<td><img src="'+imagePath+'images/title/hd_'+titleNum+'.gif" border="0" alt="'+eval(eval("functionList["+functionNum+"]")+"("+menuObjID+", "+Selected_Sub+", false)")+'"></td>');		
		}
		else
		{
			document.writeln('<td><img src="'+imagePath+'images/title/hd_'+titleNum+'.gif" border="0" alt="'+eval(eval("functionList["+functionNum+"]")+"("+menuObj[menuObjID].id+", "+Selected_Sub+", false)")+'"></td>');		
		}
	}else{
		document.writeln('<table border=0 cellspacing=0 cellpadding=0>');
		document.writeln('<tr><td><h2>'+eval(eval("functionList["+functionNum+"]")+"("+menuObjID+", "+Selected_Sub+", false)")+'</h2></td></tr>');
		document.writeln('</table>');
	}
}

function getTitlePath(ID, sub_ID){
	var strText;
	
	strText = getCaption('menuObj', ID)
	
	return strText;
}

function getSubTitlePath(ID, sub_ID){
	var strText;
	var langText;
	
	if(langID==1)
		langText=".caption";
	else
		langText=".chiCaption";
	for(var i=1;i<y;i++){
		if (subMenuObj[i])
		{
			if (subMenuObj[i].menuID==ID){
				if (subMenuObj[i].id == sub_ID){
					strText = eval('subMenuObj[i]'+langText);
				}
			}
		}
	}

	return strText;
}

function getTitle(){
	menuObjID=showMenuObj();
	
	if(langID==1)
		var firstLvText="Conserve and Revitalise HongKong Heritage";
	else
		var firstLvText="香港歷史文物-保育•活化";
	var showPath;
	showPath = "";
	if(exLink==null)
		exLink = "";
	var checkList = new Array()
		checkList[0] = "Selected_Sub"
		checkList[1] = "Selected_ID"
	var functionList = new Array()
		functionList[0] ="getSubTitlePath"
		functionList[1] ="getTitlePath"
	
	var functionNum;
	
	if(Selected_Sub>0){
		functionNum = 0;
	}
	else
	{
		functionNum = 1;	
	}

	showPath = firstLvText + " - " + showPath;
	
	if(!isText){
		showPath = showPath + eval(eval("functionList[1]")+"("+menuObjID+", "+Selected_Sub+", false)");
		if(Selected_Sub>0){
			if(exLink!=""){
				showPath = showPath + " - " + eval(eval("functionList[0]")+"("+menuObj[menuObjID].id+", "+Selected_Sub+", false)") + " - " + exLink;
			}
			else
			{
				showPath = showPath + " - " + eval(eval("functionList[0]")+"("+menuObj[menuObjID].id+", "+Selected_Sub+", false)");
			}
		}
		document.writeln('<title>'+showPath+'</title>');
	}
}

var resizeFlag;
var footerY = 600;

function moveDivs(layerObj, inObj){
	layerObj.top  = inObj;
} 

function moveTopDivs(layerObj, inObjTop, inObjLeft){
	layerObj.top  = inObjTop + "px";
	layerObj.left  = inObjLeft + "px";
} 

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}
}

function init(){
	setTopLayerPosition(true);

	if(printPage==1){
		window.print();
	}
}

//function for setting the top button
function setTopLayerPosition(resizeFlag){
	if(topButton=='Y'){
		if (document.all && document.all["footer_layer"]!=null)
		{
	//		footerY = getDim(document.images.leftMenuLineBottom).y;
			moveTopDivs(document.all["footer_layer"].style, getDim(document.images.backtotopspacer).y, getDim(document.images.backtotopspacer).x)
			if (getDim(document.images.backtotopspacer).y > footerY)
			{
				if (resizeFlag)
				{document.all["footer_layer"].style.visibility = "visible"}
			}
		}
		if (document.layers && document.layers["footer_layer"])
		{
	//		footerY = document.images["leftMenuLineBottom"].y;
			moveTopDivs(document.layers["footer_layer"], document.images["backtotopspacer"].y, document.images["backtotopspacer"].x);
			if (document.images["backtotopspacer"].y > footerY)
			{
				if (resizeFlag)
				{document.layers["footer_layer"].visibility = "show"}
			}
		}
		if (!document.all && document.getElementById && document.getElementById("footer_layer")!=null)
		{
	//		footerY = document.images["leftMenuLineBottom"].y;
			moveTopDivs(document.getElementById("footer_layer").style, document.images["backtotopspacer"].y, document.images["backtotopspacer"].x);
			if (document.images["backtotopspacer"].y > footerY)
			{
				if (resizeFlag)
				{document.getElementById("footer_layer").style.visibility = "visible"}
			}
		}
	}
}

onresize=setTopLayerPosition;

function genLeftLayer(ID, ID2){
if(ID>9)
var nav_prefix = "nav_";
else
var nav_prefix = "nav_0";

if(navigator.appName == "Netscape")
{
	var tb_align = "align=\"left\"";
}
else
{
	var tb_align = "";
}
var
	isNS4 = (document.layers) ? true : false;
	isIE4 = (document.all && !document.getElementById) ? true : false;
	isIE5 = (document.all && document.getElementById) ? true : false;
	isNS6 = (!document.all && document.getElementById) ? true : false;
	if (document.layers)
		{document.writeln('<layer name=LeftLayer_'+ID+' top=0 left=0 width=26 height=26 visibility="hide" OnMouseOver="MM_showHideLayers(\'LeftLayer_'+ID+'\',\'\',\'show\','+ID+');simg(pic'+ID+', \''+menuObj[ID2].overPic+'\'); return true;" OnMouseOut="MM_showHideLayers(\'LeftLayer_'+ID+'\',\'\',\'hidden\','+ID+');simg(pic'+ID+', \''+menuObj[ID2].offPic+'\'); return true;">');}
	else
		{document.writeln('<div id="LeftLayer_'+ID+'" style="position:absolute; left:0; top:0; width:26; height:26; z-index:10; visibility: hidden"><iframe id=\'iframex\' style="z-index:-1;position:absolute;" src="" width="130" height="100%" scrolling="No" frameborder="0" marginheight="0" marginwidth="0"></iframe> ');}
	if (isNS6) {
	document.writeln('<table align="left" border="0" cellspacing="0" cellpadding="0" OnMouseOver="MM_showHideLayers(\'LeftLayer_'+ID+'\',\'\',\'show\','+ID+'); simg(pic'+ID+', \''+menuObj[ID2].overPic+'\'); return true;" OnMouseOut="MM_showHideLayers(\'LeftLayer_'+ID+'\',\'\',\'hidden\','+ID+'); simg(pic'+ID+', \''+menuObj[ID2].offPic+'\');return true;">');
	}
	else{
	document.writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0" OnMouseOver="MM_showHideLayers(\'LeftLayer_'+ID+'\',\'\',\'show\','+ID+'); simg(pic'+ID+', \''+menuObj[ID2].overPic+'\'); return true;" OnMouseOut="MM_showHideLayers(\'LeftLayer_'+ID+'\',\'\',\'hidden\','+ID+'); simg(pic'+ID+', \''+menuObj[ID2].offPic+'\');return true;">');
	}
	for(var i=1;i<y;i++){
		if (subMenuObj[i])
		{
			if (subMenuObj[i].menuID==ID){
				var outAction = " onMouseOut=\"simg(pic"+ID+", '"+menuObj[ID2].offPic+"');simg(submenu_"+ID+"_"+subMenuObj[i].id+", '"+imagePath + "images/submenu/"+nav_prefix+ID+"_0"+subMenuObj[i].id+".gif');\"";
				var overAction = " onMouseOver=\"simg(pic"+ID+", '"+menuObj[ID2].overPic+"');simg(submenu_"+ID+"_"+subMenuObj[i].id+", '"+imagePath + "images/submenu/"+nav_prefix+ID+"_0"+subMenuObj[i].id+"_over.gif');\"";
				
				document.writeln('	<tr>');
				document.writeln('		<td><a href="'+subMenuObj[i].url+'"'+overAction+outAction+subMenuObj[i].popup+'><img src="'+imagePath+'images/submenu/'+nav_prefix+ID+'_0'+subMenuObj[i].id+'.gif" name="submenu_'+ID+'_'+subMenuObj[i].id+'" alt="'+getSubMenuPath(ID, subMenuObj[i].id, false)+'" border=0></a></td>');
				document.writeln('	</tr>');				
			}
		}
	}
	document.writeln('</table>');
	if (document.layers)
		{document.writeln('</layer>');}
	else
		{document.writeln('</div>');}			
}

//function for generating the layer for top button
function genfooterLayer(){
	var altText='Top';
	
	if(langID!=1) altText='頁首';

	if (document.layers)
		{document.writeln('<layer name=footer_layer top=0 left=0 width=26 height=26 visibility="hide">');}
	else
		{document.writeln('<div id="footer_layer" style="position:absolute; left:0; top:0; width:26; height:26; z-index:10; visibility: hidden"> ');}
	document.writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
	document.writeln('<tr valign=top>');
	document.writeln('	<td><a href="#top"><img src="'+imagePath+'images/btn_top.gif" alt="'+altText+'" border="0" name="backtotopfoot"></a></p></td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	if (document.layers)
		{document.writeln('</layer>');}
	else
		{document.writeln('</div>');}		
		
	for(var i=1;i<x;i++){
		if(menuObj[i]){
			if (menuObj[i].hasChild =="Y"){
				genLeftLayer(menuObj[i].id, i);
			}
		}
	}	
}

//function for generating the footer
function getFooter(){
	var altText='Top';
	if(langID!=1) altText='頁首';
	
	var altBack='Back';
	if(langID!=1) altBack='回上頁';
	
	var copyYear='2008';
	var noticesLink=locationPath+langPath+'notices/index.htm';
	var noticeText='Important notices';
	var revisionText='Last revision date: ';	
//	var reviewText='Last review date: ';	
	if (revisionDate==''||revisionDate=='MM/DD/YYYY') revisionDate='07/11/2008';
//	if (reviewDate==''||reviewDate=='MM/DD/YYYY') reviewDate='01/15/2008';
	if (langID==2){
		noticeText='重要告示';
		revisionText='修訂日期： ';	
//		reviewText='覆檢日期： ';	
	}
	var monthArray=new Array();
	monthArray[0]='January';
	monthArray[1]='February';
	monthArray[2]='March';
	monthArray[3]='April';
	monthArray[4]='May';
	monthArray[5]='June';
	monthArray[6]='July';
	monthArray[7]='August';
	monthArray[8]='September';
	monthArray[9]='October';
	monthArray[10]='November';
	monthArray[11]='December';
	var reDate=new Date(Date.parse(revisionDate))
	var showDate=reDate.getDate()+' '+monthArray[reDate.getMonth()]+' '+reDate.getFullYear();
	if (langID==2) showDate=reDate.getFullYear()+'年'+(reDate.getMonth()+1)+'月'+reDate.getDate()+'日';
	
/*	var reDate2=new Date(Date.parse(reviewDate))
	var showDate2=reDate2.getDate()+' '+monthArray[reDate2.getMonth()]+' '+reDate2.getFullYear();
	if (langID==2) showDate2=reDate2.getFullYear()+'年'+(reDate2.getMonth()+1)+'月'+reDate2.getDate()+'日';*/
	//generate the topic image to the buffer variable
	if(!isText){
		document.writeln('<p>');
		document.writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		if(topButton=='Y')
			document.writeln('	<tr valign=top><td colspan=2 align=right><img src="'+imagePath+'images/spacer.gif" name="backtotopspacer" width=38 height=20></td></tr>');
		document.writeln('	<tr>');
		document.writeln('		<td><img src="'+imagePath+'images/spacer.gif" alt="" border="0" width=5 height=1></td>');
		document.writeln('		<td valign="top" align="center">');
		document.writeln('		<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('		<tr bgcolor="#FFFFFF">');
		document.writeln('			<td colspan="2" align="right"><img src="'+imagePath+'images/pic_dotline.gif" alt="" width="810" border=0></td>');
		document.writeln('		</tr>');
		document.writeln('		<tr bgcolor="#FFFFFF">');
		document.writeln('			<td height="15" bgcolor="#FFFFFF" class="footer"><img src="'+imagePath+'images/spacer.gif" alt="" border="0" width=15 height=5><b>'+copyYear+'</b> &copy; | <a href="'+noticesLink+'" class="footer">'+noticeText+'</a></td>');
//		document.writeln('			<td height="15" bgcolor="#FFFFFF" class="footer"><img src="'+imagePath+'images/spacer.gif" alt="" border="0" width=15 height=5><b>'+copyYear+'</b> <img src="'+imagePath+'../images/copy.gif" alt="" width="12" height="11"> | <b><a href="'+noticesLink+'" class="footer">'+noticeText+'</a></b></td>');
//		document.writeln('			<td height="15" align="right" bgcolor="#FFFFFF" class="footer">'+reviewText+showDate2+'</td>');
		document.writeln('			<td height="15" align="right" bgcolor="#FFFFFF" class="footer">'+revisionText+showDate+'</td>');
		document.writeln('		</tr>');
		document.writeln('		</table>');
		document.writeln('		</td>');
		document.writeln('	</tr>');
		document.writeln('</table><br>');
	}else{
		document.writeln('<table border=0 cellspacing=0 cellpadding=1 width=100%>');
		document.writeln('<tr valign=top>');
		document.writeln('	<td colspan=3><hr width=100%></td>');
		document.writeln('</tr>');
		document.writeln('<tr valign=top>');
		document.writeln('	<td>[ <a href="#">'+altText+'</a> ]</td>');
		document.writeln('	<td align="right" colspan=2>&nbsp;</td>');
		document.writeln('</tr>');
		document.writeln('<tr valign=top>');
		document.writeln('	<td colspan=3><hr width=100%></td>');
		document.writeln('</tr>');
		document.writeln('<tr>');
		document.writeln('	<td class="footer"><b>'+copyYear+'</b> | <b><a href="'+noticesLink+'" class="footer">'+noticeText+'</a></b></td>');
		document.writeln('	<td height="15" align="right" bgcolor="#FFFFFF" class="footer">'+reviewText+showDate2+'</td>');
		document.writeln('	<td align="right" class="footer">'+revisionText+showDate+'</td>');
		document.writeln('</tr>');
		document.writeln('</table>');
	}
}

function getSiteMap(){
	var bulletPath1;
	var bulletPath2;
	if(!isText){
		bulletPath1='<img src="'+locationPath+'/images/bullet.gif" border=0 alt="*">';
		bulletPath2='<img src="'+locationPath+'/images/bullet2.gif" border=0 alt="*">';
	}else{
		bulletPath1='*';
		bulletPath2='*';
	}
	
	document.writeln('<table border=0 cellspacing=0 cellpadding=3 width=100%>');
	for(var i=1;i<x;i++){
		if(menuObj[i]){
			if(menuObj[i].sitemap=="Y"){
			if(menuObj[i].hasChild=="Y"){
				document.write('<tr valign=top><td nowrap>'+bulletPath1+'&nbsp;</td><td width=100%>'+getCaption('menuObj', i)+'</td>');
			}else{
				document.write('<tr valign=top><td nowrap>'+bulletPath1+'&nbsp;</td><td width=100%><a href="'+menuObj[i].url+'"'+menuObj[i].popup+' class="Link">'+getCaption('menuObj', i)+'</a></td>');
			}
//				document.write('	<li><a href="'+menuObj[i].url+'">'+getCaption('menuObj', i)+'</a>');
				if(menuObj[i].hasChild=="Y" || menuObj[i].hasChild=="L"){
					document.writeln('	<tr valign=top><td nowrap>&nbsp;</td><td width=100%><table border=0 cellspacing=0 cellpaddding=3 width=100%>');
					for(var j=1;j<y;j++){
						if (subMenuObj[j].menuID==menuObj[i].id)
							document.write('	<tr valign=top><td nowrap>'+bulletPath2+'&nbsp;</td><td width=100%><a href="'+subMenuObj[j].url+'"'+subMenuObj[j].popup+' class="Link">'+getCaption('subMenuObj', j)+'</a></td></tr>');
					}
					document.writeln('	</table></td></tr>');
				}else{
				document.writeln('</tr>');
				}
			}
		}
	}
	document.writeln('</table>');
}

function getSectionList(){
	var bulletPath1;
	if(!isText){
		bulletPath1='<img src="'+locationPath+'/images/bullet_1.gif" border=0 alt="*">';
	}else{
		bulletPath1='*';
	}

	document.writeln('<table border=0 cellspacing=0 cellpadding=3 width=100%>');
	for(var j=1;j<y;j++){
		if (subMenuObj[j].menuID==Selected_ID)
			document.write('<tr valign=top><td nowrap>'+bulletPath1+'&nbsp;</td><td width=100%><a href="'+subMenuObj[j].url+'"'+subMenuObj[j].popup+' class="Link">'+getCaption('subMenuObj', j)+'</a></td></tr>');
	}
	document.writeln('</table>');
}

function styleSheet(){
	var styleType='style.css';
	
	if(!isText){
		if(langID!=1)
			styleType=styleType.replace('.css', '_tc.css'); 
		
		if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) <= 4)) {
			document.writeln('<link href="'+locationPath.replace("/text", "")+'/css/nt_'+styleType+'" rel="STYLESHEET" type="text/css">');
		}else{
		
			document.writeln('<link href="'+locationPath.replace("/text", "")+'/css/'+styleType+'" rel="STYLESHEET" type="text/css">');
			
		}
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	var k;
	y=19;
	isNS4 = (document.layers) ? true : false;
	isIE4 = (document.all && !document.getElementById) ? true : false;
	isIE5 = (document.all && document.getElementById) ? true : false;
	isNS6 = (!document.all && document.getElementById) ? true : false;
	for (i=0, k=1; i<(args.length-3); i+=3, k+=1) {
    	if ((obj=MM_findObj(args[i]))!=null) { 
			v=args[i+2];
			if (obj.style) { obj=obj.style; }
			if (v=='show') {
				if (!document.layers) {   // all others
					if (isNS6) {
//						w = window.innerWidth;
						eval('moveTopDivs(document.getElementById("LeftLayer_'+args[3]+'").style, document.images["pic'+args[3]+'"].y, document.images["pic'+args[3]+'"].x + document.images["pic'+args[3]+'"].width)');
					}else {
//						w = window.document.body.clientWidth;
						eval('moveTopDivs(document.all["LeftLayer_'+args[3]+'"].style, getDim(document.images.pic'+args[3]+').y, getDim(document.images.pic'+args[3]+').x+ document.images["pic'+args[3]+'"].width)');
					}
				}else {  //NN4
					eval('moveTopDivs(document.layers["LeftLayer_'+args[3]+'"], document.images["pic'+args[3]+'"].y, document.images["pic'+args[3]+'"].x + document.images["pic'+args[3]+'"].width)');
				}		
			}
			v=(v=='show')?'visible':(v='hide')?'hidden':v; 
			obj.visibility=v; 
		}
	}
}

function PopWin(url,page,x,y){
	if(isText){
		var lastSlash=location.href.toString().lastIndexOf('/');
		url=location.href.toString().substring(0, lastSlash)+'/'+url;
	}
	eval("nw = window.open(url, page,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,pageXOffset=0,pageYOffset=0,top=0,left=0,width=" + x + ",height=" + y + "')");
	if ( nw.focus != null)
	{nw.focus();}
}

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
}

function clickIE4(){
if (event.button==2){
//alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
//alert(message);
return false;
}
}
}

function disable_rightclick(){
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("return false")
}


