﻿var selectedSection;
var subSection;
var secondSubSection;
var subBanner;
var exLevel;
var langID;
var langPath;
var locationPath;
var revisionDate;
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;
subBanner='';
var gbPreURL = "ht"+"tp://sc.info.gov.hk/TuniS/";

<!--
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);
//--
//Java Script variable for global use

/*if(location.href.toString().indexOf('test.cedd.gov.hk')!=-1){
	locationPath='ht'+'tp://test.cedd.gov.hk/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath='sc.info.gov.hk/gb/';
	textOnlyPath="test.cedd.gov.hk/cgi-bin/cedd/TextOnly.pl"
}else if(location.href.toString().indexOf('ceddinternet')!=-1){
	locationPath='ht'+'tp://cintranet.cedd.hksarg/ceddinternet/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath='sc.info.gov.hk/gb/';
	textOnlyPath="www.cedd.gov.hk/cgi-bin/cedd/TextOnly.pl"
}else if(location.href.toString().indexOf('www.cedd.gov.hk')!=-1){
	locationPath='ht'+'tp://cedd-demo.ai-sol.com/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath='sc.info.gov.hk/gb/';
	textOnlyPath="www.cedd.gov.hk/cgi-bin/cedd/TextOnly.pl"
}else if(location.href.toString().indexOf('se.cgi')!=-1){
	locationPath='ht'+'tp://www.cedd.gov.hk/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath='sc.info.gov.hk/gb/';
	textOnlyPath="www.cedd.gov.hk/cgi-bin/cedd/TextOnly.pl"
	isGICSearch=true;
}else
if(location.href.toString().indexOf('/TuniS/')!=-1){
	locationPath= gbPreURL+'cedd-demo.ai-sol.com/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath='';
	textOnlyPath=gbPreURL.replace('htt'+'p://',"")+"cedd-demo.ai-sol.com/cgi-bin/cedd/TextOnly.pl"
}else{
	locationPath='ht'+'tp://cedd-demo.ai-sol.com/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath=	gbPreURL+'cedd-demo.ai-sol.com/';
	textOnlyPath=gbPreURL.replace('htt'+'p://',"")+"cedd-demo.ai-sol.com/cgi-bin/cedd/TextOnly.pl"
}*/
if (location.href.toString().indexOf('www0.cms.new.cedd.gov.hk')!=-1){
	locationPath='ht'+'tp://www0.cms.new.cedd.gov.hk/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath = gbPreURL+'www0.cms.new.cedd.gov.hk/';
	textOnlyPath="www0.cms.new.cedd.gov.hk/cgi-bin/ceddnew/cedd/TextOnly.pl"
}else if(location.href.toString().indexOf('www.cms.new.cedd.gov.hk')!=-1){
	locationPath='ht'+'tp://www.cms.new.cedd.gov.hk/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath = gbPreURL+'www.cms.new.cedd.gov.hk/';
	textOnlyPath="www.cms.new.cedd.gov.hk/cgi-bin/ceddnew/cedd/TextOnly.pl"
}else if(location.href.toString().indexOf('cintranet.cedd.hksarg')!=-1){
	locationPath='ht'+'tp://cintranet.cedd.hksarg/ceddinternet/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath=gbPreURL+'cintranet.cedd.hksarg/ceddinternet/';
	textOnlyPath="www.cedd.gov.hk/cgi-bin/cedd/TextOnly.pl"
}else if(location.href.toString().indexOf('cedd-demo.ai-sol.com')!=-1){
	gbPreURL ="ht"+"tp://203.194.194.248:443/TuniS/";
	locationPath='ht'+'tp://cedd-demo.ai-sol.com/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath= gbPreURL+'cedd-demo.ai-sol.com';
	textOnlyPath="cedd-demo.ai-sol.com/cgi-bin/ceddnew/cedd/TextOnly.pl";
}else{
	locationPath='ht'+'tp://' + location.hostname + '/';
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath= gbPreURL+ location.hostname + '/';
	textOnlyPath=location.hostname + "/cgi-bin/ceddnew/cedd/TextOnly.pl";
}

if(location.href.toString().indexOf('/TuniS/')!=-1){
	locationPath= gbPreURL+locationPath.substring(7,locationPath.length);
	graphicPath=locationPath.substring(7,locationPath.length);
	gb_urlPath='';
	textOnlyPath = gbPreURL.replace('htt'+'p://',"")+textOnlyPath
}

//change the locationPath for text only version
if(location.href.toString().indexOf('TextOnly.pl')!=-1|| location.search.toString().indexOf('isText=true')!=-1){
	isText=true;
	locationPath="ht"+"tp://"+textOnlyPath+"?search=";
}else{
	isText=false;
}

//function for getting the parameter from the path
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 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('search=')!=-1)
	{
		filePath=updatePath(QueryString("search"))
		folderPath=filePath.substring(0,filePath.lastIndexOf("/")+1)
	}

	if(filePath.search('eng/')!=-1 || location.search.toString().indexOf('lang=eng')!=-1 || location.search.toString().indexOf('mode=229')!=-1 || location.href.toString().indexOf('mode=253')!=-1){
		langPath = 'eng/';
		langID=1;
		vspace=0;
	}else{
		langPath = 'tc/';
		langID=2;
		vspace=3;
	}
}else{
	if(document.URL.toString().search('/eng/')!=-1 || location.search.toString().indexOf('lang=eng')!=-1 || location.search.toString().indexOf('mode=229')!=-1 || location.href.toString().indexOf('mode=253')!=-1){
		langPath = 'eng/';
		langID=1;
		vspace=0;
	}else{
		langPath = 'tc/';
		langID=2;
		vspace=3;
	}
}

//change the location path and image path for Simplified Chinese version
if(document.URL.toString().search('/TuniS/')!=-1){
	imagePath = locationPath+"/gb/";
	locationPath='ht'+'tp://'+gb_urlPath+locationPath.substring(7, locationPath.length);
}else{
	imagePath = locationPath+langPath;
}

//function for mouse over effect on left menu
function overTopMenu(obj)
{
        if (document.images){
				eval("document.images." + obj + ".src = '"+imagePath+"images/" + obj + "_f2.gif'");
        }
}

//function for mouse out effect on left menu
function outTopMenu(obj)
{
        if (document.images){
				eval("document.images." + obj + ".src = '"+imagePath+"images/" + obj + ".gif'");
        }
}

//function for switching image
function simg(obj,src)
{
        if (document.images){
                obj.src = src;
        }
}

function 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 photos
function popup(url)
{eval("nw = window.open(url, 'photos','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,pageXOffset=0,pageYOffset=0,top=0,left=0,width=800,height=600')");
	if ( nw.focus != null)
	{nw.focus();}
}


//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 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 pdf which have Simplified Chinese version
function documentPopUpGb(url){
	if(isText) url="ht"+"tp://"+graphicPath+updatePath(folderPath+url);
	if(url.toString().search('.pdf') != -1){
		url = url.replace('doc/', 'doc_gb/');
	}

	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 switching language
function changeLanguage(switchLang){
	var locationPage;
	var currentPath=document.URL.toString();
	var slash="/";
	var tempSwitchLang=switchLang;
	var switchTc="/tc/";
	var ready = true;

	//use for special case
	//Major Project
	if(location.href.toString().search('search.*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){
		currentPath=currentPath.replace(location.search,"?search="+filePath)
		slash="=";
		switchTc="=tc/";
		tempSwitchLang="="+switchLang.substring(1,switchLang.length);
	}

	if(isGICSearch){
		currentPath=document.URL.toString();
		slash="=";
		switchTc="=tc/";
		tempSwitchLang="="+switchLang.substring(1,switchLang.length);
	}

	if(switchLang=='/text/'){
		if(isText){
			//locationPage=currentPath.replace(textOnlyPath+"?search=",graphicPath);
			locationPage=currentPath.replace(textOnlyPath,"");
			locationPage=locationPage.replace("?search=",graphicPath);
		}else{
			if(location.href.toString().search('/TuniS/')!=-1){
				locationPage=currentPath.replace(graphicPath,textOnlyPath+"?search=");
				locationPage = locationPage.replace('ht'+'tp://',gbPreURL);
			}else{
				locationPage=currentPath.replace(graphicPath,textOnlyPath+"?search=");
			}
			if(isGICSearch){
				if(langID==1){
					alert("Search function for text only version is not available");
				}else{
					alert("本網站並沒有提供純文字版本的搜尋功能")
				}
				ready=false
			}
		}
	}else if(switchLang=='/gb/'){
		locationPage = currentPath.replace('ht'+'tp://', '');
		locationPage = gbPreURL +locationPage
	}else{
		if(currentPath.search('/TuniS/')!=-1){
			locationPage=currentPath.replace(gbPreURL, 'ht'+'tp://');
			locationPage=locationPage.replace(slash+langPath, tempSwitchLang);
		}else{
			locationPage=currentPath.replace(slash+langPath, tempSwitchLang);
		}
	}

	if (ready){
		document.location=locationPage;
	}
}


//function for generating the path indicator
function getPath(){
	var strBuffer='<a href="'+MainSection[langID][0]+'"  class="topnavbn">'+MainTitle[langID][0]+'</a>';
	if(subSection>0){
		if(selectedSection>0) strBuffer+=' > <a href="'+MainSection[langID][selectedSection]+'"  class="topnavbn">'+MainTitle[langID][selectedSection]+'</a>';
	}else{
		if(exLevel){
			if(selectedSection>0) strBuffer+=' > <a href="'+MainSection[langID][selectedSection]+'"  class="topnavbn">'+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="topnavbn">'+SubSectionTitle[langID][selectedSection][subSection]+'</a>';
	}else{
		if(exLevel){
			if(subSection>0) strBuffer+=' > <a href="'+SubSection[langID][selectedSection][subSection]+'"  class="topnavbn">'+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="topnavbn">'+SecondSubSectionTitle[langID][selectedSection][subSection][secondSubSection]+'</a>';
		}else{
			strBuffer+=' > '+SecondSubSectionTitle[langID][selectedSection][subSection][secondSubSection];
		}
	}

	if(exLevel){
		strBuffer+=' > '+exLevel;
	}

	//graphic version only
	if(!isText){
		document.writeln(strBuffer);
	}
}

//function for generating the topic image
function getTopic(){
	var altText = '';
	var imgPath = '';
	altText = MainTitle[langID][selectedSection];

	if(!isText){
		document.write('<img src="'+imagePath+'images/title/title_'+(selectedSection+1)+'.jpg" alt="'+altText+'" border="0">');
	}else{
		document.writeln('<p class="title">'+altText+'</p>');
	}
}



//function for generating the the text below
function otherLangOnly(){
	var TextStr='<p>We only provide <a href="javascript:changeLanguage(\'/tc/\');" class="text_link">Chinese Version</a>.</p>';
	if(langID==2) TextStr='<p>我們只提供<a href="javascript:changeLanguage(\'/eng/\');" class="text_link">英文版本</a>。</p>';
	document.writeln(TextStr);
}

//function for generating the the text for downloading acrobat reader
function getAcrobat(){
	var StrText='To view or download the following document, please download <a class="text_link" href="javascript:externalLink(\'http://www.adobe.com/prodindex/acrobat/readstep.html\');">Acrobat Reader</a>.';
	if(langID==2) StrText='如想觀看以上文件，請下載<a class="text_link" href="javascript:externalLink(\'http://www.adobe.com/prodindex/acrobat/readstep.html\');">Acrobat Reader</a> 。';
	var StrImg='<img src="'+locationPath+'images/acrobat.gif" border=0 align=top alt="Acrobat Reader">';
	if(isText) StrImg='Acrobat Reader';

	document.writeln('<p><table border=0 cellspacing=0 cellpadding=2 width=100%>');
	document.writeln('<tr valign=top><td width=1%><a href="javascript:externalLink(\'http://www.adobe.com/prodindex/acrobat/readstep.html\');">'+StrImg+'</a></td>');
	document.writeln('<td class="maincontent" width=99%>'+StrText+'</td></tr>');
	document.writeln('</table>');
}

var resizeFlag;
var footerY = 600;

function moveDivs(layerObj, inObj){
	layerObj.top  = inObj;
}

function moveTopDivs(layerObj, inObjTop, inObjLeft){
	layerObj.top  = inObjTop;
	layerObj.left  = inObjLeft;
}

function getDim(el){
	for (var lx=0,ly=0;el!=null;
		lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
	return {x:lx,y:ly}
}

//function for setting the top button
function setTopLayerPosition(resizeFlag){
	if(topButton=='Y'){
		if (document.all && document.all["footer_layer"]!=null)
		{
	//		footerY = getDim(document.images.leftMenuLineBottom).y;
			moveTopDivs(document.all["footer_layer"].style, getDim(document.images.backtotopspacer).y, getDim(document.images.backtotopspacer).x)
			if (getDim(document.images.backtotopspacer).y > footerY)
			{
				if (resizeFlag)
				{document.all["footer_layer"].style.visibility = "visible"}
			}
		}
		if (document.layers && document.layers["footer_layer"])
		{
	//		footerY = document.images["leftMenuLineBottom"].y;
			moveTopDivs(document.layers["footer_layer"], document.images["backtotopspacer"].y, document.images["backtotopspacer"].x);
			if (document.images["backtotopspacer"].y > footerY)
			{
				if (resizeFlag)
				{document.layers["footer_layer"].visibility = "show"}
			}
		}
		if (!document.all && document.getElementById && document.getElementById("footer_layer")!=null)
		{
	//		footerY = document.images["leftMenuLineBottom"].y;
			moveTopDivs(document.getElementById("footer_layer").style, document.images["backtotopspacer"].y, document.images["backtotopspacer"].x);
			if (document.images["backtotopspacer"].y > footerY)
			{
				if (resizeFlag)
				{document.getElementById("footer_layer").style.visibility = "visible"}
			}
		}
	}
}

if(!isText){
	onresize=setTopLayerPosition;
}


//function for generating the sitemap
function getSiteMap(){
	var mainOrder = 0;
	var subOrder = 0;
	var secondSubOrder = 0;
	var LineBroken='<br>';
	var bullet1='<img src="'+locationPath+langPath+'images/bullet_1.gif" alt="*" vspace='+vspace+' border="0" hspace=3>';
	var bullet2='<img src="'+locationPath+langPath+'images/bullet_2.gif" alt="*" vspace='+vspace+' border="0" hspace=3>';
	var bullet3='<img src="'+locationPath+langPath+'images/bullet_3.gif" alt="*" vspace='+vspace+' border="0" hspace=3>';
	if(isText){
		bullet1="*";
		bullet2="*";
		bullet3="*";
	}
	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="sitemap01">'+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="sitemap02">'+SubSectionTitle[langID][mainOrder][subOrder]+'</a>'+EngOnly);
						//document.writeln(SecondSubSectionTitle[langID][mainOrder][subOrder]);
						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="sitemap03">'+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='';
	var bullet1='<img src="'+locationPath+langPath+'images/bullet_1.gif" alt="*" border="0" vspace='+vspace+' hspace=3 align=absMiddle>';
	if(isText) bullet1='*';
	if(selectedSection>0) strBuffer+='['+selectedSection+']';
	if(subSection>0) strBuffer+='['+subSection+']';
	if(subSection>0){
		textLink='SecondSubSection['+langID+']'+strBuffer;
		strSectionOrder='SecondSubSectionOrder['+langID+']'+strBuffer;
		strBuffer='SecondSubSectionTitle['+langID+']'+strBuffer;
	}else{
		textLink='SubSection['+langID+']'+strBuffer;
		strSectionOrder='SubSectionOrder['+langID+']'+strBuffer;
		strBuffer='SubSectionTitle['+langID+']'+strBuffer;
	}
	var count = eval(strSectionOrder+".length");

	if(count != 0){
		document.write('<table border=0 cellspacing=0 cellpadding=5 width=100%>');

		for(var j in eval(strSectionOrder)){
			sectionOrder=eval(strSectionOrder+"["+j+"]")
			if (eval(strBuffer+"["+sectionOrder+"]") != ""){
				checkLinkLang(eval(textLink+"["+sectionOrder+"]"));
				document.writeln('<tr>');

				finallink = eval(textLink+"["+sectionOrder+"]");
				if ((finallink.indexOf(".pdf")!=-1) || (finallink.indexOf(".doc")!=-1) || (finallink.indexOf(".txt")!=-1) || (finallink.indexOf(".xls")!=-1) || (finallink.indexOf(".zip")!=-1)) {
					finallink = finallink.replace("cgi-bin/ceddnew/cedd/TextOnly.pl?search=", "");
				}

				document.writeln('<td><div class="greenbold"><a href="'+finallink+'"  class="greenboldtxt">'+eval(strBuffer+"["+sectionOrder+"]")+'</a>'+EngOnly+'</div></td></tr>');
				//document.writeln('<td><div class="greenbold"><a href="'+eval(textLink+"["+sectionOrder+"]")+'"  class="greenboldtxt">'+eval(strBuffer+"["+sectionOrder+"]")+'</a>'+EngOnly+'</div></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+'images/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+'?search=';
	var tempGbUrl = 'sc.info.gov.hk/gb/';

	if(textLang=='eng'){
		tempLocation=tempLocation+'eng/about/welcome/index.htm';
	}else if(textLang=='tc'){
		tempLocation=tempLocation+'tc/about/welcome/index.htm';
	}else if(textLang=='gb'){
		tempLocation=tempLocation+'tc/about/welcome/index.htm';
		tempLocation=tempLocation.substring(0,7)+tempGbUrl+tempLocation.substring(7,tempLocation.length);
	}
	location=tempLocation;
}

//function for index page
function graphicLink(graphicLang){
	var tempLocation = 'ht'+'tp://'+graphicPath;

	if(graphicLang=='eng'){
		tempLocation=tempLocation+'eng/about/welcome/index.htm';
		//openWin('popup', 'popup_eng.htm', 50,10,180,200)
	}else if(graphicLang=='tc'){
		tempLocation=tempLocation+'tc/about/welcome/index.htm';
          //                      openWin('popup', 'popup_tc.htm', 50,10,180,200)
	}else if(graphicLang=='gb'){
		tempLocation=tempLocation+'tc/about/welcome/index.htm';
        //                       openWin('popup', 'popup_tc.htm', 50,10,180,200)
		tempLocation=tempLocation.substring(0,7)+gb_urlPath+tempLocation.substring(7,tempLocation.length);
	}
	location=tempLocation;

}

function openWin(name, url, top, left, width, height, resize, scroll, menu)
{
	args = 'top=' + top +
			'screenX=' + top +
			',left=' + left +
			'screenY=' + left +
			',width=' + width +
			',height=' + height +
			',resizable=' + resize +
			',scrollbars=' + scroll +
			',menubar=' + menu;
	newWin = window.open(url, name, args)
}

//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 = "_tc";}

	//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">');
	//}
}

checkStyle();
//document.writeln('	<div id="Layer1" style="position:absolute; width:793px; height:65px; z-index:1; left: 0; top: 0;"><img src="'+imagePath+'images/branding.jpg" width="793" height="65"></div>');
//document.writeln('	<div id="Layer2" style="position:absolute; width:66px; height:184px; z-index:2; left: 100px; top: 88px;"><img src="'+imagePath+'images/lantern.gif" width="66" height="184"></div>');t


function goSubmit(theForm,selectedSection){
	//theForm.category.value=MainTitle[langID][subSection];
	
	theForm.category.value=SubSectionTitle[langID][selectedSection][subSection];
	//theForm.thesec.value=selectedSection;
	theForm.thesec.value=subSection;
	if (ValidateForm('T', 'pname', 'Name of Publication', 'M', 'T', 'detail', 'Details', 'M', 'T', 'sname', 'Name', 'M', 'T', 'email', 'Email', 'M|Email')){
		theForm.submit();
	}
}
var timer;
function goSubmitc(theForm,selectedSection){
	//theForm.category.value=MainTitle[langID][subSection];
	theForm.category.value=SubSectionTitle[langID][selectedSection][subSection];
	//theForm.thesec.value=selectedSection;
	
	theForm.thesec.value=subSection;
	if(location.href.toString().indexOf('/TuniS/')!=-1){
		theForm.TuniSSession.value = "gb";
	}else{
		theForm.TuniSSession.value = "tc";
	}
	
	theForm.langID.value=langID;
	//alert(theForm.langID.value);
	display("_category","category");
	display("_pname","pname");
	display("_detail","detail");
	display("_sname","sname");
	display("_company","company");
	
	if (ValidateForm('T', 'pname', '刊物名稱', 'M', 'T', 'detail', '詳細內容', 'M', 'T', 'sname', '名稱', 'M', 'T', 'email', '電郵', 'M|Email')){
		theForm.submit();
		timer = setInterval(afterSubmit, 1000);
	}
	
}

function afterSubmit(){
	var ifr_window=window.frames["mailAction"];
	//alert(ifr_window.sent!=undefined);
	if(ifr_window.sent!=undefined)
	{
		if(ifr_window.sent=="ok"){
			document.getElementById("mailForm").style.display="none";
			document.getElementById("afterMail").style.display="inline";
			clearInterval(timer);
			return;
		}
	}
}

function display(name,name2){
	var obj = document.getElementById(name2);
	var obj2 = document.getElementById(name);
	//alert(obj.value);
	if(obj.value != ''){
		var vText = obj.value; 
         var vEncoded = display2(vText);
         
		 obj2.value = vEncoded;
	 }
} 
function display2(source){
	var result = '';
	for (i=0; i<source.length; i++) {
		if ((source.charCodeAt(i) < 65) || (source.charCodeAt(i) > 122))
			result += '&#' + source.charCodeAt(i) + ';'; 
		else
			result += source.substr(i,1);
	}
  	return result;
}

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];}
}