//function for check current Path
function getLocationPath(){
	var locPath=location.href.toString();
	var subPath='';
/*
	if(location.href.toString().search('test2.westcomzivo.com/rvd')!=-1){
		if(location.href.toString().search('/gb/')!=-1)
		{
			subPath="ht"+"tp://common.westcomzivo.com/gb/test2.westcomzivo.com/rvd"
		}
		else
		{
			subPath="ht"+"tp://test2.westcomzivo.com/rvd"
		}
		HomePath="test2.westcomzivo.com/rvd"
	}
	if(location.href.toString().search('ogcio.devprj.com/rvd.gov.hk/maindisk2/vh1/rvd')!=-1){
		if(location.href.toString().search('/gb/')!=-1)
		{
			subPath="ht"+"tp://ogcio.devprj.com/rvd.gov.hk/maindisk2/vh1/rvd"
		}
		else
		{
			subPath="ht"+"tp://ogcio.devprj.com/rvd.gov.hk/maindisk2/vh1/rvd"
		}
		HomePath="ogcio.devprj.com/rvd.gov.hk/maindisk2/vh1/rvd"
	}
	if(location.href.toString().search('www0.rvd.gov.hk')!=-1){
		if(location.href.toString().search('/gb/')!=-1)
		{
			subPath="ht"+"tp://sc.info.gov.hk/gb/www0.rvd.gov.hk"
		}
		else
		{
			subPath="ht"+"tp://www0.rvd.gov.hk"
		}
		HomePath="www0.rvd.gov.hk"
	}
	if(location.href.toString().search('www.rvd.gov.hk')!=-1){
		if(location.href.toString().search('/gb/')!=-1)
		{
			subPath="ht"+"tp://sc.info.gov.hk/gb/www.rvd.gov.hk"
		}
		else
		{
			subPath="ht"+"tp://www.rvd.gov.hk"
		}
		HomePath="www.rvd.gov.hk"
	}
	if(location.href.toString().search('se.cgi')!=-1){
//		subPath="ht"+"tp://www.rvd.gov.hk"
		if(location.href.toString().search('/gb/')!=-1)
		{
			subPath="ht"+"tp://sc.info.gov.hk/gb/www.rvd.gov.hk"
		}
		else
		{
			subPath="ht"+"tp://www.rvd.gov.hk"
		}
		HomePath="www.rvd.gov.hk"
	}

// Added for testing (@arcotect)
  if(location.href.toString().search('localhost')!=-1){
    subPath="http://localhost";
    HomePath="localhost";
  } else if(location.href.toString().search('arcotect')!=-1){
    subPath="http://ogciorvd.arcotect.com";
    HomePath="ogciorvd.arcotect.com";
  }
// Finihshed Add
*/
	if(location.href.toString().search('TextOnly.pl')!=-1){
		subPath="TextOnly.pl?search=";
	}
	if(subPath==''){
		var lastSlash=location.href.toString().lastIndexOf('/');
		subPath=location.href.toString().substring(0, lastSlash);
	}

	var langs = ["tc", "en", "sc"];
	var fromLang = '';
	var toLang = '';
	for(counter = 0; counter < langs.length; counter++){
		if(location.href.search('/'+langs[counter]+'/')!= -1){
			fromLang = langs[counter];
		}
	}
	subPath = location.href.substr(0, location.href.search('/'+fromLang+'/'));
	locationPath=subPath;
	HomePath = subPath.replace('http://', '');

	//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,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].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('http://')!=-1){
		HomeIconObj[z].url = url;
		HomeIconObj[z].popup = ' target="_blank"'
	}else if(url.search('.pdf')!=-1){
		HomeIconObj[z].url = url;
		HomeIconObj[z].popup = ' target="_blank"'
	}else if(url.search('javascript:')!=-1){
		HomeIconObj[z].url = url;
		HomeIconObj[z].popup = ''
	}else{
		HomeIconObj[z].url = url;
		HomeIconObj[z].popup = ''
	}
	HomeIconObj[z].chi_url = chi_url;
	HomeIconObj[z].pic = Pic;
	z++;
}

function addHomeIcon2(ID, caption, chi_caption, url, chi_url, Pic)
{
	HomeIconObj2[q] = new Object();
	HomeIconObj2[q].id = ID;
	HomeIconObj2[q].caption = caption;
	HomeIconObj2[q].chiCaption = chi_caption;
	if(url.search('http://')!=-1){
		HomeIconObj2[q].url = url;
		HomeIconObj2[q].popup = ' target="_blank"'
	}else if(url.search('.pdf')!=-1){
		HomeIconObj2[q].url = url;
		HomeIconObj2[q].popup = ' target="_blank"'
	}else if(url.search('javascript:')!=-1){
		HomeIconObj2[q].url = url;
		HomeIconObj2[q].popup = ''
	}else{
		HomeIconObj2[q].url = url;
		HomeIconObj2[q].popup = ''
	}
	HomeIconObj2[q].chi_url = chi_url;
	HomeIconObj2[q].pic = Pic;
	q++;
}

function getheaderHTML(){
	if(Selected_ID>=10){
		var bg=Selected_ID;
	}else{
		var bg="0"+Selected_ID;
	}
	if(!isText){
		document.writeln('<table border=0 cellspacing=0 cellpadding=0 width=760>');
		if(printPage!=1){ getTopMenu();	}
		document.writeln('<tr valign=top>');
		if(printPage!=1){ getLeftMenu(); }
		document.writeln('	<td width=612><img src="'+locationPath+'/images/top_pic.jpg" border=0 align=top alt=""></td>');
		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 height=530 background="'+locationPath+'/images/bg_'+bg+'.gif">');
		document.writeln('		<table border=0 cellspacing=0 cellpadding=0 width=100% background="'+locationPath+'/images/spacer.gif">');
		document.writeln('		<tr valign=top>');
		if(Selected_ID!=15)
		document.writeln('			<td rowspan=2 width=20><img src="'+locationPath+'/images/spacer.gif" border=0 align=top alt="" width=20 height=20></td>');
		document.writeln('			<td width="572"><img src="'+locationPath+'/images/spacer.gif" border=0 align=top alt="" width=572 height=10></td>');
		if(Selected_ID!=15)
		document.writeln('			<td rowspan=2 width=20><img src="'+locationPath+'/images/spacer.gif" border=0 align=top alt="" width=20 height=10></td>');
		document.writeln('		</tr>');
		document.writeln('		<tr valign=top>');
		document.writeln('			<td>');
	}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('			<br>');
		document.writeln('			</td>');
		document.writeln('		</tr>');
		document.writeln('		</table>');
		document.writeln('	</td>');
		document.writeln('</tr>');
		document.writeln('<tr valign=top>');
		document.writeln('	<td>');
		document.writeln('		<table border=0 cellspacing=0 cellpadding=0>');
		document.writeln('		<tr valign=top>');
		document.writeln('			<td><img src="'+locationPath+'/images/table_buttom.gif" border=0 align=top alt=""></td>');
		document.writeln('		</tr>');
		document.writeln('		<tr valign=top>');
		document.writeln('			<td><img src="'+locationPath+'/images/banner_bottom-line.gif" border=0 align=top alt=""></td>');
		document.writeln('		</tr>');
		document.writeln('		<tr valign=top>');
		document.writeln('			<td><img src="'+locationPath+'/images/spacer.gif" border=0 align=top alt="" width=1 height=8></td>');
		document.writeln('		</tr>');
		document.writeln('		</table>');
		document.writeln('	</td>');
		document.writeln('</tr>');
		if(Selected_ID==1){
			document.writeln('<tr valign=top>');
			document.writeln('	<td>');
			getHomeIcon();
			document.writeln('	</td>');
			document.writeln('</tr>');
		}
		document.writeln('<tr valign=top>');
		document.writeln('	<td>');
		getFooter();
		document.writeln('	</td>');
		document.writeln('</tr>');
		document.writeln('</table>');
	}else{
		document.writeln('	</td>');
		document.writeln('</tr>');
		if(Selected_ID==1){
			document.writeln('<tr valign=top>');
			document.writeln('	<td>');
			getHomeIcon();
			document.writeln('	</td>');
			document.writeln('</tr>');
		}
		document.writeln('<tr valign=top>');
		document.writeln('	<td>');
		getFooter();
		document.writeln('	</td>');
		document.writeln('</tr>');
		document.writeln('</table>');
	}
}

function getHomeIcon(){
	var rows=0;
	var rows2=0;

	document.writeln('		<!-- Home Icon Area -->');
	document.writeln('		<p>');
	document.writeln('		<table border=0 cellspacing=2 cellpadding=2 align=center width=100%>');
	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;
			}
		}
		document.writeln('		</tr><tr valign=top><td colspan="6"><hr></td></tr><tr valign=top>');
		for(var i=1;i<q;i++){
			if(langID==1){
				document.writeln('			<td align=center><a href="'+HomeIconObj2[i].url+'"'+HomeIconObj2[i].popup+'><img src="'+imagePath+'images/icon/'+HomeIconObj2[i].pic+'" border=0 align=top alt="'+HomeIconObj2[i].caption+'"></a></td>');
			}else{
				document.writeln('			<td align=center><a href="'+HomeIconObj2[i].chi_url+'"'+HomeIconObj2[i].popup+'><img src="'+imagePath+'images/icon/'+HomeIconObj2[i].pic+'" border=0 align=top alt="'+HomeIconObj2[i].chiCaption+'"></a></td>');
			}
			rows2++;
			if(rows2>=6){
				document.writeln('		</tr>');
				document.writeln('		<tr valign=top>');
				rows2=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><tr valign=top><td colspan="6"><hr></td></tr><tr valign=top>');
		for(var i=1;i<q;i++){
			if(langID==1){
				document.writeln('			<td><a href="'+HomeIconObj2[i].url+'" target="_blank">'+HomeIconObj2[i].caption+'</a></td>');
			}else{
				document.writeln('			<td><a href="'+HomeIconObj2[i].chi_url+'" target="_blank">'+HomeIconObj2[i].chiCaption+'</a></td>');
			}
			rows2++;
			if(rows2>=6){
				document.writeln('		</tr>');
				document.writeln('		<tr valign=top>');
				rows2=0;
			}
		}
	}
	document.writeln('		</tr>');
	document.writeln('		</table>');
	document.writeln('		<!-- Home Icon Area -->		');
}

//function for generating the top menu
function getTopMenu(){
	
	if(langID==1){
		var extarSpacer = '<td background="'+imagePath+'images/bkgdtexture.gif"><img src="'+imagePath+'images/spacer.gif" border="0" height=1 width=40 alt=""></td>';
	}else{
		var extarSpacer = '<td background="'+imagePath+'images/bkgdtexture.gif"><img src="'+imagePath+'images/spacer.gif" border="0" height=1 width=49 alt=""></td>';
	}

	var gicSearchForm;

	gicSearchForm='<form name="frmSearch" action="'+arClfTopMenu[langID][1]+'" method="get">\n';
  gicSearchForm+='<input type="hidden" name="tpl_id" value="rvd">\n';
  gicSearchForm+='<input type="hidden" name="ui_lang" value="'+arClfTopMenu[langID][24]+'">\n';
  gicSearchForm+='<input type="hidden" name="ui_charset" value="'+arClfTopMenu[langID][25]+'">\n';
  gicSearchForm+='<input type="hidden" name="gp0" value="rvd_home">\n';
  gicSearchForm+='<input type="hidden" name="gp1" value="rvd_home">\n';
  gicSearchForm+='<input type="hidden" name="web" value="this">\n';

	if(!isText){
		document.writeln('	<tr>');
		document.writeln('	<td colspan="2">');
		document.writeln('		<table width="760" border="0" cellpadding="0" cellspacing="0" background="'+locationPath+'/images/bg.gif">');
		document.writeln(gicSearchForm);
		document.writeln('		<tr align="left" valign="top">');
		document.writeln('			<td class="sidebar" background="'+imagePath+'images/bkgdtexture.gif" bgcolor="#FAFAEB">');
		document.writeln('				<table width="760" border="0" cellpadding="0" cellspacing="0">');
		document.writeln('				<tr valign="top">');
		document.writeln('					<td class="sidebar" background="'+imagePath+'images/bkgdtexture.gif" bgcolor="#FAFAEB"><a href="ht'+'tp://'+HomePath+'"><img src="'+imagePath+'images/branding.gif" border=0 alt="'+arClfTopMenu[langID][3]+'"></a></td>');
		document.writeln('					<td background="'+imagePath+'images/bkgdtexture.gif" bgcolor="#FAFAEB" width="100%">&nbsp;</td>');
		document.writeln('					<td background="'+imagePath+'images/bkgdtexture.gif" colspan="2" valign="bottom" align=right bgcolor="#FAFAEB"><a href="'+arClfTopMenu[langID][5]+'" target="_blank"><img name="BrandHK" src="'+imagePath+'images/brandhk.gif" border="0" alt="'+arClfTopMenu[langID][6]+'"></a></td>');
		document.writeln('				</tr>');
		document.writeln('				</table>');
		document.writeln('			</td>');
		document.writeln('		</tr>');
		document.writeln('		<tr align="left" valign="top">');
		document.writeln('			<td class="sidebar" background="'+imagePath+'images/bkgdtexture.gif" bgcolor="#FAFAEB">');
		document.writeln('				<table width="760" border="0" cellpadding="0" cellspacing="0">');
		document.writeln('				<tr valign="bottom">');
		document.writeln('					<td background="'+locationPath+langPath+'images/bkgdtexture.gif"><a href="'+arClfTopMenu[langID][23]+'" onMouseOut="outTopMenu(\'mainbar1\')" onMouseOver="overTopMenu(\'mainbar1\')"><img name="mainbar1" src="'+imagePath+'images/mainbar1.gif" border="0" alt="'+arClfTopMenu[langID][7]+'"></a></td>');
		document.writeln('					<td><a href="javascript:changeLanguage(\''+arClfTopMenu[langID][9]+'\')" onMouseOut="outTopMenu(\'mainbar2\')" onMouseOver="overTopMenu(\'mainbar2\')"><img name="mainbar2" src="'+imagePath+'images/mainbar2.gif" border="0" alt="'+arClfTopMenu[langID][10]+'"></a></td>');
		document.writeln('					<td><a href="javascript:changeLanguage(\''+arClfTopMenu[langID][12]+'\')" onMouseOut="outTopMenu(\'mainbar3\')" onMouseOver="overTopMenu(\'mainbar3\')"><img name="mainbar3" src="'+imagePath+'images/mainbar3.gif" border="0" alt="'+arClfTopMenu[langID][13]+'"></a></td>');
		document.writeln('					<td><a href="javascript:changeLanguage(\''+arClfTopMenu[langID][15]+'\')" onMouseOut="outTopMenu(\'mainbar4\')" onMouseOver="overTopMenu(\'mainbar4\')"><img name="mainbar4" src="'+imagePath+'images/mainbar4.gif" border="0" alt="'+arClfTopMenu[langID][16]+'"></a></td>');
		document.writeln('					<td><img src="'+imagePath+'images/mainbar5.gif" border="0"></td>');
		document.writeln(extarSpacer);
		document.writeln('					<td background="'+imagePath+'images/bkgdtexture.gif"><a href="javascript:document.frmSearch.submit();" onMouseOut="outTopMenu(\'mainbar6\')" onMouseOver="overTopMenu(\'mainbar6\')"><img name="mainbar6" src="'+imagePath+'images/mainbar6.gif" border="0" alt="'+arClfTopMenu[langID][17]+'"></a></td>');
		document.writeln('					<td background="'+imagePath+'images/bkgdtexture.gif" align=center><input type="text" name="query" size="'+arClfTopMenu[langID][4]+'" class="search"></td>');
		document.writeln('					<td background="'+imagePath+'images/bkgdtexture.gif"><a href="javascript:document.frmSearch.submit();" onMouseOut="outTopMenu(\'mainbar8\')" onMouseOver="overTopMenu(\'mainbar8\')"><img name="mainbar8" src="'+imagePath+'images/mainbar8.gif" border="0" alt="'+arClfTopMenu[langID][17]+'"></a></td>');
		document.writeln('					<td background="'+imagePath+'images/bkgdtexture.gif"><a href="'+locationPath+langPath+'sitemap/index.htm" onMouseOut="outTopMenu(\'mainbar9\')" onMouseOver="overTopMenu(\'mainbar9\')"><img name="mainbar9" src="'+imagePath+'images/mainbar9.gif" border="0" alt="'+arClfTopMenu[langID][18]+'"></a></td>');
		document.writeln('					<td background="'+imagePath+'images/bkgdtexture.gif" bgcolor="#FAFAEB"><a href="'+locationPath+langPath+'contact/index.htm" onMouseOut="outTopMenu(\'mainbar10\')" onMouseOver="overTopMenu(\'mainbar10\')"><img name="mainbar10" src="'+imagePath+'images/mainbar10.gif" border="0" alt="'+arClfTopMenu[langID][19]+'"></a></td>');
		document.writeln('				</tr>');
		document.writeln('				</table>');
		document.writeln('			</td>');
		document.writeln('		</tr>');
		document.writeln('		<tr align="left" valign="top">');
		document.writeln('			<td height=2 colspan="10" bgcolor="#BB3333"><img src="'+imagePath+'images/reddot.gif" width="760" height="2" alt="" border=0></td>');
		document.writeln('		</tr>');
		document.writeln('		</form>');
		document.writeln('		</table>');
		document.writeln('		</td>');
		document.writeln('	</tr>');
	}else{
		document.writeln('<table border=0 cellspacing=0 cellpadding=1 width=100%>');
		document.writeln(gicSearchForm);
		document.writeln('<input type="hidden" name="txtonly" value="1">');
		document.writeln('<tr valign=top>');
		document.writeln('	<td><p class="Title"><b>'+arClfTopMenu[langID][3]+'</b></p></td>');
		document.writeln('</tr>');
		document.writeln('<tr valign=middle>');
		document.writeln('	<td><br>[ <a href="'+arClfTopMenu[langID][23]+'" target="_blank">'+arClfTopMenu[langID][7]+'</a> ]&nbsp;&nbsp;');
		document.writeln('[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][22]+'\')">'+arClfTopMenu[langID][21]+'</a> ]&nbsp;&nbsp;');
		document.writeln('[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][12]+'\')">'+arClfTopMenu[langID][13]+'</a> ]&nbsp;&nbsp;');
		document.writeln('[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][15]+'\')">'+arClfTopMenu[langID][16]+'</a> ]&nbsp;&nbsp;');
//		document.writeln('[ <a href="'+arClfTopMenu[langID][1]+'">'+arClfTopMenu[langID][17]+'</a> ]&nbsp;&nbsp;');
		document.writeln('[ <a href="javascript:document.frmSearch.submit();">'+arClfTopMenu[langID][17]+'</a> ]&nbsp;&nbsp;');
		document.writeln('<input type="text" name="query" size="'+arClfTopMenu[langID][4]+'">');
		document.writeln('[ <a href="'+locationPath+langPath+'sitemap/index.htm">'+arClfTopMenu[langID][18]+'</a> ]&nbsp;&nbsp;');
		document.writeln('[ <a href="'+locationPath+langPath+'contact/index.htm">'+arClfTopMenu[langID][19]+'</a> ]</td>');
		document.writeln('</tr>');
		document.writeln('</form>');
		document.writeln('<tr valign=top>');
		document.writeln('	<td><hr width=100%></td>');
		document.writeln('</tr>');
		document.writeln('</table>');
	}
}

function changeLanguage(switchLang){
	var langs = ["tc", "en", "sc"];
	var fromLang = '';
	var toLang = '';
	for(counter = 0; counter < langs.length; counter++){
		if(location.href.search('/'+langs[counter]+'/')!= -1){
			fromLang = langs[counter];
		}
	}
/*	if(switchLang != '/text/' && switchLang != '/graphics/'){
		switch(switchLang){
			case '/tc/': toLang = langs[0]; break;
			case '/en/': toLang = langs[1]; break;
			case '/sc/': toLang = langs[2]; break;
		}
		location.href = location.href.replace(fromLang, toLang);
	}else{
		var switchGraphic=/\/cgi-bin\/rvd\/TextOnly\.pl\?search\=/;
		var switchText="/cgi-bin/rvd/TextOnly.pl?search=";
		switch (switchLang){
			case '/graphics/':
				location.href = location.href.replace(switchGraphic, "");
				break;
			case '/text/':
				location.href = location.href.replace('/'+fromLang+'/', switchText+'/'+fromLang+'/');
				break;
		}
	}
	return true;
*/	
	
	var currentPath=location.href.toString();
	var switchTc='/tc/';
	var switchEn='/en/';
if(location.href.toString().search('www0.rvd.gov.hk')!=-1){
	var switchGraphic=/\/cgi-bin\/rvd\/TextOnly\.pl\?search\=/;
	var switchText="/cgi-bin/rvd/TextOnly.pl?search=";
}else{
	var switchGraphic=/\/cgi-bin\/rvd\/TextOnly\.pl\?search\=/;
	var switchText="/cgi-bin/rvd/TextOnly.pl?search=";
}
	var urlVars=document.location.search;

//	alert(urlVars);
if(location.href.toString().search('se.cgi')!=-1){
	switch (switchLang){
		case '/graphics/':
			currentPath=currentPath.replace(switchGraphic, "");
//			currentPath=currentPath.replace(switchTc, switchText+switchTc);
			break;
		case '/text/':
			if(langID==1){
				alert("Search function for text only version is not available")
			}else{
				alert("本網站並沒有提供純文字版本的搜尋功能")
			}
			break;
		case '/gb/':
			currentPath=currentPath.replace('http://', 'http://'+gb_urlPath);
			currentPath=currentPath.replace("mode=287", "mode=288");
			break;
		case '/en/':
			currentPath=currentPath.replace("mode=288", "mode=287");
			currentPath=currentPath.replace(gb_urlPath, "");
			break;
		case '/tc/':
			currentPath=currentPath.replace("mode=287", "mode=288");
			currentPath=currentPath.replace(gb_urlPath, "");
			break;
		default:
	}
}
else{
	if(location.href.search('ogcio.devprj.com')!=-1){
		var switch2TextPath = "/20090121_rvd.gov.hk/test/rvd";
	}else{
		var switch2TextPath = "";
	}
	switch (switchLang){
		case '/graphics/':
//			currentPath=currentPath.replace(switchGraphic, "");
			currentPath=currentPath.replace(switchGraphic, switch2TextPath);
			break;
		case '/text/':
			currentPath=currentPath.replace(switch2TextPath, "");
			currentPath=currentPath.replace(switchEn, switchText+switchEn);
			currentPath=currentPath.replace(switchTc, switchText+switchTc);
			break;
		case '/sc/':
		case '/en/':
		case '/tc/':
			currentPath=currentPath.replace('/'+fromLang+'/', switchLang);
			break;
		default:
	}
}
	if(!isText){
		document.location=currentPath;
	}else{
		if(urlVars==''){
			document.location=document.location+'?search=/tc/sitemap/index.htm';
		}else{
			document.location=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(){
	if(!isText){
		document.writeln('<td rowspan=6 width=148 background="'+locationPath+'/images/left_bg.gif">');
		document.writeln('	<table border=0 cellspacing=0 cellpadding=0 width=148>');
		document.writeln('	<tr valign=top>');
		document.writeln('		<td colspan=2><img src="'+locationPath+'/images/nav_head.gif" border=0 align=top alt=""></td>');
		document.writeln('	</tr>');
		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"+i+", '"+pic+"');";
					var overAction = " onMouseOver=\"simg(pic"+i+", '"+menuObj[i].onPic+"');";

					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 colspan=2><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>');
				}
			}
		}
if (langID==1)
{
		//document.writeln('	<tr><td colspan=2 align="center"><br><a href="'+locationPath+langPath+'5day.htm"><img src="'+locationPath+'/images/common/5day_icon.jpg" alt="5 day week" border="0"></a></td></tr>');
		document.writeln('	<tr valign=top><td colspan=2 align="center"><br><a href="https://www.rvdpi.gov.hk/epayment/public/pihHome.do?req_locale=en_US" target="_blank"><img src="'+imagePath+'images/icon/pio.gif" alt="Property Information Online" border="0"></a></td></tr>');
		//document.writeln('	<tr valign=top><td colspan=2 align="center"><br><a href="javascript:PopWin(\''+locationPath+'/video/video.htm?m=pay0103_en.wmv&t=RVD&w=512&h=429\',\'pop1\',562,479)"><img src="'+imagePath+'images/icon/pay0103.gif" alt="Rates and Government rent due January 29" border="0"></a></td></tr>');
		//document.writeln('	<tr valign=top><td colspan=2 align="center"><br><a href="'+locationPath+'/images/rates_eng1.wmv" target="_blank"><img src="'+imagePath+'images/icon/pay.gif" alt="Pay Oct-Dec Quarterly Rates/Government Rent" border="0"></a></td></tr>');
		document.writeln('	<tr valign=top><td colspan=2 align="center"><br><a href="'+locationPath+langPath+'building/index.htm"><img src="'+imagePath+'images/icon/dbn.gif" alt="Display Building Numbers" border="0"></a></td></tr>');
		document.writeln('	<tr valign=top><td colspan=2 align="center"><br><a href="'+locationPath+langPath+'news/toolkit.htm"><img src="'+imagePath+'images/icon/toolkit.gif" alt="Provide Information to RVD Upon Sale/Lease" border="0"></a></td></tr>');
		document.writeln('	<tr valign=top><td colspan=2 align="center"><br><a href="'+locationPath+langPath+'concession/index.htm"><img src="'+imagePath+'images/icon/rc_icon.gif" alt="Rates Concession" border="0"></a></td></tr>');
		document.writeln('	<tr valign=top><td colspan=2 align="center"><br><a href="'+locationPath+langPath+'publications/publications.htm#parte"><img src="'+imagePath+'images/icon/names_of_buildings.gif" alt="Names of Buildings" border="0"></a></td></tr>');
		//document.writeln('	<tr><td colspan=2 align="center"><br><a href="'+locationPath+langPath+'news/news_57.htm" onclick="javascript:PopWin(\''+locationPath+langPath+'home/popup3.htm\',\'popup3\',400,180)"><img src="'+imagePath+'images/icon/rc_icon.gif" alt="Rates Concession" border="0"></a></td></tr>');
//		document.writeln('	<tr><td colspan=2><br><a href="'+locationPath+langPath+'issues/hkrates160th.htm"><img src="'+locationPath+'/images/common/icon.gif" alt="Hong Kong Rates 160th Anniversary" border="0"></a></td></tr>');
}
else
{
		//document.writeln('	<tr><td colspan=2 align="center"><br><a href="'+locationPath+langPath+'5day.htm"><img src="'+locationPath+'/images/common/5day_icon.jpg" alt="5天工作周" border="0"></a></td></tr>');
		document.writeln('	<tr valign=top><td colspan=2 align="center"><br><a href="https://www.rvdpi.gov.hk/epayment/public/pihHome.do?req_locale=zh_TW" target="_blank"><img src="'+imagePath+'images/icon/pio.gif" alt="物業資訊網" border="0"></a></td></tr>');
		//document.writeln('	<tr valign=top><td colspan=2 align="center"><br><a href="javascript:PopWin(\''+locationPath+'/video/video.htm?m=pay0103_tc.wmv&t=RVD&w=512&h=429\',\'pop1\',562,479)"><img src="'+imagePath+'images/icon/pay0103.gif" alt="2010年1月至3月季度差餉及／或地租須於1月29日或之前繳交" border="0"></a></td></tr>');
		//document.writeln('	<tr valign=top><td colspan=2 align="center"><br><a href="'+locationPath+'/images/rates_cant1.wmv" target="_blank"><img src="'+imagePath+'images/icon/pay.gif" alt="繳交10-12月季度差餉及地租" border="0"></a></td></tr>');
		document.writeln('	<tr valign=top><td colspan=2 align="center"><br><a href="'+locationPath+langPath+'building/index.htm"><img src="'+imagePath+'images/icon/dbn.gif" alt="門牌裝妥 方便你我" border="0"></a></td></tr>');
		document.writeln('	<tr valign=top><td colspan=2 align="center"><br><a href="'+locationPath+langPath+'news/toolkit.htm"><img src="'+imagePath+'images/icon/toolkit.gif" alt="向估價署提供買賣／租賃資料" border="0"></a></td></tr>');
		document.writeln('	<tr valign=top><td colspan=2 align="center"><br><a href="'+locationPath+langPath+'concession/index.htm"><img src="'+imagePath+'images/icon/rc_icon.gif" alt="差餉寬減" border="0"></a></td></tr>');
		document.writeln('	<tr valign=top><td colspan=2 align="center"><br><a href="'+locationPath+langPath+'publications/publications.htm#parte"><img src="'+imagePath+'images/icon/names_of_buildings.gif" alt="樓宇名稱" border="0"></a></td></tr>');
		//document.writeln('	<tr><td colspan=2 align="center"><br><a href="'+locationPath+langPath+'news/news_57.htm" onclick="javascript:PopWin(\''+locationPath+langPath+'home/popup3.htm\',\'popup3\',400,150)"><img src="'+imagePath+'images/icon/rc_icon.gif" alt="差餉寬減" border="0"></a></td></tr>');
//		document.writeln('	<tr><td colspan=2><br><a href="'+locationPath+langPath+'issues/hkrates160th.htm"><img src="'+locationPath+'/images/common/icon.gif" alt="香港差餉160周年" border="0"></a></td></tr>');
}
		document.writeln('	</table>');
		document.writeln('</td>');
	}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;');
					}
				}
			}
		}
if (langID==1)
{
		//document.writeln('[ <a href="'+locationPath+langPath+'5day.htm">5 day week</a> ]');
		document.writeln('[ <a href="https://www.rvdpi.gov.hk/epayment/public/pihHomePure.do?req_locale=en_US" target="_blank">Property Information Online</a> ]');
		//document.writeln('[ <a href="'+locationPath+'/images/rates_eng1.wmv" target="_blank">Pay Oct-Dec Quarterly Rates/Government Rent</a> ]');
		document.writeln('[ <a href="'+locationPath+langPath+'building/index.htm">Display Building Numbers</a> ]');
		document.writeln('[ <a href="'+locationPath+langPath+'news/toolkit.htm">Provide Information to RVD Upon Sale/Lease</a> ]');
		document.writeln('[ <a href="'+locationPath+langPath+'concession/index.htm">Rates Concession</a> ]');
		document.writeln('[ <a href="'+locationPath+langPath+'publications/publications.htm#parte">Names of Buildings</a> ]');
		//document.writeln('[ <a href="'+locationPath+langPath+'news/news_57.htm" onclick="javascript:PopWin(\'../home/popup3.htm\',\'popup3\',400,180)">Rates Concession</a> ]');
//		document.writeln('[ <a href="'+locationPath+langPath+'issues/hkrates160th.htm">Hong Kong Rates 160th Anniversary</a> ]');
}
else
{
		//document.writeln('[ <a href="'+locationPath+langPath+'5day.htm">5天工作周</a> ]');
		document.writeln('[ <a href="https://www.rvdpi.gov.hk/epayment/public/pihHomePure.do?req_locale=zh_TW" target="_blank">物業資訊網</a> ]');
		//document.writeln('[ <a href="'+locationPath+'/images/rates_cant1.wmv" target="_blank">繳交10-12月季度差餉及地租</a> ]');
		document.writeln('[ <a href="'+locationPath+langPath+'building/index.htm">門牌裝妥 方便你我</a> ]');
		document.writeln('[ <a href="'+locationPath+langPath+'news/toolkit.htm">向估價署提供買賣／租賃資料</a> ]');
		document.writeln('[ <a href="'+locationPath+langPath+'concession/index.htm">差餉寬減</a> ]');
		document.writeln('[ <a href="'+locationPath+langPath+'publications/publications.htm#parte">樓宇名稱</a> ]');
		//document.writeln('[ <a href="'+locationPath+langPath+'news/news_57.htm" onclick="javascript:PopWin(\'../home/popup3.htm\',\'popup3\',400,150)">差餉寬減</a> ]');
//		document.writeln('[ <a href="'+locationPath+langPath+'issues/hkrates160th.htm">香港差餉160周年</a> ]');
}
		document.writeln('</td></tr>');
		document.writeln('<tr valign=top>');
		document.writeln('	<td colspan=100><hr width=100%></td>');
		document.writeln('</tr>');
		if(menuObj[Selected_ID].hasChild=="Y"){
			getSubMenu();
		}
		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){
	var strText;
	
	if(showlink)
		strText = "<a href='"+menuObj[Selected_ID].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(){
	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+"]")+"("+Selected_ID+", "+Selected_Sub+", false)");
			}else{
				showPath = eval(eval("functionList["+i+"]")+"("+Selected_ID+", "+Selected_Sub+", true)") + "<span class='path_arrow'> > </span>" + showPath;
			}
		}
	}
	showPath = "<span class='path_arrow'> > </span>" + showPath;
//	alert(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(Selected_ID==1){
		menuObj[1].caption = "Commissioner's Message";
		menuObj[1].chiCaption = "署長的話";
	}

	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>');
	}else{
		document.writeln('<table border=0 cellspacing=0 cellpadding=0>');
		document.writeln('<tr><td><h2>'+eval(eval("functionList["+functionNum+"]")+"("+Selected_ID+", "+Selected_Sub+", false)")+'</h2></td></tr>');
		document.writeln('</table>');
	}
}

var resizeFlag;
var footerY = 600;

function moveDivs(layerObj, inObj){
	layerObj.top  = inObj;
} 

function moveTopDivs(layerObj, inObjTop, inObjLeft){
	layerObj.top  = inObjTop;
	layerObj.left  = inObjLeft;
} 

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){
	if (document.layers)
		{document.writeln('<layer name=LeftLayer_'+ID+' top=0 left=0 width=26 height=26 visibility="hide" OnMouseOver="simg(pic'+ID+', \''+menuObj[ID].onPic+'\');MM_showHideLayers(\'LeftLayer_'+ID+'\',\'\',\'show\','+ID+'); return true;" OnMouseOut="simg(pic'+ID+', \''+menuObj[ID].offPic+'\');MM_showHideLayers(\'LeftLayer_'+ID+'\',\'\',\'hidden\','+ID+'); return true;">');}
	else
		{document.writeln('<div id="LeftLayer_'+ID+'" style="position:absolute; left:0; top:0; width:26; height:26; z-index:1; visibility: hidden"> ');}
	document.writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0" OnMouseOver="simg(pic'+ID+', \''+menuObj[ID].onPic+'\');MM_showHideLayers(\'LeftLayer_'+ID+'\',\'\',\'show\','+ID+'); return true;" OnMouseOut="simg(pic'+ID+', \''+menuObj[ID].offPic+'\');MM_showHideLayers(\'LeftLayer_'+ID+'\',\'\',\'hidden\','+ID+'); return true;">');
	for(var i=1;i<y;i++){
		if (subMenuObj[i])
		{
			if (subMenuObj[i].menuID==ID && subMenuObj[i].navigationMenu=="Y"){
				var outAction = " onMouseOut=\"simg(pic"+ID+", '"+menuObj[ID].offPic+"');simg(submenu_"+ID+"_"+subMenuObj[i].id+", '"+imagePath+"images/submenu/layer_btn_"+ID+"_"+subMenuObj[i].id+".gif');\"";
				var overAction = " onMouseOver=\"simg(pic"+ID+", '"+menuObj[ID].onPic+"');simg(submenu_"+ID+"_"+subMenuObj[i].id+", '"+imagePath+"images/submenu/layer_btn_"+ID+"_"+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/layer_btn_'+ID+'_'+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:1; 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(i);
			}
		}
	}	
}

//function for generating the footer
function getFooter(){
	var altText='Top';
	if(langID!=1) altText='頁首';
	
	var altBack='Back';
	if(langID!=1) altBack='回上頁';
	
	var copyYear='2005';
	var noticesLink=locationPath+langPath+'notices/index.htm';
	var privacyLink=locationPath+langPath+'privacy/index.htm';
	var noticeText='Important notices';
	var	privacyText='Privacy Policy';
	var revisionText='Last revision date: ';	
	var reviewText='Last review date: ';	
	if (revisionDate==''||revisionDate=='MM/DD/YYYY') revisionDate='06/01/2005';
	if (reviewDate==''||reviewDate=='MM/DD/YYYY') reviewDate='06/01/2005';
	if (langID==2){
		noticeText='重要告示';
		privacyText='私隱政策';
		revisionText='修訂日期： ';	
		reviewText='覆檢日期： ';	
	}
	var monthArray=new Array();
	monthArray[0]='Jan';
	monthArray[1]='Feb';
	monthArray[2]='Mar';
	monthArray[3]='Apr';
	monthArray[4]='May';
	monthArray[5]='Jun';
	monthArray[6]='Jul';
	monthArray[7]='Aug';
	monthArray[8]='Sep';
	monthArray[9]='Oct';
	monthArray[10]='Nov';
	monthArray[11]='Dec';
	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="3"><img src="'+imagePath+'images/botdot.jpg" alt="" width="100%" height="3" border=0></td>');
		document.writeln('		</tr>');
		document.writeln('		<tr bgcolor="#FFFFFF">');
		document.writeln('			<td height="15" bgcolor="#FFFFFF" class="footer"><b>'+copyYear+'</b> <img src="'+imagePath+'../images/copy.gif" alt="" width="12" height="11"> | <b><a href="'+noticesLink+'" class="footer">'+noticeText+'</a></b> | <b><a href="'+privacyLink+'" class="footer">'+privacyText+'</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> | <b><a href="'+privacyLink+'" class="footer">'+privacyText+'</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_1.gif" border=0 alt="*">';
		bulletPath2='<img src="'+locationPath+'/images/bullet_2.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"){
				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"){
					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==i && subMenuObj[j].sitemap=="Y")
							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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

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,resizable){
	if(typeof(resizable)=="undefined")
	{
		resizable="no";
	}
	else
	{
		resizable="yes";
	}
	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=no,resizable="+resizable+",pageXOffset=0,pageYOffset=0,top=0,left=0,width=" + x + ",height=" + y + "')");
	if ( nw.focus != null)
	{nw.focus();}
}