var selectedSection;
var subSection;
var secondSubSection;
var exLevel;
var langID;
var langPath;
var locationPath;
var revisionDate;
var reviewDate;
var imagePath;
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;
var demo = false;
var govTestSite = false;
var govKanHan = true;
var http = "ht"+"tp://"
var sKanhanServer = "";
var hostAddress;
var z = "";
var loveablemap;

if(document.URL.toString().search('westcomzivo.com') != -1){demo = true}
else if (document.URL.toString().search('www0.') != -1){demo = true}
else {demo = false}

if(document.URL.toString().search('westcomzivo') != -1){govTestSite = false}
else if (document.URL.toString().search('gov.hk') != -1){govTestSite = true}
//else {false = false}

//Java Script variable for global use
var locPath=location.href.toString();
var targetString;
var subPath;


var leftMenuCommonImageName = "nav_";
var leftMenuSectionImageOut = ".gif";
var leftMenuSectionImageOver = "_on.gif";


if(location.href.toString().search('westcomzivo')!=-1){
	hostAddress="gohk.westcomzivo.com";
	locationPath='ht'+'tp://gohk.westcomzivo.com/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath='';
	textOnlyPath="gohk.westcomzivo.com/text/";
}else if(location.href.toString().indexOf('www0.gohk.gov.hk')!=-1){
	hostAddress="www0.gohk.gov.hk";
	locationPath='ht'+'tp://www0.gohk.gov.hk/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath='sc.info.gov.hk/gb/';
	textOnlyPath="www0.gohk.gov.hk/text/";
}else if(location.href.toString().indexOf('www.gohk.gov.hk')!=-1){
	hostAddress="www.gohk.gov.hk";
	locationPath='ht'+'tp://www.gohk.gov.hk/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath='sc.info.gov.hk/gb/';
	textOnlyPath="www.gohk.gov.hk/text/";
}else if(location.href.toString().indexOf('se.cgi')!=-1){
	locationPath='ht'+'tp://www.gohk.gov.hk/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath='sc.info.gov.hk/gb/';
	textOnlyPath="www.gohk.gov.hk/text/";
	isGICSearch=true;
}else if(location.href.toString().indexOf('202.64.223.141')!=-1){
	hostAddress="gohk.westcomzivo.com";
	locationPath='ht'+'tp://gohk.westcomzivo.com/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath='common.westcomzivo.com/gb/';
	textOnlyPath="gohk.westcomzivo.com/text/";
}else if(location.href.toString().indexOf('venus')!=-1){
	hostAddress="gohk.westcomzivo.com";
	locationPath='ht'+'tp://gohk.westcomzivo.com/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath='common.westcomzivo.com/';
	textOnlyPath="gohk.westcomzivo.com/text/";
}else{
	hostAddress="www.gohk.gov.hk";
	locationPath='ht'+'tp://www.gohk.gov.hk/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath='ht'+'tp://www.gohk.gov.hk/gb/';
	textOnlyPath="www.gohk.gov.hk/text/";
}



//change the locationPath for text only version
if(location.href.toString().indexOf('/text/')!=-1|| location.search.toString().indexOf('isText=true')!=-1|| location.href.toString().indexOf('/textrun')!=-1){
	isText=true;
	locationPath="ht"+"tp://"+textOnlyPath;
}else{
	isText=false;
}

//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("/");
}

//set the lang path and lang ID
if(isText)
{
	if(location.search.toString().indexOf('/text/')!=-1)
	{
		filePath=updatePath(QueryString("/text/"))
		folderPath=filePath.substring(0,filePath.lastIndexOf("/")+1)
	}
	
	if(location.toString().indexOf('eng/')!=-1 || location.search.toString().indexOf('mode=295')!=-1){
		langPath = 'eng/';
		lang="eng";
		langID=1;
		vspace=0;
	}else if(location.toString().indexOf('chi/')!=-1 || location.search.toString().indexOf('mode=296')!=-1){
		langPath = 'chi/';
		lang="chi";
		langID=2;
		vspace=3;
	}else if(location.toString().indexOf('gb/')!=-1 || location.search.toString().indexOf('mode=301')!=-1){
		langPath = 'gb/';
		lang="gb";
		langID=3;
		vspace=0;
	}else if(location.href.toString().indexOf('tmpLang=eng')!=-1){
		langPath = 'eng/';
		lang="eng";
		langID=1;
		vspace=0;
	}else if(location.href.toString().indexOf('tmpLang=gb')!=-1){
		langPath = 'gb/';
		lang="gb";
		langID=3;
		vspace=0;
	}else if(location.href.toString().indexOf('tmpLang=chi')!=-1){
		langPath = 'chi/';
		lang="chi";
		langID=2;
		vspace=0;
	}else{
		langPath = '';
		lang="";
		langID=2;
		vspace=3;
	}
}else{
	if(document.URL.toString().search('/eng/')!=-1 || location.search.toString().indexOf('mode=295')!=-1){
		langPath = 'eng/';
		lang="eng";
		langID=1;
		vspace=4;
		}
	else if(document.URL.toString().search('/chi/')!=-1 || location.search.toString().indexOf('mode=296')!=-1){
		langPath = 'chi/';
		lang="chi";
		langID=2;
		vspace=4;
	}
	else if(document.URL.toString().search('/gb/')!=-1 || location.search.toString().indexOf('mode=301')!=-1){
		langPath = 'gb/';
		lang="gb";
		langID=3;
		vspace=3;
	}
	//else if(document.URL.toString().search('202.64.223.141')!=-1){
	//alert();
	//	langPath = 'eng/';
	//	lang="eng";
	//	langID=1;
	//	vspace=4;
	//}
	else if(document.URL.toString().search('tmpLang=gb')!=-1){
		langPath = 'gb/';
		lang="gb";
		langID=3;
		vspace=3;
	
	}
	else if(document.URL.toString().search('tmpLang=eng')!=-1){
		langPath = 'eng/';
		lang="eng";
		langID=1;
		vspace=4;
	}
	else if(document.URL.toString().search('tmpLang=chi')!=-1){
		langPath = 'chi/';
		lang="chi";
		langID=2;
		vspace=4;
	
	
	}else{
		langPath = '';
		lang="";
		langID=2;
		vspace=4;
	}
}

//change the location path and image path for Simplified Chinese version
if(document.URL.toString().search('/gb/')!=-1){
	imagePath = locationPath+'gb/'+'images/';
	locationPath='ht'+'tp://'+gb_urlPath+locationPath.substring(7, locationPath.length);
}else{
	imagePath = locationPath+langPath+'images/';
}

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

//function for mouse out effect on left menu
function outTopMenu(obj)
{
        if (document.images){
				eval("document.images." + obj + ".src = '"+imagePath+"" + 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="/chi/";
	var ready = true;
	var modeTc = "mode=296";
	var modeEng = "mode=295";
	var modeSc = "mode=301";
	var currentMode = "";
	var targetMode = "";
//use for switch pl purpose (begin)
	var pathname = window.location.href.toLowerCase();
	var cgiFlag = false;
	var courseFormFlag = false;
//use for switch pl purpose (end)

	//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[langID][selectedSection][subSection][secondSubSection];
		}else if(subSection!="" && subSection>0){
			currentPath=SubSection[langID][selectedSection][subSection];
		}else{
			currentPath=MainSection[langID][selectedSection];
		}
	}
	
	if(isText){
		if(document.URL.toString().search('tmpLang=eng')!=-1){
			//alert ('hello2');
			if(switchLang=='/eng/'){
				currentPath=currentPath.replace('textrun',"run");
			}
			else if(switchLang=='/chi/'){
				currentPath=currentPath.replace('tmpLang=eng',"tmpLang=chi");			
			}
			else if(switchLang=='/gb/'){
				currentPath=currentPath.replace('tmpLang=eng',"tmpLang=gb");		
			}
		}else if ( langID==1){
			//alert ('hello');
			if(switchLang=='/eng/'){
				currentPath=currentPath.replace('text/',"");
			}
			else if(switchLang=='/chi/'){
				currentPath=currentPath.replace('text/eng/',"text/chi/");			
				currentPath=currentPath.replace('se.cgi?mode=295',"se.cgi?mode=296");			
			}
			else if(switchLang=='/gb/'){
				currentPath=currentPath.replace('text/eng/',"text/gb/");			
				currentPath=currentPath.replace('se.cgi?mode=295',"se.cgi?mode=301");	
			}
		}else if (document.URL.toString().search('tmpLang=chi')!=-1 ){
		//alert ('hello');
			if(switchLang=='/chi/'){
				currentPath=currentPath.replace('textrun',"run");
			}
			else if(switchLang=='/eng/'){
				currentPath=currentPath.replace('tmpLang=chi',"tmpLang=eng");			
			}
			else if(switchLang=='/gb/'){
				currentPath=currentPath.replace('tmpLang=chi',"tmpLang=gb");		
			}
		}else if(langID==2){
			if(switchLang=='/eng/'){
				currentPath=currentPath.replace('text/chi/',"text/eng/");		
				currentPath=currentPath.replace('se.cgi?mode=296',"se.cgi?mode=295");			
			}
			else if(switchLang=='/chi/'){	
				currentPath=currentPath.replace('text/',"");
			}
			else if(switchLang=='/gb/'){
				currentPath=currentPath.replace('text/chi/',"text/gb/");		
				currentPath=currentPath.replace('se.cgi?mode=296',"se.cgi?mode=301");	
			}
		}else if (document.URL.toString().search('tmpLang=gb')!=-1 ){
			if(switchLang=='/gb/'){
				currentPath=currentPath.replace('textrun',"run");
			}
			else if(switchLang=='/eng/'){
				currentPath=currentPath.replace('tmpLang=gb',"tmpLang=eng");			
			}
			else if(switchLang=='/chi/'){
				currentPath=currentPath.replace('tmpLang=gb',"tmpLang=chi");		
			}
		}else if(langID==3){
			if(switchLang=='/eng/'){
				currentPath=currentPath.replace('text/gb/',"text/eng/");		
				currentPath=currentPath.replace('se.cgi?mode=301',"se.cgi?mode=295");		
			}
			else if(switchLang=='/chi/'){
				currentPath=currentPath.replace('text/gb/',"text/chi/");		
				currentPath=currentPath.replace('se.cgi?mode=301',"se.cgi?mode=296");
			}
			else if(switchLang=='/gb/'){	
				currentPath=currentPath.replace('text/',"");
			}
		}
		slash="=";
		switchTc="=chi/";
		tempSwitchLang="="+switchLang.substring(1,switchLang.length);
//		alert (switchLang.substring(1,switchLang.length));
//		alert (tempSwitchLang);
	}
	
	if(isGICSearch){
		currentPath=document.URL.toString();
		if(langID==1){
			currentMode=modeEng
		}else if (langID==2){
			currentMode=modeTc
		}else{
			currentMode=modeSc
		}
		
		if(switchLang=='/chi/'){
			targetMode=modeTc
		}else if(switchLang=='/eng/'){
			targetMode=modeEng
		}else{
			targetMode=modeSc
		}
	}
	
	if(switchLang=='/text/'){
		if(isText){
			//locationPage=currentPath.replace(textOnlyPath+"?search=",graphicPath);
			locationPage=currentPath.replace(textOnlyPath,"");
			locationPage=locationPage.replace("text",graphicPath);
		}else{
			locationPage=currentPath.replace(graphicPath,textOnlyPath)
			if(document.URL.toString().indexOf('run.pl?sortBy=')!=-1){
				locationPage=currentPath.replace('/run.pl','/textrun.pl');
			}
			
			if(isGICSearch){
				if(langID==1){
					alert("Search function for text only version is not available")
				}else if(langID==2){
					alert("セ呼⊿Τ矗ㄑゅセ穓碝")
				}else{
					alert("本网站并没有提供纯文字版本的搜寻功能")
				}
				ready=false
			}
		}
	}else if(switchLang=='/gb/'){
		locationPage=currentPath.substring(7, currentPath.length);
		if(langID==1){
			if(isGICSearch){
				locationPage='ht'+'tp://'+locationPage.replace(modeEng, modeSc);
			}else{
				locationPage='ht'+'tp://'+locationPage.replace('/eng/', '/gb/');
				if(document.URL.toString().indexOf('run.pl?sortBy=')!=-1){
					locationPage=currentPath.replace('tmpLang=eng','tmpLang=gb');
				}
			}
		}else if(langID==2){
			if(isGICSearch){
				locationPage='ht'+'tp://'+locationPage.replace(modeTc, modeSc);
			}else{
				locationPage='ht'+'tp://'+locationPage.replace('/chi/', '/gb/');

				if(document.URL.toString().indexOf('run.pl?sortBy=')!=-1){
					locationPage=currentPath.replace('tmpLang=chi','tmpLang=gb');
				}
			}
		}else{
				if(location.href.toString().search(gb_urlPath)!=-1){
					//locationPage='ht'+'tp://'+locationPage.replace('/text/chi/', '/chi/');
					locationPage='ht'+'tp://'+locationPage;
				}
				else{
				locationPage='ht'+'tp://'+locationPage.replace('/chi/', '/gb/');
				}
					
		}
	}else{

			if(isGICSearch){
				locationPage=currentPath.replace(currentMode, targetMode);
			}else{
				//alert (currentPath);
				//if(){}
				if(langPath!=""){
					locationPage=currentPath.replace(slash+langPath, tempSwitchLang);
				}
				//alert (locationPage);
				
				
				if(document.URL.toString().indexOf('run.pl?sortBy=')!=-1){
					if(switchLang=='/chi/'){
						if(langID==1){
							locationPage=currentPath.replace('tmpLang=eng','tmpLang=chi');
						}
						else if(langID==3){
							locationPage=currentPath.replace('tmpLang=gb','tmpLang=chi');
						}
					}else if(switchLang=='/eng/'){
						if(langID==2){
							locationPage=currentPath.replace('tmpLang=chi','tmpLang=eng');
						}
						else if(langID==3){
							locationPage=currentPath.replace('tmpLang=gb','tmpLang=eng');
						}						
					}
				}
				
			}

	}
	
//use for switch pl purpose (begin)

//	if (pathname.indexOf("/cgi-bin/")!=-1)
//	{
		if (pathname.indexOf("coursesearch.pl")!=-1 || pathname.indexOf("coursesearch_detail.pl")!=-1 || pathname.indexOf("course.pl")!=-1)
		{
//			if (switchLang.indexOf("/text/")!=-1)
			if (switchLang=='/text/')
			{
				alert('Text Only Version is not available at the moment.');
//				locationPage = "javascript:alert('Text Only Version is not available at the moment.')";
//				pathname = pathname.replace(".pl", "_t.pl");
//				switchLang = switchLang.replace("/text", "");
				ready = false;
			}
			cgiFlag = true
			courseFormFlag = true
		}
/*		
		else if (pathname.indexOf("coursesearch_t.pl")!=-1 || pathname.indexOf("coursesearch_detail_t.pl")!=-1 || pathname.indexOf("course_t.pl")!=-1)
		{
			if (curLang.indexOf("/text/")!=-1)
			{
				pathname = pathname.replace("_t.pl", ".pl");
			}
			cgiFlag = true
			courseFormFlag = true
		}
*/
//	}
	
//	if (curLang == "/gb/"){pathname = pathname.replace(http+sKanhanServer, http);curLang="/tc/"}
//	if (switchLang == "/gb/"){pathname = pathname.replace(http, http+sKanhanServer);switchLang="/tc/"}
	if (cgiFlag)
//	{location = pathname.replace(curLang, tarLang);}
//	else
	{

		if (courseFormFlag)
		{locationPage=courseFormSwitchLang(pathname, switchLang);}
//		else if (gicSearchFlag)
//		{gicSearchSwitchLang(pathname, curLang, tarLang);}
	}	
//use for switch pl purpose (end)

//	alert(locationPage);
	if (ready){
		document.location=locationPage;
	}
}

//function for generating the top menu
function getTopMenu(){
//  Yahoo Search Form 
 	var gicSearchForm;
 	gicSearchForm='<form name="frmSearch" action="'+arClfTopMenu[langID][1]+'" method="get">\n';
 	gicSearchForm=gicSearchForm+'<input type="hidden" name="tpl_id" value="stdsearch"> ';
	gicSearchForm=gicSearchForm+'<input type="hidden" name="gp0" value="gohk_home"> ';
	gicSearchForm=gicSearchForm+'<input type="hidden" name="gp1" value="gohk_home"> ';
	gicSearchForm=gicSearchForm+'<input type="hidden" name="web" value="this"> ';
	gicSearchForm=gicSearchForm+'<input type="hidden" name="ui_lang" value="' + arClfTopMenu[langID][26] + '"> ';
	gicSearchForm=gicSearchForm+'<input type="hidden" name="ui_charset" value="' + arClfTopMenu[langID][27] + '">  ';

	//graphic version
	if(!isText){
		//document.writeln('	<title>'+arClfTopMenu[langID][3]+' - '+MainTitle[langID][selectedSection] +'</title>');

		document.writeln('	<table border="0" cellpadding="0" cellspacing="0" width="100%">');
		
		document.writeln('		<tr valign="top">');
		document.writeln('			<td colspan="11" background="'+imagePath+'top_nav_bg.gif">');
		
		
		document.writeln('	<table border="0" cellpadding="0" cellspacing="0">');
		
		
		document.writeln(gicSearchForm);
		document.writeln('		<tr valign="top">');
		document.writeln('			<td rowspan="2"><a href="http://www.had.gov.hk" target="_blank"><IMG SRC="'+imagePath+'logo.gif" border="0" alt="'+arClfTopMenu[langID][6]+'"></a></td>');
		document.writeln('			<td rowspan="2"><a href="http://www.gohk.gov.hk/index.html"><IMG SRC="'+imagePath+'btn_gohk.gif" border="0" alt="'+arClfTopMenu[langID][3]+'"></a></td>');

		for (var i in MainSectionOrder[langID]){
			mainOrder=MainSectionOrder[langID][i];

			if (mainOrder == selectedSection)
			{
				document.write('<td rowspan="2"><a href="'+MainSection[langID][mainOrder]+'" target="_parent"><IMG name="btn_'+mainOrder+'" SRC="'+imagePath+'btn_'+mainOrder+'_o.gif" border="0" alt="'+MainTitle[langID][mainOrder]+'"></a></td>');
			}else
			{
				document.writeln('			<td rowspan="2"><a href="'+MainSection[langID][mainOrder]+'" onMouseOut="outTopMenu(\'btn_'+mainOrder+'\');overTopMenu(\'btn_'+selectedSection+'\');" onMouseOver="overTopMenu(\'btn_'+mainOrder+'\');outTopMenu(\'btn_'+selectedSection+'\');" target="_parent"><IMG name="btn_'+mainOrder+'" SRC="'+imagePath+'btn_'+mainOrder+'.gif" border="0" alt="'+MainTitle[langID][mainOrder]+'"></a></td>');
			}
		}

		
		document.writeln('			<td background="'+imagePath+'search_bg.gif"><IMG SRC="'+imagePath+'search.gif"></td>');
		document.writeln('			<td background="'+imagePath+'search_bg.gif"><input type="text" name="query" class="search" size="4"><img src="'+imagePath+'spacer.gif" alt="" width="13" height="1" border=0></td>');
		document.writeln('			<td background="'+imagePath+'top_nav_bg.gif"><a href="javascript:document.frmSearch.submit();" onMouseOut="outTopMenu(\'btn_101\')" onMouseOver="overTopMenu(\'btn_101\')"><IMG name="btn_101" SRC="'+imagePath+'btn_101.gif" border="0"></a></td>');
		document.writeln('		</tr>');
		
		document.writeln('		<tr valign="top">');
		document.writeln('			<td colspan="3">');
		document.writeln('				<table border="0" cellpadding="0" cellspacing="0">');
		document.writeln('					<tr valign="top">');
		document.writeln('						<td colspan="8"><IMG SRC="'+imagePath+'search_bottom.gif"></td>');
		document.writeln('					</tr>');
		document.writeln('					<tr valign="top">');
		document.writeln('						<td><IMG SRC="'+imagePath+'language_left.gif"></td>');

		if (langID==1||location.toString().indexOf('tmpLang=eng')!=-1){
			document.writeln('						<td><a href="javascript:changeLanguage(\'/chi/\');" onMouseOut="outTopMenu(\'btn_tc\')" onMouseOver="overTopMenu(\'btn_tc\')"><IMG name="btn_tc" SRC="'+imagePath+'btn_tc.gif" border="0" alt="'+arClfTopMenu[langID][13]+'"></a></td>');
			document.writeln('						<td><a href="javascript:changeLanguage(\'/gb/\');" onMouseOut="outTopMenu(\'btn_sc\')" onMouseOver="overTopMenu(\'btn_sc\')"><IMG name="btn_sc" SRC="'+imagePath+'btn_sc.gif" border="0" alt="'+arClfTopMenu[langID][16]+'"></a></td>');
			document.writeln('						<td><IMG name="btn_eng" SRC="'+imagePath+'btn_eng_d.gif" border="0" alt="'+arClfTopMenu[langID][24]+'"></td>');
		}else
		{
			if(location.toString().indexOf('/gb/')!=-1||location.toString().indexOf('tmpLang=gb')!=-1||langID==3){
				document.writeln('						<td><a href="javascript:changeLanguage(\'/chi/\');" onMouseOut="outTopMenu(\'btn_tc\')" onMouseOver="overTopMenu(\'btn_tc\')"><IMG name="btn_tc" SRC="'+imagePath+'btn_tc.gif" border="0" alt="'+arClfTopMenu[langID][13]+'"></a></td>');
				document.writeln('						<td><IMG name="btn_sc" SRC="'+imagePath+'btn_sc_d.gif" border="0" alt="'+arClfTopMenu[langID][16]+'"></td>');
				document.writeln('						<td><a href="javascript:changeLanguage(\'/eng/\');" onMouseOut="outTopMenu(\'btn_eng\')" onMouseOver="overTopMenu(\'btn_eng\')"><IMG name="btn_eng" SRC="'+imagePath+'btn_eng.gif" border="0" alt="'+arClfTopMenu[langID][24]+'"></a></td>');			
			}else
			{
				document.writeln('						<td><IMG name="btn_tc" SRC="'+imagePath+'btn_tc_d.gif" border="0" alt="'+arClfTopMenu[langID][13]+'"></td>');
				document.writeln('						<td><a href="javascript:changeLanguage(\'/gb/\');" onMouseOut="outTopMenu(\'btn_sc\')" onMouseOver="overTopMenu(\'btn_sc\')"><IMG name="btn_sc" SRC="'+imagePath+'btn_sc.gif" border="0" alt="'+arClfTopMenu[langID][16]+'"></a></td>');
				document.writeln('						<td><a href="javascript:changeLanguage(\'/eng/\');" onMouseOut="outTopMenu(\'btn_eng\')" onMouseOver="overTopMenu(\'btn_eng\')"><IMG name="btn_eng" SRC="'+imagePath+'btn_eng.gif" border="0" alt="'+arClfTopMenu[langID][24]+'"></a></td>');
			}
		}

		document.writeln('						<td><IMG SRC="'+imagePath+'language_right.gif"></td>');
		document.writeln('						<td><a href="javascript:changeLanguage(\'/text/\');" onMouseOut="outTopMenu(\'btn_textonly\')" onMouseOver="overTopMenu(\'btn_textonly\')"><IMG name="btn_textonly" SRC="'+imagePath+'btn_textonly.gif" border="0" alt="'+arClfTopMenu[langID][10]+'"></a></td>');
		document.writeln('						<td><IMG SRC="'+imagePath+'language_right_01.gif"></td>');
		document.writeln('						<td><a href="javascript:window.print();" onMouseOut="outTopMenu(\'btn_print\')" onMouseOver="overTopMenu(\'btn_print\')"><IMG name="btn_print" SRC="'+imagePath+'btn_print.gif" border="0" alt="Print"></a></td>');
		document.writeln('					</tr>');
		document.writeln('					<tr valign="top">');
		document.writeln('						<td colspan="8"><IMG SRC="'+imagePath+'language_bottom.gif"></td>');
		document.writeln('					</tr>');
		document.writeln('				</table>');
		document.writeln('			</td>');
		document.writeln('		</tr>');
		
		
		
		document.writeln('</table>');
		document.writeln('</td>');
		document.writeln('<td background="'+imagePath+'top_nav_bg.gif"><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1"></td>');
		document.writeln('</tr>');
		
		
		document.writeln('		<tr valign="top">');
		document.writeln('			<td colspan="12" background="'+imagePath+'bg_'+selectedSection+'.jpg">');
		document.writeln('				<table width="100%" cellpadding="0" cellspacing="0" border="0" background="'+imagePath+'spacer.gif">');
		
		
		if(selectedSection==0){
			document.writeln('					<tr valign="top">');
			document.writeln('						<td><IMG SRC="'+imagePath+'banner_0.gif"></td>');
			document.writeln('						<td background="'+imagePath+'new_nav_23.gif" width="100%"><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1"></td>');
			document.writeln('					</tr>');
		}
		else if((selectedSection==4 && subSection != '')||selectedSection==14){
			
			document.writeln('					<tr valign="top">');
			document.writeln('						<td rowspan="2"><IMG SRC="'+imagePath+'banner_left.gif"></td>');
			document.writeln('						<td rowspan="2" background="'+imagePath+'new_nav_23.gif">')

		}else if(selectedSection==2){
			
			document.writeln('					<tr valign="top">');
			document.writeln('						<td rowspan="2"><IMG SRC="'+imagePath+'banner_left.gif" border="0"></td>');
			document.writeln('						<td rowspan="2" background="'+imagePath+'new_nav_23.gif">')
			getTopic();
		}
		else if (selectedSection==5&&loveablemap==1)
		{
//			alert ('hello');
			document.writeln('					<tr valign="top">');
			document.writeln('						<td><IMG SRC="'+imagePath+'banner_left.gif" border="0"></td>');
			document.writeln('						<td background="'+imagePath+'new_nav_23.gif">')
			getTopic();
			document.writeln('</td>');
			document.writeln('						<td background="'+imagePath+'new_nav_23.gif" width="100%"><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1"></td>');
			document.writeln('					</tr>');
/*			document.writeln('					<tr valign="bottom">');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="40" border="0"></td>');
			document.writeln('						<td>')
			getPath();
			document.writeln('						</td>');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="40" border="0"></td>');
			document.writeln('					</tr>');
*/		
		}
		else
		{
//			alert ('hello');
			document.writeln('					<tr valign="top">');
			document.writeln('						<td><IMG SRC="'+imagePath+'banner_left.gif" border="0"></td>');
			document.writeln('						<td background="'+imagePath+'new_nav_23.gif">')
			getTopic();
			document.writeln('</td>');
			document.writeln('						<td background="'+imagePath+'new_nav_23.gif" width="100%"><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1"></td>');
			document.writeln('					</tr>');
			document.writeln('					<tr valign="bottom">');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="40" border="0"></td>');
			document.writeln('						<td>')
			getPath();
			document.writeln('						</td>');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="40" border="0"></td>');
			document.writeln('					</tr>');
		
		}
		

		
		if(selectedSection==0){
			document.writeln('					<tr valign="top">');
			document.writeln('						<td>');
		}
		else if (!((selectedSection==4 && subSection != '')||selectedSection==14||selectedSection==2)){
//		else if ((selectedSection==4 && subSection != '')||selectedSection==5||selectedSection==2){
//		}	
//		else{
			document.writeln('					<tr valign="top">');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1"></td>');
			document.writeln('						<td>');
			document.writeln('							<table border="0" cellpadding="0" cellspacing="0" background="'+imagePath+'spacer.gif" width="100%">');
			document.writeln('								<tr valign="top">');
			if (selectedSection!=5){
				document.writeln('									<td><IMG SRC="'+imagePath+'spacer.gif" width="20" height="1" border="0"></td>');
				document.writeln('									<td width="700">');		
			} else {
				document.writeln('									<td width="735">');
			}
		}
		
	}else{
	//text only version


		document.writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('<tr>');
		document.writeln('	<td colspan="3"><p><span class="Heading"><b>'+arClfTopMenu[langID][20]+'</b></span></p>');
		document.writeln('</td></tr>');
		document.writeln('<tr>');
		document.writeln('	<td colspan="3">&nbsp;');
		document.writeln('</td>');
		document.writeln('</tr>');
		document.writeln(gicSearchForm);
		document.writeln('<input type="hidden" name="txtonly" value="1">');
		document.writeln('<tr valign="middle">');
		document.writeln('	<td colspan=3>');
		
		//document.writeln('			[ <a href="http://www.info.gov.hk/">'+arClfTopMenu[langID][7]+'</a> ]&nbsp;');
		if(langID==1||location.toString().indexOf('tmpLang=eng')!=-1){
		document.writeln('			[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][8]+'\')">'+arClfTopMenu[langID][21]+'</a> ]&nbsp;');
		document.writeln('			[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][12]+'\')">'+arClfTopMenu[langID][13]+'</a> ]&nbsp;');
		document.writeln('			[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][15]+'\')">'+arClfTopMenu[langID][16]+'</a> ]&nbsp;');
		
		}else
		{
			if(location.toString().indexOf('/gb/')!=-1||location.toString().indexOf('tmpLang=gb')!=-1){
				document.writeln('			[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][15]+'\')">'+arClfTopMenu[langID][21]+'</a> ]&nbsp;');
				document.writeln('			[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][11]+'\')">'+arClfTopMenu[langID][24]+'</a> ]&nbsp;');
				document.writeln('			[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][12]+'\')">'+arClfTopMenu[langID][13]+'</a> ]&nbsp;');
			}else
			{
				document.writeln('			[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][12]+'\')">'+arClfTopMenu[langID][21]+'</a> ]&nbsp;');
				document.writeln('			[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][11]+'\')">'+arClfTopMenu[langID][24]+'</a> ]&nbsp;');
				document.writeln('			[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][15]+'\')">'+arClfTopMenu[langID][16]+'</a> ]&nbsp;');
			}
		}
		
/*		
		document.writeln('			[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][8]+'\')">'+arClfTopMenu[langID][21]+'</a> ]&nbsp;');
		document.writeln('			[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][11]+'\')">'+arClfTopMenu[langID][24]+'</a> ]&nbsp;');
		document.writeln('			[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][12]+'\')">'+arClfTopMenu[langID][13]+'</a> ]&nbsp;');
		document.writeln('			[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][15]+'\')">'+arClfTopMenu[langID][16]+'</a> ]&nbsp;');

*/

		document.writeln('			&nbsp;[&nbsp;<a href="javascript:document.frmSearch.submit();">'+arClfTopMenu[langID][17]+'</a>&nbsp;]&nbsp;');
		document.writeln('			<input type="text" size="9" name="query">&nbsp;');
		document.writeln('	</td>');
		document.writeln('</tr>');
		document.writeln('<tr>');
		document.writeln('	<td colspan="3"><hr></td>');
		document.writeln('</tr>');
		document.writeln('</table>');
		
		
		
		
		
		document.writeln('	<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('	<tr>');
		document.writeln('	<td>');
		for (var i in MainSectionOrder[langID]){
			mainOrder=MainSectionOrder[langID][i];
			if(parseInt(mainOrder) < 100){
			
				//if (mainOrder == selectedSection){
				//	document.writeln('[ '+MainTitle[langID][mainOrder]+' ]');
				//}
				//else{
					document.writeln('[ <a href="'+MainSection[langID][mainOrder]+'">'+MainTitle[langID][mainOrder]+'</a> ]');
				//}
			}
		}
		document.writeln('	</td>');
		document.writeln('	</tr>');
		document.writeln('	<tr>');
		document.writeln('	<td><hr>');
		document.writeln('	</td>');
		document.writeln('	</tr>');
		document.writeln('	</table>');
		
		document.writeln('<p class="HL1">'+MainTitle[langID][selectedSection]+'</p>');
		
	}
	document.writeln('		</form>');
}

//function for get the main pic
function getTopPic(){
	if(!isText){
		document.write('<img src="'+imagePath+'top_bar2.jpg" alt="" border="0">');
	}else
	{
		document.write(MainTitle[langID][selectedSection]);
	}
}


//function for generating the left menu
function getLeftMenu(){
	var isOver='';
	var iconNo = '';
	var mainOrder = 0;
	
	//graphic version
	if(!isText){
	/*
		document.writeln('	<td rowspan=2 valign="top" width="153" background="'+imagePath+'nav_bg.gif">');
	document.writeln('<table border="0" cellspacing="0" cellpadding="0">');
		document.writeln('		<tr><td><img src="'+imagePath+'top_bar1.jpg" alt="" border="0"></td></tr>');

		for (var i in MainSectionOrder[langID])
		{
			mainOrder=MainSectionOrder[langID][i];
			if (mainOrder == selectedSection)
			{
					document.writeln('<tr>');
					document.writeln('<td><a href="'+MainSection[langID][mainOrder]+'" onMouseOver="leftMenuMouseOver(\''+leftMenuCommonImageName+arMainTopicImage[mainOrder]+'\')" onMouseOut="leftMenuMouseOut(\''+leftMenuCommonImageName+arMainTopicImage[mainOrder]+'\')"><img src="'+imagePath+''+leftMenuCommonImageName+arMainTopicImage[mainOrder+1]+leftMenuSectionImageOver+'" border="0" name="'+leftMenuCommonImageName+arMainTopicImage[mainOrder]+'" alt="'+MainTitle[langID][mainOrder]+'"></a></td>');
					document.writeln('</tr>');
							}
			else
			{

					document.writeln('<tr>');
					document.writeln('<td><a href="'+MainSection[langID][mainOrder]+'" onMouseOver="leftMenuMouseOver(\''+leftMenuCommonImageName+arMainTopicImage[mainOrder]+'\')" onMouseOut="leftMenuMouseOut(\''+leftMenuCommonImageName+arMainTopicImage[mainOrder]+'\')"><img src="'+imagePath+''+leftMenuCommonImageName+arMainTopicImage[mainOrder+1]+leftMenuSectionImageOut+'" border="0" name="'+leftMenuCommonImageName+arMainTopicImage[mainOrder]+'" alt="'+MainTitle[langID][mainOrder]+'"></a></td>');
					document.writeln('</tr>');

			}
		}
      	document.writeln('</table>');
		document.writeln('	</td>');
		*/
	}else{
	//text only version
	/*
		document.writeln('	<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('	<tr>');
		document.writeln('	<td>');
		for (var i in MainSectionOrder[langID]){
			mainOrder=MainSectionOrder[langID][i];
			if(parseInt(mainOrder) < 100){
				document.writeln('[ <a href="'+MainSection[langID][mainOrder]+'">'+MainTitle[langID][mainOrder]+'</a> ]');
			}
		}
		document.writeln('	</td>');
		document.writeln('	</tr>');
		document.writeln('	<tr>');
		document.writeln('	<td><hr>');
		document.writeln('	</td>');
		document.writeln('	</tr>');
		document.writeln('	</table>');
	*/
	}
	mainOrder = 0;
}


//function for generating the path indicator
function getPath(){
	var strBuffer='<a href="'+MainSection[langID][0]+'" class="pathLink">'+MainTitle[langID][0]+'</a>';
	if(subSection>0){
		if(selectedSection>0) strBuffer+=' > <a href="'+MainSection[langID][selectedSection]+'" class="pathLink">'+MainTitle[langID][selectedSection]+'</a>';
	}else{
		if(exLevel){
			if(selectedSection>0) strBuffer+=' > <a href="'+MainSection[langID][selectedSection]+'" class="pathLink">'+MainTitle[langID][selectedSection]+'</a>';
		}else{
			if(selectedSection>0) strBuffer+=' > '+MainTitle[langID][selectedSection];
		}
	}
	if(secondSubSection>0){
		if(subSection>0) strBuffer+=' > <a href="'+SubSection[langID][selectedSection][subSection]+'" class="pathLink">'+SubSectionTitle[langID][selectedSection][subSection]+'</a>';
	}else{
		if(exLevel){
			if(subSection>0) strBuffer+=' > <a href="'+SubSection[langID][selectedSection][subSection]+'" class="pathLink">'+SubSectionTitle[langID][selectedSection][subSection]+'</a>';
		}else{
			if(subSection>0) strBuffer+=' > '+SubSectionTitle[langID][selectedSection][subSection];
		}
		
	}
	if(secondSubSection>0){
		if(exLevel){
			strBuffer+=' > <a href="'+SecondSubSection[langID][selectedSection][subSection][secondSubSection]+'" class="pathLink">'+SecondSubSectionTitle[langID][selectedSection][subSection][secondSubSection]+'</a>';
		}else{
			strBuffer+=' > '+SecondSubSectionTitle[langID][selectedSection][subSection][secondSubSection];		
		}
	}	
	
	if(exLevel){
		strBuffer+=' > '+exLevel;
	}
	
	//graphic version only
	if(!isText){
		document.writeln('<table border=0 cellpadding=0 cellspacing=0 background="'+imagePath+'spacer.gif">');
		document.writeln('<tr valign=top>');
		document.writeln('<td width=20><img src="'+imagePath+'spacer.gif" alt="" border="0" width=20 height=1></td>');
		document.writeln('<td class="path">'+strBuffer+'</td>');
		document.writeln('</tr>');
		document.writeln('<tr><td colspan=2><img src="'+imagePath+'spacer.gif" alt="" border="0" width=1 height=10></td></tr>');
		document.writeln('</table>');
	}
}

//function for generating the topic image
function getTopic(){
	var altText = '';
	var imgPath = '';
	altText = MainTitle[langID][selectedSection]; 
	
	if(!isText){
		if(selectedSection==2 && subSection == ''){
			document.writeln('<table border="0" cellpadding="0" cellspacing="0">');
			document.writeln('	<tr valign="top">');
			document.writeln('		<td><img src="'+imagePath+'banner_'+selectedSection+'.jpg" alt="'+altText+'" border="0"></td>');
			document.writeln('	</tr>');
			document.writeln('	<tr valign="top">');
			document.writeln('		<td><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="735" HEIGHT="323" id="18districts" ALIGN=""><PARAM NAME=movie VALUE="18districts_index.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="18districts_index.swf" quality=high bgcolor=#FFFFFF  WIDTH="735" HEIGHT="323" NAME="gohk_gm" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT></td>');
			document.writeln('	</tr>');
			document.writeln('</table>');
		}
		else if(selectedSection==5 && subSection == '' && loveablemap != 1){
			document.writeln('	<table border="0" cellpadding="0" cellspacing="0" height="126">');
			document.writeln('	<tr valign="top">');
			document.writeln('		<td height="126"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="735" HEIGHT="126" id="loveable" ALIGN=""><PARAM NAME=movie VALUE="'+imagePath+'loveable_index.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="'+imagePath+'loveable_index.swf" quality=high bgcolor=#FFFFFF  WIDTH="735" HEIGHT="126" NAME="loveable" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT></td>');
			document.writeln('	</tr>');
			document.writeln('</table>');
		}
		else if(selectedSection==5 && subSection == '' && loveablemap == 1){
			document.writeln('	<table border="0" cellpadding="0" cellspacing="0" height="126">');
			document.writeln('	<tr valign="top">');
			document.writeln('		<td height="126"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="735" HEIGHT="126" id="loveable" ALIGN=""><PARAM NAME=movie VALUE="'+imagePath+'loveable_map_banner.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="'+imagePath+'loveable_map_banner.swf" quality=high bgcolor=#FFFFFF  WIDTH="735" HEIGHT="126" NAME="loveable" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT></td>');
			document.writeln('	</tr>');
			document.writeln('</table>');
		}
		else if(selectedSection==5 && subSection != ''){
			document.writeln('	<table border="0" cellpadding="0" cellspacing="0" height="137">');
			document.writeln('	<tr valign="top">');
			document.writeln('		<td height="137"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="735" HEIGHT="137" id="loveable" ALIGN=""><PARAM NAME=movie VALUE="'+imagePath+'loveable_'+subSection+'_banner.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> <EMBED src="'+imagePath+'loveable_'+subSection+'_banner.swf" quality=high bgcolor=#FFFFFF  WIDTH="735" HEIGHT="137" NAME="loveable" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT></td>');
			document.writeln('	</tr>');
			document.writeln('</table>');
		}
		else{
			document.write('<img src="'+imagePath+'banner_'+selectedSection+'.jpg" alt="'+altText+'" border="0">');
		}
	}else{
		document.write('<p class="title">'+altText+'</p>');
	}
}

//function for generating the top button
function getButton(){
	var altText='Top';
	if(langID!=1) altText='';
	if(!isText){
		document.write('<p><a href="#"><img src="'+imagePath+'btn_top.gif" alt="'+altText+'" border="0" align="right"></a>&nbsp;</p>');
	}else{
		document.writeln('<p align=right><a href="#">'+altText+'</a></p>');
	}

}

//function for generating the the text below
function otherLangOnly(){
	var TextStr='<p>We only provide <a href="javascript:changeLanguage(\'/chi/\');" 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+'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"}
			}
		}
	}
}

if(!isText){
	onresize=setTopLayerPosition;
}

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

	if(!isText){
		if (document.layers)
			{document.writeln('<layer name=footer_layer top=0 left=0 width=602 height=26 visibility="hide" >');}
		else
			{document.writeln('<div id="footer_layer" style="position:absolute; left:0; top:0; width:26; height:26; z-index:1; visibility: hidden">');}
		document.writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('<tr valign=top>');
		document.writeln('	<td align="right"><a href="#top"><img src="'+imagePath+'btn_top.gif" alt="'+altText+'" border="0"></a></td>');
		document.writeln('</tr>');
		document.writeln('</table>');
		if (document.layers)
			{document.writeln('</layer>');}
		else
			{document.writeln('</div>');}			
	}
}

//function for generating the footer
function getFooter(){
	var altText='Top';
	if(langID!=1) altText='';
	var copyYear='2005 ';
	var noticesLink=locationPath+langPath+'terms/index.html';
	var noticeText='Terms and Conditions';
	var policyLink=locationPath+langPath+'policy/index.html';
	var policyText='Privary Policy';
	var revisionText='Last revision date: ';	
	var reviewText='Last review date: ';	
	var copyrightText = 'Copyright (c) ';
	var backText = 'Back';
	var topText = 'Back to Top';
	var remarkforpl = 'Remarks: <BR>* Events of particular interest to Mainland tourists<br>@ Time or/ and date to be fixed';
	var rightreserveText = 'Home Affairs Department. All Rights Reserved.'
	
	if(location.href.indexOf('run.pl')!=-1){
		revisionDate = "08/12/2006"
	}
	
	if (revisionDate==''||revisionDate=='MM/DD/YYYY') revisionDate='03/31/2006';
	if (reviewDate == null||reviewDate==''||reviewDate=='MM/DD/YYYY') reviewDate='03/30/2009';
	if (langID==2){
		policyText='戈Μ栋羘 ';
		noticeText='璶ボ';
		revisionText='程璹ら戳 ';	
		reviewText='程滦浪ら戳 ';	
		copyrightText = '舦┮Τ(c) ';
		backText = '';
		topText = '';
		remarkforpl = '爹: <BR>* 癸ずㄣま笆<br>@ 丁┪/のら戳﹚';
		rightreserveText = 'チ現ㄆ叭羆竝'
	}else if(langID==3){
		policyText='个人资料收集声明 ';
		noticeText='重要告示';
		revisionText='最近修订日期： ';	
		reviewText='最近覆检日期： ';	
		copyrightText = '版权所有(c) ';
		backText = '上一页';
		topText = '回页首';
		remarkforpl = '注: <BR>* 对内地旅客别具吸引力的活动<br>@ 时间或/及日期待定';
		rightreserveText = '民政事务总署'
	}
	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 rvDate=new Date(Date.parse(reviewDate))
	
	var showRwDate = rvDate.getFullYear() + "" + (rvDate.getMonth()+1) + "" + rvDate.getDate();
	var showRnDate = reDate.getFullYear() + "" + (reDate.getMonth()+1) + "" + reDate.getDate();
	
	if(rvDate > reDate){
		var showDate=rvDate.getDate()+' '+monthArray[rvDate.getMonth()]+' '+rvDate.getFullYear();
		if (langID==2) showDate=rvDate.getFullYear()+''+(rvDate.getMonth()+1)+'る'+rvDate.getDate()+'ら';
		if (langID==3) showDate=rvDate.getFullYear()+'年'+(rvDate.getMonth()+1)+'月'+rvDate.getDate()+'日';	
		revisionText = reviewText;
	}else{
		var showDate=reDate.getDate()+' '+monthArray[reDate.getMonth()]+' '+reDate.getFullYear();
		if (langID==2) showDate=reDate.getFullYear()+''+(reDate.getMonth()+1)+'る'+reDate.getDate()+'ら';
		if (langID==3) showDate=reDate.getFullYear()+'年'+(reDate.getMonth()+1)+'月'+reDate.getDate()+'日';	
	}
	
	//generate the topic image to the buffer variable
	if(!isText){
		
		if(selectedSection==0){

		document.writeln('							</td>');
		document.writeln('						<td background="'+imagePath+'spacer.gif"><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1" border="0"></td>');
		document.writeln('					</tr>');
		}else if((selectedSection==4 && subSection != '')||selectedSection==14||selectedSection==2){
			document.writeln('</td>');
			document.writeln('						<td background="'+imagePath+'new_nav_23.gif" width="100%"><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1" border="0"></td>');
			document.writeln('					</tr>');
		} else{
			if(document.URL.toString().indexOf('run.pl?sortBy=')!=-1){
			document.writeln('									<P>'+remarkforpl+'</P>');
			}
			if (selectedSection==5 && loveablemap!=1){
				document.writeln('									<P>&nbsp;</P>');
			}
			document.writeln('									</td>');
			if (selectedSection!=5){
				document.writeln('									<td><IMG SRC="'+imagePath+'spacer.gif" width="20" height="1" border="0"></td>');
			}
			document.writeln('								</tr>');
			if (loveablemap !=1){
				document.writeln('								<tr valign="top">');
				if (selectedSection!=5){
					document.writeln('									<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1" border="0"></td>');
				}
				document.writeln('									<td>');
				document.writeln('										<table width="100%" border="0" cellpadding="0" cellspacing="0">');
				document.writeln('											<tr valign="Top">');
				if (selectedSection==5){
					document.writeln('											<td><IMG SRC="'+imagePath+'spacer.gif" width="20" height="1" border="0"></td>');
				}//alert ('hello');
				document.writeln('												<td>');
				document.writeln('												<a href="javascript:history.go(-1);" onMouseOut="outTopMenu(\'btn_backb\')" onMouseOver="overTopMenu(\'btn_backb\')"><IMG name="btn_backb" SRC="'+imagePath+'btn_backb.gif" border="0" alt="'+backText+'"></a>');
				document.writeln('												</td>');
				document.writeln('												<td><IMG SRC="'+imagePath+'spacer.gif" width="400" height="1"></td>');
				document.writeln('												<td align="right"><a href="#top" onMouseOut="outTopMenu(\'btn_backtotop\')" onMouseOver="overTopMenu(\'btn_backtotop\')"><IMG name="btn_backtotop" SRC="'+imagePath+'btn_backtotop.gif" border="0" alt="'+topText+'"></a></td>');
				if (selectedSection==5){
					document.writeln('											<td><IMG SRC="'+imagePath+'spacer.gif" width="20" height="1" border="0"></td>');
				}
				document.writeln('											</tr>');
				document.writeln('										</table>');
				document.writeln('									</td>');
				document.writeln('									<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1"></td>');
				document.writeln('								</tr>');
			}
			document.writeln('							</table>');
			document.writeln('						</td>');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1"></td>');
			document.writeln('					</tr>');
		}
		if(selectedSection==0){
//			alert ('hello1');
			document.writeln('					<tr valign="top">');
			document.writeln('						<td><IMG SRC="'+imagePath+'tb_bottom2.gif"></td>');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1"></td>');
			document.writeln('					</tr>');
		}
		else if((selectedSection==4 && subSection != '')||selectedSection==2||selectedSection==14){
//			alert ('hello2');
			document.writeln('					<tr valign="top">');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="10" border="0"></td>');
			document.writeln('					</tr>');
			document.writeln('					<tr valign="top">');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1"></td>');
			document.writeln('						<td><IMG SRC="'+imagePath+'tb_bottom.gif"></td>');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1"></td>');
			document.writeln('					</tr>');
		}
		else if((selectedSection==4 && subSection != '')){
//			alert ('hello3');
			document.writeln('					<tr valign="top">');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="10" border="0"></td>');
			document.writeln('					</tr>');
			document.writeln('					<tr valign="top">');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="20" height="1" border="0"></td>');
			document.writeln('						<td>');
			document.writeln('							<table width="100%" border="0" cellpadding="0" cellspacing="0">');
			document.writeln('								<tr valign="Top">');
			document.writeln('									<td><IMG SRC="'+imagePath+'spacer.gif" width="20" height="1"></td>');
			document.writeln('									<td>');
			document.writeln('									<a href="javascript:history.go(-1);" onMouseOut="outTopMenu(\'btn_backb\')" onMouseOver="overTopMenu(\'btn_backb\')"><IMG name="btn_backb" SRC="'+imagePath+'btn_backb.gif" border="0" alt="'+backText+'"></a>');
			document.writeln('									</td>');
			document.writeln('									<td><IMG SRC="'+imagePath+'spacer.gif" width="400" height="1"></td>');
			document.writeln('									<td align="right"><a href="#top" onMouseOut="outTopMenu(\'btn_backtotop\')" onMouseOver="overTopMenu(\'btn_backtotop\')"><IMG name="btn_backtotop" SRC="'+imagePath+'btn_backtotop.gif" border="0" alt="'+topText+'"></a></td>');
			document.writeln('									<td><IMG SRC="'+imagePath+'spacer.gif" width="20" height="1"></td>');
			document.writeln('								</tr>');
			document.writeln('							</table>');
			document.writeln('						</td>');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="20" height="1"></td>');
			document.writeln('					</tr>');
			
			document.writeln('					<tr valign="top">');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1"></td>');
			document.writeln('						<td><IMG SRC="'+imagePath+'tb_bottom.gif"></td>');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1"></td>');
			document.writeln('					</tr>');
		}else{
//			alert ('hello4');
			document.writeln('					<tr valign="top">');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1"></td>');
			document.writeln('						<td><IMG SRC="'+imagePath+'tb_bottom.gif" border="0"></td>');
			document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="1" height="1" border="0"></td>');
			document.writeln('					</tr>');
		}
		document.writeln('				</table>');
		document.writeln('			</td>');
		document.writeln('		</tr>');
		document.writeln('		<tr valign="top">');
		document.writeln('			<td colspan="12">');
//		document.writeln('				<table border="0" cellpadding="0" cellspacing="0" background="'+imagePath+'spacer.gif">');
		document.writeln('				<table border="0" cellpadding="0" cellspacing="0" background="'+imagePath+'spacer.gif" width="755">');
		document.writeln('					<tr valign="top">');
		document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="20" height="1"></td>');
		document.writeln('						<td><a href="'+MainSection[langID][7]+'" onMouseOut="outTopMenu(\'btn_7\')" onMouseOver="overTopMenu(\'btn_7\')"><IMG name="btn_7" SRC="'+imagePath+'btn_7.gif" border="0" alt="'+MainTitle[langID][7]+'"></a></td>');
		document.writeln('						<td><a href="'+MainSection[langID][8]+'" onMouseOut="outTopMenu(\'btn_8\')" onMouseOver="overTopMenu(\'btn_8\')"><IMG name="btn_8" SRC="'+imagePath+'btn_8.gif" border="0" alt="'+MainTitle[langID][8]+'"></a></td>');
		document.writeln('						<td width="100%"><a href="'+MainSection[langID][9]+'" onMouseOut="outTopMenu(\'btn_9\')" onMouseOver="overTopMenu(\'btn_9\')"><IMG name="btn_9" SRC="'+imagePath+'btn_9.gif" border="0" alt="'+MainTitle[langID][9]+'"></a></td>');
		document.writeln('						<td><a href="'+MainSection[langID][13]+'" onMouseOut="outTopMenu(\'btn_13\')" onMouseOver="overTopMenu(\'btn_13\')"><IMG name="btn_13" SRC="'+imagePath+'btn_13.gif" border="0" alt="'+MainTitle[langID][13]+'"></a></td>');
		document.writeln('						<td><a href="'+MainSection[langID][11]+'" onMouseOut="outTopMenu(\'btn_11\')" onMouseOver="overTopMenu(\'btn_11\')"><IMG name="btn_11" SRC="'+imagePath+'btn_11.gif" border="0" alt="'+MainTitle[langID][11]+'"></a></td>');
		document.writeln('						<td><a href="'+MainSection[langID][12]+'" onMouseOut="outTopMenu(\'btn_12\')" onMouseOver="overTopMenu(\'btn_12\')"><IMG name="btn_12" SRC="'+imagePath+'btn_12.gif" border="0" alt="'+MainTitle[langID][12]+'"></a></td>');
		document.writeln('					</tr>');
		document.writeln('					<tr valign="top">');
		document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="20" height="1"></td>');
		document.writeln('						<td colspan="3"><IMG SRC="'+imagePath+'spacer.gif" width="20" height="1"></td>');
		document.writeln('						<td colspan="3"><a href="'+MainSection[langID][14]+'" onMouseOut="outTopMenu(\'btn_14\')" onMouseOver="overTopMenu(\'btn_14\')"><IMG name="btn_14" SRC="'+imagePath+'btn_14.gif" border="0" alt="'+MainTitle[langID][14]+'"></a><a href="'+MainSection[langID][10]+'" onMouseOut="outTopMenu(\'btn_10\')" onMouseOver="overTopMenu(\'btn_10\')"><IMG name="btn_10" SRC="'+imagePath+'btn_10.gif" border="0" alt="'+MainTitle[langID][10]+'"></a></td>');
		document.writeln('					</tr>');
		document.writeln('					<tr valign="top">');
		document.writeln('						<td><IMG SRC="'+imagePath+'spacer.gif" width="20" height="1"></td>');
		document.writeln('						<td colspan="6">')
		
		
		document.writeln('							<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('								<tr bgcolor="#FFFFFF">');
		document.writeln('									<td><img src="'+imagePath+'spacer.gif" alt="" width="1" height="8" border=0></td>');
		document.writeln('								</tr>');
		document.writeln('								<tr bgcolor="#FFFFFF">');
		document.writeln('									<td bgcolor="#FFFFFF" class="footer" nowrap><a href="#" onclick="javascript:window.open(\''+policyLink+'\', \'\',\'scrollbars=yes, width=400, height=500\');" class="footer_link">'+policyText+'</a> | <a href="#" onclick="javascript:window.open(\''+noticesLink+'\', \'\',\'scrollbars=yes, width=400, height=500\');" class="footer_link">'+noticeText+'</a></td>');
		document.writeln('								</tr>');
		document.writeln('								<tr bgcolor="#FFFFFF">');
		document.writeln('									<td>&nbsp;</td>');
		document.writeln('								</tr>');
		document.writeln('								<tr bgcolor="#FFFFFF">');
		document.writeln('									<td bgcolor="#FFFFFF" class="footer" nowrap>'+revisionText+showDate+'</td>');
		document.writeln('								</tr>');
		document.writeln('								<tr bgcolor="#FFFFFF">');
		document.writeln('									<td>&nbsp;</td>');
		document.writeln('								</tr>');
		document.writeln('								<tr bgcolor="#FFFFFF">');
		document.writeln('									<td bgcolor="#FFFFFF" class="footer" nowrap>'+copyrightText+copyYear+rightreserveText+'</td>');
		document.writeln('								</tr>');
		document.writeln('							</table>');
		
		
		document.writeln('						</td>');
		document.writeln('					</tr>');
		document.writeln('				</table>');
		document.writeln('			</td>');
		document.writeln('		</tr>');
		
		document.write('</table>');
		
		
		
		
		/*
		document.writeln('<p>');
		document.writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		if(topButton=='Y')
			document.writeln('	<tr valign=top><td colspan=2 align=right><img src="'+imagePath+'spacer.gif" name="backtotopspacer" width=50 height=25 border="0" align="right"></td></tr>');
		document.writeln('	<tr>');
		document.writeln('		<td><img src="'+imagePath+'spacer.gif" alt="" border="0" width=5 height=1></td>');
		document.writeln('		<td valign="top" align="center"> ');
		document.writeln('		</td>');
		document.writeln('	</tr>');
		document.writeln('</table><br>');
		
		
		*/
	}else{
	
			if(document.URL.toString().indexOf('run.pl?sortBy=')!=-1){
			document.writeln('									<P>'+remarkforpl+'</P>');
			}
		document.writeln('	<table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('	<tr>');
		document.writeln('	<td><hr>');
		document.writeln('	</td>');
		document.writeln('	</tr>');
		document.writeln('	<tr>');
		document.writeln('	<td>');
		for (var i in MainSectionFooterOrder[langID]){
			mainOrder=MainSectionFooterOrder[langID][i];
			if(parseInt(mainOrder) < 100){
				//if (mainOrder == selectedSection){
				//	document.writeln('[ '+MainTitle[langID][mainOrder]+' ]');
				//}
				//else
				//{
					document.writeln('[ <a href="'+MainSection[langID][mainOrder]+'">'+MainTitle[langID][mainOrder]+'</a> ]');
				//}
			}
		}
		document.writeln('	</td>');
		document.writeln('	</tr>');
		document.writeln('	<tr>');
		document.writeln('	<td><hr>');
		document.writeln('	</td>');
		document.writeln('	</tr>');
	
		document.writeln('	<tr>');
		document.writeln('	<td>');
		
		document.writeln('	<table width="100%" border="0" cellpadding="4" cellspacing="0">');
		document.writeln('	<tr valign="top">');
		document.writeln('	<td nowrap><a href="javascript:history.back();">['+backText+']</a></td>');
		document.writeln('	<td width="99%">');
		document.writeln('&nbsp;');
		document.writeln('	</td>');
		document.writeln('	<td nowrap><a href="#top">['+topText+']</a></td>');
		document.writeln('	</tr>');
		document.writeln('	</table>');

		document.writeln('	</td>');
		document.writeln('	</tr>');
		document.writeln('	<tr>');
		document.writeln('	<td><hr>');
		document.writeln('	</td>');
		document.writeln('	</tr>');
		document.writeln('	</table>');
		
		document.writeln('<p><table width="100%" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('<tr>');
		document.writeln('	<td><a href="#" onclick="javascript:window.open(\''+policyLink+'\', \'\',\'scrollbars=yes, width=400, height=500\');" class="footer_link">'+policyText+'</a> | <a href="#" onclick="javascript:window.open(\''+noticesLink+'\', \'\',\'scrollbars=yes, width=400, height=500\');" class="footer_link">'+noticeText+'</a></td>');
		document.writeln('</tr>');
		document.writeln('<tr>');
		document.writeln('	<td>'+revisionText+showDate+'</td>');
		document.writeln('</tr>');
		document.writeln('<tr>');
		document.writeln('	<td><br></td>');
		document.writeln('</tr>');
		document.writeln('<tr>');
		document.writeln('	<td>'+copyrightText+copyYear+rightreserveText+'</td>');
		document.writeln('</tr>');
		document.writeln('</table></p>');

	}
}

//function for generating the sitemap
function getSiteMap(){
	var mainOrder = 0;
	var subOrder = 0;
	var secondSubOrder = 0;
	var LineBroken='';
	var bullet1='<img src="'+imagePath+'bullet_1.gif" alt="*" vspace='+vspace+' border="0" hspace=3>';
	var bullet2='<img src="'+imagePath+'bullet_1.gif" alt="*" vspace='+vspace+' border="0" hspace=3>';
	var bullet3='<img src="'+imagePath+'bullet_1.gif" alt="*" vspace='+vspace+' border="0" hspace=3>';
	if(isText){
		bullet1="<li>";
		bullet2="<li>";
		bullet3="<li>";
	}

	document.write('<table border=0 cellspacing=0 cellpadding=0 width=100%>');	
	for(var i in MainSectionOrder[langID]){
		mainOrder=MainSectionOrder[langID][i];
		if (MainTitle[langID][mainOrder] != ''){
			checkLinkLang(MainSection[langID][mainOrder]);
			document.writeln('<tr valign=top><td width=1%>'+bullet1+'</td>');
			document.writeln('<td class="maincontent" width=99%><a href="'+MainSection[langID][mainOrder]+'" class="text_link">'+MainTitle[langID][mainOrder]+'</a>'+EngOnly);
			if((SubSectionTitle[langID][mainOrder] != null) && (SubSectionTitle[langID][mainOrder].length > 0)){
				document.write(LineBroken+LineBroken+'<table border=0 cellspacing=0 cellpadding=0 width=100%>');	
				for(var j in SubSectionOrder[langID][mainOrder]){
					subOrder=SubSectionOrder[langID][mainOrder][j];
					if (SubSectionTitle[langID][mainOrder][subOrder] != ''){
						checkLinkLang(SubSection[langID][mainOrder][subOrder]);
						document.writeln('<tr valign=top><td width=1%>'+bullet2+'</td>');
						document.writeln('<td class="maincontent" width=99%><a href="'+SubSection[langID][mainOrder][subOrder]+'" class="text_link">'+SubSectionTitle[langID][mainOrder][subOrder]+'</a>'+EngOnly);
						if((SecondSubSectionTitle[langID][mainOrder][subOrder] != null) && (SecondSubSectionTitle[langID][mainOrder][subOrder].length > 0)){
							document.write(LineBroken+LineBroken+'<table border=0 cellspacing=0 cellpadding=0 width=100%>');	
								for(var k in SecondSubSectionOrder[langID][mainOrder][subOrder]){
									secondSubOrder=SecondSubSectionOrder[langID][mainOrder][subOrder][k];
									if (SecondSubSectionTitle[langID][mainOrder][subOrder][secondSubOrder] != ''){
										checkLinkLang(SecondSubSection[langID][mainOrder][subOrder][secondSubOrder]);
										document.writeln('<tr valign=top><td width=1%>'+bullet3+'</td>');
										document.writeln('<td class="maincontent" width=99%><a href="'+SecondSubSection[langID][mainOrder][subOrder][secondSubOrder]+'" class="text_link">'+SecondSubSectionTitle[langID][mainOrder][subOrder][secondSubOrder]+'</a>'+EngOnly);
										if((SecondSubSectionTitle[langID][mainOrder][subOrder][secondSubOrder+1] != null) && (SecondSubSectionTitle[langID][mainOrder][subOrder][secondSubOrder+1].length > 0)){
											document.writeln(LineBroken+LineBroken+'</td></tr>');
										}else{
											document.writeln('</td></tr>');
										}
									}
								}
							document.write('</table>');
						}
						if((SecondSubSectionTitle[langID][mainOrder][subOrder] != null) && (SecondSubSectionTitle[langID][mainOrder][subOrder].length > 0)){
							document.write(LineBroken);					
						}else{
							document.write(LineBroken+LineBroken);
						}
						document.writeln('</td></tr>');
					}
				}
				document.write('</table>');
			}else{
				if((SubSectionTitle[langID][mainOrder] != null) && (SubSectionTitle[langID][mainOrder].length > 0)){
					document.write(LineBroken);
				}else{
					document.write(LineBroken+LineBroken);
				}
			}
			document.writeln('</td></tr>');
		}
		mainOrder = 0;
		subOrder = 0;
		secondSubOrder = 0;
	}

	for(var i in MainSectionFooterOrder[langID]){
		mainOrder=MainSectionFooterOrder[langID][i];
		if (MainTitle[langID][mainOrder] != ''){
			checkLinkLang(MainSection[langID][mainOrder]);
			document.writeln('<tr valign=top><td width=1%>'+bullet1+'</td>');
			document.writeln('<td class="maincontent" width=99%><a href="'+MainSection[langID][mainOrder]+'" class="text_link">'+MainTitle[langID][mainOrder]+'</a>'+EngOnly);
			if((SubSectionTitle[langID][mainOrder] != null) && (SubSectionTitle[langID][mainOrder].length > 0)){
				document.write(LineBroken+LineBroken+'<table border=0 cellspacing=0 cellpadding=0 width=100%>');	
				for(var j in SubSectionOrder[langID][mainOrder]){
					subOrder=SubSectionOrder[langID][mainOrder][j];
					if (SubSectionTitle[langID][mainOrder][subOrder] != ''){
						checkLinkLang(SubSection[langID][mainOrder][subOrder]);
						document.writeln('<tr valign=top><td width=1%>'+bullet2+'</td>');
						document.writeln('<td class="maincontent" width=99%><a href="'+SubSection[langID][mainOrder][subOrder]+'" class="text_link">'+SubSectionTitle[langID][mainOrder][subOrder]+'</a>'+EngOnly);
						if((SecondSubSectionTitle[langID][mainOrder][subOrder] != null) && (SecondSubSectionTitle[langID][mainOrder][subOrder].length > 0)){
							document.write(LineBroken+LineBroken+'<table border=0 cellspacing=0 cellpadding=0 width=100%>');	
								for(var k in SecondSubSectionOrder[langID][mainOrder][subOrder]){
									secondSubOrder=SecondSubSectionOrder[langID][mainOrder][subOrder][k];
									if (SecondSubSectionTitle[langID][mainOrder][subOrder][secondSubOrder] != ''){
										checkLinkLang(SecondSubSection[langID][mainOrder][subOrder][secondSubOrder]);
										document.writeln('<tr valign=top><td width=1%>'+bullet3+'</td>');
										document.writeln('<td class="maincontent" width=99%><a href="'+SecondSubSection[langID][mainOrder][subOrder][secondSubOrder]+'" class="text_link">'+SecondSubSectionTitle[langID][mainOrder][subOrder][secondSubOrder]+'</a>'+EngOnly);
										if((SecondSubSectionTitle[langID][mainOrder][subOrder][secondSubOrder+1] != null) && (SecondSubSectionTitle[langID][mainOrder][subOrder][secondSubOrder+1].length > 0)){
											document.writeln(LineBroken+LineBroken+'</td></tr>');
										}else{
											document.writeln('</td></tr>');
										}
									}
								}
							document.write('</table>');
						}
						if((SecondSubSectionTitle[langID][mainOrder][subOrder] != null) && (SecondSubSectionTitle[langID][mainOrder][subOrder].length > 0)){
							document.write(LineBroken);					
						}else{
							document.write(LineBroken+LineBroken);
						}
						document.writeln('</td></tr>');
					}
				}
				document.write('</table>');
			}else{
				if((SubSectionTitle[langID][mainOrder] != null) && (SubSectionTitle[langID][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 sub-section list. Up to level 3 only
function getSectionList(){
	var sectionOrder=0;
	var strSectionOrder='';
	var strBuffer='';
 	var textLink='';
//	alert (vspace);
	var bullet1='<img src="'+imagePath+'bullet_1.gif" alt="*" vspace='+vspace+' border="0" hspace=3>';
	if(isText) bullet1='<li>';
	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");
//	alert (count);
	if(count != 0){
		document.write('<table border=0 cellspacing=0 cellpadding=0 width=100%>');
		
		if (eval(strSectionOrder+".length")==1){
			if (eval(strBuffer+"[1]") != ""){
//				alert (textLink+"[1]")
				checkLinkLang(eval(textLink+"[1]"));
				document.writeln('<tr valign=top><td width=1%>'+bullet1+'</td>');
				document.writeln('<td class="maincontent" width=99%><a href="'+eval(textLink+"[1]")+'" class="TLink">'+eval(strBuffer+"[1]")+'</a>'+EngOnly+'<br></td></tr>');
			}
		}else{
		
			for(var j in eval(strSectionOrder)){
				sectionOrder=eval(strSectionOrder+"["+j+"]")
				if (eval(strBuffer+"["+sectionOrder+"]") != ""){
	//				alert (sectionOrder)
					checkLinkLang(eval(textLink+"["+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></td></tr>');
				}
			}
		}
		document.write('</table>');
	}
	sectionOrder=0;
}

function checkLinkLang(inputLink){
	if((eval(inputLink.search('/eng/')!=-1))&&(eval(inputLink.search('javascript:')==-1))&&(langID!=1)){
		EngOnly='&nbsp;<img src="'+locationPath+langPath+'btn_tc_eng.gif" align=absMiddle border=0 alt="Τ璣ゅ">';
		if(isText) EngOnly='&nbsp;Τ璣ゅ';
		vspace=3;
	}else{
		EngOnly='';
		vspace=0;
	}
}

//function for index page
function textOnlyLink(textLang){
	var tempLocation = 'ht'+'tp://'+textOnlyPath;
	var tempGbUrl = 'sc.info.gov.hk/gb/';
	
	if(textLang=='eng'){
		tempLocation=tempLocation+'eng/index.html';
	}else if(textLang=='chi'){
		tempLocation=tempLocation+'chi/index.html';
	}else if(textLang=='gb'){
		tempLocation=tempLocation+'gb/index.html';
		tempLocation=tempLocation.substring(0,7)+gb_urlPath+tempLocation.substring(7,tempLocation.length);
	}
	location=tempLocation;
}

//function for index page
function graphicLink(graphicLang){
	var tempLocation = 'ht'+'tp://'+graphicPath;
	
	if(graphicLang=='eng'){
		tempLocation=tempLocation+'eng/index.html';
	}else if(graphicLang=='chi'){
		tempLocation=tempLocation+'chi/index.html';
	}else if(graphicLang=='gb'){
		tempLocation=tempLocation+'gb/index.html';
		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 = "";
	/*if(secondSubSection!="" && secondSubSection>0){
		cssLevel="../../../../";
	}else if(subSection!="" && subSection>0){
		cssLevel="../../../";
	}else if(selectedSection!="" && selectedSection>0){
		cssLevel="../../";
	}else{
		cssLevel="ht"+"tp://"+graphicPath;
	}
	
	if(location.href.toString().indexOf('/cgi-bin/')!=-1){
		cssLevel="ht"+"tp://"+graphicPath;
	}*/
	cssLevel="ht"+"tp://"+graphicPath;
	
	if(isText){
		cssExtension = "_text.css"
	}
	
	if(langID==2) {cssLang = "_chi";}
	if(langID==3) {cssLang = "_chi";}
	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 changeSortMethod(SortMethod){
	var tmpAddress = document.location.toString().replace(document.location.search, '');
	document.location = tmpAddress+'?'+SortMethod;
}

function getTextTitle(){
		document.writeln('	<title>'+arClfTopMenu[langID][3]+' - '+MainTitle[langID][selectedSection] +'</title>');
}


checkStyle();