/*************************** MouseOver & MouseOut Function **************************************/
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_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_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 over(imgname, filname){
	if (document.images)
		{imgname.src = filname;}
}

function out(imgname, filname){
	if (document.images)
		{imgname.src = filname;}
}

/*************************** MouseOver & MouseOut Function Finish **************************************/


//function for check current Path
function getLocationPath(){
	var locPath=location.href.toString();
	var subPath='';

	if(location.href.toString().search('dev02.westcomzivo.com/landreg')!=-1){
		if(location.href.toString().search('/gb/')!=-1)
		{
			subPath="ht"+"tp://common.westcomzivo.com/gb/dev02.westcomzivo.com/landreg"
		}
		else
		{
			subPath="ht"+"tp://dev02.westcomzivo.com/landreg"
		}
		HomePath="dev02.westcomzivo.com/landreg"
	}
	if(location.href.toString().search('www0.landreg.gov.hk')!=-1){
		if(location.href.toString().search('/gb/')!=-1)
		{
			subPath="ht"+"tp://sc.info.gov.hk/gb/www0.landreg.gov.hk"
		}
		else
		{
			subPath="ht"+"tp://www0.landreg.gov.hk"
		}
		HomePath="www0.landreg.gov.hk"
	}
	if(location.href.toString().search('www.landreg.gov.hk')!=-1){
		if(location.href.toString().search('/gb/')!=-1)
		{
			subPath="ht"+"tp://sc.info.gov.hk/gb/www.landreg.gov.hk"
		}
		else
		{
			subPath="ht"+"tp://www.landreg.gov.hk"
		}
		HomePath="www.landreg.gov.hk"
	}
	if(location.href.toString().search('www.cms.landreg.gov.hk')!=-1){
		if(location.href.toString().search('/gb/')!=-1)
		{
			subPath="ht"+"tp://sc.info.gov.hk/gb/www.cms.landreg.gov.hk"
		}
		else
		{
			subPath="ht"+"tp://www.cms.landreg.gov.hk"
		}
		HomePath="www.cms.landreg.gov.hk"
	}
	if(location.href.toString().search('www0.cms.landreg.gov.hk')!=-1){
		if(location.href.toString().search('/gb/')!=-1)
		{
			subPath="ht"+"tp://sc.info.gov.hk/gb/www0.cms.landreg.gov.hk"
		}
		else
		{
			subPath="ht"+"tp://www0.cms.landreg.gov.hk"
		}
		HomePath="www0.cms.landreg.gov.hk"
	}
	if(location.href.toString().search('L:')!=-1){
		if(location.href.toString().search('/gb/')!=-1)
		{
			//subPath="ht"+"tp://sc.info.gov.hk/gb/www0.cms.landreg.gov.hk"
		}
		else
		{
			subPath="file:///L://MCSD/landreg/"
		}
		HomePath="file:///L://MCSD/landreg/"
	}
	if(location.href.toString().substr(7).search(/\w\:/)!=-1){
		var temploca = location.href.toString();
		var tempDriveName = temploca.substr(7).substr(temploca.substr(7).search(/\w\:/),2);
		
		var trimDomainPath = temploca.substr(temploca.substr(7).search(/\w\:/)+9);
		var localFolder = temploca.substr(8+tempDriveName.length,temploca.search(/\/(en|tc)\//)-7-tempDriveName.length);
		
		subPath ='file:///'+tempDriveName+'/'+localFolder+''
		HomePath='file:///'+tempDriveName+'/'+localFolder+''
	}
	if(location.href.toString().search('se.cgi')!=-1){
		subPath="ht"+"tp://www.landreg.gov.hk"
		if(location.href.toString().search('/gb/')!=-1)
		{
			subPath="ht"+"tp://sc.info.gov.hk/gb/www.landreg.gov.hk"
		}
		else
		{
			subPath="ht"+"tp://www.landreg.gov.hk"
		}
		HomePath="www.landreg.gov.hk"
	}
// Added for testing purpose, subject to delete
	if (location.href.indexOf('ogciolandreg.arcotect.com')!=-1){
		subPath="http://ogciolandreg.arcotect.com";
		if(location.href.indexOf('/gb/')!=-1)
		{
			subPath="http://sc.info.gov.hk/gb/www.landreg.gov.hk";
		}
		else
		{
			subPath="http://ogciolandreg.arcotect.com";
		}
		HomePath="ogciolandreg.arcotect.com";
	}

	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);
	}

	locationPath=subPath;
}

//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%>');
	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/mainbar/" + obj + "_f2.gif'");
      }
}

//function for mouse out effect on left menu
function outTopMenu(obj)
{
      if (document.images){
		eval("document.images." + obj + ".src = '"+imagePath+"images/mainbar/" + 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, chiCaption,url,offPic,onPic,hasChild,sitemap,navigationMenu)
{
	menuObj[x] = new Object();
	menuObj[x].id = sectionID;
	menuObj[x].caption = caption;
	menuObj[x].chiCaption = chiCaption;
	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, chiCaption, url, sitemap, navigationMenu)
{
	subMenuObj[y] = new Object();
	subMenuObj[y].id = subSectionID;
	subMenuObj[y].menuID = menuID;
	subMenuObj[y].caption = caption;
	subMenuObj[y].chiCaption = chiCaption;
	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, chiCaption, url, chi_url, Pic)
{
	HomeIconObj[z] = new Object();
	HomeIconObj[z].id = ID;
	HomeIconObj[z].caption = caption;
	HomeIconObj[z].chiCaption = chiCaption;
	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(){
	document.writeln('<meta http-equiv="pics-label" content=\'(pics-1.1 "http://www.icra.org/ratingsv02.html" comment "ICRAonline EN v2.0" l gen true for "http://www.landreg.gov.hk" r (nz 1 vz 1 lz 1 oz 1 cz 1) gen true for "http://sc.info.gov.hk/" r (nz 1 vz 1 lz 1 oz 1 cz 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://www.landreg.gov.hk" r (n 0 s 0 v 0 l 0)) gen true for "http://sc.info.gov.hk/" r (n 0 s 0 v 0 l 0))\'><META http-equiv=Content-Type content="text/html; charset=big5">');
	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='+printfriendpixel+'>');
		if(printPage!=1){
			getTopMenu();
			document.writeln('	<tr valign=top>');
			document.writeln('		<td colspan=2><img src="'+imagePath+'/images/visual.jpg" border=0 align=top alt=""></td>');
			document.writeln('	</tr>');
			document.writeln('	<tr valign=top>');
			getLeftMenu(); 
		}
		document.writeln('	<td background="'+locationPath+'/images/bg_'+bg+'.gif" width="842">');
		getTopic();
		document.writeln('		<table border=0 cellspacing=0 cellpadding=0 width=100%>');
		document.writeln('		<tr valign=top>');
		document.writeln('			<td rowspan=2 width=20><img src="'+locationPath+'/images/spacer.gif" border=0 align=top alt="" width=20 height=0></td>');
		document.writeln('			<td><img src="'+locationPath+'/images/spacer.gif" border=0 align=top alt="" height=0></td>');
		document.writeln('			<td rowspan=2 width=20><img src="'+locationPath+'/images/spacer.gif" border=0 align=top alt="" width=20 height=0></td>');
		document.writeln('		</tr>');
		document.writeln('		<tr>');
		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('			<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/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){
			getHomeIcon();
		}
		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){
			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="../../images/homeicon'+langPath+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="../../images/homeicon'+langPath+HomeIconObj[i].pic+'" border=0 align=top alt="'+HomeIconObj[i].chiCaption+'"></a></td>');
			}
			rows++;
			if(rows>=((printPage!=1)?6:4)){
				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>=((printPage!=1)?6:4)){
				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>');
	document.writeln('<tr>');
	document.writeln('	<td colspan="3" align="center">');
	if(langID==1){
		document.writeln('		Best viewed with 1024 x 768 resolution on IE5.0 or Netscape 4.7 or above');
	}else{
		document.writeln('用 IE 5.0 或 Netscape 4.7 或 以 上 版 本 以 1024 x 768 解 像 度<br />觀 看 可 得 到 更 佳 效 果');
	}	
	document.writeln('	</td>');
	document.writeln('</tr>');
}

//function for generating the top menu
function getTopMenu(){
	
	if(langID==1){
		var extarSpacer = '<td background="'+imagePath+'images/branding_bg.jpg" width="100%"><img src="'+locationPath+'/images/spacer.gif" border="0" height=1 width=395 alt=""></td>';
	}else{
		var extarSpacer = '<td background="'+imagePath+'images/branding_bg.jpg" width="100%"><img src="'+locationPath+'/images/spacer.gif" border="0" height=1 width=395 alt=""></td>';
	}

	var gicSearchForm;
	gicSearchForm='<form name="frmSearch" action="'+arClfTopMenu[langID][1]+'" method="get">\n';
	gicSearchForm+='<input type="hidden" name="tpl_id" value="landreg">\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="landreg_home">\n';
	gicSearchForm+='<input type="hidden" name="gp1" value="landreg_home">\n';
	gicSearchForm+='<input type="hidden" name="web" value="this">\n';
	/*gicSearchForm=gicSearchForm+'<INPUT name="mode" type="hidden" value="'+arClfTopMenu[langID][2]+'">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="lmode" type="hidden" value="1">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="pq" type="hidden" value="">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="pg" type="hidden" value="">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="pn" type="hidden" value="0">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="qm" type="hidden" value="0">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="la" type="hidden" value="1">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="de" type="hidden" value="0">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="so" type="hidden" value="0">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="nu" type="hidden" value="10">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="ca" type="hidden" value="0">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="ta" type="hidden" value="all">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="fu" type="hidden" value="">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="fd" type="hidden" value="">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="ma" type="hidden" value="100">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="ft_1" type="hidden" value="alltype">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="gr_1" type="hidden" value="'+arClfTopMenu[langID][20]+'">'*/
	/*
	gicSearchForm='<form name="frmSearch" action="'+arClfTopMenu[langID][1]+'" method="get" target="_blank">\n';
	gicSearchForm=gicSearchForm+'<input type="hidden" value="'+arClfTopMenu[langID][2]+'" name="mode">\n';
	gicSearchForm=gicSearchForm+'<input type="hidden" value="alltype" name="ft_1">\n';
	gicSearchForm=gicSearchForm+'<input type="hidden" value="100" name="ma">\n';
	gicSearchForm=gicSearchForm+'<input type="hidden" value="'+arClfTopMenu[langID][20]+'" name="gr_1">\n';*/
	
	if(!isText){
		document.writeln('	<tr>');
		document.writeln('	<td colspan="2">');
		document.writeln('		<table width="1000" border="0" cellpadding="0" cellspacing="0" background="'+locationPath+'/images/bg.gif" style="background-repeat:no-repeat;">');
		document.writeln(gicSearchForm);
		document.writeln('		<tr align="left" valign="top">');
		document.writeln('			<td class="sidebar" background="'+imagePath+'images/branding.jpg" bgcolor="#FAFAEB">');
		document.writeln('				<table width="1000" border="0" cellpadding="0" cellspacing="0">');
		document.writeln('				<tr valign="top">');
		document.writeln('					<td class="sidebar" background="'+locationPath+'/images/branding_bg.jpg" bgcolor="#FAFAEB"><a href="ht'+'tp://'+HomePath+'/index.htm"><img src="'+imagePath+'/images/branding.jpg" border=0 alt="'+arClfTopMenu[langID][3]+'"></a></td>');
		document.writeln('					<td background="'+locationPath+'/images/branding_bg.jpg" bgcolor="#FAFAEB" width="100%">&nbsp;</td>');
		document.writeln('					<td background="'+locationPath+'/images/branding_bg.jpg" colspan="2" valign="bottom" align=right bgcolor="#FAFAEB"><a href="'+arClfTopMenu[langID][5]+'" target="_blank"><img name="BrandHK" src="'+locationPath+langPath+'/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="'+locationPath+'/images/branding_bg.jpg" bgcolor="#FAFAEB">');
		document.writeln('				<table width="1000" border="0" cellpadding="0" cellspacing="0">');
		document.writeln('				<tr valign="bottom">');
		document.writeln('					<td width="5%"><a href="'+arClfTopMenu[langID][23]+'" target="_blank" onMouseOut="outTopMenu(\'mainbar1\')" onMouseOver="overTopMenu(\'mainbar1\')"><img name="mainbar1" src="'+imagePath+'images/mainbar/mainbar1.gif" border="0" alt="'+arClfTopMenu[langID][7]+'"></a></td>');

		document.writeln('					<td width="5%"><a href="javascript:changeLanguage(\''+arClfTopMenu[langID][12]+'\')" onMouseOut="outTopMenu(\'mainbar3\')" onMouseOver="overTopMenu(\'mainbar3\')"><img name="mainbar3" src="'+imagePath+'images/mainbar/mainbar3.gif" border="0" alt="'+arClfTopMenu[langID][13]+'"></a></td>');
		document.writeln('					<td width="5%"><a href="javascript:changeLanguage(\''+arClfTopMenu[langID][15]+'\')" onMouseOut="outTopMenu(\'mainbar4\')" onMouseOver="overTopMenu(\'mainbar4\')"><img name="mainbar4" src="'+imagePath+'images/mainbar/mainbar4.gif" border="0" alt="'+arClfTopMenu[langID][16]+'"></a></td>');
		document.writeln('					<td width="5%"><img src="'+imagePath+'images/mainbar/mainbar5.gif" border="0"></td>');
		document.writeln(extarSpacer);
		document.writeln('					<td><a href="javascript:document.frmSearch.submit();" onMouseOut="outTopMenu(\'mainbar6\')" onMouseOver="overTopMenu(\'mainbar6\')"><img name="mainbar6" src="'+imagePath+'images/mainbar/mainbar6.gif" border="0" alt="'+arClfTopMenu[langID][17]+'"></a></td>');
		document.writeln('					<td align=center><input type="text" name="query" size="'+arClfTopMenu[langID][4]+'" class="search"></td>');
		document.writeln('					<td><a href="javascript:document.frmSearch.submit();" onMouseOut="outTopMenu(\'mainbar8\')" onMouseOver="overTopMenu(\'mainbar8\')"><img name="mainbar8" src="'+imagePath+'images/mainbar/mainbar8.gif" border="0" alt="'+arClfTopMenu[langID][17]+'"></a></td>');
		document.writeln('					<td><a href="'+locationPath+langPath+'sitemap/index.htm" onMouseOut="outTopMenu(\'mainbar9\')" onMouseOver="overTopMenu(\'mainbar9\')"><img name="mainbar9" src="'+imagePath+'images/mainbar/mainbar9.gif" border="0" alt="'+arClfTopMenu[langID][18]+'"></a></td>');
		document.writeln('					<td bgcolor="#FAFAEB"><a href="'+locationPath+langPath+'contact/contact.htm" onMouseOut="outTopMenu(\'mainbar10\')" onMouseOver="overTopMenu(\'mainbar10\')"><img name="mainbar10" src="'+imagePath+'images/mainbar/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="'+locationPath+'/images/reddot.gif" width="1000" 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('<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(l) {
	var lh = parent.location.href;
	lh = lh.replace("/tc/", l);
	lh = lh.replace("/chs/", l);
	lh = lh.replace("/en/", l);
	parent.location.href = lh;
}
/*
function changeLanguage(switchLang){
	var currentPath=location.href.toString();
	var switchTc='/tc/';
	var switchEn='/en/';
if(location.href.toString().search('www0.langreg.gov.hk')!=-1)
{
	var switchGraphic=/\/cgi-bin\/langreg\/TextOnly\.pl\?search\=/;
	var switchText="/cgi-bin/langreg1/TextOnly.pl?search=";
}
else
{
	var switchGraphic=/\/cgi-bin\/langreg\/TextOnly\.pl\?search\=/;
	var switchText="/cgi-bin/langreg/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='http://'+gb_urlPath+locationPath.substring(7, locationPath.length)+switchTc;
			currentPath=currentPath.replace('http://', 'http://'+gb_urlPath);
			currentPath=currentPath.replace("mode=78", "mode=79");
			break;
		case '/en/':
			currentPath=currentPath.replace("mode=79", "mode=78");
			currentPath=currentPath.replace(gb_urlPath, "");
			break;
		case '/tc/':
			currentPath=currentPath.replace("mode=78", "mode=79");
			currentPath=currentPath.replace(gb_urlPath, "");
			break;
		default:
	}
}
else{
	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;
			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:
	}
}
	if(currentPath.search('oi-ind-u-')!=-1){
		switch (switchLang){
			case '/en/':
				currentPath=currentPath.replace(/\-\d{1,2}\.htm/, '-a.htm');
				break;
			case '/tc/':
			case '/gb/':
				currentPath=currentPath.replace(/\-\w{1}\.htm/, '-1.htm');
				break;
			default:
		}
	}
	if(!isText){
		document.location=currentPath;
	}else{
		if(urlVars==''){
			document.location=document.location+'?search=/tc/sitemap/index.htm';
		}else{
			document.location=currentPath;
		}
	}
//	alert(currentPath);
}
*/
function getCaption(menu, i){
	var showAlt;
	var showID = '';
	showID = (typeof showSiteMapIDFlag == "undefined")?'':i+' : '; // typeof showSiteMapIDFlag == "undefined"
	if(langID==1)
		eval('showAlt="'+showID+'"+'+menu+'['+i+'].caption'); //"'+showID+'"+
	else
		eval('showAlt="'+showID+'"+'+menu+'['+i+'].chiCaption');
	return showAlt;
}


function getLeftMenu(){
		document.writeln('<td rowspan=6 width=148 background="'+locationPath+'/images/btn_bg.jpg" valign="top">');
		document.writeln('	<table border=0 cellspacing=0 cellpadding=0 width=148>');
		document.writeln('	<tr>');
		document.writeln('		<td valign="top"><img src="'+locationPath+'/images/btn_bg2.jpg" width="10" height="160" /></td>');
        document.writeln('	    <td><table width="159" 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"+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>');
				}
			}
		}
		document.writeln('		</table></td>');
		document.writeln('	</tr>');
		
if (langID==1)
{
		document.writeln('	<tr><td valign="top"><img src="'+locationPath+'/images/btn_bg2.jpg" width="10" height="10" /></td><td align="center"><br><a href="http://www.iris.gov.hk/" target="_blank"><img src="'+locationPath+'/images/common/vm-iris-is-o.gif" alt="Internet Search Services" border="0"></a></td></tr>');
		document.writeln('	<tr><td valign="top"><img src="'+locationPath+'/images/btn_bg2.jpg" width="10" height="10" /></td><td 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>');
}
else
{
		document.writeln('	<tr><td valign="top"><img src="'+locationPath+'/images/btn_bg2.jpg" width="10" height="10" /></td><td align="center"><br><a href="http://www.iris.gov.hk/" target="_blank"><img src="'+locationPath+'/images/common/vm-iris_is_over.gif" alt="網上查冊服務" border="0"></a></td></tr>');
		document.writeln('	<tr><td valign="top"><img src="'+locationPath+'/images/btn_bg2.jpg" width="10" height="10" /></td><td align="center"><br><a href="'+locationPath+langPath+'5day.htm"><img src="'+locationPath+'/images/common/5day_icon.jpg" alt="五天工作週" border="0"></a></td></tr>');
}
		document.writeln('	</table>');
		document.writeln('</td>');
}

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(!isText){		
		if(Selected_ID == 4 && printPage == 0){
			document.writeln('<div style="position:absolute;top:178;left:658;"><img src="../../images/P_AboutUs.jpg"><br />'+((printPage!=1)?'<div style="width:100%;text-align:right;"><a href=\"javascript:void(0);\" onclick=\"javascript:PrintDocument();\"><img src="'+imagePath+'images/btn_print.gif"  onmouseout="javascript: this.src =\''+imagePath+'images/btn_print.gif\';" onmouseover="javascript: this.src =\''+imagePath+'images/btn_print_o.gif\'" border="0" /></a></div>':"")+'</div>');
		}
		document.writeln('<div style="width:100%"><div style="text-align:left; float: left;"><img src="'+locationPath+'/images/spacer.gif" border=0 align=top alt="" width=20 height=20><img src="'+imagePath+'images/head/head'+titleNum+'.jpg" border=0 align=top alt="'+eval(eval("functionList["+functionNum+"]")+"("+Selected_ID+", "+Selected_Sub+", false)")+'"></div><div style="text-align:right;"><a href=\"javascript:void(0);\" onclick=\"javascript:PrintDocument();\">'+((printPage!=1)?'<img src="'+imagePath+'images/btn_print.gif"  onmouseout="javascript: this.src =\''+imagePath+'images/btn_print.gif\';" onmouseover="javascript: this.src =\''+imagePath+'images/btn_print_o.gif\'" border="0">':"")+'</a></div></div><br /><br />');
	}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(){
	function findPos(obj) {
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
			return [curleft,curtop];
		}
	}
	if(printPage==1){
		var specialHandlePrint = new Array();
		var counter = 0;
		specialHandlePrint[0] = new Array('home/index.htm', 'index');
		var isSpecial = -99;
		for(counter = 0; counter < specialHandlePrint.length; counter ++){
			if(location.href == locationPath+langPath + specialHandlePrint[counter][0]){
				isSpecial = counter;
			}
		}
		if(isSpecial != -99){
			location.href = location.href.replace('/' + specialHandlePrint[isSpecial][1], '/print_' + specialHandlePrint[isSpecial][1]);
		}
		if(document.getElementById('divContNews') != null){
			var curNews = findPos(document.getElementById('divContNews'));
			var curPR = findPos(document.getElementById('divContPR'));
			var curTitle = findPos(document.getElementById('divContTitle'));
			document.getElementById('divContNews').style.top = curNews[1] - 175;
			document.getElementById('divContPR').style.top = curPR[1] - 175;
			document.getElementById('divContTitle').style.top = curTitle[1] - 175;
			
			if(location.href.search("/en/") != -1){
				document.getElementById('divContNews').style.left = curNews[0] - 320;
				document.getElementById('divContPR').style.left = curPR[0] - 335;
				document.getElementById('divContTitle').style.left = curTitle[0] - 335;
			}else{
				document.getElementById('divContNews').style.left = curNews[0] - 280;
				document.getElementById('divContPR').style.left = curPR[0] - 290;
				document.getElementById('divContTitle').style.left = curTitle[0] - 290;
			}
		}else{
			printfriendpixel = "620";
			$('table, img').each(function(){
				if($(this).width() > printfriendpixel){
					$(this).css('width', printfriendpixel + 'px');
					$(this).attr('width', printfriendpixel );
				}
			});
			if(location.href.search("en/public/no16")!=-1){
				$('p, blockquote table, blockquote p, blockquote img, ul li').each(function(){
					if($(this).width() > printfriendpixel - 80){
						$(this).css('width', printfriendpixel-80 + 'px');
						$(this).attr('width', printfriendpixel-80);
					}
				});
			}
			if(location.href.search("form/regs")!=-1 || location.href.search("public/ar01")!=-1  || location.href.search("monthly")!=-1 || location.href.search("public/operation")!=-1 || location.href.search("no25.ht")!=-1 || location.href.search("no23.ht")!=-1){
			/*	$('.Table_whole').css('word-wrap', 'break-word');
				$('.Table_whole').css('word-break', 'break-all');
				$('.Table_whole').css('white-space', 'normal');
				$('blockquote').css('word-wrap', 'break-word');
				$('blockquote').css('word-break', 'break-all');
				$('blockquote').css('white-space', 'normal');*/
			}
			if(location.href.search("services/services_b")!=-1){
				$('.Table_whole').css('word-wrap', 'break-word');
				$('.Table_whole').css('word-break', 'break-all');
				$('.Table_whole').css('white-space', 'normal');
				$('ol li').each(function(){
					if($(this).width() > printfriendpixel - 200){
						$(this).css('width', printfriendpixel-200 + 'px');
						$(this).attr('width', printfriendpixel-200);
					}
				});
				$('blockquote table, blockquote img, ul li').each(function(){
					if($(this).width() > printfriendpixel - 200){
						$(this).css('width', printfriendpixel-200 + 'px');
						$(this).attr('width', printfriendpixel-200);
					}
				});
			}
			if(location.href.search("public/contro")!=-1){
				printfriendpixel = 200
				$('blockquote table, blockquote img').each(function(){
					if($(this).width() > printfriendpixel - 80){
						$(this).css('width', printfriendpixel - 80 + 'px');
						$(this).attr('width', printfriendpixel - 80);
					}
				});
			}
			if(location.href.search("form/regs")!=-1){
				$('blockquote table, blockquote img, ul li').each(function(){
					if($(this).width() > printfriendpixel - 80){
						$(this).css('width', printfriendpixel - 80 + 'px');
						$(this).attr('width', printfriendpixel - 80);
					}
				});
			}
			if( location.href.search("lrcm0502")!=-1){
				$('p, blockquote table, blockquote p, blockquote img, ul li').each(function(){
					if($(this).width() > printfriendpixel - 80){
						$(this).css('width', printfriendpixel-80 + 'px');
						$(this).attr('width', printfriendpixel-80);
					}
				});
			}
			$('td[background*="bg_"] div').after("<br /><br /><br />");
		}
		if(isSpecial == -99){
			window.print();
			window.close();
		}
	}
}

//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="MM_showHideLayers(\'LeftLayer_'+ID+'\',\'\',\'show\','+ID+'); return true;" OnMouseOut="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="MM_showHideLayers(\'LeftLayer_'+ID+'\',\'\',\'show\','+ID+'); return true;" OnMouseOut="MM_showHideLayers(\'LeftLayer_'+ID+'\',\'\',\'hidden\','+ID+'); return true;">');
	document.writeln('<tr><td width="4">&nbsp;</td><td width="5" background="' + locationPath + '/images/Sub_bg.jpg"><img src="' + locationPath + '/images/Sub_bg.jpg" width="5" height="5" /></td><td><table width="100%" border="0" cellspacing="0" cellpadding="0" OnMouseOver="MM_showHideLayers(\'LeftLayer_'+ID+'\',\'\',\'show\','+ID+'); return true;" OnMouseOut="MM_showHideLayers(\'LeftLayer_'+ID+'\',\'\',\'hidden\','+ID+'); return true;">');
	for(var i=1;i<y;i++){
		if (subMenuObj[i])
		{
			if (subMenuObj[i].menuID==ID){
				var outAction = " onMouseOut=\"simg(submenu_"+ID+"_"+subMenuObj[i].id+", '" + imagePath + "images/submenu/"+returnBtnSubMenu(ID, subMenuObj[i].id)+"');\"";
				var overAction = " onMouseOver=\"simg(submenu_"+ID+"_"+subMenuObj[i].id+", '" + imagePath + "images/submenu/"+returnBtnOverSubMenu(ID, subMenuObj[i].id)+"');\"";
				
				document.writeln('	<tr>');
				document.writeln('		<td><a href="'+subMenuObj[i].url+'"' + overAction + outAction + subMenuObj[i].popup+'><img src="'+imagePath+'images/submenu/'+returnBtnSubMenu(ID, subMenuObj[i].id)+'" name="submenu_'+ID+'_'+subMenuObj[i].id+'" alt="'+getSubMenuPath(ID, subMenuObj[i].id, false)+'" border=0></a></td>');
				document.writeln('	</tr>');				
			}
		}
	}
	document.writeln('</table></td></tr></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=0 height=0 visibility="hide">');}
	else
		{document.writeln('<div id="footer_layer" style="position:absolute; left:0; top:0; width:0; height:0; z-index:1; visibility: hidden"> ');}
	document.writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
	document.writeln('<tr valign=top>');
	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='2007';
	var noticesLink=locationPath+langPath+'imp-notice.htm';
	var privacyLink=locationPath+langPath+'privacy.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=default_revisionDate;
	if (reviewDate==''||reviewDate=='MM/DD/YYYY') reviewDate=default_reviewDate;
	if (langID!=1){
		noticeText='重要告示';
		privacyText='私隱政策';
		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="'+((printPage!=1)?"100%":"95%")+'" border="0" cellspacing="0" cellpadding="0">');
		if(topButton=='Y' || backButton.length>0){
			document.writeln('<tr><td><img src="'+locationPath+'/images/spacer.gif" alt="" border="0" width=5 height=1></td><td><table width="100%" border="0" cellspacing="0" cellpadding="0">');
			if(backButton.length>0 && topButton=='Y'){
				document.writeln('	<tr><td><script>getBackBtn("'+backButton+'")</script></td><td><script>getTopBtn(999)</script></td><td width="22"></td></tr>');
			}else{
				if(backButton.length<=0 && topButton=='Y'){
					document.writeln('	<tr><td>&nbsp;</td><td><script>getTopBtn(999)</script></td><td width="22"></td></tr>');
				}else{
					document.writeln('	<tr><td><script>getBackBtn("'+backButton+'")</script></td><td>&nbsp;</td></tr>');
				}
			}
			document.writeln('</table></td></tr>');
		}
		
		document.writeln('	<tr><td><img src="'+locationPath+'/images/spacer.gif" alt="" border="0" width=5 height=10></td></tr>');
		document.writeln('	<tr>');
		document.writeln('		<td><img src="'+locationPath+'/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" background="'+locationPath+'/images/footer_line.jpg"><img src="'+locationPath+'/images/spacer.gif" 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">'+copyYear+'<img src="'+imagePath+'../images/copy.gif" alt="" width="12" height="11"> | <a href="'+noticesLink+'" class="footer">'+noticeText+'</a> | <a href="'+privacyLink+'" class="footer">'+privacyText+'</a></td>');
		if(which_date_shown){
			if (which_date_shown!='1'){
				document.writeln('			<td height="15" align="right" bgcolor="#FFFFFF" class="footer">'+revisionText+showDate+'</td>');
			}else{
				document.writeln('			<td height="15" align="right" bgcolor="#FFFFFF" class="footer">'+reviewText+showDate2+'</td>');
			}
		}else{
			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.gif" border=0 alt="*">';
		bulletPath2='<img src="'+locationPath+'/images/bullet.gif" border=0 alt="*">';
	}else{
		bulletPath1='*';
		bulletPath2='*';
	}
	
	document.writeln('<ul class="content_list">');
	for(var i=1;i<x;i++){
		if(menuObj[i]){
			if(menuObj[i].sitemap=="Y"){
				document.write('<li><a href="'+menuObj[i].url+'"'+menuObj[i].popup+' class="Link">'+getCaption('menuObj', i)+'</a>');
				if(menuObj[i].hasChild=="Y" || menuObj[i].hasChild=="L"){
					document.writeln('		<ul class="content_list">');
					for(var j=1;j<y;j++){
						if (subMenuObj[j].menuID==i)
							document.write('	<li><a href="'+subMenuObj[j].url+'"'+subMenuObj[j].popup+' class="Link">'+getCaption('subMenuObj', j)+'</a>');
							var found = false;
							var contentFound = '';
							for(var k=1;k<_3rdIndex;k++){
								if(_3rdMenuObj[k].parentID==j && _3rdMenuObj[k].menuID==i){
									found = true;
									
									var found4th = false;
									var contentfound4th = '';
									for(var l=1;l<_4thIndex;l++){
										if(_4thMenuObj[l].parentID==k){
											found4th = true;
											contentfound4th += '	<li><a href="'+_4thMenuObj[l].url+'"'+_4thMenuObj[l].popup+' class="Link">'+getCaption('_4thMenuObj', l)+'</a></li>';
										}
									}
									if(found4th){
										contentfound4th='	<ul class="content_list">'+contentfound4th+'</ul>'
									}
									
									if(_3rdMenuObj[k].url.length==0){
										contentFound += '	<li>'+getCaption('_3rdMenuObj', k)+contentfound4th+'</li>';
									}else{
										contentFound += '	<li><a href="'+_3rdMenuObj[k].url+'"'+_3rdMenuObj[k].popup+' class="Link">'+getCaption('_3rdMenuObj', k)+'</a>'+contentfound4th+'</li>';
									}
								}
							}
							if(found){
								document.write('	<ul class="content_list">');
								document.write(contentFound);
								document.write('	</ul>');
							}
							document.write('	</li>');
					}
					document.writeln('		</ul>');
				}else{
				document.writeln('</li>');
				}
			}
		}
	}
}

function addSiteMap3rd(parentID, sectionID, caption, chiCaption, url){
	_3rdMenuObj[_3rdIndex] = new Object();
	_3rdMenuObj[_3rdIndex].caption = caption;
	_3rdMenuObj[_3rdIndex].chiCaption = chiCaption;
	_3rdMenuObj[_3rdIndex].parentID = parentID;
	_3rdMenuObj[_3rdIndex].menuID = subMenuObj[parentID].menuID;
		
	if(url.search('http://')!=-1){
		_3rdMenuObj[_3rdIndex].url = url;
		_3rdMenuObj[_3rdIndex].popup = ' target="_blank"'
	}else{
		if(url.length==0){
			_3rdMenuObj[_3rdIndex].url = url;
			_3rdMenuObj[_3rdIndex].popup = ''
		}else{
			_3rdMenuObj[_3rdIndex].url = locationPath+langPath+url;
			_3rdMenuObj[_3rdIndex].popup = ''
		}
	}
	_3rdMenuObj[_3rdIndex++].id = sectionID;
}

function addSiteMap4th(parentID, sectionID, caption, chiCaption, url){
	_4thMenuObj[_4thIndex] = new Object();
	_4thMenuObj[_4thIndex].caption = caption;
	_4thMenuObj[_4thIndex].chiCaption = chiCaption;
	_4thMenuObj[_4thIndex].parentID = parentID;
	if(url.search('http://')!=-1){
		_4thMenuObj[_4thIndex].url = url;
		_4thMenuObj[_4thIndex].popup = ' target="_blank"'
	}else{
		if(url.length==0){
			_4thMenuObj[_4thIndex].url = url;
			_4thMenuObj[_4thIndex].popup = ''
		}else{
			_4thMenuObj[_4thIndex].url = locationPath+langPath+url;
			_4thMenuObj[_4thIndex].popup = ''
		}
	}
	_4thMenuObj[_4thIndex++].id = sectionID;
}

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){
	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 returnBtnMenu(counter){
	var index;
	if(counter<10){ index = "0" + counter} else {index = counter}
	return "btn_" + index + ".jpg"
}

function returnBtnOverMenu(counter){
	var index;
	if(counter<10){ index = "0" + counter} else {index = counter}
	return "btn_" + index + "_over.jpg"
}

function returnBtnSubMenu(counter1, counter2){
	var index;
	if(counter1<10){ index = "0" + counter1} else {index = counter1}
	var index2;
	if(counter2<10){ index2 = "0" + counter2} else {index2 = counter2}
	return "btn_" + index + "_" + index2 + ".jpg"
}

function returnBtnOverSubMenu(counter1, counter2){
	var index;
	if(counter1<10){ index = "0" + counter1} else {index = counter1}
	var index2;
	if(counter2<10){ index2 = "0" + counter2} else {index2 = counter2}
	return "btn_" + index + "_" + index2 + "_over.jpg"
}

function getTopBtn(counter){
	var altText='Top';
	if(langID!=1) altText='頁首';
	
	document.writeln('<table width="100%"><tr><td align="right"><a href="#top" onmouseout="simg(backtotop'+counter+', \''+imagePath+'images/btn_top.jpg\');" onmouseover="simg(backtotop'+counter+', \''+imagePath+'images/btn_top_over.jpg\');"><img align="right" src="'+imagePath+'images/btn_top.jpg" alt="'+altText+'" border="0" name="backtotop'+counter+'"></a></td></tr></table>');
}

function getBackBtn(backlink, counter){
	var altBack='Back';
	if(langID!=1) altBack='回上頁';
		
	document.writeln('<table width="100%"><tr><td align="left"><a href="'+backlink+'" onmouseout="simg(backtoback'+counter+', \''+imagePath+'images/btn_back.jpg\');" onmouseover="simg(backtoback'+counter+', \''+imagePath+'images/btn_back_over.jpg\');"><img align="left" src="'+imagePath+'images/btn_back.jpg" alt="'+altBack+'" border="0" name="backtoback'+counter+'"></a></td></tr></table>');
}

function getLRnewsComment(){
	document.write('<p><span class="heading2">COMMENTS</span></p>');
	document.write('<p>Land Registry News would like to hear from you. If there are any specific subjects you would like to read about or if you have any comments on what you have read so far, please write to us at the freepost address (local mail only) given below:</p>');
	document.write('<p>');
	document.write('<strong>The Land Registry<br />Freepost No. 10<br />Hong Kong</strong><br /><br />For enquiries, please contact:</span> ');
	document.write('<table border="0" width="428">');
	document.write('	<tbody>');
	document.write('		<tr>');
	document.write('			<td width="160" height="24"><strong><em>Mr. Kenneth POON </em></strong></td>');
	document.write('			<td width="258"><strong>Customer Service Manager</strong></td>');
	document.write('		</tr>');
	document.write('		<tr>');
	document.write('			<td height="23"><strong>TEL: (852) 3105 0000</strong></td>');
	document.write('			<td><strong>FAX: (852) 2523 0065</strong></td>');
	document.write('		</tr>');
	document.write('		<tr>');
	document.write('			<td colspan="2"><strong>e-mail: <a href="mailto:csa@landreg.gov.hk">csa@landreg.gov.hk</a></strong></td>');
	document.write('		</tr>');
	document.write('	</tbody>');
	document.write('</table>');
	document.write('</p>');
}

function win_popup(str_url,str_winname,int_width,int_height,str_feature){
	if (!str_feature){
		str_feature = 'toolbars='	+ 'no'
		+ ',width=' 			+ int_width
		+ ',height=' 			+ int_height
		+ ',scrollbars='		+ 'no'
		+ ',resizable='			+ 'no'
		+ ',screenX='			+ '0'
		+ ',screenY='			+ '0'
		+ ',status='			+ 'no'
		+ ',top='			+ '0'
		+ ',left='			+ '0' 
	}else
	{
		str_feature = 'toolbars='	+ 'no'
		+ ',width=' 			+ int_width
		+ ',height=' 			+ int_height
		+ ',scrollbars='		+ 'no'
		+ ',resizable='			+ 'no'
		+ ',screenX='			+ '0'
		+ ',screenY='			+ '0'
		+ ',status='			+ 'no'
		+ ',top='			+ '129'
		+ ',left='			+ '0' 
	}
	
	var win = window.open(str_url, str_winname , str_feature);		
	win.focus();
	//return win;
}
