﻿var domain_pref ="hkeconomy";
var domain="test2.westcomzivo.com/"+domain_pref;

if(location.href.search(domain)==-1){
	/*
	domain_pref="censtatd";
	domain="202.64.223.114/"+domain_pref	;
	*/
	domain="www.hkeconomy.gov.hk";
	if (location.href.search('www.hkeconomy')!=-1){
		domain="www.hkeconomy.gov.hk";
	}else if (location.href.search('www0.hkeconomy')!=-1){
		domain="www0.hkeconomy.gov.hk";
	}else if (location.href.search('www0.cms.hkeconomy')!=-1){
		domain="www0.cms.hkeconomy.gov.hk";
	}else if (location.href.search('www.cms.hkeconomy')!=-1){
		domain="www.cms.hkeconomy.gov.hk";
	}else if (location.href.search('active.hkeconomy')!=-1){
		domain="active.hkeconomy.gov.hk";
	}else if (location.href.search('staging.hkeconomy')!=-1){
		domain="staging.hkeconomy.gov.hk";
	}else if (location.href.search('wip.hkeconomy')!=-1){
		domain="wip.hkeconomy.gov.hk";
	}
}

if(document.URL.toString().search('/gb/')!=-1 ){
	langID=2;
	langFolder='/chs/';
	imgFolder='/sc/';
}else if(document.URL.toString().search('/chs/')!=-1 || document.URL.toString().search('mode=288')!=-1){
	langID=2;
	langFolder='/chs/';
	imgFolder=langFolder;
}else{
	langID=1;
	langFolder='/en/';
	imgFolder=langFolder;
}

if(location.href.toString().search('westcomzivo')!=-1){			//Setting kanhan Server
	gb_urlPath='common.westcomzivo.com/gb/';
}else{
	gb_urlPath='sc.info.gov.hk/gb/';
}

if(document.URL.toString().search('/gb/')!=-1){					//Setting kanhan path
	domain_url = "ht"+"tp://"+gb_urlPath+domain;
}else{
	domain_url = "ht"+"tp://"+domain;
}

if(document.URL.toString().search('/text/')!=-1){					//TEXTONLY VERSION
	langPath = domain_url + '/text' + langFolder;
}else{													//GRAPHIC VERSION
	langPath = domain_url + langFolder;
	imgPath = domain_url + imgFolder;
}

if(location.href.toString().search('search.info.gov.hk') != -1){
	selectedSection=13;
	selectedSubSection=0;
	revisionDate='MM/DD/YYYY'; //Date Format: MM/DD/YYYY
}

var printPage;
if(window.name=='PrintPage'){
	printPage=1;
}
// -------------------------------------------------------------    Variable for Common Function for Left Menu -----------------------------------------

//Browser Type var:
var isNS4 = (document.layers) ? true : false;
var isIE4 = (document.all && !document.getElementById) ? true : false;
var isIE5 = (document.all && document.getElementById) ? true : false;
var isNS6 = (!document.all && document.getElementById) ? true : false;
//If not NS4. It should be IE or NS6+
isIE5 =!isNS4;


var leftMenuSectionImageOut = ".gif";
var leftMenuSectionImageOver = "_over.gif";
var leftMenuName = "Menu";
var leftMenuImageName = "icon";
var layerCommonName = "Popup";
var leftMenuFlag = false;
var firstLayerFlag = false;
var firstLayerTimerID;
var activeLeftMenuID = "";
var mainTopic = "";

var arLayer = new Array()
var arLayer2 = new Array()

// -------------------------------------------------------------    End of Variable for Common Function for Left Menu -----------------------------------------

// -------------------------------------------------------------    Variable for Common Function for First Level Layers-----------------------------------------

var firstLayerImagesFlag = false;
var secondLayerFlag = false;
var activeFirstLayerImageID = "";
var activeSecondLayerID = "";
var secondLayerTimerID;
var subTopic = "";

var arSecondLayer = new Array()
var arSecondLayer2 = new Array()

// -------------------------------------------------------------    End of Variable for Common Function for First Level Layers -----------------------------------------

// -------------------------------------------------------------    Variable for Common Function for Second Level Layers-----------------------------------------

var secondLayerImagesFlag = false;
var thirdLayerFlag = false;
var activeSecondLayerImageID = "";
var activeThirdLayerID = "";
var thirdLayerTimerID;
var subSubTopic = "";

var arThirdLayer = new Array()
var arThirdLayer2 = new Array()

// -------------------------------------------------------------    End of Variable for Common Function for Second Level Layers -----------------------------------------

// -------------------------------------------------------------    Common Function for Left Menu -----------------------------------------
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 moveDivs(layerObj, inObjTop){
layerObj.top  = inObjTop - 1;
//	var objLeft = layerObj.left;
//	objLeft = objLeft.repalce("px");
//	objLeft = int(objLeft)+10;
//	alert(objLeft);
//layerObj.left  = leftMenuWidth;
}

var arLayerPos = new Array()
//arLayerPos[5] = 180;

function setLayerPosition()
{
//	alert (arLayer.length);
	for (var i in arLayer)
	{
			 if(arLayerPos[arLayer2[i]]!=null)
			 {
				 if (document.all){moveDivs(document.all[arLayer[i]].style, arLayerPos[arLayer2[i]]);}
				 if (document.layers){moveDivs(document.layers[arLayer[i]], arLayerPos[arLayer2[i]]);}
				 if (!document.all && document.getElementById) {moveDivs(document.getElementById(arLayer[i]).style, arLayerPos[arLayer2[i]]);}
			}
			else
			{
				 if (document.all){moveDivs(document.all[arLayer[i]].style, getDim(document.images[leftMenuName+arLayer2[i]]).y);}
				 if (document.layers){moveDivs(document.layers[arLayer[i]], document.images[leftMenuName+arLayer2[i]].y);}
				 if (!document.all && document.getElementById) {moveDivs(document.getElementById(arLayer[i]).style, document.images[leftMenuName+arLayer2[i]].y);}
			}
	}
} 

function doShowMenu(imgName)
{
	var iconNo = parseInt(imgName)+1;
	(iconNo<10)?iconNo='0'+iconNo:iconNo=iconNo;
	if(mainTopic != imgName && !leftMenuFlag)

	{
		document.images[leftMenuName+imgName].src=document.images[leftMenuName+imgName].src.replace(leftMenuSectionImageOut, leftMenuSectionImageOver)
		leftMenuFlag = true;
	}
	if (!firstLayerFlag)
	{
		MM_showHideLayers(layerCommonName+iconNo,'','show');
		firstLayerFlag=true;
	}
	activeLeftMenuID = imgName
}

function leftMenuMouseOver(imgName) 
{
	if (activeLeftMenuID == imgName)
	{
		if (firstLayerTimerID) clearTimeout(firstLayerTimerID);
		firstLayerTimerID = null;
	}
	else
	{
		if (firstLayerTimerID) clearTimeout(firstLayerTimerID);
		firstLayerTimerID = null;
		if (activeLeftMenuID!=""){doHideMenu(activeLeftMenuID);}
		doShowMenu(imgName)	
	}
}

function doHideMenu(imgName)
{
	var iconNo = parseInt(imgName)+1;
	(iconNo<10)?iconNo='0'+iconNo:iconNo=iconNo;

	if(mainTopic != imgName)
	{
		document.images[leftMenuName+imgName].src=document.images[leftMenuName+imgName].src.replace(leftMenuSectionImageOver, leftMenuSectionImageOut)
		leftMenuFlag = false;
	}
	if (firstLayerFlag)
	{
		MM_showHideLayers(layerCommonName+iconNo,'','hide')
		firstLayerFlag=false;
	}
	activeLeftMenuID = "";
}

function leftMenuMouseOut(imgName) {
	
	if (activeLeftMenuID == imgName)
	{
		firstLayerTimerID = setTimeout("doHideMenu('"+imgName+"')", 500);
	}
	else
	{
		doHideMenu(imgName);
	}
}

// -------------------------------------------------------------   End of Common Function for Left Menu -----------------------------------------

// -------------------------------------------------------------    Common Function for First Level Layers -----------------------------------------
function findHeightForLayer(layerObj, obj)
{
	var height = 0;
	var flag = true;
	for (i=0;i<layerObj.images.length;i++)
	{
		if (obj==layerObj.images[i].name)
		{flag = false;}
		if (flag)
		{height+=parseInt(layerObj.images[i].height);}
	}
	return height;
}

var arSecondLayerPos = new Array();
arSecondLayerPos[6] = new Array();
arSecondLayerPos[6][11] = 300;

function setSecondLayerPosition()
{
	for (var i in arSecondLayer)
	{
			 var tempLayer = arSecondLayer[i].substring(0, arSecondLayer[i].length-2)
			 var tempImage = leftMenuName+arSecondLayer2[i];
			 var tempImagePos = tempImage.indexOf("_")

			 tempImage = tempImage.substring(0, tempImagePos)
		 
			 var tempFirstNo = parseFloat(arSecondLayer[i].substring(arSecondLayer[i].length-4, arSecondLayer[i].length-2));
			 var tempSecondNo = parseFloat(arSecondLayer[i].substring(arSecondLayer[i].length-2, arSecondLayer[i].length));
			 
			 if (arLayerPos[parseInt(tempFirstNo-1)] != null)
			 {
				if (arSecondLayerPos[parseInt(tempFirstNo)][parseInt(tempSecondNo)] != null)
				{
					if (document.all){moveDivs(document.all[arSecondLayer[i]].style, arSecondLayerPos[parseInt(tempFirstNo)][parseInt(tempSecondNo)]);}
				 	if (document.layers){moveDivs(document.layers[arSecondLayer[i]], arSecondLayerPos[parseInt(tempFirstNo)][parseInt(tempSecondNo)]);}
				 	if (!document.all && document.getElementById) {moveDivs(document.getElementById(arSecondLayer[i]).style, arSecondLayerPos[parseInt(tempFirstNo)][parseInt(tempSecondNo)]);}	
				}
				else
				{
					if (document.all){moveDivs(document.all[arSecondLayer[i]].style, getDim(document.images[leftMenuName+arSecondLayer2[i]]).y);}
				 	if (document.layers){moveDivs(document.layers[arSecondLayer[i]], arLayerPos[parseInt(tempFirstNo-1)] + findHeightForLayer(document.layers[tempLayer].document, leftMenuName+arSecondLayer2[i]) - 1);}
				 	if (!document.all && document.getElementById) {moveDivs(document.getElementById(arSecondLayer[i]).style, document.images[leftMenuName+arSecondLayer2[i]].y);}	
				}
			 }
			 else
			 {
			 	if (document.all){moveDivs(document.all[arSecondLayer[i]].style, getDim(document.images[leftMenuName+arSecondLayer2[i]]).y);}
			 	if (document.layers){moveDivs(document.layers[arSecondLayer[i]], document.images[tempImage].y + findHeightForLayer(document.layers[tempLayer].document, leftMenuName+arSecondLayer2[i]) - 1);}
			 	if (!document.all && document.getElementById) {moveDivs(document.getElementById(arSecondLayer[i]).style, document.images[leftMenuName+arSecondLayer2[i]].y);}	
			 }
	}
} 

function doShowLayer(imgName, layerName)
{
	var tempLayerName = layerName.substring(0, (layerName.length-2))
	var tempLayer = "";
	var tempImage = "";
	var tempPath = "";
	if(subTopic != imgName && !firstLayerImagesFlag)
	{
		if(document.layers) //netscape 4.x version
		{
			tempLayer = document.layers[tempLayerName].document;
			tempImage = tempLayer.images[imgName];
//			tempImage.src=tempImage.src.replace(leftMenuSectionImageOut, leftMenuSectionImageOver)
		}
		else
		{
//			document.images[imgName].src=document.images[imgName].src.replace(leftMenuSectionImageOut, leftMenuSectionImageOver)
		}
		
		firstLayerImagesFlag = true;
	}
	if (!secondLayerFlag )
	{
		MM_showHideLayers(layerName,'','show');
		secondLayerFlag =true;
	}
	activeFirstLayerImageID = imgName
	activeSecondLayerID = layerName
}

function firstLayerMouseOver(imgName, layerName) 
{
	if (activeFirstLayerImageID == imgName && activeSecondLayerID == layerName)
	{
		if (secondLayerTimerID) clearTimeout(secondLayerTimerID);
		secondLayerTimerID = null;
	}
	else
	{
		if (secondLayerTimerID) clearTimeout(secondLayerTimerID);
		secondLayerTimerID = null;
		if (activeFirstLayerImageID!=""){doHideLayer(activeFirstLayerImageID, activeSecondLayerID);}
		doShowLayer(imgName, layerName)	
	}
}

function doHideLayer(imgName, layerName)
{
	var tempLayerName = layerName.substring(0, layerName.length-2)
	var tempLayer = "";
	var tempImage = "";

	if(subTopic != imgName)
	{
		if(document.layers) //netscape 4.x version
		{
			tempLayer = document.layers[tempLayerName].document;
			tempImage = tempLayer.images[imgName];
//			tempImage.src=tempImage.src.replace(leftMenuSectionImageOver, leftMenuSectionImageOut)
		}
		else
		{
//			document.images[imgName].src=document.images[imgName].src.replace(leftMenuSectionImageOver, leftMenuSectionImageOut)
		}
		
		firstLayerImagesFlag = false;
	}
	if (secondLayerFlag )
	{
		MM_showHideLayers(layerName,'','hide')
		secondLayerFlag =false;
	}
	activeFirstLayerImageID = "";
	activeSecondLayerID = "";
}

function firstLayerMouseOut(imgName, layerName) {
	
	if (activeFirstLayerImageID == imgName && activeSecondLayerID == layerName)
	{
		secondLayerTimerID = setTimeout("doHideLayer('"+imgName+"', '"+layerName+"')", 500);
	}
	else
	{
		doHideLayer(imgName, layerName);
	}
}

// -------------------------------------------------------------   End of Common Function for First Level Layers -----------------------------------------

// -------------------------------------------------------------    Common Function for Second Level Layers -----------------------------------------
function doShowSecondLayer(imgName, layerName)
{
	var tempLayerName = layerName.substring(0, (layerName.length-2))
	var tempLayer = "";
	var tempImage = "";
	var tempPath = "";
	if(subSubTopic != imgName && !secondLayerImagesFlag)
	{
		if(document.layers) //netscape 4.x version
		{
			tempLayer = document.layers[tempLayerName].document;
			tempImage = tempLayer.images[imgName];
//			tempImage.src=tempImage.src.replace(leftMenuSectionImageOut, leftMenuSectionImageOver)
		}
		else
		{
//			document.images[imgName].src=document.images[imgName].src.replace(leftMenuSectionImageOut, leftMenuSectionImageOver)
		}
		
		secondLayerImagesFlag = true;
	}
	if (!thirdLayerFlag )
	{
		MM_showHideLayers(layerName,'','show');
		thirdLayerFlag =true;
	}
	activeSecondLayerImageID = imgName
	activeThirdLayerID = layerName
}

function secondLayerMouseOver(imgName, layerName) 
{
	if (activeSecondLayerImageID == imgName && activeThirdLayerID == layerName)
	{
		if (thirdLayerTimerID) clearTimeout(thirdLayerTimerID);
		thirdLayerTimerID = null;
	}
	else
	{
		if (thirdLayerTimerID) clearTimeout(thirdLayerTimerID);
		thirdLayerTimerID = null;
		if (activeSecondLayerImageID!=""){doHideSecondLayer(activeSecondLayerImageID, activeThirdLayerID);}
		doShowSecondLayer(imgName, layerName)	
	}
}

function doHideSecondLayer(imgName, layerName)
{
	var tempLayerName = layerName.substring(0, layerName.length-2)
	var tempLayer = "";
	var tempImage = "";

	if(subSubTopic != imgName)
	{
		if(document.layers) //netscape 4.x version
		{
			tempLayer = document.layers[tempLayerName].document;
			tempImage = tempLayer.images[imgName];
//			tempImage.src=tempImage.src.replace(leftMenuSectionImageOver, leftMenuSectionImageOut)
		}
		else
		{
//			document.images[imgName].src=document.images[imgName].src.replace(leftMenuSectionImageOver, leftMenuSectionImageOut)
		}
		
		secondLayerImagesFlag = false;
	}
	if (thirdLayerFlag )
	{
		MM_showHideLayers(layerName,'','hide')
		thirdLayerFlag =false;
	}
	activeSecondLayerImageID = "";
	activeThirdLayerID = "";
}

function secondLayerMouseOut(imgName, layerName) {
	
	if (activeSecondLayerImageID == imgName && activeThirdLayerID == layerName)
	{
		thirdLayerTimerID = setTimeout("doHideSecondLayer('"+imgName+"', '"+layerName+"')", 500);
	}
	else
	{
		doHideSecondLayer(imgName, layerName);
	}
}

// -------------------------------------------------------------   End of Common Function for Second Level Layers -----------------------------------------


//print this page
function printPage(){
	if(location.href.toString().search('search.info.gov.hk')!=-1){
		window.open(document.URL+'?p=1','PrintPage','top=10,left=10,height=500,width=650,scrollbars=1');
	}else{
		window.open(document.location.pathname+'?p=1','PrintPage','top=10,left=10,height=500,width=650,scrollbars=1');
	}
}

function getTitle() {
	var scriptBuffer='';
	var scriptBuffer2='';
	
	scriptBuffer2+=sitetitle+' - '+title[selectedID];
	if(selectedSection!=0&&selectedSection!='') {
		scriptBuffer2+= ' - ' + subTitle[selectedID+1][selectedSection]
		if(selectedSubSection>0&&selectedSubSection!='') {
			scriptBuffer2+= ' - ' + subSubTitle[selectedID+1][selectedSection][selectedSubSection]
		}
	}
	
	scriptBuffer+='<title>'+scriptBuffer2+'</title>\n';
	scriptBuffer+='<meta name="Keywords" content="'+sitetitle+', '+title[selectedID]+'">\n';
	
	//alert(scriptBuffer);
	return scriptBuffer;	
	/*
	var scriptBuffer='';
	scriptBuffer+='<meta name="Keywords" content="';
	scriptBuffer+='Census and Statistics Department - '+title[selectedSection];
	if(selectedSubSection!=0&&selectedSubSection!='') {
		scriptBuffer+= ' - ' + subTitle[selectedSection+1][selectedSubSection]
		if(subLevelSection>0&&subLevelSection!='') {
			scriptBuffer+= ' - ' + subSubTitle[selectedSection+1][selectedSubSection][subLevelSection]
		}
	}
	scriptBuffer+='">';
	return scriptBuffer;	
	*/
}


//change to text only version
function textSwitch() {
	document.location = domain_url+ "/index.htm";
	if(location.href.toString().search('search.info.gov.hk') != -1){
		if (location.href.toString().search('mode=174') != -1) { //change to English version
			goPath=location.href.replace("mode=174", "mode=16");
		}
		if (location.href.toString().search('mode=175') != -1) { //change to traditional chinese version
			goPath=location.href.replace("mode=175", "mode=15");
		}
		document.location=goPath;
	}else{
	var arrayEle = new Array()
	arrayEle = document.location.pathname.split('/')
	document.location = 't_'+arrayEle[arrayEle.length-1]
	}
}

//switch language version
var chi_str = document.URL.toString(); 

if(chi_str.search('/gb/') != -1){ 
	chi_str = chi_str.substring( chi_str.indexOf('/gb/')+4, chi_str.length ); 
} 
else {
	chi_str = chi_str.substring( 7, chi_str.length ); 
}


function langSwitch(lang) {
var currentPath=location.href.toString();
var switchTc='/tc/';
var switchSc='/chs/';
var switchEn='/en/';

	if(lang=="graphic"){
		currentPath=currentPath.replace('/text', "");
	}else if(lang=="textonly"){
		/*currentPath=currentPath.replace(switchEn, '/text'+switchEn);
		currentPath=currentPath.replace(switchTc, '/text'+switchTc);*/
		currentPath=currentPath.replace(switchSc, '/text'+switchSc);
	}else if(lang=="tc"){
		currentPath=currentPath.replace(switchEn, switchTc);
		currentPath=currentPath.replace(switchSc, switchTc);
	}else if(lang=="sc"){
/*		currentPath=currentPath.replace('http://', 'http://'+gb_urlPath);
		currentPath=currentPath.replace(switchEn, switchTc);*/
		currentPath=currentPath.replace(switchTc, switchSc);
		currentPath=currentPath.replace(switchEn, switchSc);
	}else if(lang=="en"){
		currentPath=currentPath.replace(switchTc, switchEn);
		currentPath=currentPath.replace(switchSc, switchEn);
	}
	location.href=currentPath;
}

function getheaderHTML()
{
	if(document.URL.toString().search('/chs/')!=-1){
		var AltMain='香港经济近况';
	}else{
		var AltMain='Hong Kong Economy';
	}
	//check not textonly version
	if(document.URL.toString().search('/text/')==-1){
	
		if(printPage!=1){
			document.writeln(getHeader());
		}
		if(printPage!=1){
			document.writeln('<table width="770" border="0" cellspacing="0" cellpadding="0">');
		}else{
			document.writeln('<table width="617" border="0" cellspacing="0" cellpadding="0">');
		}
		if(printPage!=1){
			document.writeln('<tr>');
			document.writeln('	<td colspan="2" align="left" valign="top"><img src="'+imgPath+'images/mainVis.jpg" alt="'+AltMain+'" title="'+AltMain+'" border="0"></td>');
			document.writeln('</tr>');
		}
		document.writeln('<tr>');
		if(printPage!=1){
			document.writeln('	<td width="153" align="left" valign="top" background="'+domain_url+'/images/nav_bg.jpg">');
			document.writeln(getLeftMenu());
			document.writeln('	</td>');
		}
		document.writeln('	<td width="617" align="left" valign="top" background="'+imgPath+'images/right_bg.jpg">');
		document.writeln('		<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('		<tr>');
		document.write('			<td colspan=\"3\" align=\"right\">');
		document.write(getPrintButton());
		document.write('<img src=\"'+imgPath+'images/spacer.gif" width="1" height="20"></td>');
		document.writeln('		</tr>');
		document.writeln('		<tr>');
		document.writeln('			<td width="21">&nbsp;</td>');
		getTopic();
	//	document.writeln('			<td><img src="'+imgPath+'images/hd_01.jpg" width="568" height="20" /></td>');
	
		if((document.URL.toString().search('/sitemap/')!=-1)||(document.URL.toString().search('/notices/')!=-1)){
			document.writeln('			<td width="28"><img src="../../images/spacer.gif" width="28" height="20" /></td>');
		}else{
			document.writeln('			<td width="28"><img src="'+imgPath+'images/hd_right.jpg" width="28" height="20" /></td>');
		}//end site map
	
		document.writeln('		</tr>');
		document.writeln('		<tr>');
		document.writeln('			<td>&nbsp;</td>');
		document.writeln('			<td background="'+imgPath+'images/sub_hd_bg.jpg" class="sub_hd"><img src="../../images/spacer.gif" width="10" height="10" />');
		//sitemap
		if((document.URL.toString().search('/sitemap/')==-1) && (document.URL.toString().search('/notices/')==-1)){
		
		if (typeof(subTitle[parseInt(selectedID)+1]) !='undefined'){
			if (typeof(subTitle[parseInt(selectedID)+1][selectedSection])!='undefined'){
				if(subTitle[parseInt(selectedID)+1][selectedSection]!=null){
					document.writeln(subTitle[parseInt(selectedID)+1][selectedSection]);
				}else{
					document.writeln('&nbsp;');
				}
			}
		}
		}//end site map
		document.writeln('			</td>');
		document.writeln('			<td valign="top"><img src="'+imgPath+'images/sub_hd_right.jpg" width="28" height="20" /></td>');
		//document.writeln('			<td background="'+imgPath+'images/sub_hd_right.jpg"><img src="'+imgPath+'images/spacer.gif" width="28" height="20" /></td>');
		document.writeln('		</tr>');
		document.writeln('		<tr>');
		document.writeln('			<td>&nbsp;</td>');
		document.writeln('			<td>&nbsp;</td>');
		document.writeln('			<td>&nbsp;</td>');
		document.writeln('		</tr>');
		document.writeln('		<tr>');
		document.writeln('			<td>&nbsp;</td>');
		document.writeln('			<td>');
	
	}else{//istextonly version
		document.writeln('<table width="100%" border="0" cellspacing="2" cellpadding="2">');
		document.writeln('<tr><td>');
		//document.writeln('<p><b>Hong Kong Enconomic</b></p>');
		if(printPage!=1) {
			document.writeln(getHeader());
			document.writeln('<hr>');
			document.writeln(getLeftMenu());
			document.writeln('<hr>');
		}
		getTopic();
	}//check not textonly version
	SiteMap();
}

//generate common look & feel header
function getHeader(){
	//define the common background image path
	var bkImgPath=domain_url+'/images/bkgdtexture.gif';
	//define the language icon image path
	var textPath=domain_url+'/images/textonly.gif';
	var textOverPath=domain_url+'/images/textonly_over.gif';
	var lang1Path=domain_url+'/images/tc.gif';
	var lang1OverPath=domain_url+'/images/tc_over.gif';
	var lang2Path=domain_url+'/images/sc.gif';
	var lang2OverPath=domain_url+'/images/sc_over.gif';
	//set hyperlink for items
	var brandingLink='ht'+'tp://'+domain+'/index.html';
	var brandhkLink='javascript:externalLink(\'http://www.brandhk.gov.hk/brandhk/eindex.htm\')';
	var gicLink='javascript:externalLink(\'http://www.gov.hk/sc/residents\')';
	var textLink='javascript:langSwitch(\'textonly\')';//domain_url+"/index.htm"; //Change to text only version //	var textLink='javascript:textSwitch()'; //Change to text only version
	var graphicLink='javascript:langSwitch(\'graphic\')'; //Graphic
	var SearchLang="";
	var SearchCharset="";

	if(document.URL.toString().search('/gb/')!=-1){
		var lang1Link='javascript:langSwitch(\'tc\')'; //Traditional Chinese
		var lang2Link='javascript:langSwitch(\'en\')'; //English
		//set alternate text for the items
		var brandingAlt='香港经济近况';
		var brandhkAlt='Brand Hong Kong';
		var gicAlt='GovHK 香港政府一站通';
		var textAlt='纯文字';
		var lang1Alt='繁体版';
		var lang2Alt='English';
		var searchAlt='搜寻';
		var sitemapAlt='网页指南';	
		var contactusAlt='联络我们';
		var graphicAlt='图像版';
		SearchLang="zh-cn";
		SearchCharset="gb";
	}else if(document.URL.toString().search('/chs/')!=-1 || document.URL.toString().search('mode=288')!=-1){
		var lang1Link='javascript:langSwitch(\'tc\')'; //Simplified Chinese
		var lang2Link='javascript:langSwitch(\'en\')'; //English
		//set alternate text for the items
		var brandingAlt='香港经济近况';
		var brandhkAlt='Brand Hong Kong';
		var gicAlt='GovHK 香港政府一站通';
		var textAlt='纯文字';
		var lang1Alt='繁体版';
		var lang2Alt='English';
		var searchAlt='搜寻';
		var sitemapAlt='网页指南';	
		var contactusAlt='联络我们';
		var graphicAlt='图像版';
		SearchLang="zh-cnhk";
		SearchCharset="utf-8";
	}else{
		var lang1Link='javascript:langSwitch(\'tc\')'; //Traditional Chinese
		var lang2Link='javascript:langSwitch(\'sc\')'; //Simplified Chinese
		//set alternate text for the items
		var brandingAlt='Hong Kong Economy';
		var brandhkAlt='Brand Hong Kong';
		var gicAlt='GovHK 香港政府一站通';
		var textAlt='Text Only';
		var lang1Alt='Traditional Chinese';
		var lang2Alt='Simpilified Chinese';
		var searchAlt='Search';
		var sitemapAlt='Site Map';	
		var contactusAlt='Contact Us';
		var graphicAlt='Graphic Version';
		SearchLang="en";
		SearchCharset="iso-8859-1";
	}	
	
	var searchLink='javascript:document.forms.search.submit()';
	var sitemapLink=langPath+'sitemap/index.htm';	
	var contactusLink=langPath+'contactus/index.htm';
	//generate the menu to the buffer variable
	var scriptBuffer='';
	
	//form hidden field add here
	var scriptFormBuffer='';
	scriptFormBuffer+='<form name="search" action="http://search.gov.hk/search.html" method="get">';
	scriptFormBuffer+='<INPUT name="exact_q" type="hidden" value="">';
	scriptFormBuffer+='<INPUT name="any_q" type="hidden" value="">';
	scriptFormBuffer+='<INPUT name="none_q" type="hidden" value="">';
	scriptFormBuffer+='<INPUT name="gp0" type="hidden" value="hkecon_home">';
	scriptFormBuffer+='<INPUT name="gp1" type="hidden" value="hkecon_home">';
	scriptFormBuffer+='<INPUT name="p_size" type="hidden" value="10">';
	scriptFormBuffer+='<INPUT name="doc_type" type="hidden" value="all">';
	scriptFormBuffer+='<INPUT name="last_mod" type="hidden" value="#-1">';
	scriptFormBuffer+='<INPUT name="ui_lang" type="hidden" value="'+SearchLang+'">';
	scriptFormBuffer+='<INPUT name="r_lang" type="hidden" value="all">';
	scriptFormBuffer+='<INPUT name="ui_charset" type="hidden" value="'+SearchCharset+'">';
	scriptFormBuffer+='<INPUT name="tpl_id" type="hidden" value="hkecon">';
	scriptFormBuffer+='<INPUT name="a_submit" type="hidden" value="false">';
	scriptFormBuffer+='<INPUT name="web" type="hidden" value="this">';
	/*
	if(document.URL.toString().search('/sc/')!=-1){
		scriptFormBuffer+='<form name="search" action="http://sc.info.gov.hk/gb/search.info.gov.hk/cgi-bin/se.cgi" method="get">';
	} else {
		scriptFormBuffer+='<form name="search" action="http://search.info.gov.hk/cgi-bin/se.cgi" method="get">';
	}
	if(document.URL.toString().search('/tc/')!=-1 || document.URL.toString().search('/sc/')!=-1){
		scriptFormBuffer+='<input name=mode type=hidden value=0>';
	} else {
		scriptFormBuffer+='<input name=mode type=hidden value=1>';
	}
	scriptFormBuffer+='<input name=la type=hidden value=1>';
	scriptFormBuffer+='<input name=gr_1 type=hidden value="hkecon">';
	scriptFormBuffer+='<input name=ma type=hidden value=100>';
	scriptFormBuffer+='<input name=ft_1 type=hidden value="alltype">';
	scriptFormBuffer+='<input name=so type=hidden value=0>';
	scriptFormBuffer+='<input name=nu type=hidden value=10>';
	scriptFormBuffer+='<input name=ca type=hidden value=0>';
	scriptFormBuffer+='<input name=ta type=hidden value="all">';
	scriptFormBuffer+='<input name=fu type=hidden value="">';
	scriptFormBuffer+='<input name=fd type=hidden value="">';
	*/
	/*
	scriptFormBuffer+='<form name="search" action="http://search.info.gov.hk/cgi-bin/se.cgi" method="get">';
	scriptFormBuffer+='<input name=mode type=hidden value=174>';
	scriptFormBuffer+='<input name=la type=hidden value=1>';
	scriptFormBuffer+='<input name=gr_1 type=hidden value="censtatd">';
	scriptFormBuffer+='<input name=ma type=hidden value=100>';
	scriptFormBuffer+='<input name=ft_1 type=hidden value="alltype">';
	scriptFormBuffer+='<input name=so type=hidden value=0>';
	scriptFormBuffer+='<input name=nu type=hidden value=10>';
	scriptFormBuffer+='<input name=ca type=hidden value=0>';
	scriptFormBuffer+='<input name=ta type=hidden value="all">';
	scriptFormBuffer+='<input name=fu type=hidden value="">';
	scriptFormBuffer+='<input name=fd type=hidden value="">';
	*/
	//form hidden field add here

	//check not textonly version
	if(document.URL.toString().search('/text/')==-1){
	
		scriptBuffer+='<table width="770" border="0" cellpadding="0" cellspacing="0" background="'+imgPath+'images/bkgdtexture.gif">';
		scriptBuffer+=scriptFormBuffer;
		scriptBuffer+='<tr align="left" valign="top">';
		scriptBuffer+='<td>';
		scriptBuffer+='<table border="0" cellpadding="0" cellspacing="0">';
		scriptBuffer+='<tr align="left" valign="top">';
		scriptBuffer+='<td>';
		scriptBuffer+='<td class="sidebar" background="'+imgPath+'images/bkgdtexture.gif"><a href="'+brandingLink+'"><img src="'+imgPath+'images/branding.jpg" alt="'+brandingAlt+'" title="'+brandingAlt+'" border="0"></a></td>';
		scriptBuffer+='<td><img src="'+imgPath+'images/spacer.gif" width="86" height="1" border="0"></td>';
		scriptBuffer+='<td background="'+imgPath+'images/bkgdtexture.gif" valign="bottom"><div align="right"><a href="'+brandhkLink+'"><img name="BrandHK" src="'+imgPath+'images/BrandHK.gif" border="0" alt="'+brandhkAlt+'"></a></div></td>';
		scriptBuffer+='</tr>';
		scriptBuffer+='</table>';
		scriptBuffer+='</td>';
		scriptBuffer+='</tr>';
		scriptBuffer+='<tr align="left" valign="top">';
		scriptBuffer+='<td>';
		scriptBuffer+='<table border="0" cellpadding="0" cellspacing="0">';
		scriptBuffer+='<tr align="left" valign="bottom">';
		scriptBuffer+='<td>';
		scriptBuffer+='<td background="'+imgPath+'images/bkgdtexture.gif"><a href="'+gicLink+'" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'mainbar1\',\'\',\''+imgPath+'images/mainbar1_f2.gif\',1)" ><img name="mainbar1" src="'+imgPath+'images/mainbar1.gif" border="0" alt="'+gicAlt+'"></a></td>';
		scriptBuffer+='<td align="left"><a href="'+textLink+'" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'mainbar2\',\'\',\''+imgPath+'images/mainbar2_f2.gif\',1)" ><img name="mainbar2" src="'+imgPath+'images/mainbar2.gif" border="0" alt="'+textAlt+'"></a></td>';
		scriptBuffer+='<td align="left"><a href="'+lang1Link+'" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'mainbar3\',\'\',\''+imgPath+'images/mainbar3_f2.gif\',1)" ><img name="mainbar3" src="'+imgPath+'images/mainbar3.gif" border="0" title="'+lang1Alt+'" alt="'+lang1Alt+'"></a></td>';
		scriptBuffer+='<td align="left"><a href="'+lang2Link+'" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'mainbar4\',\'\',\''+imgPath+'images/mainbar4_f2.gif\',1)" ><img name="mainbar4" src="'+imgPath+'images/mainbar4.gif" border="0" title="'+lang2Alt+'" alt="'+lang2Alt+'"></a></td>';
		scriptBuffer+='<td><img name="mainbar5" src="'+imgPath+'images/mainbar5.gif" border="0"></td>';
		scriptBuffer+='<td><img src="'+imgPath+'images/spacer.gif" width="40" height="20" border="0"></td>';
		scriptBuffer+='<td background="'+imgPath+'images/bkgdtexture.gif"><a href="'+searchLink+'" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'mainbar6\',\'\',\''+imgPath+'images/mainbar6_f2.gif\',1)" ><img name="mainbar6" src="'+imgPath+'images/mainbar6.gif" border="0" alt="'+searchAlt+'"></a></td>';
		scriptBuffer+='<td background="'+imgPath+'images/bkgdtexture.gif" width="99">';
		scriptBuffer+='<div align="center">';
		scriptBuffer+='<INPUT name="txtonly" type="hidden" value="0"><input name="query" type="text" id="qu" size="12" class="search">';
//	scriptBuffer+='<input class="search" type="text" name="search" size="12">';
		scriptBuffer+='</div>';
		scriptBuffer+='</td>';
		scriptBuffer+='<td background="'+imgPath+'images/bkgdtexture.gif"><a href="'+searchLink+'" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'mainbar8\',\'\',\''+imgPath+'images/mainbar8_f2.gif\',1)" ><img name="mainbar8" src="'+imgPath+'images/mainbar8.gif" border="0" alt="'+searchAlt+'"></a></td>';
		scriptBuffer+='<td background="'+imgPath+'images/bkgdtexture.gif"><a href="'+sitemapLink+'" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'mainbar9\',\'\',\''+imgPath+'images/mainbar9_f2.gif\',1)" ><img name="mainbar9" src="'+imgPath+'images/mainbar9.gif" border="0" alt="'+sitemapAlt+'"></a></td>';
		scriptBuffer+='<td background="'+imgPath+'images/bkgdtexture.gif"><a href="'+contactusLink+'" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage(\'mainbar10\',\'\',\''+imgPath+'images/mainbar10_f2.gif\',1)" ><img name="mainbar10" src="'+imgPath+'images/mainbar10.gif" border="0" alt="'+contactusAlt+'"></a></td>';
		scriptBuffer+='</tr>';
		scriptBuffer+='</table>';
		scriptBuffer+='</td>';
		scriptBuffer+='</tr>';
		scriptBuffer+='<tr align="left" valign="top" bgcolor="#BB3333">';
		scriptBuffer+='<td height="2"><img src="'+imgPath+'images/reddot.gif" width="1" height="1"></td>';
		scriptBuffer+='</tr>';
		scriptBuffer+='</form>';
		scriptBuffer+='</table>';
//	scriptBuffer+='<img src="'+domain_url+'/images/top_view.jpg"><br>';
	}else{//textonly version
		scriptBuffer+='<p><b><a href="'+brandingLink+'">'+brandingAlt+'</a></b></p>';
		scriptBuffer+='<table width="100%" border="0" cellpadding="0" cellspacing="0">';
		scriptBuffer+=scriptFormBuffer;
		scriptBuffer+='<tr><td>';
		scriptBuffer+='[<a href="'+gicLink+'">'+gicAlt+'</a>] ';
		scriptBuffer+='[<a href="'+graphicLink+'">'+graphicAlt+'</a>] ';
		scriptBuffer+='[<a href="'+lang1Link+'">'+lang1Alt+'</a>] ';
		scriptBuffer+='[<a href="'+lang2Link+'">'+lang2Alt+'</a>] ';
		scriptBuffer+='[<a href="'+searchLink+'">'+searchAlt+'</a>] <INPUT name="txtonly" type="hidden" value="0"><input name="query" type="text" id="qu" size="12" class="search">';
		scriptBuffer+='[<a href="'+sitemapLink+'">'+sitemapAlt+'</a>] ';
		scriptBuffer+='[<a href="'+contactusLink+'">'+contactusAlt+'</a>] ';
		scriptBuffer+='</td></tr>';
		scriptBuffer+='</form>';
		scriptBuffer+='</table>';
	
	}//check not textonly version
	
	return scriptBuffer;
}

function SiteMap(){
	if(document.URL.toString().search('/sitemap/')!=-1){
		document.writeln('<table border="0" cellpadding="2" cellspacing="0"><tr><td>');
		document.writeln('<ul>');
		for (var i in MainLink){
			document.writeln('	<li><a href="'+MainLink[i]+'">'+title[i]+'</a>');
			if (SubLink[i]!=null){
				document.writeln('<ul>');
				for (var k in SubLink[i]){
					document.writeln('	<li><a href="'+SubLink[i][k]+'">'+subTitle[parseInt(i)+1][k]+'</a>');
					if (SubLink2[i][k]!=null){
						document.writeln('<ul>');
						for (var m in SubLink2[i][k]){
							document.writeln('	<li><a href="'+SubLink2[i][k][m]+'">'+subSubTitle[parseInt(i)+1][k][m]+'</a>');
						}
						document.writeln('</ul>');
					}
				}
				document.writeln('</ul>');
			}
			document.writeln('</li>');
		}
		document.writeln('</ul>');
		document.writeln('</td></tr></table>');
			
	}
}
//generate the left side menu
function getLeftMenu(){
	var scriptBuffer='';
	var isOver='';
	var iconNo = 0;
	
	//check not textonly version
	if(document.URL.toString().search('/text/')==-1){
	
	scriptBuffer+='<table border="0" cellspacing="0" cellpadding="0">\n';
	for (var i in MainLink)
	{
//	alert(leftMenuName+i)
		(iconNo<10)?iconNo='0'+iconNo:iconNo=iconNo;
		(selectedID==i)?isOver='_over':isOver='';
		if (selectedID==i){mainTopic=i;}
		scriptBuffer+='<tr><td><a href="'+MainLink[i]+'" onmouseout="leftMenuMouseOut(\''+i+'\')" onmouseover="leftMenuMouseOver(\''+i+'\')"><img src="'+imgPath+'images/nav_'+iconNo+isOver+'.gif" name="'+leftMenuName+i+'" border="0" alt="'+title[i]+'" title="'+title[i]+'"></a></td></tr>\n';
		iconNo = parseInt(i) + 1;
	}
	scriptBuffer+='<tr valign="top"><td><img src="'+domain_url+'/images/nav_bg_pix.jpg" alt=""></td></tr>\n';
	scriptBuffer+='</table>\n';
	}else{//istextonly version
	
		//mainmenu
		scriptBuffer+='<table border="0" cellspacing="0" cellpadding="2">\n';
		scriptBuffer+='<tr><td>';
		for (var i in MainLink){
			iconNo = parseInt(i) + 1;
			(iconNo<10)?iconNo='0'+iconNo:iconNo=iconNo;
			(selectedSection==i)?isOver='_o':isOver='';
			if(i!=selectedID){
				scriptBuffer+='[<a href="'+MainLink[i]+'">'+title[i]+'</a>]\n';
			}else{
				scriptBuffer+='['+title[i]+']\n';
			}
		}
		scriptBuffer+='</td></tr>';
		scriptBuffer+='</table>\n';
		//mainmenu
	

		//submenu
		
		
		var TempSelectedID=selectedID+1;
		if (SubLink[selectedID]!=null){
			
			scriptBuffer+='<table border="0" cellspacing="0" cellpadding="2">\n';
			scriptBuffer+='<tr><td>';
		
		  	for (var k in SubLink[selectedID]){
		  		if(k!=selectedSection){
					scriptBuffer+='[<a href="'+SubLink[selectedID][k]+'">'+subTitle[TempSelectedID][k]+'</a>] ';
				}else{
					scriptBuffer+='['+subTitle[TempSelectedID][k]+'] ';
				}//end if
		  	}//end for
			
			scriptBuffer+='</td></tr>';
			scriptBuffer+='</table>\n';
		}
			
		
		//submenu
		
		//Sub Submenu
		if (SubLink[TempSelectedID]!=null){
		
		scriptBuffer+='<table border="0" cellspacing="0" cellpadding="2">\n';
		scriptBuffer+='<tr><td>';
		if (SubLink2[TempSelectedID][selectedSection]!=null){
			for (var l in SubLink2[TempSelectedID][selectedSection]){
				if(l!=selectedSubSection){
					scriptBuffer+='[<a href="'+SubLink2[TempSelectedID][selectedSection][l]+'">'+subSubTitle[selectedID][selectedSection][l]+'</a>] ';
				}else{
					scriptBuffer+='['+subSubTitle[selectedID][selectedSection][l]+'] ';
				}
			}
		}
		scriptBuffer+='</td></tr>';
		scriptBuffer+='</table>\n';
		
		}//Sub Submenu

		
	}//check not textonly version

	return scriptBuffer;
}

function getLayer()
{
	var scriptBuffer='';
	var isOver='';
	var iconNo = '';
	var subIconNo = '';
	
	//check not textonly version
	if(document.URL.toString().search('/text/')==-1){
	
	for (var j in MainLink)
	{
		if (SubLink[j]!=null)
		{
			
			//Start Layer
			iconNo = parseInt(j) + 1;
			(iconNo<10)?iconNo='0'+iconNo:iconNo=iconNo;
			arLayer[arLayer.length] = layerCommonName+iconNo;
			arLayer2[arLayer2.length] = j;
			
			if (document.layers)
			{document.writeln('<layer name="'+layerCommonName+iconNo+'" top=0 left='+(leftOffSet+154)+' width=145 height=58 visibility="hide" onMouseOver="leftMenuMouseOver(\''+j+'\')" onMouseOut="leftMenuMouseOut(\''+j+'\')">');}
			else
			{document.writeln('<div id="'+layerCommonName+iconNo+'" style="position:absolute; left:'+(leftOffSet+154)+'; top:0; width:145; height:58; z-index:2; visibility: hidden"> ');}
			
			//content for Layers
			document.writeln('<table width="145" border="0" cellspacing="0" cellpadding="0" onMouseOver="leftMenuMouseOver(\''+j+'\')" onMouseOut="leftMenuMouseOut(\''+j+'\')">');
			
			for (var k in SubLink[j])
			{
				(selectedSection==j && selectedSubSection==k)?isOver='_over':isOver='';
				subIconNo = parseInt(k);
				(subIconNo<10)?subIconNo='0'+subIconNo:subIconNo=subIconNo;
				if (selectedSection==j && selectedSubSection==k){subTopic=leftMenuName+j+'_'+k;}

				document.writeln('<tr valign=top>');
//				document.writeln('	<td><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td align="left" width="100%" class="menu"><a href="'+SubLink[j][k]+'" onMouseOver="MM_swapImage(\''+leftMenuName+j+'_'+k+'\',\'\',\''+imgPath+'images/btn_lv1_'+iconNo+subIconNo+'_o.jpg\',1); firstLayerMouseOver(\''+leftMenuName+j+'_'+k+'\', \''+layerCommonName+iconNo+subIconNo+'\');" onMouseOut="MM_swapImgRestore(); firstLayerMouseOut(\''+leftMenuName+j+'_'+k+'\', \''+layerCommonName+iconNo+subIconNo+'\');"><img name="'+leftMenuName+j+'_'+k+'" src="'+imgPath+'images/btn_lv1_'+iconNo+subIconNo+'.jpg" alt="'+subTitle[parseInt(j)+1][k]+'" border="0"></a></td></tr></table></td>');
//				document.writeln('	<td bgcolor="#AAAAA5" onMouseover="this.style.backgroundColor=\'4D9EB9\',this.style.color=\'FFFFFF\';menuTitle'+parseInt(j)+"_"+k+'.style.color=\'FFFFFF\';"  onMouseout="this.style.backgroundColor=\'AAAAA5\',this.style.color=\'FFFFFF\';menuTitle'+parseInt(j)+"_"+k+'.style.color=\'FFFFFF\';"><table border="0" cellspacing="0" cellpadding="0" width="145"><tr><td colspan="3"><img src="'+imgPath+'images/spacer.gif" alt="'+subTitle[parseInt(j)+1][k]+'" height="3" border="0" name="'+leftMenuName+j+'_'+k+'" width="145"></td></tr><tr><td><img src="'+imgPath+'images/spacer.gif" width="7"></td><td align="left" width="100%" class="menu"><a href="'+SubLink[j][k]+'" onMouseOver="firstLayerMouseOver(\''+leftMenuName+j+'_'+k+'\', \''+layerCommonName+iconNo+subIconNo+'\');"  onMouseOut="firstLayerMouseOut(\''+leftMenuName+j+'_'+k+'\', \''+layerCommonName+iconNo+subIconNo+'\');"><span style="font-size:11px;font-family:Arial, Helvetica, sans-serif;line-height:13px;color:#FFFFFF;text-decoration:none" onMouseover="this.style.color=\'FFFFFF\';" onMouseout="this.style.color=\'FFFFFF\';" name="menuTitle'+parseInt(j)+"_"+k+'" id="menuTitle'+parseInt(j)+"_"+k+'">'+subTitle[parseInt(j)+1][k]+'</span></a></td><td><img src="'+imgPath+'images/spacer.gif" width="7"></td></tr><tr><td colspan="3"><img src="'+imgPath+'images/spacer.gif" alt="'+subTitle[parseInt(j)+1][k]+'" height="3" border="0" name="'+leftMenuName+j+'_'+k+'" width="145"></td></tr></table><img src="'+imgPath+'images/nav_sub_Line.gif" width="100%"></td>');
				document.write('<td bgcolor=\"#dfedf5\" onMouseover=\"this.style.backgroundColor=\'f3f9fb\',this.style.color=\'007b3f\';menuTitle'+parseInt(j)+"_"+k+'.style.color=\'007b3f\';"  onMouseout="this.style.backgroundColor=\'dfedf5\',this.style.color=\'585858\';menuTitle'+parseInt(j)+"_"+k+'.style.color=\'585858\';">');
				document.write('<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"145\">');
				document.write('<tr><td colspan=\"1\"><img src=\"'+imgPath+'images/spacer.gif" alt="'+subTitle[parseInt(j)+1][k]+'" height="3" border="0" name="'+leftMenuName+j+'_'+k+'" width="145"></td></tr>');
				document.write('<tr><!-- <td><img src=\"'+imgPath+'images/spacer.gif" width="7"></td> -->');
				document.write('	<td align=\"left\" width=\"100%\" class=\"menu\"><a href=\"'+SubLink[j][k]+'" onMouseOver="firstLayerMouseOver(\''+leftMenuName+j+'_'+k+'\', \''+layerCommonName+iconNo+subIconNo+'\');"  onMouseOut="firstLayerMouseOut(\''+leftMenuName+j+'_'+k+'\', \''+layerCommonName+iconNo+subIconNo+'\');"><span onMouseover="this.style.color=\'585858\';" onMouseout="this.style.color=\'585858\';" name="menuTitle'+parseInt(j)+"_"+k+'" id="menuTitle'+parseInt(j)+"_"+k+'">'+subTitle[parseInt(j)+1][k]+'</span></a></td>');
				document.write('	<!-- <td><img src=\"'+imgPath+'images/spacer.gif" width="7"></td> --></tr>');
				document.write('<tr><td colspan=\"1\"><img src=\"'+imgPath+'images/spacer.gif" alt="'+subTitle[parseInt(j)+1][k]+'" height="3" border="0" name="'+leftMenuName+j+'_'+k+'" width="145"></td></tr>');
				document.write('</table><img src=\"'+imgPath+'images/nav_sub_Line.gif" width="100%">');
				document.write('</td>');

				document.writeln('</tr>');
			}
			document.writeln('</table>');
			
			//Close Layer
			if (document.layers)
			{document.writeln('</layer>');}
			else
			{document.writeln('</div>');}
		}
	}
	
	}//check not textonly version
	
	return scriptBuffer;
}

function getSecondLayer()
{
	var scriptBuffer='';
	var isOver='';
	var iconNo = '';
	var subIconNo = '';
	var subSubIconNo = '';
	
	//check not textonly version
	if(document.URL.toString().search('/text/')==-1){
	
	for (var j in MainLink)
	{
		if (SubLink[j]!=null)
		{
			
			//Start Layer
			iconNo = parseInt(j) + 1;
			(iconNo<10)?iconNo='0'+iconNo:iconNo=iconNo;
			
			for (var k in SubLink[j])
			{
				if (SubLink2[j][k]!=null)
				{
					subIconNo = parseInt(k);
					(subIconNo<10)?subIconNo='0'+subIconNo:subIconNo=subIconNo;
					arSecondLayer[arSecondLayer.length] = layerCommonName+iconNo+subIconNo;
					arSecondLayer2[arSecondLayer2.length] = j+'_'+k;
					
					if (document.layers)
					{document.writeln('<layer name='+layerCommonName+iconNo+subIconNo+' top=0 left='+(leftOffSet+350)+' width=120 height=58 visibility="hide" onMouseOver="leftMenuMouseOver(\''+j+'\');firstLayerMouseOver(\''+leftMenuName+j+'_'+k+'\', \''+layerCommonName+iconNo+subIconNo+'\');" onMouseOut="leftMenuMouseOut(\''+j+'\');firstLayerMouseOut(\''+leftMenuName+j+'_'+k+'\', \''+layerCommonName+iconNo+subIconNo+'\');">');}
					else
					{document.writeln('<div id="'+layerCommonName+iconNo+subIconNo+'" style="position:absolute; left:'+(leftOffSet+350)+'; top:0; width:120; height:58; z-index:2; visibility: hidden"> ');}
					
					//content for Layers
					document.writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0" onMouseOver="leftMenuMouseOver(\''+j+'\');firstLayerMouseOver(\''+leftMenuName+j+'_'+k+'\', \''+layerCommonName+iconNo+subIconNo+'\');" onMouseOut="leftMenuMouseOut(\''+j+'\');firstLayerMouseOut(\''+leftMenuName+j+'_'+k+'\', \''+layerCommonName+iconNo+subIconNo+'\');">');
					document.writeln('<tr valign=top>');
					document.writeln('	<td><img src="'+imgPath+'images/btn_lv2_top.jpg" border="0"></td>');
					document.writeln('</tr>');
					
					for (var l in SubLink2[j][k])
					{
						subSubIconNo = parseInt(l);
						(subSubIconNo<10)?subSubIconNo='0'+subSubIconNo:subSubIconNo=subSubIconNo;
						
						document.writeln('<tr valign=top>');
						document.writeln('	<td><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td width="100%" class="menu"><a href="'+SubLink2[j][k][l]+'" onMouseOver="MM_swapImage(\''+leftMenuName+j+'_'+k+'_'+l+'\',\'\',\''+imgPath+'images/btn_lv2_'+iconNo+subIconNo+subSubIconNo+'_o.jpg\',1); secondLayerMouseOver(\''+leftMenuName+j+'_'+k+'_'+l+'\', \''+layerCommonName+iconNo+subIconNo+subSubIconNo+'\');" onMouseOut="MM_swapImgRestore(); secondLayerMouseOut(\''+leftMenuName+j+'_'+k+'_'+l+'\', \''+layerCommonName+iconNo+subIconNo+subSubIconNo+'\');"><img name="'+leftMenuName+j+'_'+k+'_'+l+'" src="'+imgPath+'images/btn_lv2_'+iconNo+subIconNo+subSubIconNo+'.jpg" alt="'+subSubTitle[parseInt(j)+1][k][l]+'" border="0"></a></td></tr></table></td>');
//						document.writeln('	<td bgcolor="#2365C3" onMouseover="this.style.backgroundColor=\'348FEA\',this.style.color=\'FFFFFF\';smenuTitle'+parseInt(j)+"_"+k+l+'.style.color=\'ffffff\';"  onMouseout="this.style.backgroundColor=\'2365C3\',this.style.color=\'B9CBE7\';smenuTitle'+parseInt(j)+"_"+k+l+'.style.color=\'B9CBE7\';"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td colspan="3" width="100%" background="images/nav_sub_Line.gif"><img src="images/nav_sub_Line.gif" alt="'+subSubTitle[parseInt(j)+1][k][l]+'" border="0" name="'+leftMenuName+j+'_'+k+'_'+l+'" width="180"></td></tr><tr><td><img src="images/spacer.gif" width="5"></td><td width="100%" class="menu"><a href="'+SubLink2[j][k][l]+'" onMouseOver="secondLayerMouseOver(\''+leftMenuName+j+'_'+k+'_'+l+'\', \''+layerCommonName+iconNo+subIconNo+subSubIconNo+'\');"  onMouseOut="secondLayerMouseOut(\''+leftMenuName+j+'_'+k+'_'+l+'\', \''+layerCommonName+iconNo+subIconNo+subSubIconNo+'\');"><span style="color:#B9CBE7;font-family:Verdana; text-decoration:none"  onMouseover="this.style.color=\'FFFFFF\';" onMouseout="this.style.color=\'B9CBE7\';" name="smenuTitle'+parseInt(j)+"_"+k+l+'"  id="smenuTitle'+parseInt(j)+"_"+k+l+'">'+subSubTitle[parseInt(j)+1][k][l]+'</span></a></td></tr></table></td>');
						document.writeln('</tr>');
					}
					document.writeln('<tr valign=top>');
					document.writeln('	<td><img src="'+imgPath+'images/btn_lv2_bottom.jpg" border="0"></td>');
					document.writeln('</tr>');
					document.writeln('</table>');		
			
					//Close Layer
					if (document.layers)
					{document.writeln('</layer>');}
					else
					{document.writeln('</div>');}
				}
			}
		}
	}
	
	}//check not textonly version
	
	return scriptBuffer;
}

function getTopic()
{
	
	/*
	//check sitemap
	if(document.URL.toString().search('/sitemap/')!=-1) {
		if(document.URL.toString().search('/en/')!=-1){//english
			var sitemapAlt="Site Map";
		}else{//chinese
			var sitemapAlt="网页指南";
		}//end english
		if(document.URL.toString().search('/text/')==-1){//sitemap graphic
			document.writeln('<td><b>'+sitemapAlt+'</b></td>');	
		}else{//is sitemap text
			document.writeln('<p><b>'+sitemapAlt+'</b></p>');
		}//end sitemap graphic
		
	//check important notice
	}else if(document.URL.toString().search('/notices/')!=-1){
		if(document.URL.toString().search('/en/')!=-1){//english
			var txtImportantNotices='Important notices';
		}else{//chinese
			var txtImportantNotices='重要告示';
		}//end english
		if(document.URL.toString().search('/text/')==-1){//sitemap graphic
			document.writeln('<td><b>'+txtImportantNotices+'</b></td>');	
		}else{//is sitemap text
			document.writeln('<p><b>'+txtImportantNotices+'</b></p>');
		}//end sitemap graphic
		
	}else{//not is sitemap & notices
	*/
	//check not textonly version
	if(document.URL.toString().search('/text/')==-1){

		document.writeln('<td><img src="'+imgPath+'images/hd_0'+selectedID+'.jpg" alt="'+title[selectedID]+'" title="'+title[selectedID]+'" /></td>');
	
	}else{//istextonly version
		var TempSelectedID=selectedID+1;
		if (SubLink[selectedID]!=null){
			if (SubLink[selectedID][selectedSection]!=null) {
				document.writeln('<p><a href="'+MainLink[selectedID]+'">'+title[selectedID]+'</a>');
				document.writeln(' > <b>'+subTitle[TempSelectedID][selectedSection]+'</b></p>');

			}else{
				document.writeln('<p><b>'+title[selectedID]+'</b></p>');
			}
		}else{
			document.writeln('<p><b>'+title[selectedID]+'</b></p>');
		}
		document.write('<div align=\"right\">'+getPrintButton()+'</div>');
	}//check not textonly version
	
	//}//end sitemap
	
}

//generate the current topic
function getCurrentTopic(){
	//set image path for the topics
	var imagePath=domain_url+'/images/topic/'
	var topicPath = new Array();
	topicPath[1]='title02';
	topicPath[2]='title03';
	topicPath[3]='title04';
	topicPath[4]='title05';
	topicPath[5]='title06';
	topicPath[6]='title07';
	topicPath[7]='title08';
	topicPath[8]='title09';
	topicPath[9]='title10';
	topicPath[10]='title11';
	topicPath[11]='title12';
	topicPath[12]='title13';
	topicPath[13]='title14';
	//generate the topic image to the buffer variable
	var scriptBuffer='';
	var altTitle='';
	if(selectedSubSection != 0){
		if (selectedSubSection < 10){
			imagePath = imagePath+topicPath[selectedSection] + '_0' + selectedSubSection;
		}else{
			imagePath = imagePath+topicPath[selectedSection] + '_' + selectedSubSection;
		}

		if (subLevelSection > 0){
			if (subLevelSection < 10){
				imagePath = imagePath + '_0' + subLevelSection;
			}else{
				imagePath = imagePath + '_' + subLevelSection;	
			}

		altTitle = subTitle[selectedSection+1][selectedSubSection]+' > '+subSubTitle[selectedSection+1][selectedSubSection][subLevelSection];			

		}else{
			altTitle = title[selectedSection]+' > '+subTitle[selectedSection+1][selectedSubSection];
		}

	}else{
		imagePath = imagePath+topicPath[selectedSection];
		altTitle = title[selectedSection];
	}
	
	scriptBuffer+='<a name="top"></a>';
	scriptBuffer+='<img src="'+imagePath+'.gif" alt="'+altTitle+'">'
	return scriptBuffer;
}

function getPrintButton() {
	var scriptBuffer='';
		if(document.URL.toString().search('/en/')!=-1){//english
			var txtPrint='Print This Page';
		}else{//chinese
			var txtPrint='列印';
		}//end 
//	scriptBuffer+='<a href="javascript:printPage();"><img src="'+domain_url+'/images/common/but_print.gif" alt="Print This Page" border="0"></a>';
	if(p==0){
		if(document.URL.toString().search('/text/')!=-1){
			scriptBuffer+='<a href="javascript:printPage();" >'+txtPrint+'</a>';
		}else{
			scriptBuffer+='<a href="javascript:printPage();" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'btnprint\',\'\',\''+imgPath+'images/btn_print_over.gif\',1)"><img src="'+imgPath+'images/btn_print.gif" name="btnprint" alt="'+txtPrint+'" title="'+txtPrint+'" border="0"></a>';
		}
	}
	return scriptBuffer;
}


function PdfReader(){
	
	var scriptBuffer='';
	var PdfText='';
	var PdfLogoAlt='';
	var PdfLogo='';
	var checker=false;
	var CheckPdfSection = new Array();
	CheckPdfSection[1]  = new Array();
	CheckPdfSection[1][1]  = true;
	CheckPdfSection[1][4]  = true;
	
	CheckPdfSection[2]  = new Array();
	CheckPdfSection[2][0]  = true;
	
	CheckPdfSection[4]  = new Array();
	CheckPdfSection[4][0]  = true;
	
	/*
	CheckPdfSection[3]  = new Array();
	CheckPdfSection[3][1]  = true;
	CheckPdfSection[3][5]  = new Array();
	CheckPdfSection[3][5][0] = false;
	CheckPdfSection[3][5][1] = true;
	CheckPdfSection[3][5][2] = true;
	CheckPdfSection[3][5][3] = true;
	CheckPdfSection[3][5][4] = true;
	*/
	
	if (typeof(CheckPdfSection[selectedID]) !='undefined'){
		if (CheckPdfSection[selectedID].length>1){
			if (typeof(CheckPdfSection[selectedID][selectedSection]) !='undefined'){
				if (CheckPdfSection[selectedID][selectedSection]){
					checker=true;
				}
				if (CheckPdfSection[selectedID][selectedSection].length>1){
					if (typeof(CheckPdfSection[selectedID][selectedSection][selectedSubSection]) !='undefined'){
						
						//check isTrue add content here
						if (CheckPdfSection[selectedID][selectedSection][selectedSubSection]){
							checker=true;
						}else{
							checker=false;
						}
						//check isTrue add content
						
					}//check defind 3-lv
				}//check length 2-lv
			} //check defind 2-lv
		}else{
			if (CheckPdfSection[selectedID]){
				checker=true;
			}
		}//check length 1-lv
	}//check defind 1-lv
		
	
	if (checker){
	if(document.URL.toString().search('/en/')!=-1){
		PdfText='To view the above document, you need to use an Adobe Acrobat Reader. Please click <a href="http://www.adobe.com/products/acrobat/readstep2.html" target="_blank">here</a> to download the latest version and install the <a href="http://www.adobe.com/products/acrobat/acrrasianfontpack.html" target="_blank">Asian Font Pack</a> if necessary.';
		PdfLogoAlt='Get Adobe Acrobat Reader';
	/*
	}else if(document.URL.toString().search('/sc/')!=-1){
		PdfText='眕奻恅璃眕PDF 迹宒揣湔ㄛ斓剒猁妏蚚Adobe Acrobat Reader 懂堐拟〔⺼剒假蚾ㄛ褫偌<a href="http://www.chinese-t.adobe.com/products/acrobat/readstep2.html?c=hk" target="_blank">森揭</a> 狟婥蚬⻏璃挚［<a href="http://www.chinese-t.adobe.com/products/acrobat/acrrasianfontpack.html?c=hk">捚粔趼倰杶璃</a> 〔';
		PdfLogoAlt='假蚾 Acrobat Reader';
	*/
	}else{
		PdfText='以上文件以PDF 格式储存，你需要使用Adobe Acrobat Reader 来阅览。如需安装，可按<a href="http://www.chinese-t.adobe.com/products/acrobat/readstep2.html?c=hk" target="_blank">此处</a> 下载该软件及其<a href="http://www.chinese-t.adobe.com/products/acrobat/acrrasianfontpack.html?c=hk">亚洲字型套件</a> 。';
		PdfLogoAlt='安装 Acrobat Reader';
	}
	//check not textonly version
	if(document.URL.toString().search('/text/')==-1){
		PdfLogo='<img src="'+domain_url+'/images/pdficon.gif" width="88" height="31" border="0" title="'+PdfLogoAlt+'" alt="'+PdfLogoAlt+'">';
	}else{//istextonly version
		PdfLogo=PdfLogoAlt;
	}
	scriptBuffer+='<table border="0" cellpadding="2" cellspacing="0" width="100%">';
	scriptBuffer+='<tr><td><a href="http://www.adobe.com/products/acrobat/readstep2.html" target="_blank">'+PdfLogo+'</a></td><td>';
	scriptBuffer+=PdfText;
	scriptBuffer+='</td></tr>';
	scriptBuffer+='</table>';
	}
	
	return scriptBuffer;
}
//generate the page footer to show the notices and revision date
function getFooter() {
	var copyYear='2007';
	var noticesLink=langPath+'notices/index.htm';
	if (revisionDate==''||revisionDate=='MM/DD/YYYY') revisionDate='08/20/2010';
	var reDate=new Date(Date.parse(revisionDate))
	
	//set language format
	if(document.URL.toString().search('/en/')!=-1){
		var txtLastRevisionDate='Last revision date: ';
		var txtImportantNotices='Important notices';
		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 showDate=reDate.getDate()+' '+monthArray[reDate.getMonth()]+' '+reDate.getFullYear();
	}else{
		var txtLastRevisionDate='修订日期:';
		var txtImportantNotices='重要告示';
		var showMonth=reDate.getMonth()+1;
		var showDate=reDate.getFullYear()+'年'+showMonth+'月'+reDate.getDate()+'日';
	}
	//generate the topic image to the buffer variable
	var scriptBuffer='';
	
	//check not textonly version
	if(document.URL.toString().search('/text/')==-1){
	
	scriptBuffer+='<table width="100%" border="0" cellspacing="0" cellpadding="0">';
/*
	if(!p) {
		scriptBuffer+='<tr>';
		scriptBuffer+='<td colspan="2" align="right" class="footer">'; 

		if (selectedSubSection != 0) {
			var thisLink;
			thisLink = '';
			if (selectedSubSubSection > 0 ) {
				thisLink = 'javascript: history.go(-1);';
			}else if (isArrayContain(document.location.pathname)){
				thisLink = MainLink[selectedSection];
			}else {
				thisLink = SubLink[selectedSection][selectedSubSection];
			}
			
			if((selectedSection==2)&&(selectedSubSection==2)&&(subLevelSection==2))
				thisLink = '/about_us/organization/responsibilities/major.htm';
			
			if((selectedSection==2)&&(selectedSubSection==2)&&(subLevelSection==1)&&(selectedSubSubSection==1))
				thisLink = '/about_us/organization/orgainzation_chart/chart.htm';
				
			if((selectedSection==5)&&(selectedSubSection==2)&&(subLevelSection==2)&&(selectedSubSubSection==1))
				thisLink = '/public_services/community_halls_centres/ccch.htm';
	
			if (vLink != '') {
				thisLink = vLink;
			}
			
//			scriptBuffer+='<a href="'+thisLink+'"><img src="'+domain_url+'/images/common/but_back.gif" border=0 align=top alt="Back"></a>&nbsp;&nbsp;&nbsp;';
		}
		if((selectedSection==1)&&(selectedSubSection==0)){
			thisLink = MainLink[selectedSection];
//			scriptBuffer+='<a href="'+thisLink+'"><img src="'+domain_url+'/images/common/but_back.gif" border=0 align=top alt="Back"></a>&nbsp;&nbsp;&nbsp;';
		}
//		scriptBuffer+='<a href="#"><img src="'+domain_url+'/images/common/but_top.gif" border=0 align=top alt="Top"></a></td>';
		scriptBuffer+='</tr>';
	}
*/
/*	scriptBuffer+='<tr>';
	scriptBuffer+='<td colspan="2"><img src="'+imgPath+'images/spacer.gif" width="16" height="16"></td>';
	scriptBuffer+='</tr>';
	scriptBuffer+='<tr>';
	scriptBuffer+='<td colspan="2" background="'+imgPath+'images/botdot.jpg"><img src="'+imgPath+'images/botdot.jpg"></td>';
	scriptBuffer+='</tr>';
	scriptBuffer+='<tr>';
	scriptBuffer+='<td colspan="2"><img src="'+imgPath+'images/spacer.gif" width="1" height="4"></td>';
	scriptBuffer+='</tr>';*/
	scriptBuffer+='<tr>';
	scriptBuffer+='<td class="footer" align="left">&nbsp;'+copyYear+'<img src="'+imgPath+'images/copy.gif" align="absmiddle"> | <a href="'+noticesLink+'" class="notices">'+txtImportantNotices+'</a></td>';
	scriptBuffer+='<td align="right" class="reDate"><div align=right>'+txtLastRevisionDate+showDate+'&nbsp;</div></td>';
	scriptBuffer+='</tr>';
	scriptBuffer+='<tr>';
	scriptBuffer+='<td colspan="2"><img src="'+imgPath+'images/spacer.gif" width="1" height="20"></td>';
	scriptBuffer+='</tr>';
	scriptBuffer+='</table>';

	}else{// istextonly version
	
		scriptBuffer+='<table width="100%" border="0" cellspacing="0" cellpadding="0">';
		scriptBuffer+='<tr>';
		scriptBuffer+='<td>'+copyYear+' | <a href="'+noticesLink+'" class="notices">'+txtImportantNotices+'</a></td><td align="right"><div align=right>'+txtLastRevisionDate+showDate+'</div></td>';
		scriptBuffer+='</tr>';
		scriptBuffer+='</table>';
	
	}//check not textonly version
	return scriptBuffer;
}

function getfooterHTML()
{
	document.writeln(PdfReader());
	//check not textonly version
	if(document.URL.toString().search('/text/')==-1){

/*
document.writeln('		        	</td>');
document.writeln('		        	<td align="left" valign="top">&nbsp;</td>');
document.writeln('		        </tr>');
document.writeln('		        </table>');
document.writeln('			</td>');
document.writeln('      </tr>');
document.writeln('      <tr>');
document.writeln('	        <td valign="top"><div align="right"><a href="#top" onMouseOver="MM_swapImage(\'Image1\',\'\',\''+imgPath+'images/btn_top_o.jpg\',1)" onMouseOut="MM_swapImgRestore()"><img src="'+imgPath+'images/btn_top.jpg" id="Image1" alt="Top" border="0"></a></div></td>');
document.writeln('      <tr>');
document.writeln('		</table>');
document.writeln('	</td>');
document.writeln('</tr>');*/
document.writeln('		      </td>');
document.writeln('            <td>&nbsp;</td>');
document.writeln('          </tr>');
document.writeln('          <tr>');
document.writeln('            <td>&nbsp;</td>');
document.writeln('            <td><p></p><br></td>');
document.writeln('            <td>&nbsp;</td>');
document.writeln('          </tr>');
document.writeln('        </table>');
document.writeln('	</td>');
document.writeln('</tr>');
document.writeln('<tr>');
if(printPage!=1){
	document.writeln('	<td valign="bottom" background="'+domain_url+'/images/nav_bg.jpg"><img src="'+domain_url+'/images/footer_left.jpg" border="0"></td>');
}
document.writeln('	<td background="'+imgPath+'images/footer_bg.jpg">');
document.writeln(getFooter());
document.writeln('	</td>');
document.writeln('</tr>');
document.writeln('</table>');
	
	}else{//istextonly version
		document.writeln('<hr>');
		document.writeln(getFooter());
		
		document.writeln('</td></tr>');
		document.writeln('</table>');

	}//check not textonly version
}

function isArrayContain(sLink) {
	for (var i in SubLink[selectedSection]){
		if (SubLink[selectedSection][i].indexOf(sLink)!=-1) {
			return true;
		}
	}
	return false;
}


function getSubSectionList() {
	var scriptBuffer;
	var bulletPath;
	bulletPath = 'images/bullet_1.gif';
	
	scriptBuffer = '';
	scriptBuffer+='<table cellspacing="0" cellpadding="0" border="0" width="100%">';
	if (selectedSubSection==0){
		for (i=1; i<SubLink[selectedSection].length;i++ ) {
			scriptBuffer+='<tr>';
			scriptBuffer+='<td width="10%" align="right" valign="top"><img src="'+bulletPath+'" border=0 align=middle alt="*">&nbsp;&nbsp;&nbsp;</td>';
			scriptBuffer+='<td width="90%" align="left" valign="top"><a href="'+SubLink[selectedSection][i]+'">'+subTitle[selectedSection+1][i]+'</a><br><br></td>';
			scriptBuffer+='</tr>';
		}
	} else {
		for (i=1; i<SubLink2[selectedSection][selectedSubSection].length;i++ ) {
			scriptBuffer+='<tr>';
			scriptBuffer+='<td width="10%" align="right" valign="top"><img src="'+bulletPath+'" border=0 align=middle alt="*">&nbsp;&nbsp;&nbsp;</td>';
			scriptBuffer+='<td width="90%" align="left" valign="top"><a href="'+SubLink2[selectedSection][selectedSubSection][i]+'">'+subSubTitle[selectedSection+1][selectedSubSection][i]+'</a><br><Br></td>';
			scriptBuffer+='</tr>';
		}
	}
	scriptBuffer+='</table>';
	return scriptBuffer;
}


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=780,height=560')");
	if ( nw.focus != null)
	{nw.focus();}
}

function documentPopUp(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=800,height=300')");
	if ( nw.focus != null)
	{nw.focus();}
}

function setVistorTopPos(){
	if(!isNS4){
		document.getElementById('rightMenuTop').style.visibility = "visible";
		document.getElementById('rightMenuTop').style.left=getDim(document.images.ptest).x;
	}
}

function changeSubBg(obj){
}

function restoreSubBg(obj){
}


function changeSubSubBg(obj){
}

function restoreSubSubBg(obj){
}

//Dreamweaver Code
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 MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function PopWin(url, x, y, w, h){
	url = domain_url + url;
    eval("popup0 = window.open(url,'popup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,pageXOffset=300,pageYOffset=500,top=" + y + ",left=" + x +",width=" + w + ",height=" + h + "')");
        if ( popup0.focus != null){
        popup0.focus();
    }
}

function customPreload(pageType){
	if(pageType==0)
		MM_preloadImages('images/spacer.gif','images/spacer_over.gif','images/nav_sub_Line.gif','images/nav_sub_Line_over.gif','images/top_view.jpg','images/btn_01.gif' ,'images/btn_01_over.gif' ,'images/btn_02.gif' ,'images/btn_02_over.gif' ,'images/btn_03.gif' ,'images/btn_03_over.gif' ,'images/btn_04.gif' ,'images/btn_04_over.gif' ,'images/btn_05.gif' ,'images/btn_05_over.gif' ,'images/btn_06.gif' ,'images/btn_06_over.gif' ,'images/btn_07.gif' ,'images/btn_07_over.gif' ,'images/btn_08.gif' ,'images/btn_08_over.gif' ,'images/btn_09.gif' ,'images/btn_09_over.gif' ,'images/btn_10.gif' ,'images/btn_10_over.gif' ,'images/btn_11.gif' ,'images/btn_11_over.gif' ,'images/btn_12.gif' ,'images/btn_12_over.gif',"btn_gotoTop.gif","btn_gotoTop_over.gif","btn_logIn.gif","btn_logIn_over.gif","btn_next.gif","btn_next_over.gif","btn_previous.gif","btn_previous_over.gif","btn_signUp.gif","btn_signUp_over.gif","btn_visit.gif","btn_visit_over.gif","btn_visit_top.gif","key_pix_01.gif","key_pix_01.jpg","key_pix_01_over.gif","key_pix_01_over.jpg","title_pop_R_On.gif","title_pop_R.gif","title_key_R.gif","title_key_R_On.gif","title_highlight_bg.gif","sub_title_R.gif","subHead_bg_01.gif","subHead_bg_02.gif","subHead_pix_top.gif","sub_title_bg.gif","stat_low.gif","sub_R.gif","stat_bgR.gif","stat_bgL.gif","smal_low_L.gif","smal_low_R.gif","RSS.gif","reg_right.jpg","regist_bgL.gif","reg_left.jpg","regist_bgR.gif","new.gif")
	else	
		MM_preloadImages('images/spacer.gif','images/spacer_over.gif','images/nav_sub_Line.gif','images/nav_sub_Line_over.gif','images/top_view.jpg','images/btn_01.gif' ,'images/btn_01_over.gif' ,'images/btn_02.gif' ,'images/btn_02_over.gif' ,'images/btn_03.gif' ,'images/btn_03_over.gif' ,'images/btn_04.gif' ,'images/btn_04_over.gif' ,'images/btn_05.gif' ,'images/btn_05_over.gif' ,'images/btn_06.gif' ,'images/btn_06_over.gif' ,'images/btn_07.gif' ,'images/btn_07_over.gif' ,'images/btn_08.gif' ,'images/btn_08_over.gif' ,'images/btn_09.gif' ,'images/btn_09_over.gif' ,'images/btn_10.gif' ,'images/btn_10_over.gif' ,'images/btn_11.gif' ,'images/btn_11_over.gif' ,'images/btn_12.gif' ,'images/btn_12_over.gif');
}


function genRightSpacer(){
	document.write('<img src=\"images/spacer.gif\" width=\"8\">');
}

//print style sheet
if(document.URL.toString().search('/en/')!=-1){
	var css_file='style_sheet.css';
}else{
	var css_file='style_sheet_sc.css';
} 
if(document.URL.toString().search('/text/')!=-1){
	document.writeln('<link href="../../../css/'+css_file+'" rel="stylesheet" type="text/css">');
}else{
	document.writeln('<link href="../../css/'+css_file+'" rel="stylesheet" type="text/css">');
} 


function IndexIcon(){
	
	var iconBrandHK='gov_site_header_chi_trans.gif';
	var iconCepa='cepa_c.gif';
	var iconGst='gst_c.jpg';
	var iconInfo='infogov.gif';
	var iconPolicy='84x50sc.gif';
	var iconNews='news_c.gif';
	var iconBudget='pre-budget_84x50_sc.gif';
	var iconTax='efiling_c.gif';
	var iconVoter='voter2007.jpg';
	var iconInvestHK='logo_investhk.jpg';
	var iconYearBook='yearbook2008_sc.jpg';

	var txt5day='政府五天工作周';
	var txtBrandHK='亚洲国际都会';
	var txtYearBook='2008香港年报';
	var txtBudget='2010-2011财政预算案';
	var txtCepa='更紧密经贸关系的安排';
	var txtGst='税制改革';
	var txtInfo='香港政府一站通';
	var txtPolicy='2009-10施政报告';
	var txtNews='政府新闻网';
	var txtTax='电子报税';
	var txtVoter='2007选民登记';
	var txtInvestHK='投资推广署';
	
	var linkCepa='http://www.tid.gov.hk/tc_chi/cepa/';
	var linkYearBook='http://www.yearbook.gov.hk/';
	var linkBrandHK='http://www.brandhk.gov.hk/';
	var linkBudget='http://www.budget.gov.hk/';
	var linkInfo='http://www.gov.hk/';
	var linkGst='http://www.taxreform.gov.hk/';
	var linkPolicy='http://www.policyaddress.gov.hk/';
	var linkNews='http://www.news.gov.hk/';
	var linkTax='https://etax21.ird.gov.hk/ird/login/jsp/LandingPage.jsp?userLang=zh&userCountry=HK';
	var linkVoter='http://www.voterregistration.gov.hk';
	var linkInvestHK='http://www.investhk.gov.hk';
	
	if(document.URL.toString().search('/gb/')!=-1){
		/*
		txt5day='淉葬拻毞驮釬笚';
		txtBrandHK='捚粔弊昵饮颇';
		txtYearBook='2008茠妀厍';
		txtBudget='2010-2011笙淉啎呾偶';
		txtCepa='载蜷躇幂籀寿炵腔假龉';
		txtGst='阭秶蜊赂';
		txtInfo='眅诚淉葬珨桴籵';
		txtPolicy='2009-10囥淉惆豢';
		txtNews='淉葬陔恓厍';
		txtTax='苌赽惆阭';
		txtVoter='2007恁镙肾暮';
		txtInvestHK='芘訧芢嫘扰';
		*/
		
		iconTax='efiling_gb.gif';
		iconPolicy='report_sc.jpg';

		linkCepa='http://www.tid.gov.hk/sc_chi/cepa/';
		linkTax='https://etax21.ird.gov.hk/ird/login/jsp/LandingPage.jsp?userLang=zh&userCountry=HK';
		
	}else if(document.URL.toString().search('/en/')!=-1){
		txt5day='5 days work';
		txtBrandHK='HK Brand';
		txtYearBook='2008 Hong Kong Yearbook';
		txtBudget='Budget';
		txtCepa='CEPA';
		txtGst='Tax Reform';
		txtInfo='GovHK';
		txtPolicy='2009-10 Policy Address';
		txtNews='News';
		iconBrandHK='BrandHK.jpg';
		iconBudget='pre-budget_84x50_e.gif';
		iconCepa='cepa.gif';
		iconGst='gst.jpg';
		iconInfo='infogovhkeng.gif';
		iconPolicy='84x50e.gif';
		iconNews='news.gif';
		txtTax='Internet Filing of Tax Return';
		txtVoter='2007 Voter Registration';
		txtInvestHK='InvestHK';
		
		iconTax='efiling_e.gif';
		
		linkTax='https://etax21.ird.gov.hk/ird/login/jsp/LandingPage.jsp?APPID=null&userLang=en&userCountry=us';
		linkCepa='http://www.tid.gov.hk/english/cepa/';
	}
	if(document.URL.toString().search('/text/')!=-1){
		document.write('<div align=\"center\"><table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">');
		document.write('<tr align=\"center\">');
		//document.write('	<td><a href=\"javascript:PopWin(\''+langFolder+'5day.htm\', 0, 0, 260, 169);">'+txt5day+'</a></td>');
		document.write('	<td><a href=\"'+linkYearBook+'" target="_blank">'+txtYearBook+'</a></td>');
		document.write('	<td><a href=\"'+linkBrandHK+'" target="_blank">'+txtBrandHK+'</a></td>');
		document.write('	<td><a href=\"'+linkBudget+'" target="_blank">'+txtBudget+'</a></td>');
		document.write('</tr>');
		document.write('<tr align=\"center\">');
		//document.write('	<td><a href=\"'+linkCepa+'" target="_blank">'+txtCepa+'</a></td>');
		document.write('	<td><a href=\"'+linkInfo+'" target="_blank">'+txtInfo+'</a></td>');
		document.write('	<td><a href=\"'+linkGst+'" target="_blank">'+txtGst+'</a></td>');
		document.write('	<td><a href=\"'+linkPolicy+'" target="_blank">'+txtPolicy+'</a></td>');
		document.write('</tr>');
		document.write('<tr align=\"center\">');
		document.write('	<td><a href=\"'+linkNews+'" target="_blank">'+txtNews+'</a></td>');
		document.write('	<td><a href=\"'+linkTax+'" target="_blank">'+txtTax+'</a></td>');
		//document.write('	<td><a href=\"'+linkVoter+'" target="_blank">'+txtVoter+'</a></td>');
		document.write('	<td><a href=\"'+linkInvestHK+'" target="_blank">'+txtInvestHK+'</a></td>');
		document.write('</tr>');
		document.write('</table></div>');
	}else {
		document.write('<div align=\"center\"><table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">');
		document.write('<tr align=\"center\">');
		//document.write('	<td><a href=\"javascript:PopWin(\''+langFolder+'5day.htm\', 0, 0, 260, 169);"><img src="'+domain_url+'/images/icon/5day_icon.jpg" border="0" title="'+txt5day+'" alt="'+txt5day+'"></a></td>');
		document.write('	<td><a href=\"'+linkYearBook+'" target="_blank"><img src="'+domain_url+'/images/icon/'+iconYearBook+'" border="0" title="'+txtYearBook+'" alt="'+txtYearBook+'"></a></td>');
		document.write('	<td><a href=\"'+linkBrandHK+'" target="_blank"><img src="'+domain_url+'/images/icon/'+iconBrandHK+'" border="0" title="'+txtBrandHK+'" alt="'+txtBrandHK+'"></a></td>');
		document.write('	<td><a href=\"'+linkBudget+'" target="_blank"><img src="'+domain_url+'/images/icon/'+iconBudget+'" border="0" title="'+txtBudget+'" alt="'+txtBudget+'"></a></td>');
		document.write('</tr>');
		document.write('<tr align=\"center\">');
		//document.write('	<td><a href=\"'+linkCepa+'" target="_blank"><img src="'+domain_url+'/images/icon/'+iconCepa+'" border="0" title="'+txtCepa+'" alt="'+txtCepa+'"></a></td>');
		document.write('	<td><a href=\"'+linkInfo+'" target="_blank"><img src="'+domain_url+'/images/icon/'+iconInfo+'" border="0" title="'+txtInfo+'" alt="'+txtInfo+'"></a></td>');
		document.write('	<td><a href=\"'+linkGst+'" target="_blank"><img src="'+domain_url+'/images/icon/'+iconGst+'" border="0" title="'+txtGst+'" alt="'+txtGst+'"></a></td>');
		document.write('	<td><a href=\"'+linkPolicy+'" target="_blank"><img src="'+domain_url+'/images/icon/'+iconPolicy+'" border="0" title="'+txtPolicy+'" alt="'+txtPolicy+'"></a></td>');
		document.write('</tr>');
		document.write('<tr align=\"center\">');
		document.write('	<td><a href=\"'+linkNews+'" target="_blank"><img src="'+domain_url+'/images/icon/'+iconNews+'" border="0" title="'+txtNews+'" alt="'+txtNews+'"></a></td>');
		document.write('	<td><a href=\"'+linkTax+'" target="_blank"><img src="'+domain_url+'/images/icon/'+iconTax+'" border="0" title="'+txtTax+'" alt="'+txtTax+'"></a></td>');
		document.write('	<td><a href=\"'+linkInvestHK+'" target="_blank"><img src="'+domain_url+'/images/icon/'+iconInvestHK+'" border="0" title="'+txtInvestHK+'" alt="'+txtInvestHK+'" width="100"></a></td>');
		//document.write('	<td><img src=\"'+domain_url+'/images/icon/civil.gif" border="0" title="" alt=""></td>');
		//document.write('	<td><a href=\"'+linkVoter+'" target="_blank"><img src="'+domain_url+'/images/icon/'+iconVoter+'" border="0" title="'+txtVoter+'" alt="'+txtVoter+'"></a></td>');
		//document.write('	<td>&nbsp;</td>');
		document.write('</tr>');
		document.write('</table></div>');
	}
}


function listsub_section(){
	document.writeln('<table border="0" cellpadding="2" cellspacing="0"><tr><td>');
	/*
	document.writeln('<ul>');
	for (var i in MainLink){
		document.writeln('	<li><a href="'+MainLink[i]+'">'+title[i]+'</a>');
		*/
		if (SubLink[selectedID]!=null){
			document.writeln('<ul>');
			for (var k in SubLink[selectedID]){
				document.writeln('	<li><a href="'+SubLink[selectedID][k]+'">'+subTitle[parseInt(selectedID)+1][k]+'</a>');
				if (SubLink2[selectedID][k]!=null){
					document.writeln('<ul>');
					for (var m in SubLink2[selectedID][k]){
						document.writeln('	<li><a href="'+SubLink2[selectedID][k][m]+'">'+subSubTitle[parseInt(selectedID)+1][k][m]+'</a>');
					}
					document.writeln('</ul>');
				}
			}
			document.writeln('</ul>');
		}
		document.writeln('</li>');
	//document.writeln('</ul>');
	document.writeln('</td></tr></table>');
			
}