var selectedSection;
var subSection;
var secondSubSection;
var exLevel;
var langID;
var revisionDate;
var locationPath;
var	topButton;
var	backPage;
var	nextPage;
var	EngOnly;
var	vspace;
var isText;
var filePath='';
var folderPath='';
var textOnlyPath;
var graphicPath;
var isGICSearch=false;
var mainTopicNo = "";
var activeLeftMenuID = "";
var firstLayerTimerID;
var leftMenuFlag = false;
var firstLayerFlag = false;
var leftMenuWidth = 153;
var highestLeftMenuButton = 0;


//The below is used for the news
var swidth=520;
//scroller height: change to your own;
var sheight=70;
//background color: change to your own; 
var sbcolor="#D6F3FF";
//scroller's speed: change to your own;
var sspeed=1;
var restart=sspeed;
var rspeed=sspeed;
var wholemessage="";

//Java Script variable for global use
var locPath=location.href.toString();
var targetString;
var subPath;


var leftMenuCommonImageName = "nav_";
var leftMenuSectionImageOut = ".gif";
var leftMenuSectionImageOver = "_o.gif";
var leftMenuSectionImageHit = "_h.gif";


if(location.href.toString().search('westcomzivo')!=-1){
	locationPath='ht'+'tp://test1.westcomzivo.com/dev/hketolondon/';
	graphicPath=locationPath.substring(7,locationPath.length);
}else if(location.href.toString().indexOf('www0.hketolondon.gov.hk')!=-1){
	locationPath='ht'+'tp://www0.hketolondon.gov.hk/';
	graphicPath=locationPath.substring(7,locationPath.length);
}else if(location.href.toString().indexOf('wwwnew.hketolondon.gov.hk')!=-1){
	locationPath='ht'+'tp://wwwnew.hketolondon.gov.hk/';
	graphicPath=locationPath.substring(7,locationPath.length);
}else if(location.href.toString().indexOf('www.hketolondon.gov.hk')!=-1){
	locationPath='ht'+'tp://www.hketolondon.gov.hk/';
	graphicPath=locationPath.substring(7,locationPath.length);
}else if(location.href.toString().indexOf('se.cgi')!=-1){
	locationPath='ht'+'tp://www.hketolondon.gov.hk/';
	graphicPath=locationPath.substring(7,locationPath.length);
	isGICSearch=true;
}else{
	//locationPath='ht'+'tp://202.64.223.171:8050/dev/';
	locationPath='ht'+'tp://www.hketolondon.gov.hk/';
	graphicPath=locationPath.substring(7,locationPath.length);
}




//-- begin: Scroller's Algorithm -->

function start(){
	if(document.all) iemarquee(slider);
	else if(document.getElementById)ns6marquee(document.getElementById('slider'));
	else if(document.layers)ns4marquee(document.slider1.document.slider2);
}

function iemarquee(whichdiv){
	iediv=eval(whichdiv);
	iediv.style.pixelTop=sheight;
	iediv.innerHTML=wholemessage;
	sizeup=iediv.offsetHeight;
	ieslide();
}

function ieslide(){
	if(iediv.style.pixelTop>=sizeup*(-1)){
		iediv.style.pixelTop-=sspeed;
		setTimeout("ieslide()",100);
	}else{
		iediv.style.pixelTop=sheight;
		ieslide();
	}
}

function ns4marquee(whichlayer){
	ns4layer=eval(whichlayer);
	ns4layer.top=sheight;
	ns4layer.document.write(wholemessage);
	ns4layer.document.close();
	sizeup=ns4layer.document.height;
	ns4slide();
}

function ns4slide(){
	if(ns4layer.top>=sizeup*(-1)){
		ns4layer.top-=sspeed;
		setTimeout("ns4slide()",100);
	}else{
		ns4layer.top=sheight;ns4slide();
	}
}

function ns6marquee(whichdiv){
	ns6div=eval(whichdiv);
	ns6div.style.top=sheight;
	ns6div.innerHTML=wholemessage;
	sizeup=ns6div.offsetHeight;
	ns6slide();
}

function ns6slide(){
	if(parseInt(ns6div.style.top)>=sizeup*(-1)){
		ns6div.style.top=parseInt(ns6div.style.top)-sspeed;
		setTimeout("ns6slide()",100);
	}else{
		ns6div.style.top=sheight;ns6slide();
	}
}
  
function getNews(){
document.write('<table border="0" align="center"><tr><td width='+swidth+'>');
if (document.getElementById || document.all)
{
	document.writeln('<span style="height:'+sheight+';"><div style="position:relative;overflow:hidden;width:'+swidth+';height:'+sheight+';clip:rect(0 '+swidth+' '+sheight+' 0);background-color:'+sbcolor+';" onMouseover="sspeed=0;" onMouseout="sspeed=restart"><div id="slider" style="position:relative;width:'+swidth+';"></div></div></span>')
}
	document.writeln('<ilayer width='+swidth+'; height='+sheight+'; name="slider1" bgcolor="'+sbcolor+'";><layer name="slider2" width='+swidth+'; onMouseover="sspeed=0;" onMouseout="sspeed=restart"></layer></ilayer></td></tr></table>');

}

//-- End: Scroller's Algorithm -->



//change the locationPath for text only version
function QueryString(key)
{
	var value = null;
	for (var i=0;i<QueryString.keys.length;i++)
	{
		if (QueryString.keys[i]==key)
		{
			value = QueryString.values[i];
			break;
		}
	}
	return value;
}
QueryString.keys = new Array();
QueryString.values = new Array();

function QueryString_Parse()
{
	var query = window.location.search.substring(1);
	var pairs = query.split("&");
	
	for (var i=0;i<pairs.length;i++)
	{
		var pos = pairs[i].indexOf('=');
		if (pos >= 0)
		{
			var argname = pairs[i].substring(0,pos);
			var value = pairs[i].substring(pos+1);
			QueryString.keys[QueryString.keys.length] = argname;
			QueryString.values[QueryString.values.length] = value;		
		}
	}
}
QueryString_Parse();

//function for document. e.g. doc, pdf
function documentPopUp(url){
	if(isText) url="ht"+"tp://"+graphicPath+updatePath(folderPath+url);
	eval("nw = window.open(url, 'document','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,pageXOffset=0,pageYOffset=0,top=0,left=0,width=700,height=500')");
	if ( nw.focus != null)
	{nw.focus();}
}

//function for text only version to get the real path of the HTML file
function updatePath(oldFilePath)
{
	var arFilePath = new Array();
	arFilePath = oldFilePath.split("/");
	var arFilePathTemp = new Array();
	for (i in arFilePath) 
	{
	   if (arFilePath[i] != "..") 
	   {arFilePathTemp.push(arFilePath[i]);}
	   else 
	   {arFilePathTemp.pop();}
	}
	var newFilePath = "";
	return newFilePath = arFilePathTemp.join("/");
}



//function for mouse over effect on left menu
function overTopMenu(obj)
{
        if (document.images){
				eval("document.images." + obj + ".src = '"+locationPath+"images/" + obj + "_f2.gif'");
        }
}

//function for mouse out effect on left menu
function outTopMenu(obj)
{
        if (document.images){
				eval("document.images." + obj + ".src = '"+locationPath+"images/" + obj + ".gif'");
        }
}

//function for switching image
function simg(obj,src)
{
        if (document.images){
                obj.src = src;
        }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  if(isText) theURL="ht"+"tp://"+graphicPath+updatePath(folderPath+theURL);
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  var tempPath = "";
  if(isText) {tempPath=locationPath+folderPath;}
  eval(targ+".location='"+tempPath+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//function for switching language
function changeLanguage(switchLang){
	var locationPage;
	var currentPath=document.URL.toString();
	var slash="/";
	var tempSwitchLang=switchLang;
	var switchTc="/tc/";
	var ready = true;
	var modeTc = "mode=1";
	var modeEng = "mode=0";
	var currentMode = "mode=0";
	var targetMode = "";
	
	//use for special case 
	//Major Project
	if(location.href.toString().search('search.*cgi')!=-1){
	//if(location.search.toString().indexOf('isText=true')!=-1&&location.href.toString().indexOf('/cgi-bin/se.cgi')==-1){
		if(secondSubSection!="" && secondSubSection>0){
			currentPath=SecondSubSection[selectedSection][subSection][secondSubSection];
		}else if(subSection!="" && subSection>0){
			currentPath=SubSection[selectedSection][subSection];
		}else{
			currentPath=MainSection[selectedSection];
		}
	}

	
	if(isGICSearch){
		currentPath=document.URL.toString();

			currentMode=modeEng

		

			targetMode=modeEng

	}
	
	
//	alert(locationPage);
	if (ready){
		document.location=locationPage;
	}
}


//function for generating the top menu
function getTopMenu(num){
	var printVer = false;
	
	if(location.href.toString().search('printVer=true')!=-1){
		printVer=true;
	}
	
	if (printVer == false){
		if(num==0){	
			document.writeln('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="javascript:setTopLayerPosition(true);setLayerPosition();">');
		}
		else{
			document.writeln('		<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="javascript:setTopLayerPosition(true);setLayerPosition();start();">');
		}
		document.writeln('<table width="760" border="0" cellpadding="0" cellspacing="0">');
	}
	else{
		document.writeln('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="javascript:setTopLayerPosition(true);setLayerPosition();">');
		document.writeln('<table border="0" cellpadding="0" cellspacing="0">');
	}

	if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) <= 4))
	{
		var extarSpacer = '<td background="'+locationPath+'images/mainbar5.gif" bgcolor="#FAFAEB"><img name="mainbar5" src="'+locationPath+'images/spacer.gif" border="0" height=1 width=162 alt=""></td>';
	}
	else
	{
		var extarSpacer = '<td background="'+locationPath+'images/mainbar5.gif" bgcolor="#FAFAEB"><img name="mainbar5" src="'+locationPath+'images/spacer.gif" border="0" height=1 width=138 alt=""></td>';
	}

	
	var extarSpacer = '<td background="'+locationPath+'images/bkgdtexture.gif" bgcolor="#FAFAEB"><img name="mainbar5" src="'+locationPath+'images/spacer.gif" border="0" height=1 width=184 alt=""></td>';
	
	var gicSearchForm;
	
  gicSearchForm='<form name="frmSearch" action="http://search.gov.hk/search.html" method="get">\n';
  gicSearchForm+='<input type="hidden" name="tpl_id" value="hketolondon">\n';
  gicSearchForm+='<input type="hidden" name="ui_lang" value="en">\n';
  gicSearchForm+='<input type="hidden" name="ui_charset" value="iso-8859-1">\n';
  gicSearchForm+='<input type="hidden" name="gp0" value="hketolondon_home">\n';
  gicSearchForm+='<input type="hidden" name="gp1" value="hketolondon_home">\n';
  gicSearchForm+='<input type="hidden" name="web" value="this">\n';

	//graphic version

	document.writeln('	<tr>');
	document.writeln('	<td colspan="4">');
	if (printVer == false){
	
			document.writeln('		<table width="780" border="0" cellpadding="0" cellspacing="0" background="'+locationPath+'images/bkgdtexture.gif">');
			document.writeln(gicSearchForm);
			document.writeln('		<tr align="left" valign="top">');
			document.writeln('			<td colspan="5" class="sidebar" background="'+locationPath+'images/bkgdtexture.gif" bgcolor="#FAFAEB"><a href="'+locationPath+'index.htm"><img src="'+locationPath+'images/branding.gif" border=0 alt="'+arClfTopMenu[3]+'"></a></td>');
			document.writeln('			<td background="'+locationPath+'images/bkgdtexture.gif" colspan="2" valign="bottom" align=right bgcolor="#FAFAEB"><a href="'+arClfTopMenu[5]+'" target="_top"><img name="BrandHK" src="'+locationPath+'images/brandhk.gif" border="0" alt="'+arClfTopMenu[6]+'"></a></td>');
			document.writeln('		</tr>');
			document.writeln('		<tr align="left" valign="top" background="'+locationPath+'images/bkgdtexture.gif">');
			document.writeln('			<td><a href="http://www.gov.hk/en/residents" onMouseOut="outTopMenu(\'mainbar1\')" onMouseOver="overTopMenu(\'mainbar1\')"><img name="mainbar1" src="'+locationPath+'images/mainbar1.gif" border="0" alt="'+arClfTopMenu[7]+'"></a></td>');
			document.writeln(extarSpacer);
		//	document.writeln('			<td background="'+locationPath+'images/mainbar5.gif" bgcolor="#FAFAEB"><img name="mainbar5" src="'+locationPath+'images/spacer.gif" border="0" height=1 width=64 alt=""></td>');
			document.writeln('			<td background="'+locationPath+'images/bkgdtexture.gif"><a href="javascript:document.frmSearch.submit();" onMouseOut="outTopMenu(\'mainbar6\')" onMouseOver="overTopMenu(\'mainbar6\')"><img name="mainbar6" src="'+locationPath+'images/mainbar6.gif" border="0" alt="'+arClfTopMenu[17]+'"></a></td>');
			document.writeln('			<td valign="bottom" background="'+locationPath+'images/bkgdtexture.gif" align=center><input type="text" name="query" size="'+arClfTopMenu[4]+'" class="search"></td>');
			document.writeln('			<td background="'+locationPath+'images/bkgdtexture.gif"><a href="javascript:document.frmSearch.submit();" onMouseOut="outTopMenu(\'mainbar8\')" onMouseOver="overTopMenu(\'mainbar8\')"><img name="mainbar8" src="'+locationPath+'images/mainbar8.gif" border="0" alt="'+arClfTopMenu[17]+'"></a></td>');
			document.writeln('			<td background="'+locationPath+'images/bkgdtexture.gif"><a href="'+locationPath+'sitemap/index.htm" onMouseOut="outTopMenu(\'mainbar9\')" onMouseOver="overTopMenu(\'mainbar9\')"><img name="mainbar9" src="'+locationPath+'images/mainbar9.gif" border="0" alt="'+arClfTopMenu[18]+'"></a></td>');
			document.writeln('			<td background="'+locationPath+'images/bkgdtexture.gif" bgcolor="#FAFAEB"><a href="'+locationPath+'contact/index.htm" onMouseOut="outTopMenu(\'mainbar10\')" onMouseOver="overTopMenu(\'mainbar10\')"><img name="mainbar10" src="'+locationPath+'images/mainbar10.gif" border="0" alt="'+arClfTopMenu[19]+'"></a></td>');
			document.writeln('		</tr>');
			document.writeln('		<tr align="left" valign="top" bgcolor="#BB3333">');
			document.writeln('			<td height=2 colspan="10"><img src="'+locationPath+'images/reddot.gif" width="778" height="2" alt="" border=0></td>');
			document.writeln('		</tr>');
			document.writeln('		</form>');
			document.writeln('		</table>');
		
		
			document.writeln('	</td>');
			document.writeln('	</tr>');
			document.writeln('	<tr>');
			document.writeln('	<td colspan="4">');
			document.writeln('		<table border="0" cellspacing="0" cellpadding="0" width="780">');
			document.writeln('		  <tr valign="top">');
		 	document.writeln('		   <td><img src="'+locationPath+'images/topimage_1.jpg" width="159" height="129"></td>');
		 	document.writeln('		   <td>');
			document.writeln('		      <table width="621" border="0" cellspacing="0" cellpadding="0">');
		 	document.writeln('		       <tr valign="top"> ');
		 	document.writeln('		         <td valign="top" width="141"><img src="'+locationPath+'images/topimage_2.jpg" width="141" height="87"></td>');
		 	document.writeln('		         <td valign="top"><!-- banner start --> ');
		 	document.writeln('		           <table width="100%" border="0" cellspacing="0" cellpadding="0">');
		 	document.writeln('		             <tr valign="top"> ');
			document.writeln('		                <td rowspan="3"><img src="'+locationPath+'images/top_a_1.jpg" width="395" height="87"></td>');
			document.writeln('		                <td><img src="'+locationPath+'images/top_a_2.jpg" width="65" height="51"></td>');
			document.writeln('		                <td rowspan="3"> <img src="'+locationPath+'images/top_a_4.jpg" width="10" height="87"></td>');
			document.writeln('		              </tr>');
		    document.writeln('		          <tr valign="top"> ');
		 	document.writeln('		               <td><A href="javascript:getPrint();" onMouseOver="leftMenuMouseOver(\'btn_print\')" onMouseOut="leftMenuMouseOut(\'btn_print\')"><img src="'+locationPath+'images/btn_print.gif" border="0" name="btn_print" alt="Print it"></A></td>');
		 	document.writeln('		             </tr>');
		 	document.writeln('		             <tr valign="top"> ');
		  	document.writeln('		              <td><img src="'+locationPath+'images/top_a_3.jpg" width="65" height="16"></td>');
		 	document.writeln('		             </tr>');
			document.writeln('		            </table>');
		 	document.writeln('		           <!-- banner end --> </td>');
		 	document.writeln('		         <td valign="top" width="10"><img src="'+locationPath+'images/topimage_4.gif" width="10" height="87"></td>');
			document.writeln('		        </tr>');
		 	document.writeln('		     </table>');
		 	document.writeln('		     <table width="100%" border="0" cellspacing="0" cellpadding="0">');
		 	document.writeln('		       <tr valign="top"> ');
		  	document.writeln('		        <td width="141"><img src="'+locationPath+'images/topimage_3.jpg" width="141" height="42"></td>');
		 	document.writeln('		         <td width="424" align="right">');
			getTopic();
		 	document.writeln('</td>');
		 	document.writeln('		         <td><img src="'+locationPath+'images/line1.gif" width="36" height="42"></td>');
		 	document.writeln('		         <td><img src="'+locationPath+'images/line2.gif" width="10" height="42"></td>');
		 	document.writeln('		         <td bgcolor="5EC6E7"><img src="'+locationPath+'images/spacer.gif" width="10" height="10"></td>');
		 	document.writeln('		       </tr>');
		 	document.writeln('		     </table>');
			document.writeln('		    </td>');
			document.writeln('		  </tr>');
			document.writeln('		</table>');
			document.writeln('		</td>');
			document.writeln('	</tr>');
			
			document.writeln('	<tr>');
			
			document.writeln('	<!-- Left Menu Bar Begin -->');
			getLeftMenu();
			document.writeln('	<!-- Left Menu Bar End -->');
			
			
			document.writeln('	<td valign="top" width="605">');

	}
	else{
			document.writeln('	<div align="right">');
			getTopic();
			document.writeln('</div>');
	}	
	document.writeln('		<table border="0" cellpadding="0" cellspacing="0" width="601">');
	document.writeln('			<tr valign="top">');
	document.writeln('				<td align="left" rowspan="4" width="36"><img src="'+locationPath+'images/spacer.gif" border="0" height=36 width=36 alt=""></td>');
	
	
	document.writeln('				<td align="left"><img src="'+locationPath+'images/spacer.gif" border="0" height=10 width=10 alt=""></td>');
	document.writeln('				<td align="left" rowspan="4" width="36"><img src="'+locationPath+'images/spacer.gif" border="0" height=36 width=36 alt=""></td>');
	document.writeln('			</tr>');
	document.writeln('			<tr valign="top">');
	document.writeln('				<td align="left">');
	getPath();
	document.writeln('				</td>');
	document.writeln('			</tr>');
	document.writeln('			<tr valign="top">');
	document.writeln('				<td align="left"><img src="'+locationPath+'images/spacer.gif" border="0" height=10 width=10 alt=""></td>');
	
	document.writeln('			</tr>');
		
	document.writeln('			<tr valign="top">');
	document.writeln('				<td align="left">');
		
}



//function for generating the topic image
function getTopic(){
	var altText = '';
	var imgPath = '';
	altText = MainTitle[selectedSection]; 

	document.write('			<img src="'+locationPath+'images/title_'+(selectedSection)+'.gif" alt="'+altText+'" border="0">');
}



//function for generating the left menu
function getLeftMenu(){
	var isOver='';
	var iconNo = '';
	var mainOrder = 0;
	
	//graphic version

	document.writeln('	<td rowspan=2 valign="top" width="159" background="'+locationPath+'images/nav_bg.gif">');
	document.writeln('<table border="0" cellspacing="0" cellpadding="0">');
	
	for (var i in MainSectionOrder)
	{
		mainOrder=MainSectionOrder[i];
		if (mainOrder == selectedSection)
		{
				document.writeln('<tr>');
				document.writeln('<td><a href="'+MainSection[mainOrder]+'" onMouseOver="leftMenuMouseOver(\''+leftMenuCommonImageName+arMainTopicImage[mainOrder]+'\')" onMouseOut="leftMenuMouseOut(\''+leftMenuCommonImageName+arMainTopicImage[mainOrder]+'\')"><img src="'+locationPath+'images/'+leftMenuCommonImageName+arMainTopicImage[mainOrder+1]+leftMenuSectionImageHit+'" border="0" name="'+leftMenuCommonImageName+arMainTopicImage[mainOrder]+'" alt="'+MainTitle[mainOrder]+'"></a></td>');
				document.writeln('</tr>');
						}
		else
		{
		//alert(MainSection[mainOrder]);
	
				document.writeln('<tr>');
				document.writeln('<td><a href="'+MainSection[mainOrder]+'" onMouseOver="leftMenuMouseOver(\''+leftMenuCommonImageName+arMainTopicImage[mainOrder]+'\')" onMouseOut="leftMenuMouseOut(\''+leftMenuCommonImageName+arMainTopicImage[mainOrder]+'\')"><img src="'+locationPath+'images/'+leftMenuCommonImageName+arMainTopicImage[mainOrder+1]+leftMenuSectionImageOut+'" border="0" name="'+leftMenuCommonImageName+arMainTopicImage[mainOrder]+'" alt="'+MainTitle[mainOrder]+'"></a></td>');
				document.writeln('</tr>');
	
		}
	}
	document.writeln('</table>');
	document.writeln('	</td>');
	mainOrder = 0;
}



//function for generating the top button
function getButton(){
	var altText='Top';
	if(langID!=1) altText='頁首';
	if(!isText){
		document.write('<p><a href="#"><img src="'+locationPath+'images/btn_top.gif" alt="'+altText+'" border="0" align="right"></a>&nbsp;</p>');
	}else{
		document.writeln('<p align=right><a href="#">'+altText+'</a></p>');
	}
	
	/*if(backPage!='' || nextPage!=''){
		document.writeln('<p><table border=0 cellspacing=0 cellpadding=0 width=100%><tr valign=top>');
	
		if(backPage!='')
			document.writeln('<td><a href="'+backPage+'"><img src="../images/btn_back.gif" alt="" border="0"></a></td>');
		if(nextPage!='')
			document.writeln('<td align=right><a href="'+nextPage+'"><img src="../images/btn_next.gif" alt="" border="0"></a></td>');
	
		document.writeln('</tr></table>');
	}*/
}

//function for generating the the text below
function otherLangOnly(){
	var TextStr='<p>We only provide <a href="javascript:changeLanguage(\'/tc/\');" class="text_link">Chinese Version</a>.</p>';
	if(langID==2) TextStr='<p>我們只提供<a href="javascript:changeLanguage(\'/eng/\');" class="text_link">英文版本</a>。</p>';
	document.writeln(TextStr);
}

//function for generating the the text for downloading acrobat reader
function getAcrobat(){
	var StrText='To view or download the following document, please download <a class="text_link" href="javascript:externalLink(\'http://www.adobe.com/prodindex/acrobat/readstep.html\');">Acrobat Reader</a>.';
	if(langID==2) StrText='如想觀看以上文件，請下載<a class="text_link" href="javascript:externalLink(\'http://www.adobe.com/prodindex/acrobat/readstep.html\');">Acrobat Reader</a> 。';
	var StrImg='<img src="'+locationPath+'images/acrobat.gif" border=0 align=top alt="Acrobat Reader">';
	if(isText) StrImg='Acrobat Reader';
	
	document.writeln('<p><table border=0 cellspacing=0 cellpadding=2 width=100%>');
	document.writeln('<tr valign=top><td width=1%><a href="javascript:externalLink(\'http://www.adobe.com/prodindex/acrobat/readstep.html\');">'+StrImg+'</a></td>');
	document.writeln('<td class="maincontent" width=99%>'+StrText+'</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 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"}
			}
		}
	}
}




//function for generating the footer
function getFooter(){
	var altText='Top';
	if(langID!=1) altText='頁首';
	var copyYear='2009';
	var noticesLink=locationPath+'disclaimer/index.htm';
	var noticeText='Important notices';
	var revisionText='Last revision date: ';	
	if (revisionDate==''||revisionDate=='MM/DD/YYYY') revisionDate='02/23/2010';

	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();
	
	var printVer = false;
	
	if(location.href.toString().search('printVer=true')!=-1){
		printVer=true;
	}

	//generate the topic image to the buffer variable

	document.writeln('				</td>');
	document.writeln('			</tr>');
	document.writeln('		</table>');
	document.writeln('	</td>');
	if(printVer==false){
		document.writeln('	<td valign="bottom" rowspan="2" width=10 bgcolor="#BDEBF7"><img src="'+locationPath+'images/fadeout_1.gif" border="0" height=112 width=10 alt=""></td>');
		document.writeln('	<td valign="bottom" rowspan="2" width=10 bgcolor="#5AC7E7"><img src="'+locationPath+'images/fadeout_2.gif" border="0" height=112 width=10 alt=""></td>');
	}
	else
	{
		document.writeln('	<td valign="bottom" rowspan="2" width=10 bgcolor="#BDEBF7"><img src="'+locationPath+'images/spacer.gif" alt="" border="0" width=10 height=1></td>');
		document.writeln('	<td valign="bottom" rowspan="2" width=10 bgcolor="#5AC7E7"><img src="'+locationPath+'images/spacer.gif" alt="" border="0" width=10 height=1></td>');
	}
	document.write('</tr>');
	document.write('<tr valign=top>');
	document.writeln('	<td valign="bottom">');
	
	document.writeln('<p><br>');
	if(printVer==false){
		document.writeln('<table width="580" border="0" cellspacing="0" cellpadding="0" align="center">');
		document.writeln('	<tr valign=top><td align=right>');
		document.writeln('	<table border="0" cellpadding="0" cellspacing="0" width="580" background="'+locationPath+'images/bottom_bg.gif">');
		document.writeln('		<tr valign="top">');
		document.writeln('			<td align="left"><img src="'+locationPath+'images/image_bottom_left.gif"></td>');
		document.writeln('			<td><img src="'+locationPath+'images/spacer.gif" alt="" border="0" width=480 height=1></td>');
		document.writeln('			<td align="right"><A href="#" onMouseOver="leftMenuMouseOver(\'btn_top\')" onMouseOut="leftMenuMouseOut(\'btn_top\')"><img src="'+locationPath+'images/btn_top.gif" alt="Top" border="0" name="btn_top"></A></td>');
		document.writeln('		</tr>');
		document.writeln('	</table>');
	document.writeln('	</td></tr>');
	}
	else{
		document.writeln('<table width="580" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('	<tr><td rowspan=3><img src="'+locationPath+'images/spacer.gif" alt="" border="0" width=20 height=1></td>');
	
	}	
	document.writeln('		<td valign="top" align="center"> ');
	document.writeln('		<img src="'+locationPath+'images/spacer.gif" alt="" border="0" width=480 height=1>');
	document.writeln('		</td>');
	document.writeln('	</tr>');
	document.writeln('	<tr>');
	document.writeln('		<td valign="top" align="center" background="'+locationPath+'images/botdot.jpe" height=3><img src="'+locationPath+'images/spacer.gif" alt="" border="0" width=480 height=1></td> ');
	document.writeln('	</tr>');
	document.writeln('	<tr>');
	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 width="300" height="15" bgcolor="#FFFFFF" class="footer" nowrap><b>'+copyYear+'</b> <img src="'+locationPath+'images/copy.gif" alt="" width="12" height="11"> | <b><a href="'+noticesLink+'" class="footer_link">'+noticeText+'</a></b></td>');
	document.writeln('			<td height="15" bgcolor="#FFFFFF" class="footer" align="right" nowrap>'+revisionText+showDate+'</td>');
	document.writeln('		</tr>');
	document.writeln('		</table>');
	document.writeln('		</td>');
	document.writeln('	</tr>');
	document.writeln('</table><br>');

	

	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('</table>');
		
	if (printVer == false){ 
		genLayer();
	}else{
		document.write('<script>window.print();</script>');
	}
}

//function for generating the sitemap
function getSiteMap(){
	var mainOrder = 0;
	var subOrder = 0;
	var secondSubOrder = 0;
	var LineBroken='<br>';
	var bullet1='<li type="disc">';
	var bullet2='<li type="square">';
	var bullet3='<li type="circle">';
	if(isText){
		bullet1="*";
		bullet2="*";
		bullet3="*";
	}
	document.write('<table border=0 cellspacing=0 cellpadding=0 width=100%>');	
	for(var i in MainSectionOrder){
		mainOrder=MainSectionOrder[i];
		if (MainTitle[mainOrder] != ''){
			document.writeln('<tr valign=top><td width=1%>'+bullet1+'</td>');
			document.writeln('<td class="maincontent" width=99%><a href="'+MainSection[mainOrder]+'" class="text_link">'+MainTitle[mainOrder]+'</a>');
			if((SubSectionTitle[mainOrder] != null) && (SubSectionTitle[mainOrder].length > 0)){
				document.write(LineBroken+LineBroken+'<table border=0 cellspacing=0 cellpadding=0 width=100%>');	
				for(var j in SubSectionOrder[mainOrder]){
					subOrder=SubSectionOrder[mainOrder][j];
					if (SubSectionTitle[mainOrder][subOrder] != ''){
						document.writeln('<tr valign=top><td width=1%>'+bullet2+'</td>');
						document.writeln('<td class="maincontent" width=99%><a href="'+SubSection[mainOrder][subOrder]+'" class="text_link">'+SubSectionTitle[mainOrder][subOrder]+'</a>');
						if((SecondSubSectionTitle[mainOrder][subOrder] != null) && (SecondSubSectionTitle[mainOrder][subOrder].length > 0)){
							document.write(LineBroken+LineBroken+'<table border=0 cellspacing=0 cellpadding=0 width=100%>');	
								for(var k in SecondSubSectionOrder[mainOrder][subOrder]){
									secondSubOrder=SecondSubSectionOrder[mainOrder][subOrder][k];
									if (SecondSubSectionTitle[mainOrder][subOrder][secondSubOrder] != ''){
										document.writeln('<tr valign=top><td width=1%>'+bullet3+'</td>');
										document.writeln('<td class="maincontent" width=99%><a href="'+SecondSubSection[mainOrder][subOrder][secondSubOrder]+'" class="text_link">'+SecondSubSectionTitle[mainOrder][subOrder][secondSubOrder]+'</a>');
										if((SecondSubSectionTitle[mainOrder][subOrder][secondSubOrder+1] != null) && (SecondSubSectionTitle[mainOrder][subOrder][secondSubOrder+1].length > 0)){
											document.writeln(LineBroken+LineBroken+'</td></tr>');
										}else{
											document.writeln('</td></tr>');
										}
									}
								}
							document.write('</table>');
						}
						if((SecondSubSectionTitle[mainOrder][subOrder] != null) && (SecondSubSectionTitle[mainOrder][subOrder].length > 0)){
							document.write(LineBroken);					
						}else{
							document.write(LineBroken+LineBroken);
						}
						document.writeln('</td></tr>');
					}
				}
				document.write('</table>');
			}else{
				if((SubSectionTitle[mainOrder] != null) && (SubSectionTitle[mainOrder].length > 0)){
					document.write(LineBroken);
				}else{
					document.write(LineBroken+LineBroken);
				}
			}
			document.writeln('</td></tr>');
		}
		mainOrder = 0;
		subOrder = 0;
		secondSubOrder = 0;
	}
	
	document.write('</table>');
}


//function for generating the path indicator
function getPath(){
	var strBuffer='<a href="'+MainSection[0]+'" class="pathLink">'+MainTitle[0]+'</a>';
	if(subSection>0){
		if(selectedSection>0) strBuffer+=' > <a href="'+MainSection[selectedSection]+'" class="pathLink">'+MainTitle[selectedSection]+'</a>';
	}else{
		if(exLevel){
			if(selectedSection>0) strBuffer+=' > <a href="'+MainSection[selectedSection]+'" class="pathLink">'+MainTitle[selectedSection]+'</a>';
		}else{
			if(selectedSection>0) strBuffer+=' > '+MainTitle[selectedSection];
		}
	}
	if(secondSubSection>0){
		if(subSection>0) strBuffer+=' > <a href="'+SubSection[selectedSection][subSection]+'" class="pathLink">'+SubSectionTitle[selectedSection][subSection]+'</a>';
	}else{
		if(exLevel){
			if(subSection>0) strBuffer+=' > <a href="'+SubSection[selectedSection][subSection]+'" class="pathLink">'+SubSectionTitle[selectedSection][subSection]+'</a>';
		}else{
			if(subSection>0) strBuffer+=' > '+SubSectionTitle[selectedSection][subSection];
		}
		
	}
	if(secondSubSection>0){
		if(exLevel){
			strBuffer+=' > <a href="'+SecondSubSection[selectedSection][subSection][secondSubSection]+'" class="pathLink">'+SecondSubSectionTitle[selectedSection][subSection][secondSubSection]+'</a>';
		}else{
			strBuffer+=' > '+SecondSubSectionTitle[selectedSection][subSection][secondSubSection];		
		}
	}	
	
	if(exLevel){
		strBuffer+=' > '+exLevel;
	}
	
	//graphic version only
		document.writeln('<table border=0 cellpadding=0 cellspacing=0 background="'+locationPath+'images/spacer.gif">');
		document.writeln('<tr valign=top>');
		document.writeln('<td class="path">'+strBuffer+'</td>');
		document.writeln('</tr>');
		document.writeln('</table>');
}


//function for generating the sub-section list. Up to level 3 only
function getSectionList(){
	var sectionOrder=0;
	var strSectionOrder='';
	var strBuffer='';
 	var textLink='';
	var bullet1='<img src="'+locationPath+'images/bullet_1.gif" alt="*" border="0" vspace='+vspace+' hspace=3 align=absMiddle>';
	if(isText) bullet1='*';
	if(selectedSection>0) strBuffer+='['+selectedSection+']';
	if(subSection>0) strBuffer+='['+subSection+']';
	if(subSection>0){
		textLink='SecondSubSection['+langID+']'+strBuffer;
		strSectionOrder='SecondSubSectionOrder['+langID+']'+strBuffer;
		strBuffer='SecondSubSectionTitle['+langID+']'+strBuffer;
	}else{
		textLink='SubSection['+langID+']'+strBuffer;
		strSectionOrder='SubSectionOrder['+langID+']'+strBuffer;
		strBuffer='SubSectionTitle['+langID+']'+strBuffer;
	}
	var count = eval(strSectionOrder+".length");
	if(count != 0){
		document.write('<table border=0 cellspacing=0 cellpadding=0 width=100%>');
		for(var j in eval(strSectionOrder)){
			sectionOrder=eval(strSectionOrder+"["+j+"]")
			if (eval(strBuffer+"["+sectionOrder+"]") != ""){
				document.writeln('<tr valign=top><td width=1%>'+bullet1+'</td>');
				document.writeln('<td class="maincontent" width=99%><a href="'+eval(textLink+"["+sectionOrder+"]")+'" class="TLink">'+eval(strBuffer+"["+sectionOrder+"]")+'</a>'+EngOnly+'<br><br></td></tr>');
			}
		}
		document.write('</table>');
	}
	sectionOrder=0
}



//function for index page
function textOnlyLink(textLang){
	var tempLocation = 'ht'+'tp://'+textOnlyPath+'?search=';
	var tempGbUrl = 'sc.info.gov.hk/gb/';
	
	if(textLang=='eng'){
		tempLocation=tempLocation+'eng/about/welcome/index.htm';
	}else if(textLang=='tc'){
		tempLocation=tempLocation+'tc/about/welcome/index.htm';
	}else if(textLang=='gb'){
		tempLocation=tempLocation+'tc/about/welcome/index.htm';
		tempLocation=tempLocation.substring(0,7)+tempGbUrl+tempLocation.substring(7,tempLocation.length);
	}
	location=tempLocation;
}

//function for index page
function graphicLink(graphicLang){
	var tempLocation = 'ht'+'tp://'+graphicPath;
	
	if(graphicLang=='eng'){
		tempLocation=tempLocation+'home/index.htm';
	}else if(graphicLang=='tc'){
		tempLocation=tempLocation+'tc/index.htm';
	}else if(graphicLang=='gb'){
		tempLocation=tempLocation+'tc/index.htm';
		tempLocation=tempLocation.substring(0,7)+gb_urlPath+tempLocation.substring(7,tempLocation.length);
	}
	location=tempLocation;
}

//function for external link
function externalLink(url)
{eval("nw = window.open(url, 'external','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,pageXOffset=0,pageYOffset=0,top=0,left=0,width=700,height=500')");
	if ( nw.focus != null)
	{nw.focus();}
}

//function for setting the CSS for different browser and language
function checkStyle(){
	var cssLevel = "";
	var cssExtension = ".css"
	var cssLang = "";

	cssLevel="ht"+"tp://"+graphicPath;
	
	
	if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) <= 4)) {
		document.writeln('<link href="'+cssLevel+'css/style_nt'+cssLang+cssExtension+'" rel="STYLESHEET" type="text/css">');
	}else{
		document.writeln('<link href="'+cssLevel+'css/style'+cssLang+cssExtension+'" rel="STYLESHEET" type="text/css">');
	}
}

function getPrint(){
	url_text = location.href.toString();
	url_text = url_text+'?printVer=true';
	eval("nw = window.open(url_text, 'external','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,pageXOffset=0,pageYOffset=0,top=0,left=0,width=700,height=500')");
}

function getSpacer(x,y){
	document.writeln('<img src="'+locationPath+'images/spacer.gif" alt="" border="0" width='+x+' height='+y+'>');
}

checkStyle();
