//Page Status var:
var printPage;
var isText;
var isGdns;
var isGB;
var isProd;
var isProds;
var isTest;
var isSearch;
var gb_img_prefix="";

/******** Global setting ********/

var textOnly_pl="text_only.pl";
var gdns_pl="gdne";
var gdns_pl2="hcoll_gdne.html";
var search_pl="se.cgi";
//var gbUrl="/gb/";
var gbUrl="/sc/";

//Difference Server's URL
var htmlurl = ""; //Test site  folder
var testUrl="http://www0.try.gov.hk/";
var test2Url="http://localhost/try/"; //The internal test site domain.
var prodUrl="http://www.try.gov.hk/";
var textonlyUrl="http://www0.try.gov.hk/"; //The textonly program domain.
//var gb_urlPath="sc.info.gov.hk/gb/";  //Use this domain when the current url not equal to www/www0
var gb_urlPath="";  //Use this domain when the current url not equal to www/www0

//Gdns Url
var gdnsProdUrl="http://gdns.try.gov.hk/gdns/eenquiry/gdne";
//var gdnsProdUrl_tpl="http://www0.try.gov.hk/cgi-bin/try/gdne.pl";
//var gdnsProdUrl_tpl="http://gdns.try.gov.hk/cgi-bin/try/gdne.pl";
var gdnsProdUrl_tpl=gdnsProdUrl;
var gdnsProdDomain="gdns.try.gov.hk/gdns/eenquiry"

//Perl Program Var:
var cgiPath1 = "cgi-bin"; //Cgi Folder Part 1
var cgiPath2 = "/try/"; //Cgi Folder Part 2
var cgiPath=cgiPath1+cgiPath2; //Cgi Folder 
var cgiName = textOnly_pl+"?search="; //Cgi Name in url

//Last Revision Date
var revisionDateType=2;	// 0 is based on HTML page, 1 is based on common.js, 2 is based on the latest date
var revisionDateGlobal='12/02/2004';
/******** End of Global setting ********/

//Gdns Var:
var gdns_lang= new Array();
gdns_lang[1]="ver=en";
gdns_lang[2]="ver=zh_tc";
gdns_lang[3]="ver=zh_sc";



//Browser Type var:
var isNS4 = (document.layers) ? true : false;
var isIE4 = (document.all && !document.getElementById) ? true : false;
var isIE5 = (document.all && document.getElementById) ? true : false;
var isNS6 = (!document.all && document.getElementById) ? true : false;

//If not NS4. It should be IE or NS6+
isIE5 =!isNS4;

//Timer for left menu
var timer1;
var timer2;



//Menu, Link, other Object Length
var x = 1;	 //menuObj.length
var y = 1;	 //subMenuObj.length
var z = 1;	 //subSubMenuObj.length
var r = 1;	 //releaseObj.length
var s = 1;	 //accountObj.length
var t = 1;	 //annualObj.length
var e = 1;	 //envirObj.length
var a = 1;	 //accuObj.length
var ac = 1;	 //accuObj.length
var lc= 1;  //linksObj.length
var lf = 1; //lowerleftObj.length

//Menu, Link, other Object
var menuObj = new Array();
var subMenuObj = new Array();
var subSubMenuObj = new Array();
var releaseObj = new Array();
var accountObj = new Array();
var annualObj = new Array();
var envirObj = new Array();
var accuObj = new Array();
var linksObj = new Array();
var lowerleftObj = new Array();

//Section Var
var Selected_ID;
var Selected_Sub;
var Selected_SubSub;
var revisionDate;

//Path Var
var imagePath;
var locationPath;
var langPath;
var langID;
var prodURL='ht'+'tp://';
var externalURL;


var topButton;

//Return page status:
function getPageStatus(statusType){
 switch(statusType){
   case "isGdns":
	if(document.URL.toString().search(gdns_pl)!=-1 || document.URL.toString().search(gdns_pl2)!=-1)
	 return true;
	else
	 return false;
   break;

  case "isText":
	if(document.URL.toString().search(textOnly_pl)!=-1 || location.href.toString().search("text=1")!=-1)
	 return true;
	else
	 return false;
   break;

  case "isGB":
	if(document.URL.toString().search(gbUrl)!=-1 || location.href.toString().search(gdns_lang[3])!=-1)
	 return true;
	else
	 return false;
   break;
   
  case "isProd":
	if(document.URL.toString().search(prodUrl.substring(0,prodUrl.length-1))!=-1)
	 return true;
	else
	 return false;
   break;
   
  case "isTest":
	if(document.URL.toString().search("www0")!=-1)
	 return true;
	else
	 return false;
   break;
   
  case "isInternal":
	if(document.URL.toString().search(clearFirstWord(test2Url))!=-1)	
	 return true;
	else
	 return false;
   break;

  case "isSearch":
	if(document.URL.toString().search(search_pl)!=-1 || document.URL.toString().search("resultcs_try.html")!=-1 || document.URL.toString().search("resultes_try.html")!=-1)
	 return true;
	else
	 return false;
   break;
	 	
  case "printPage":
	if(window.name=='PrintPage' || document.URL.toString().search('printPage=1')!=-1)
	 return true;
	else
	 return false;
   break;

	case "langID":
	 if(document.URL.toString().search('/internet/')!=-1 || location.href.toString().search(gdns_lang[1])!=-1 || location.href.toString().search("259")!=-1 || location.href.toString().search("e"+gdns_pl2)!=-1)
	  return 1;
	 if(document.URL.toString().search('/cinternet/')!=-1 || location.href.toString().search(gdns_lang[1])==-1 || location.href.toString().search("260")!=-1 || location.href.toString().search("c"+gdns_pl2)!=-1)
	  return 2;
   break;

	case "langPath":
	 if(document.URL.toString().search('/internet/')!=-1 || location.href.toString().search(gdns_lang[1])!=-1 || location.href.toString().search("259")!=-1 || location.href.toString().search("e"+gdns_pl2)!=-1)
	  return "/internet/";
	 if((document.URL.toString().search('/cinternet/')!=-1) || (document.URL.toString().search('ver=zh_tc')!=-1))
	  return "/cinternet/";
	 if((document.URL.toString().search('/sc/')!=-1)||isGB)
	  return "/sc/";
   break;
 
  default:
  return false;
 }
}




//Set status to var:
printPage=getPageStatus("printPage");
isText=getPageStatus("isText");
isGdns=getPageStatus("isGdns");
isGB=getPageStatus("isGB");
isProd=false;
isProds=getPageStatus("isProd");
isTest=getPageStatus("isTest");
isInternal=getPageStatus("isInternal");
isSearch=getPageStatus("isSearch");
langPath=getPageStatus("langPath");
langID=getPageStatus("langID");

if(langID==1)
gdnsProdUrl=gdnsProdUrl+"?ver=en";
if(langID==2)
gdnsProdUrl=gdnsProdUrl+"?ver=zh_tc";
if(langID==3)
gdnsProdUrl=gdnsProdUrl+"?ver=zh_sc";

//Set textonly domain;
	if(isProds || isGdns || isSearch)
		textonlyUrl="http://www.try.gov.hk/"; //The textonly program domain.	
	
//Set  gb var.
	if(!isInternal)
		//gb_urlPath='sc.info.gov.hk/gb/';
		gb_urlPath='';

	if (isGB){
		gb_img_prefix="imgb_";
		imagePath = locationPath+'/common/images/sc/';
	}else{
		gb_img_prefix="imc_";
		imagePath = locationPath+langPath;  
	}

var LayerPostion=0;
x1=150;
x2=215;
x3=293;
x4=372;
x5=478;

z1=150;
z2=233;
z3=313;
z4=388;
z5=514;


var layerPosArray=new Array();
layerPosArray[1]=220;
layerPosArray[2]=220;
layerPosArray[3]=210;
layerPosArray[4]=232;
layerPosArray[5]=267;
layerPosArray[6]=290;
layerPosArray[7]=312;
layerPosArray[8]=334;
layerPosArray[9]=357;
layerPosArray[10]=310;
layerPosArray[11]=330;
layerPosArray[12]=426;
layerPosArray[13]=370;

//Dreamwaver Prgram -Start-

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}


function MM_showHideLayers() { //v3.0


  var i,p,v,obj,args=MM_showHideLayers.arguments;
  var k;
  y=19;

  for (i=0, k=1; i<(args.length-3); i+=3, k+=1) {
    if ((obj=MM_findObj(args[i]))!=null) { 
	  v=args[i+2];
	  obj2=obj;
      if (obj.style) { obj=obj.style; }
	  if (v=='show') {
	    if (!document.layers) {   // all others
			if (isNS6) {
			    w = window.innerWidth;
			}
			else {
			    w = window.document.body.clientWidth;
			}

			w = 160;
			w=w<0?0:w;
			obj.left= w + args[args.length-1];
        }
	    else {  //NN4
		 if(navigator.appName=="Netscape" && navigator.appVersion.substring(0,1)!="5"){
   	      obj.left = document.layers[args[0]].pageX;  
		  obj.top = document.layers[args[0]].pageY;
		 }
	    }		
	  }
 	  v=(v=='show')?'visible':(v='hide')?'hidden':v; 

	  if(MM_showHideLayers.arguments[0]!="Layer1"){
	if (isNS4){		
		var tmp=" changeLayerPicPi('"+Selected_ID+"')";
		timer1=setTimeout(tmp,500);
		tmp="document."+obj.name+".visibility='"+v+"'";		
		timer2=setTimeout(tmp,500);
	}else{
		changeLayerPicPi(Selected_ID);
        obj.visibility=v; 
	}

	  }
	}
  }
}

function simg(obj,src)
{
        if (document.images){
            obj.src = src;
        }
}

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}
}

//Dreamwaver Prgram -End-


//Set the position of layer
function setLayerPosition()
{
	for(var i=1;i<=13;i++){
	if(document.layers){
		LayerPostion=eval("document.pic"+i+".y");
	}else{
		LayerPostion=eval("getDim(document.images.pic"+i+").y");
	}

		if(i != 2){
			if(document.layers){
				eval('document.layers.Layer'+i+'.y='+LayerPostion);
				eval('document.layers.Layer'+i+'.x=160');
			}else{

				if (navigator.appName != "Netscape"){ 
				 eval('document.all["Layer'+i+'"].style.top='+LayerPostion);
				 eval('document.all["Layer'+i+'"].style.top=600');
				}else{
				 if (navigator.appVersion.substring(0,1)!="5"){
				  eval('document.all["Layer'+i+'"].style.top='+LayerPostion);
				  eval('document.all["Layer'+i+'"].style.top=600');
				 }
				}
			}
		}
	}
	
	for(var i=1;i<=13;i++){
	if(document.layers){
		LayerPostion=eval("document.pic"+i+".y");
	}else{
		LayerPostion=eval("getDim(document.images.pic"+i+").y");
	}
	
		if(document.layers){
			eval('document.layers.Layer'+(i)+'.y='+LayerPostion);
			eval('document.layers.Layer'+(i)+'.x=160');
		}else{
				if (navigator.appName != "Netscape"){ 
					eval('document.all["Layer'+(i)+'"].style.top='+LayerPostion);
					eval('document.all["Layer'+(i)+'"].style.left=160');		
				}else{
				 if (navigator.appVersion.substring(0,1)!="5"){
					eval('document.all["Layer'+(i)+'"].style.top='+LayerPostion);
					eval('document.all["Layer'+(i)+'"].style.left=160');		
				 }
				}
			
		}
	}

}





function hidden_show(l_name){
l_name="Layer1";
if(navigator.appName=="Netscape"){
if (document.layers["Layer1"].style.visibility=="hidden"){
 document.layers["Layer1"].style.visibility="";
}else{
 document.layers["Layer1"].style.visibility="hidden";
}

}else{

if (document.all[l_name].style.visibility=="hidden"){
 document.all[l_name].style.visibility="";
}else{
 document.all[l_name].style.visibility="hidden";
}

}

}






//menu:

//Language for image
	 var tmpImgPath = Array();
	  tmpImgPath[1]="en";
	  tmpImgPath[2]="tc";
	  tmpImgPath[3]="sc";

	 var tmpUrlPath = Array();
	  tmpUrlPath[1]="/eh";
	  tmpUrlPath[2]="/ch";
	  tmpUrlPath[3]="/sc";

	  if(isGB)
	   tmpImgPath[2]="sc";
		  


		  
//function for check current Path
function getLocationPath(){

	var locPath=location.href.toString();
	var targetString;
	var subPath;
	
	if(location.href.toString().search('/en/')!=-1){
		targetString=location.href.search('/en/');
		subPath=locPath.substring(0, targetString);
	}
	if(location.href.toString().search('/tc/')!=-1){
		targetString=location.href.search('/tc/');
		subPath=locPath.substring(0, targetString);
	}
	if(location.href.toString().search('/sc/')!=-1){
		targetString=location.href.search('/sc/');
		subPath=locPath.substring(0, targetString);
	}
	/*if(location.href.toString().search('/gb/')!=-1){
		targetString=location.href.search('/gb/')+4;
		locationPath=locPath.substring(targetString);
		targetString=locPath.search('/tc/');
		subPath=locPath.substring(0, targetString);
	}*/

	if(location.href.toString().search('/internet/')!=-1){
		if(isText){
		 targetString=location.href.search('internet/');
		}else{
		 targetString=location.href.search('/internet/');
		subPath=locPath.substring(0, targetString);
	    }
	}
	if(location.href.toString().search('/cinternet/')!=-1){
		if(isText){
		 targetString=location.href.search('cinternet/');
		}else{
		 targetString=location.href.search('/cinternet/');
		subPath=locPath.substring(0, targetString);
	    }		
	}	

	if(isText){
		subPath=cgiName.replace("search=/","search=");
	}

	if(isSearch){
	 if(isText)
		subPath=textonlyUrl+cgiPath+cgiName;			
	 else
		subPath=clearLastWord(prodUrl);
	}

	if(isProds){
	 if(isText)
		subPath=textonlyUrl+cgiPath+cgiName;			
	 else
		subPath=clearLastWord(prodUrl);
	}
	
	if(isGdns){
	 if(isText)
		subPath=textonlyUrl+cgiPath+cgiName;			
	 else
		subPath=clearLastWord(prodUrl);
	}

	if(isTest){
	 if(isText)
		subPath=textonlyUrl+cgiPath+cgiName;			
	 else	
		subPath=clearLastWord(testUrl);	
	}
	
	if(isInternal){
	 if(isText)
		subPath=textonlyUrl+cgiPath+cgiName;			
	 else	
		subPath=clearLastWord(test2Url);
	}

	locationPath=subPath;
	
}


	   
	   
//function for Draw Print Button
function genPrintButton(){
	if(!printPage){
		if(langID==1){ var altText='Print'; }else{ if((document.URL.toString().search('/sc/') != -1)||isGB) var altText='列印';else var altText='列印';}
		document.writeln('<p><table border=0 cellspacing=0 cellpadding=0 width=100%>');
		if(!isText)
			document.writeln('<tr valign=top><td align=right><a href="javascript:PrintDocument();"><img src="'+locationPath+'/common/images/'+tmpImgPath[langID]+'/btn_print.gif" border=0 align=top title="'+altText+'" alt="'+altText+'"></a></td></tr>');
		else
			document.writeln('<tr valign=top><td align=right><a href="javascript:PrintDocument();">'+altText+'</a></td></tr>');
		document.writeln('</table>');
	}else{
		if(langID==1){ var altText='Close'; }else{ if((document.URL.toString().search('/sc/') != -1)||isGB) var altText='关闭'; else var altText='關閉';}
		document.writeln('<p><table border=0 cellspacing=0 cellpadding=0 width=100%>');
		if(!isText)
			document.writeln('<tr valign=top><td align=right><a href="javascript:window.close();"><img src="'+locationPath+'/common/images/'+tmpImgPath[langID]+'/btn_close.gif" border=0 align=top title="'+altText+'" alt="'+altText+'"></a></td></tr>');
		else
			document.writeln('<tr valign=top><td align=right><a href="javascript:window.close();">'+altText+'</a></td></tr>');
		document.writeln('</table>');
	}

	
/*
 		if(langID==1){
		 var altText='Close'; 	   
		 if (!isText){
		  altText='<img src="btn_close.gif" width="61" height="20" alt="Close" border="0" title="Close">'; 
		}else{
		 var altText='關閉'; 	   
		 if (isText)
		  altText='<img src="btn_close.gif" width="53" height="20" alt="關閉" title="關閉" border="0">'; 
		}
		
		document.writeln('<p><table border=0 cellspacing=0 cellpadding=0 width=100%>');
		document.writeln('<tr valign=top><td align=right><a href="javascript:window.close();">'+altText+'</a></td></tr>');
*/		
}

//function for Print Function
function PrintDocument(){
	var gt=getPath2Title();
	var s="The Treasury - "+gt;
	if (sitemap && sitemap=="Y")
	 s="The Treasury - Site Map";

	if(document.URL.toString().search("hcoll_gdne.html")!=-1)
	 isGdns=false;

	if(!isGdns){
 	  w=window.open(document.URL,'PrintPage','top=10,left=10,height=500,width=650,scrollbars=1');
	}else{

	var tmp_winlink=document.URL;
 	 if (tmp_winlink.search("ref=")==-1)
	 	tmp_winlink=tmp_winlink+"&ref="+document.changever.ref.value.toUpperCase()+"&ver="+document.changever.ver.value+"&printPage=1";
	else
		tmp_winlink=tmp_winlink.replace(document.changever.ref.value.toLowerCase(),document.changever.ref.value.toUpperCase());
     w=window.open(tmp_winlink,'PrintPage','top=10,left=10,height=500,width=650,scrollbars=1');	
	}
	 w.title=s;
}

//function for mouse over effect on left menu
function overTopMenu(obj)
{
      if (document.images){
		eval("document.images." + obj + ".src = '"+locationPath+"/common/images/'+ getImagePath(tmpImgPath[langID]) +'/" + obj + "_f2.gif'");
      }
}

//function for mouse out effect on left menu
function outTopMenu(obj)
{
      if (document.images){
		eval("document.images." + obj + ".src = '"+locationPath+"/common/images/'+ getImagePath(tmpImgPath[langID]) +'/" + obj + ".gif'");
      }
}


function getAcrobat(){
	var StrText='To view or download the following document, please download <a class="text_link" href="javascript:externalLink(1, \'http://www.adobe.com/prodindex/acrobat/readstep.html\');">Acrobat Reader</a>.';
	if(langID==2) StrText='如想觀看以上文件，請下載<a class="text_link" href="javascript:externalLink(1, \'http://www.adobe.com/prodindex/acrobat/readstep.html\');">Acrobat Reader</a> 。';
	var StrImg='<img src="'+locationPath+'/acrobat.gif" border=0 align=top  title="Acrobat Reader" alt="Acrobat Reader">';
		
	document.writeln('<p><table border=0 cellspacing=0 cellpadding=2 width=585><tr valign=top>');
	if(isText!=1)
		document.writeln('<td width=1%><a href="javascript:externalLink(1, \'http://www.adobe.com/prodindex/acrobat/readstep.html\');">'+StrImg+'</a></td>');
	document.writeln('<td class="maincontent" width=99%>'+StrText+'</td>');
	document.writeln('</tr></table>');
}

function getRealPlayer(){
	var StrText='You can use RealPlayer to view the videos in Real Media format. RealPlayer is available free at <a class="text_link" href="javascript:externalLink(1, \'http://www.real.com/\');">www.real.com</a>.';
	if(langID==2) StrText='以上短片須使用RealPlayer觀看, 此軟件可於<a class="text_link" href="javascript:externalLink(1, \'http://www.real.com/\');">www.real.com</a>免費下載:';
	var StrImg='<img src="'+locationPath+'/realplayer.gif" border=0 align=top title="RealPlayer" alt="RealPlayer">';
		
	document.writeln('<p><table border=0 cellspacing=0 cellpadding=2 width=585><tr valign=top>');
	if(isText!=1)
		document.writeln('<td width=1%><a href="javascript:externalLink(1, \'http://www.real.com/\');">'+StrImg+'</a></td>');
	document.writeln('<td width=99%>'+StrText+'</td>');
	document.writeln('</tr></table>');
}

//Add Left Menu Object
function addMenu(sectionID, caption, chi_caption,url,offPic,onPic,hasChild,sitemap,navigationMenu)
{
	menuObj[x]	= new Object();
	menuObj[x].id = sectionID;
	menuObj[x].caption = caption;
	menuObj[x].chiCaption = chi_caption;
if (langID==1){
	menuObj[x].url = locationPath+langPath+url;
}else{
	menuObj[x].url = locationPath+langPath+url;
	menuObj[x].url = menuObj[x].url.replace("/eh","/ch");
}	
	menuObj[x].onPic = locationPath + "/common/images/"+getImagePath(tmpImgPath[langID])+"/" + onPic;
	menuObj[x].offPic = locationPath + "/common/images/"+getImagePath(tmpImgPath[langID])+"/" + offPic;
	menuObj[x].hasChild = hasChild;
	menuObj[x].sitemap = sitemap;
	menuObj[x].navigationMenu = navigationMenu;
	x++;
}

//Add Sub Left Menu Object
function addSubMenu(menuID, subSectionID, caption, chi_caption,url,sitemap,navigationMenu)
{
	subMenuObj[y] = new Object();
	subMenuObj[y].id = subSectionID;
	subMenuObj[y].menuID = menuID;
	subMenuObj[y].caption = caption;
	subMenuObj[y].chiCaption = chi_caption;
if (langID==1){
	subMenuObj[y].url = locationPath+langPath+url;
}else{
	subMenuObj[y].url = locationPath+langPath+url;
	subMenuObj[y].url = subMenuObj[y].url.replace("/eh","/ch");
}	
	subMenuObj[y].sitemap = sitemap;
	subMenuObj[y].navigationMenu = navigationMenu;
	y++;
}

//Add Sub Sub Left Menu Object
function addSubSubMenu(menuID, subSectionID,subSubSectionID, caption, chi_caption,url,sitemap,navigationMenu)
{
	subSubMenuObj[z] = new Object();
	subSubMenuObj[z].id = subSubSectionID;
	subSubMenuObj[z].subSectionID = subSectionID;
	subSubMenuObj[z].menuID = menuID;
	subSubMenuObj[z].caption = caption;
	subSubMenuObj[z].chiCaption = chi_caption;
if (langID==1){
	subSubMenuObj[z].url = locationPath+langPath+url;
}else{
	subSubMenuObj[z].url = locationPath+langPath+url;
	subSubMenuObj[z].url = subSubMenuObj[z].url.replace("/eh","/ch");
}	
	subSubMenuObj[z].sitemap = sitemap;
	subSubMenuObj[z].navigationMenu = navigationMenu;
	z++;
}

//Add Object in Archives 
function addRelease(releTitle, chi_releTitle, releUrl)
{
	releaseObj[r] = new Object();
	releaseObj[r].reletitle = releTitle;
	releaseObj[r].chi_reletitle = chi_releTitle;
if (langID==1){
	releaseObj[r].releurl = releUrl;
}else{
	releaseObj[r].releurl = releUrl;
	releaseObj[r].releurl = "c"+releUrl.substring(1,releUrl.length);
}	
	r++;
}

//Add Object in Archives 
function addAccount(accTitle, chi_accTitle, accUrl)
{
	accountObj[s] = new Object();
	accountObj[s].acctitle = accTitle;
	accountObj[s].chi_acctitle = chi_accTitle;
if (langID==1){
	accountObj[s].accurl = accUrl;
}else{
	accountObj[s].accurl = accUrl;
	accountObj[s].accurl = "c"+accUrl.substring(1,accUrl.length);
}	
	s++;
}

//Add Object in Archives 
function addAnnual(annTitle, chi_annTitle, annUrl)
{
	annualObj[t] = new Object();
	annualObj[t].anntitle = annTitle;
	annualObj[t].chi_anntitle = chi_annTitle;
if (langID==1){
	annualObj[t].annurl = annUrl;
}else{
	annualObj[t].annurl = annUrl;
	annualObj[t].annurl = "c"+annUrl.substring(1,annUrl.length);
}	
	t++;
}

//Add Object in Archives 
function addAccu(accuTitle, chi_accuTitle, accuUrl)
{	
	accuObj[ac] = new Object();
	accuObj[ac].accutitle = accuTitle;
	accuObj[ac].chi_accutitle = chi_accuTitle;
if (langID==1){
	accuObj[ac].accuurl = accuUrl;
}else{
	accuObj[ac].accuurl = accuUrl;
	accuObj[ac].accuurl = "c"+accuUrl.substring(1,accuUrl.length);
}		
	ac++;

}

//Add Object in Archives 
function addEnvir(envirTitle, chi_envirTitle, envirUrl)
{
	envirObj[e] = new Object();
	envirObj[e].envirtitle = envirTitle;
	envirObj[e].chi_envirtitle = chi_envirTitle;
if (langID==1){
	envirObj[e].envirurl = envirUrl;
}else{
	envirObj[e].envirurl = envirUrl;
	envirObj[e].envirurl = "c"+envirUrl.substring(1,envirUrl.length);
}	
	e++;
}

//function for generating the top menu
function getTopMenu(){
 if (!printPage){

 	if(langID==1){
		var extarSpacer = '<td background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif" bgcolor="#FAFAEB"><img src="'+locationPath+'/common/images/spacer.gif" border="0" height="1" width="90" alt="" title=""></td>';
	}else{
		var extarSpacer = '<td background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif" bgcolor="#FAFAEB"><img src="'+locationPath+'/common/images/spacer.gif" border="0" height="1" width="100" alt="" title=""></td>';
	}

	if(location.href.toString().search('/gb/')!=-1 && navigator.appName=="Netscape" && navigator.appVersion.substring(0,1)!="5")
	extarSpacer = '<td background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif" bgcolor="#FAFAEB"><img src="'+locationPath+'/common/images/spacer.gif" border="0" height="1" width="104" alt="" title=""></td>';

//  Yahoo Search Form 
	var gicSearchForm;
	
	gicSearchForm='<form id="frmSearch" name="frmSearch" action="'+arClfTopMenu[langID][1]+'" method="get" onsubmit="if( document.frmSearch.query.value.length == 0 ) {alert(\''+arClfTopMenu[langID][25]+'\');}  else { document.frmSearch.submit();} return false;">\n';
	gicSearchForm=gicSearchForm+'<input type="hidden" name="tpl_id" value="try"> ';
	gicSearchForm=gicSearchForm+'<input type="hidden" name="gp0" value="try_home"> ';
	gicSearchForm=gicSearchForm+'<input type="hidden" name="gp1" value="try_home"> ';
	gicSearchForm=gicSearchForm+'<input type="hidden" name="web" value="this"> ';
	gicSearchForm=gicSearchForm+'<input type="hidden" name="ui_lang" value="' + arClfTopMenu[langID][23] + '"> ';
	gicSearchForm=gicSearchForm+'<input type="hidden" name="ui_charset" value="' + arClfTopMenu[langID][24] + '">  ';


	if(!isText){
	if(!isSearch)
		document.writeln('	<table border=0 cellspacing=0 cellpadding=0 width=770>');
		document.writeln('	<tr>');
		document.writeln('	<td colspan="2">');
		document.writeln('		<table width="680" border="0" cellpadding="0" cellspacing="0" background="'+locationPath+'/common/images/reddot.gif">');
		document.writeln(gicSearchForm);
		document.writeln('		<tr align="left" valign="top">');
		document.writeln('			<td colspan="7" class="sidebar" background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif" bgcolor="#FAFAEB"><a href="'+locationPath+'/index.html"><img src="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/branding.gif" border=0 title="'+arClfTopMenu[langID][3]+'"alt="'+arClfTopMenu[langID][3]+'"></a></td>');
		document.writeln('			<td background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif" colspan="4" valign="bottom" align=right bgcolor="#FAFAEB"><a href="'+arClfTopMenu[langID][5]+'" target="_top"><img name="BrandHK" src="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/brandhk.gif" border="0" title="'+arClfTopMenu[langID][6]+'" alt="'+arClfTopMenu[langID][6]+'"></a></td>');
		document.writeln('		</tr>');
		document.writeln('		<tr align="left" valign="top">');
		document.writeln('			<td valign="bottom" background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif"><a href="'+arClfTopMenu[langID][26]+'" onMouseOut="outTopMenu(\'mainbar1\')" onMouseOver="overTopMenu(\'mainbar1\')"><img name="mainbar1" src="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar1.gif" border="0" title="'+arClfTopMenu[langID][7]+'" alt="'+arClfTopMenu[langID][7]+'"></a></td>');
		document.writeln('			<td align="left" valign="bottom" background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif"><a href="javascript:changeLanguage(\''+arClfTopMenu[langID][9]+'\')" onMouseOut="outTopMenu(\'mainbar2\')" onMouseOver="overTopMenu(\'mainbar2\')"><img name="mainbar2" src="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar2.gif" border="0" title="'+arClfTopMenu[langID][10]+'" alt="'+arClfTopMenu[langID][10]+'"></a></td>');
		document.writeln('			<td align="left" valign="bottom" background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif"><a href="javascript:changeLanguage(\''+arClfTopMenu[langID][12]+'\')" onMouseOut="outTopMenu(\'mainbar3\')" onMouseOver="overTopMenu(\'mainbar3\')"><img name="mainbar3" src="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar3.gif" border="0" title="'+arClfTopMenu[langID][13]+'" alt="'+arClfTopMenu[langID][13]+'"></a></td>');
		document.writeln('			<td align="left" valign="bottom" background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif"><a href="javascript:changeLanguage(\''+arClfTopMenu[langID][15]+'\')" onMouseOut="outTopMenu(\'mainbar4\')" onMouseOver="overTopMenu(\'mainbar4\')"><img name="mainbar4" src="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar4.gif" border="0" title="'+arClfTopMenu[langID][16]+'" alt="'+arClfTopMenu[langID][16]+'"></a></td>');
		document.writeln('			<td align="left" valign="bottom" background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif"><img name="mainbar5" src="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar5.gif" border="0" alt="" title=""></td>');
		document.writeln(extarSpacer);
		document.writeln('			<td valign="bottom" background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif"><a href="javascript:document.frmSearch.submit();" onMouseOut="outTopMenu(\'mainbar6\')" onMouseOver="overTopMenu(\'mainbar6\')"><img name="mainbar6" src="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar6.gif" border="0" title="'+arClfTopMenu[langID][17]+'" alt="'+arClfTopMenu[langID][17]+'" onclick="if(document.frmSearch.query.value.length==0){alert(\''+arClfTopMenu[langID][25]+'\');return false;}else{document.frmSearch.submit();}" onkeypress="if(document.frmSearch.query.value.length==0){alert(\''+arClfTopMenu[langID][25]+'\');return false;}else{document.frmSearch.submit();}"></a></td>');
		document.writeln('			<td valign="bottom" background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif" align=center><input type="text" name="query" size="'+arClfTopMenu[langID][4]+'" class="search"></td>');
		document.writeln('			<td valign="bottom" background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif"><a href="javascript:document.frmSearch.submit();" onMouseOut="outTopMenu(\'mainbar8\')" onMouseOver="overTopMenu(\'mainbar8\')"><img name="mainbar8" src="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar8.gif" border="0" title="'+arClfTopMenu[langID][17]+'" alt="'+arClfTopMenu[langID][17]+'" onclick="if(document.frmSearch.query.value.length==0){alert(\''+arClfTopMenu[langID][25]+'\');return false;}else{document.frmSearch.submit();}" onkeypress="if(document.frmSearch.query.value.length==0){alert(\''+arClfTopMenu[langID][25]+'\');return false;}else{document.frmSearch.submit();}"></a></td>');
		document.writeln('			<td valign="bottom" background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif"><a href="'+chgUrlLang("ehsitemap.html")+'" onMouseOut="outTopMenu(\'mainbar9\')" onMouseOver="overTopMenu(\'mainbar9\')"><img name="mainbar9" src="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar9.gif" border="0" title="'+arClfTopMenu[langID][18]+'" alt="'+arClfTopMenu[langID][18]+'"></a></td>');
		document.writeln('			<td valign="bottom" background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif" bgcolor="#FAFAEB"><a href="'+chgUrlLang("ehcontact.html")+'" onMouseOut="outTopMenu(\'mainbar10\')" onMouseOver="overTopMenu(\'mainbar10\')"><img name="mainbar10" src="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar10.gif" border="0" title="'+arClfTopMenu[langID][19]+'" alt="'+arClfTopMenu[langID][19]+'"></a></td>');
		document.writeln('		</tr>');
		document.writeln('		<tr align="left" valign="top" bgcolor="#BB3333">');
		document.writeln('			<td colspan="11" height=2 width=100%><img src="'+locationPath+'/common/images/reddot.gif" border="0" alt="" title=""></td>');
		document.writeln('		</tr>');
		document.writeln('		</form>');
		document.writeln('		</table>');
		document.writeln('		</td>');
		document.writeln('	</tr>');
	if(!isSearch)
		document.writeln('	</table>');

	}else{
		//Text-only
		document.writeln('<table border=0 cellspacing=0 cellpadding=1 width=100%>');
		document.writeln(gicSearchForm);
		document.writeln('<input type="hidden" name="txtonly" value="1">');
		document.writeln('<tr valign=top>');
		document.writeln('	<td><p class="Title"><b>'+arClfTopMenu[langID][3]+'</b></p></td>');
		document.writeln('</tr>');
		document.writeln('<tr valign=middle>');
		document.writeln('	<td><br>[ <a href="'+arClfTopMenu[langID][26]+'" target="_blank">'+arClfTopMenu[langID][7]+'</a> ]&nbsp;&nbsp;');
		document.writeln('[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][22]+'\')">'+arClfTopMenu[langID][21]+'</a> ]&nbsp;&nbsp;');
		document.writeln('[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][12]+'\')">'+arClfTopMenu[langID][13]+'</a> ]&nbsp;&nbsp;');
		document.writeln('[ <a href="javascript:changeLanguage(\''+arClfTopMenu[langID][15]+'\')">'+arClfTopMenu[langID][16]+'</a> ]&nbsp;&nbsp;');
		document.writeln('[ <a href="javascript:document.frmSearch.submit();" onclick="if(document.frmSearch.query.value.length==0){alert(\''+arClfTopMenu[langID][25]+'\');return false;}else{document.frmSearch.submit();}" onkeypress="if(document.frmSearch.query.value.length==0){alert(\''+arClfTopMenu[langID][25]+'\');return false;}else{document.frmSearch.submit();}">'+arClfTopMenu[langID][17]+'</a> ]&nbsp;&nbsp;');
		document.writeln('<input type="text" name="query" size="'+arClfTopMenu[langID][4]+'">');
		document.writeln('[ <a href="'+chgUrlLang("ehsitemap.html")+'">'+arClfTopMenu[langID][18]+'</a> ]&nbsp;&nbsp;');
		document.writeln('[ <a href="'+chgUrlLang("ehcontact.html")+'">'+arClfTopMenu[langID][19]+'</a> ]</td>');
		document.writeln('</tr>');
		document.writeln('</form>');
		document.writeln('<tr valign=top>');
		document.writeln('	<td><hr width=100%></td>');
		document.writeln('</tr>');
		document.writeln('</table>');

	if(isText) getLeftMenu2();
	}
}
}

//Change url to sc version.
function gotoText(s,langNo){
	var currentPath=location.href.toString();
	currentPath=currentPath.replace(htmlurl, cgiPath+cgiName);
	if (langNo!=3){
		return currentPath;
	}else{
		currentPath=currentPath.replace('http://', gb_urlPath);
	}			
	return currentPath;
}

//Goto Gdns Program or get the url only
function gotoGdns(valueType){

var tmp_text="";
var tmp_url="";
if(isText)
tmp_text="&text=1";
if(langID==1)
tmp_url=gdnsProdUrl+"&"+tmp_text;
if(langID==2)
tmp_url=gdnsProdUrl+"&"+tmp_text;
if(langID==3)
tmp_url=gdnsProdUrl+"&"+tmp_text;

 return tmp_url;
}


//Switch language
function changeLanguage(switchLang){

	var currentPath=location.href.toString();
	var switchTc='/cinternet/';
	var switchEn='/internet/';
	var switchSc='/sc/';
	var switchText='/text';

 if(isGdns){
 	switch (switchLang){
		case '/graphics/':
		 if(isGB){
		   currentPath="ht"+"tp://"+gb_urlPath+gdnsProdDomain+switchSc+"c"+gdns_pl2;
		 	break;		 		
		}	
		   if(langID==1){
			    currentPath="ht"+"tp://"+gdnsProdDomain+switchEn+"e"+gdns_pl2;
			 	break;		 		
			}
		   if(langID==2){
			    currentPath="ht"+"tp://"+gdnsProdDomain+switchTc+"c"+gdns_pl2;
				break;		 		
			}					 

		case '/internet/':
		 if(isText)
		    currentPath="ht"+"tp://"+gdnsProdDomain+switchEn+"e"+gdns_pl2+"?text=1";
		 else
		    currentPath="ht"+"tp://"+gdnsProdDomain+switchEn+"e"+gdns_pl2;
		 break;

		case '/cinternet/':
		 if(isText)
		    currentPath="ht"+"tp://"+gdnsProdDomain+switchTc+"c"+gdns_pl2+"?text=1";
		 else
		    currentPath="ht"+"tp://"+gdnsProdDomain+switchTc+"c"+gdns_pl2;
		 break;

		case '/gb/':		 
		 if(isText)
			currentPath="ht"+"tp://"+gb_urlPath+gdnsProdDomain+switchSc+"c"+gdns_pl2+"?text=1";
		 else
		    currentPath="ht"+"tp://"+gb_urlPath+gdnsProdDomain+switchSc+"c"+gdns_pl2;
		 break;

		case '/text/':
		 if(isGB){
	       currentPath="ht"+"tp://"+gb_urlPath+gdnsProdDomain+switchSc+"c"+gdns_pl2+"?text=1";		   
		 }else{
		   if(langID==1)
			currentPath="ht"+"tp://"+gdnsProdDomain+switchEn+"e"+gdns_pl2+"?text=1";						
		   if(langID==2)
		    currentPath="ht"+"tp://"+gdnsProdDomain+switchTc+"c"+gdns_pl2+"?text=1";									
		 }
		 break;		 

		default:
		break;		
	}		

 }

if(isSearch){
	currentPath=location.href.toString();
	switch (switchLang){
		case '/internet/':
		    currentPath=currentPath.replace(gb_urlPath,"");					
		 if(isText)
		    currentPath=currentPath.replace("mode=260","mode=259")+"&text=1";			
		 else
	 	    currentPath=currentPath.replace("mode=260","mode=259");			
		 break;

		case '/cinternet/':
		    currentPath=currentPath.replace("sc.info.gov.hk/gb/","");					
		 if(isText)
		    currentPath=currentPath.replace("mode=259","mode=260")+"&text=1";			
		 else
	 	    currentPath=currentPath.replace("mode=259","mode=260");			
		 break;

		case '/gb/':		 
	 	    currentPath=currentPath.replace("mode=259","mode=260");			
		 if(isText)
		    currentPath=currentPath.replace("http://","http://"+gb_urlPath);
		 else
		    currentPath=currentPath.replace("http://","http://"+gb_urlPath);
		 break;

		case '/text/':
		if(langID==1)
			alert("Search function for text only version is not available");
		else
			alert("本網站並沒有提供純文字版本的搜尋功能");
		 break;		 

		default:
		break;		
	}		
} 

 if(!isGdns && !isSearch){  
 	switch (switchLang){
				case '/graphics/':
//		 if(isGB){
/*
			currentPath=currentPath.replace(cgiName+"/","");
			currentPath=currentPath.replace(cgiPath1,"");
			currentPath=currentPath.replace(cgiPath2,"");
			break;
*/
//		 }else{
//		 	var strTmp=currentPath.substring(0,currentPath.search("gov.hk/")+7);		
//			currentPath=currentPath.substring(currentPath.search("search=/")+8,currentPath.length);
			if(isProds){

			var tmp_prodUrl=clearLastWord(prodUrl);
				tmp_prodUrl=clearFirstWord(tmp_prodUrl);
				currentPath=currentPath.replace(clearFirstWord(textonlyUrl)+cgiPath+textOnly_pl,tmp_prodUrl);				
				currentPath=currentPath.replace("?search=","");				
//			     currentPath=currentPath.replace(clearFirstWord(prodUrl)+cgiPath+cgiName+"/",clearFirstWord(prodUrl));			
			}else{
				  if(isInternal){
					var tmp_Url=clearLastWord(test2Url);
						tmp_Url=clearFirstWord(tmp_Url);
						currentPath=currentPath.replace(clearFirstWord(textonlyUrl)+cgiPath+textOnly_pl,tmp_Url);				
						currentPath=currentPath.replace("?search=","");								  
//					  currentPath=currentPath.replace(clearFirstWord(textonlyUrl)+cgiPath+cgiName+"/",clearFirstWord(test2Url));			
				  }else{
					var tmp_Url=clearLastWord(testUrl);
						tmp_Url=clearFirstWord(tmp_Url);
						currentPath=currentPath.replace(clearFirstWord(textonlyUrl)+cgiPath+textOnly_pl,tmp_Url);				
						currentPath=currentPath.replace("?search=","");								  				  
//					  currentPath=currentPath.replace(clearFirstWord(textonlyUrl)+cgiPath+cgiName+"/",clearFirstWord(testUrl));			
				  }
			}
//		 }			
			break;
		case '/text/':
			if(isProds){
			  currentPath=currentPath.replace(clearFirstWord(prodUrl), clearFirstWord(prodUrl)+cgiPath+cgiName+"/");			
			  }else{
				  if(isInternal)
					  currentPath=currentPath.replace(clearFirstWord(test2Url), clearFirstWord(textonlyUrl)+cgiPath+cgiName+"/");
				  else
					  currentPath=currentPath.replace(clearFirstWord(testUrl), clearFirstWord(textonlyUrl)+cgiPath+cgiName+"/");
			  }
			  currentPath=currentPath.replace(switchEn, switchEn);
			  currentPath=currentPath.replace(switchTc, switchTc);

			break;
		case '/gb/':
			currentPath=currentPath.replace(switchTc, switchSc);
			currentPath=currentPath.replace(switchEn, switchSc);
			currentPath=currentPath.replace("/eh", "/ch");
			break;
		case '/internet/':
			currentPath=currentPath.replace(switchTc, switchEn);
			currentPath=currentPath.replace(switchSc, switchEn);
			currentPath=currentPath.replace("internet/ch", "internet/eh");
			currentPath=currentPath.replace(gb_urlPath, "");
			break;
		case '/cinternet/':
			currentPath=currentPath.replace(switchEn, switchTc);
			currentPath=currentPath.replace(switchSc, switchTc);
			currentPath=currentPath.replace("internet/eh", "internet/ch");			
			currentPath=currentPath.replace(gb_urlPath, "");
			break;

		default:
	}
 }	
// added to overcome IE issue when handling currentPath with "#" sign
// currently handles #top and url ended with #
	currentPath = currentPath.replace("#top", "");
	currentPath = currentPath.replace(/\#$/, "");
// end - added by ac (jul22, 2010)

	document.location=currentPath;
}


//Get Image Caption in menu
function getCaption(menu, i){
	var showAlt;

	if(i==1 && menu=="menuObj"){
		if(langID==1)
			showAlt="Home";
		else
			if((document.URL.toString().search('/sc/') != -1)||isGB)
			showAlt="主页";
			else
			showAlt="主頁";
	}else{	
		if(langID==1)
			eval('showAlt='+menu+'['+i+'].caption');
		else
			eval('showAlt='+menu+'['+i+'].chiCaption');
	}

	return showAlt;
}

//Get Left Menu
function getLeftMenu(){
if(!isText) getLeftMenu2();
}

//Get Left Menu
function getLeftMenu2(){
if(!printPage){ 
	if(!isText){
		//document.writeln('<td rowspan=4 width=164 background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/nav_bg.gif">');
		
		document.writeln('<td width=164 background="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/nav_bg.gif">');
		document.writeln('	<table border=0 cellspacing=0 cellpadding=0 bgcolor=white>');
		document.writeln('	<tr valign=top>');
		document.writeln('		<td><img src="'+locationPath+'/common/images/en/topbanner_01.gif" border=0 align=top  title="'+arClfTopMenu[langID][3]+'" alt="'+arClfTopMenu[langID][3]+'"></td>');
		document.writeln('	</tr>');
		for(var i=1;i<x;i++){
			if(menuObj[i]){
				if(menuObj[i].navigationMenu=="Y"){
					if (Selected_ID==menuObj[i].id){
						var pic = menuObj[i].onPic;
					}else{
						var pic = menuObj[i].offPic;
					}
					var outAction = "onMouseOut=\"MM_showHideLayers(\'Layer"+i+"\',\'\',\'hide\',0);simg(pic"+i+", '"+pic+"',0);\"";
					var overAction = " onMouseOver=\"MM_showHideLayers(\'Layer"+i+"\',\'\',\'show\',0);simg(pic"+i+", '"+menuObj[i].onPic+"',1);\" ";
					
					if (i==1)
					document.writeln("<tr><td><a href='"+menuObj[i].url+"' "+ outAction + " " + overAction + "><img name='pic"+i+"' id='pic"+i+"' src='" + pic +  "' title=\""+getCaption('menuObj', i)+"\" alt=\""+getCaption('menuObj', i)+"\" border=0></a></td></tr>");
					else					
					document.writeln("<tr><td><a href='"+menuObj[i].url+"' "+ outAction + " " + overAction + "><img name='pic"+i+"' id='pic"+i+"' src='" + pic +  "' title=\""+getCaption('menuObj', i)+"\" alt=\""+getCaption('menuObj', i)+"\" border=0></a></td></tr>");
									
					if (menuObj[i].id ==Selected_ID){
//						getSubMenu();
					}
				}
			}
		}

		getLowerLeftLinks();

		document.write('<tr><TD><img src="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/nav_bottom.gif" border="0" alt="" title="" ></td></tr>');
		
		document.writeln('	</table>');
		document.writeln('</td>');
	}else{

		document.writeln('<table border=0 cellspacing=0 cellpadding=1 width=100%><tr><td>');
		for(var i=1;i<x;i++){
			if(menuObj[i]){
				if(menuObj[i].navigationMenu=="Y"){
					if(menuObj[i].id!=Selected_ID){
						if (menuObj[i].caption!=""){
						document.writeln("[ <a href='"+menuObj[i].url+"'>"+getCaption('menuObj', i)+"</a> ]&nbsp;&nbsp;");
						}else{
								 if(menuObj[i].url!="" && menuObj[i].caption!=""){
								  document.writeln("[ <a href='"+menuObj[i].url+"'>"+getCaption('menuObj', i)+"</a> ]&nbsp;&nbsp;");
								 }else{
								  if(langID==1)
								   document.writeln("[ <a href='"+textonlyUrl+cgiPath+cgiName+"/internet/ehhome.html'>Home</a> ]&nbsp;&nbsp;");
								  else
								  if((document.URL.toString().search('/sc/') != -1)||isGB)
								   document.writeln("[ <a href='"+textonlyUrl+cgiPath+cgiName+"/sc/chhome.html'>主页</a> ]&nbsp;&nbsp;");
								   else
								   document.writeln("[ <a href='"+textonlyUrl+cgiPath+cgiName+"/cinternet/chhome.html'>主頁</a> ]&nbsp;&nbsp;");
								 }
						}
					}else{
						if (menuObj[i].caption!=""){
						document.writeln("[ <b><a href='"+menuObj[i].url+"'>"+getCaption('menuObj', i)+"</a></b> ]&nbsp;&nbsp;");
						}else{
								 if(menuObj[i].url!="" && menuObj[i].caption!=""){
								  document.writeln("[ <b><a href='"+menuObj[i].url+"'>"+getCaption('menuObj', i)+"</b></a> ]&nbsp;&nbsp;");
								 }else{
								  if(langID==1)
								   document.writeln("[ <b><a href='"+textonlyUrl+cgiPath+cgiName+"/internet/ehhome.html'>Home</a></b> ]&nbsp;&nbsp;");
								  else
								  if((document.URL.toString().search('/sc/') != -1)||isGB)
								   document.writeln("[ <b><a href='"+textonlyUrl+cgiPath+cgiName+"/sc/chhome.html'>主页</a></b> ]&nbsp;&nbsp;");
								   else
								   document.writeln("[ <b><a href='"+textonlyUrl+cgiPath+cgiName+"/cinternet/chhome.html'>主頁</a></b> ]&nbsp;&nbsp;");
								 }						
						}
					}
				}
			}
		}
		document.writeln('</td></tr>');
		document.writeln('<tr valign=top>');
		document.writeln('	<td><hr width=100%></td>');
		document.writeln('</tr>');
		getSubMenu();
		document.writeln('</table>');

		
	}
}

}

//Get Sub Menu in Text-only ver.
function getSubMenu(){
	if(isText==1){
		var str_subSubMenu="";	
		var str_subSubMenu_url="";
		var str_subMenu="";			
		var nextLine=0;

		for(var i=1;i<y;i++){
			if (subMenuObj[i] && subMenuObj[i].url.search("gotoGdns")==-1){
				if (subMenuObj[i].menuID==Selected_ID){
					if(nextLine==0){
						document.writeln('<tr>');
						document.writeln('	<td>');
					}
					nextLine++;
					
					 for (var j=1;j<subSubMenuObj.length;j++){
					  if(subSubMenuObj[j].menuID==Selected_ID && subSubMenuObj[j].subSectionID==Selected_Sub && subSubMenuObj[j].id==Selected_SubSub)
			 		   str_subSubMenu=getCaption('subSubMenuObj',j) +"";
					   str_subMenu="<a href='"+subMenuObj[i].url+"'>"+getCaption('subMenuObj', i)+"</a>";
					 if(str_subSubMenu!="" && subSubMenuObj[j].menuID==Selected_ID && subSubMenuObj[j].subSectionID==Selected_Sub && subSubMenuObj[j].id==Selected_SubSub){
					   str_subSubMenu_url=subSubMenuObj[j].url;
					   str_subMenu=""+str_subMenu+"</a>";					   					 					   
					  }
					}
				      str_subMenu="[ "+str_subMenu+" ]&nbsp;&nbsp;";					   					 					
					  document.writeln(str_subMenu);		
				}
			}
		}

		if(str_subSubMenu==exLevel)
		  exLevel=""; 		

		if(nextLine!=0){
		 document.writeln('	</td>');
		 document.writeln('</tr>');
		 document.writeln('<tr valign=top>');
//		  document.writeln('	<td><hr width=100%>AA'+exLevel+'</td>');
		 document.writeln('</tr>');
		 if(str_subSubMenu!=""){
			  if(exLevel!=""){			  
			   document.writeln("<tr><td><hr width=100%>[ <b><a href='"+str_subSubMenu_url+"'>"+str_subSubMenu+"</a></b> ]</td></tr>");
			  }else{
			   document.writeln("<tr><td><hr width=100%>[ "+str_subSubMenu+" ]</td></tr>");
			   }
		  document.writeln('<tr valign=top>');
		  document.writeln('	<td><hr width=100%>'+exLevel+'</td>');
		  document.writeln('</tr>');		  
		 }else{
			document.writeln("<tr><td><hr width=100%></td></tr>");
		 }
		}
   }		
}

//Get Header Graphics
function getTopic(){
	if(Selected_ID<10)
		var titleNum="0"+Selected_ID;
	else
		var titleNum=Selected_ID;

	if(isText!=1){		
		document.writeln('<img src="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/hd/hd_'+titleNum+'.gif" border=0 align=top title="'+getCaption('menuObj', Selected_ID)+'" alt="'+getCaption('menuObj', Selected_ID)+'">');
	}else{
		document.writeln('<p class="Title"><b>'+getCaption('menuObj', Selected_ID)+'</b>');
	}
}

//Var to set layer position
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 initPrint(){
}

//Run When document start
function init(){
	if (printPage){
		window.print();
	}else{
		if(printPage){
			 window.print();
		}else{
			 if (!isText){
			    setTopLayerPosition(true);
			    setLayerPosition();
			 }
		}
	}
}

//function for setting the top button
function setTopLayerPosition(resizeFlag){
	if(topButton=='Y'){
		if (document.all && document.all["footer_layer"]!=null)
		{
			moveTopDivs(document.all["footer_layer"].style, getDim(document.images.backtotopspacer).y-10, getDim(document.images.backtotopspacer).x-12)
			if (getDim(document.images.backtotopspacer).y > footerY)
			{
				if (resizeFlag)
				{document.all["footer_layer"].style.visibility = "visible"}
			}
		}
		if (document.layers && document.layers["footer_layer"])
		{
			moveTopDivs(document.layers["footer_layer"], document.images["backtotopspacer"].y-10, document.images["backtotopspacer"].x-12);
			if (document.images["backtotopspacer"].y > footerY)
			{
				if (resizeFlag)
				{document.layers["footer_layer"].visibility = "show"}
			}
		}
		if (!document.all && document.getElementById && document.getElementById("footer_layer")!=null)
		{
			moveTopDivs(document.getElementById("footer_layer").style, document.images["backtotopspacer"].y-10, document.images["backtotopspacer"].x-12);
			if (document.images["backtotopspacer"].y > footerY)
			{
				if (resizeFlag)
				{document.getElementById("footer_layer").style.visibility = "visible"}
			}
		}
	}
}

onresize=setTopLayerPosition;

//function for generating the layer for top button
function genfooterLayer(){
	var altText='Top';
	
	if((document.URL.toString().search('/sc/') != -1)||isGB)
	{
		if(langID!=1) altText='页首';
	}
	else
	{
		if(langID!=1) altText='頁首';
	}
	
	if (document.layers)
		{document.writeln('<layer name=footer_layer top=0 left=0 width=26 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="60%" border="0" cellspacing="0" cellpadding="0">');
	document.writeln('<tr valign=top>');
	if (navigator.appName=="Netscape" && navigator.appVersion.substring(0,1)!="4")
	 var topLink="#";	 
	else
	 var topLink="#top";	 
	document.writeln('	<td><a href="'+topLink+'"><img src="'+locationPath+'/common/images/'+tmpImgPath[langID]+'/btn_top.gif" title="'+altText+'" alt="'+altText+'" border="0" name="backtotopfoot"></a></p></td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	if (document.layers)
		{document.writeln('</layer>');}
	else
		{document.writeln('</div>');}			
}

//function for generating the footer
function getFooter(){
 if (!printPage){		
	var altText='Top';
	var altBack='Back';
	
	if((document.URL.toString().search('/sc/') != -1)||isGB)
	{
		if(langID!=1) altText='页首';
		if(langID!=1) altBack='回上页';
	}
	else
	{
		if(langID!=1) altText='頁首';
		if(langID!=1) altBack='回上頁';
	}
	
	var copyYear='2004';
	var noticesLink=chgUrlLang("ehimportant.html");
	var noticeText='Important notices';
	var privacyLink=chgUrlLang("ehprivacy.html");
	var privacyText='Privacy policy';
	var revisionText='Last revision date: ';	
	
	switch (revisionDateType){
		case 0:
			if (revisionDate==''||revisionDate=='MM/DD/YYYY') revisionDate=revisionDateGlobal;
			break;
		case 1:
			revisionDate=revisionDateGlobal;
			break;
		case 2:
			if (revisionDate==''||revisionDate=='MM/DD/YYYY') {
				revisionDate=revisionDateGlobal;
			}else{
				revisionDate=getLatestDate(revisionDate, revisionDateGlobal);
			}
			
			break;
		default:
			if (revisionDate==''||revisionDate=='MM/DD/YYYY') revisionDate=revisionDateGlobal;
			break;
	}
	
	if((document.URL.toString().search('/sc/') != -1)||isGB)
	{
		if (langID==2){
			noticeText='重要告示';
			privacyText='私隐政策';
			revisionText='修订日期： ';	
		}
			if(langID==1)
			 var tmp_copy_text="Copyright";		
			else
			 var tmp_copy_text="版权所有";
	}
	else
	{
		if (langID==2){
			noticeText='重要告示';
			privacyText='私隱政策';
			revisionText='修訂日期： ';	
		}
			if(langID==1)
			 var tmp_copy_text="Copyright";		
			else
			 var tmp_copy_text="版權所有";
	}
		 
	var monthArray=new Array();
	monthArray[0]='January';
	monthArray[1]='February';
	monthArray[2]='March';
	monthArray[3]='April';
	monthArray[4]='May';
	monthArray[5]='June';
	monthArray[6]='July';
	monthArray[7]='August';
	monthArray[8]='September';
	monthArray[9]='October';
	monthArray[10]='November';
	monthArray[11]='December';
	var reDate=new Date(Date.parse(revisionDate))
	var showDate=reDate.getDate()+' '+monthArray[reDate.getMonth()]+' '+reDate.getFullYear();
	if (langID==2) 
	{
		if((document.URL.toString().search('/sc/') != -1)||isGB)
		{
			showDate=reDate.getFullYear()+'年'+(reDate.getMonth()+1)+'月'+reDate.getDate()+'日';
		}
		else {
			showDate=reDate.getFullYear()+'年'+(reDate.getMonth()+1)+'月'+reDate.getDate()+'日';
		}
	}
	//generate the topic image to the buffer variable
	if(!isText){
		document.writeln('<table border=0 cellpadding=0 cellspacing=0><tr><td><img src="'+locationPath+'/common/images/spacer.gif" border="0" alt="" title=""></td></tr></table>');		
		document.writeln('<p>');
		document.writeln('<table border=0 cellspacing=0 cellpadding=1 width=100%>');
		if(topButton=='Y')
			document.writeln('	<tr valign=top><td colspan=2 align=right><img src="'+locationPath+'/common/images/spacer.gif" name="backtotopspacer" width="55" height="20" alt="" title=""></td></tr>');
		document.writeln('	<tr>');
		document.writeln('		<td><img src="'+locationPath+'/common/images/spacer.gif" border="0" width="5" height="1" alt="" title=""></td>');
		document.writeln('		<td valign="top" align="center"> ');
		document.writeln('		<table width="570" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('		<tr bgcolor="#FFFFFF">');
		document.writeln('			<td colspan="2"><img src="'+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/botdot.jpg" width="585" height="3" border="0" alt="" title=""></td>');
		document.writeln('		</tr>');
		document.writeln('		<tr bgcolor="#FFFFFF">');
		document.writeln('			<td height="15" bgcolor="#FFFFFF" class="footer"><b>'+copyYear+'</b> <img src="'+locationPath+'/common/images/copy.gif" width="12" height="11" border="0" alt="'+tmp_copy_text+'" title="'+tmp_copy_text+'"> | <b><a href="'+noticesLink+'" class="footer">'+noticeText+'</a></b> | <b><a href="'+privacyLink+'" class="footer">'+privacyText+'</a></b></td>');
		document.writeln('			<td height="15" align="right" bgcolor="#FFFFFF" class="footer">'+revisionText+showDate+'</td>');
		document.writeln('		</tr>');
		document.writeln('		</table>');
		document.writeln('		</td>');
		document.writeln('	</tr>');
		document.writeln('</table><br>');

	
	}else{
		document.writeln('<table border=0 cellspacing=0 cellpadding=1 width=600>');
		document.writeln('<tr valign=top>');
		document.writeln('	<td colspan=2><hr ></td>');
		document.writeln('</tr>');
		document.writeln('<tr valign=top>');
		document.writeln('	<td>[ <a href="#">'+altText+'</a> ]</td>');
		document.writeln('</tr>');
		document.writeln('<tr valign=top>');
		document.writeln('	<td colspan=2><hr ></td>');
		document.writeln('</tr>');
		document.writeln('<tr>');
		document.writeln('	<td class="footer"><b>'+copyYear+'</b> '+tmp_copy_text+'  | <b><a href="'+noticesLink+'" class="footer">'+noticeText+'</a></b>  | <b><a href="'+privacyLink+'" class="footer">'+privacyText+'</a></b></td>');
		document.writeln('	<td align="right" class="footer">'+revisionText+showDate+'</td>');
		document.writeln('</tr>');
		document.writeln('</table>');
	}
 }
}

//Get sitemap
function getSiteMap(){
var strSiteMap="";
var bullet_alt="";
var tmp_bullet;

if(!isText){
 bullet_alt=" alt=* title=* ";
 tmp_bullet1='<img src='+locationPath+'/common/images/bullet1.gif'+bullet_alt+'>';
 tmp_bullet2='<img src='+locationPath+'/common/images/bullet2.gif'+bullet_alt+'>';
 tmp_bullet3='<img src='+locationPath+'/common/images/bullet3.gif'+bullet_alt+'>';
} else{
 tmp_bullet1='*';
 tmp_bullet2='*';
 tmp_bullet3='*';
}
 
	strSiteMap='<table border=0 cellpadding=2 cellspacing=2 width=500>';
	if (langID==1)
     strSiteMap=strSiteMap+'	<tr><td valign=top>'+tmp_bullet1+'</td><td colspan=3><a href="'+chgUrlLang("ehhome.html")+'" class=text_link>Home</a></td></tr>';
	else
	if((document.URL.toString().search('/sc/') != -1)||isGB)
     strSiteMap=strSiteMap+'	<tr><td valign=top>'+tmp_bullet1+'</td><td colspan=3><a href="'+chgUrlLang("ehhome.html")+'" class=text_link>主页</a></td></tr>';
	 else
     strSiteMap=strSiteMap+'	<tr><td valign=top>'+tmp_bullet1+'</td><td colspan=3><a href="'+chgUrlLang("ehhome.html")+'" class=text_link>主頁</a></td></tr>';
	
	for(var i=2;i<x;i++){
		if(menuObj[i]){
			if(menuObj[i].sitemap=="Y"){
				strSiteMap=strSiteMap+'	<tr><td valign=top>'+tmp_bullet1+'</td><td colspan=3><a href="'+menuObj[i].url+'" class=text_link>'+getCaption('menuObj', i)+'</a></td></tr>';
				if(menuObj[i].hasChild=="Y" || i>0){
					strSiteMap=strSiteMap+'	';
					for(var j=1;j<y;j++){
						if (subMenuObj[j].menuID==i && subMenuObj[j].sitemap=="Y"){
							strSiteMap=strSiteMap+'	<tr><td>&nbsp;</td><td valign=top>'+tmp_bullet2+'</td><td colspan=2><a href="'+subMenuObj[j].url+'" class=text_link>'+getCaption('subMenuObj', j)+'</a>';
							 if(subSubMenuObj){
							  for(var subi=1;subi<subSubMenuObj.length;subi++){
							   if (subSubMenuObj[subi].subSectionID==subMenuObj[j].id && subSubMenuObj[subi].menuID==subMenuObj[j].menuID){
								if(subSubMenuObj[subi].sitemap=="Y")
							    strSiteMap=strSiteMap+'	<tr><td colspan=2>&nbsp;</td><td valign=top>'+tmp_bullet3+'</td><td width=100%><a href="'+subSubMenuObj[subi].url+'" class=text_link>'+getCaption('subSubMenuObj', subi)+'</a></td></tr>';
							   }
							  }
							 }
						}
					}					
				}else{
				strSiteMap=strSiteMap+'</td></tr>';
				}
			}
		}
	}
	if (langID==1){
	 strSiteMap=strSiteMap+'	<tr><td valign=top>'+tmp_bullet1+'</td><td colspan=3><a href="'+chgUrlLang("ehimportant.html")+'" class=text_link>Important Notices</a></td></tr>';
	 strSiteMap=strSiteMap+'	<tr><td valign=top>'+tmp_bullet1+'</td><td colspan=3><a href="'+chgUrlLang("ehprivacy.html")+'" class=text_link>Privacy Policy</a></td></tr>';
	 }else{
	if((document.URL.toString().search('/sc/') != -1)||isGB) {
	 strSiteMap=strSiteMap+'	<tr><td valign=top>'+tmp_bullet1+'</td><td colspan=3><a href="'+chgUrlLang("ehimportant.html")+'" class=text_link>重要告示</a></td></tr>';
	 strSiteMap=strSiteMap+'	<tr><td valign=top>'+tmp_bullet1+'</td><td colspan=3><a href="'+chgUrlLang("ehprivacy.html")+'" class=text_link>私隐政策</a></td></tr>';
	} else {
	 strSiteMap=strSiteMap+'	<tr><td valign=top>'+tmp_bullet1+'</td><td colspan=3><a href="'+chgUrlLang("ehimportant.html")+'" class=text_link>重要告示</a></td></tr>';
	 strSiteMap=strSiteMap+'	<tr><td valign=top>'+tmp_bullet1+'</td><td colspan=3><a href="'+chgUrlLang("ehprivacy.html")+'" class=text_link>私隱政策</a></td></tr>';
	}
	 }
	strSiteMap=strSiteMap+'</table>';

if(isText){
var bullet_lang="e";
 if(langID!=1)
  bullet_lang="c";

strBullet="<img src=bullet1.gif>";
strBullet2="<img src=bullet2.gif>";
strBullet3="<img src=bullet3.gif>";

while(strSiteMap.search(strBullet)!=-1 || strSiteMap.search(strBullet2)!=-1 ||  strSiteMap.search(strBullet3)!=-1){
 strSiteMap=strSiteMap.replace(strBullet,"<li>"); 
 strSiteMap=strSiteMap.replace(strBullet2,"<li>");
 strSiteMap=strSiteMap.replace(strBullet3,"<li>");
}  
}
 
 document.writeln(strSiteMap);
}


//Get styleSheet
function styleSheet(){

styleType="style";
var cssTmp="";

if (langID==2)
 styleType=styleType+"_tc";
	if (isNS4) {
		styleType=styleType+"_nt";
		cssTmp='<link href="'+locationPath+'/common/css/'+styleType+'.css" rel="STYLESHEET" type="text/css">';
	}else{
		cssTmp='<link href="'+locationPath+'/common/css/'+styleType+'.css" rel="STYLESHEET" type="text/css">';
	}

if(!isText)
document.writeln(cssTmp);
	
}

function getPath2Title(){
var section_flag=true;
var i=2;
var strBuffer="";
var caption="";

if (langID==1){
 caption="caption";
 rootCaption="Home";
}else{
 caption="chiCaption";
 if((document.URL.toString().search('/sc/') != -1)||isGB)
 rootCaption="主页";
 else
 rootCaption="主頁";
}


var sectionVer= Array();
sectionVer[0]=0;
sectionVer[1]=0;
sectionVer[2]=0;

var sectionName= Array();
sectionName[0]="SectionID";
sectionName[1]="SectionID";
sectionName[2]="subSectionID";


if (Selected_ID!=null) 
sectionVer[0]=Selected_ID;
if (Selected_Sub!=null) 
sectionVer[1]=Selected_Sub;
if (Selected_SubSub!=null) 
sectionVer[2]=Selected_SubSub;


var sectionObj= Array();
sectionObj[0]="menuObj";
sectionObj[1]="subMenuObj";
sectionObj[2]="subSubMenuObj";



if (exLevel!="")
strBuffer=exLevel;

for (j=2;j>=0;j--){
	objLen=eval(sectionObj[j]+".length");
	for (i=1;i<objLen;i++){

	 section_flag=false;
     if (j==2){
	  if (eval(sectionObj[j]+"["+i+"].menuID")==Selected_ID && eval(sectionObj[j]+"["+i+"].subSectionID")==Selected_Sub && eval(sectionObj[j]+"["+i+"].id")==Selected_SubSub)
	   section_flag=true;
	 }
     if (j==1){
	  if (eval(sectionObj[j]+"["+i+"].menuID")==Selected_ID && eval(sectionObj[j]+"["+i+"].id")==Selected_Sub)
	   section_flag=true;
	 }
     if (j==0){
	  if (eval(sectionObj[j]+"["+i+"].id")==Selected_ID)
	   section_flag=true;
	 }
	 
	 if (section_flag){
	  if (strBuffer!=""){
	   strBuffer=eval(sectionObj[j]+"["+i+"]."+caption) +" - " +strBuffer;
	  }else{
	   strBuffer=eval(sectionObj[j]+"["+i+"]."+caption) +strBuffer;
	  } 
	 }  
	}
}

if (strBuffer=="")
strBuffer=rootCaption;
else
strBuffer=rootCaption+" - "+strBuffer;

return strBuffer

}

//Get Section Path
function getPath(exPath){
setSubPic(Selected_ID,Selected_Sub);

var section_flag=true;
var i=2;
var strBuffer="";
var caption="";

if (langID==1){
 caption="caption";
 rootCaption="Home";
}else{
 caption="chiCaption";
 if((document.URL.toString().search('/sc/') != -1)||isGB)
 rootCaption="主页";
 else
 rootCaption="主頁";
}


var sectionVer= Array();
sectionVer[0]=0;
sectionVer[1]=0;
sectionVer[2]=0;

var sectionName= Array();
sectionName[0]="SectionID";
sectionName[1]="SectionID";
sectionName[2]="subSectionID";


if (Selected_ID!=null) 
sectionVer[0]=Selected_ID;
if (Selected_Sub!=null) 
sectionVer[1]=Selected_Sub;
if (Selected_SubSub!=null) 
sectionVer[2]=Selected_SubSub;


var sectionObj= Array();
sectionObj[0]="menuObj";
sectionObj[1]="subMenuObj";
sectionObj[2]="subSubMenuObj";



if (exLevel!="")
strBuffer=exLevel;

for (j=2;j>=0;j--){
	objLen=eval(sectionObj[j]+".length");
	for (i=1;i<objLen;i++){

	 section_flag=false;
     if (j==2){
	  if (eval(sectionObj[j]+"["+i+"].menuID")==Selected_ID && eval(sectionObj[j]+"["+i+"].subSectionID")==Selected_Sub && eval(sectionObj[j]+"["+i+"].id")==Selected_SubSub)
	   section_flag=true;
	 }
     if (j==1){
	  if (eval(sectionObj[j]+"["+i+"].menuID")==Selected_ID && eval(sectionObj[j]+"["+i+"].id")==Selected_Sub)
	   section_flag=true;
	 }
     if (j==0){
	  if (eval(sectionObj[j]+"["+i+"].id")==Selected_ID)
	   section_flag=true;
	 }
	 
	 if (section_flag){
	  if (strBuffer!=""){
	   strBuffer="<a href='"+eval(sectionObj[j]+"["+i+"].url")+"' class='pathlink'>"+eval(sectionObj[j]+"["+i+"]."+caption) +"</a> > " +strBuffer;
	  }else{
	   strBuffer=eval(sectionObj[j]+"["+i+"]."+caption) +strBuffer;
	  } 
	 }  
	}
}

if (strBuffer=="")
strBuffer="<a href='"+chgUrlLang("ehhome.html")+"' class='pathlink'>"+rootCaption+"</a>";
else
strBuffer="<a href='"+chgUrlLang("ehhome.html")+"' class='pathlink'>"+rootCaption+"</a> > "+strBuffer;


	//graphic version only
	if(!isText){
		document.writeln('<table border=0 cellpadding=0 width=580 cellspacing=0 background="'+locationPath+'/common/images/spacer.gif">');
		document.writeln('<tr valign=top>');
	    document.writeln('<td width=1><img src="'+locationPath+'/common/images/spacer.gif" height="1" border="0" alt="" title=""></td>'+'<td class="path" width=96%>');		   
		document.writeln(strBuffer+'</td>');
		document.writeln('</tr>');
		document.writeln('<tr><td colspan=2><img src="'+locationPath+'/common/images/spacer.gif" width="1" height="10" border="0" alt="" title=""></td></tr>');
		document.writeln('</table>');
	}
}



//Create sub Menu Layer
function loadLeftLayer(){
if(!printPage){
	y=160;
	for (i=1;i<=13;i++){
		if (document.layers){
			document.writeln('<layer name="Layer'+i+'" top=212 left=540 width=158 height=1 visibility="hide" onMouseOver="simg(\'pic'+i+'\',\''+menuObj[i].onPic+'\',1); MM_showHideLayers(\'Layer'+i+'\',\'\',\'show\',0);" onMouseOut="changeLayerPic(\'pic'+i+'\',\''+menuObj[i].offPic+'\',1);MM_showHideLayers(\'Layer'+i+'\',\'\',\'hide\',0);">');
		}else{
			 if (navigator.appName == "Netscape" && navigator.appVersion.substring(0,1)=="5"){
				if(langID==2 && i>=5) layerPosArray[i]=layerPosArray[i]-10;
				y=layerPosArray[i];
				document.writeln('<div id="Layer'+i+'" style="position:absolute; z-index:1; left: 165; top: '+ y +'px; width: 158; visibility: hidden" onMouseOver="changeLayerPic(\'pic'+i+'\',\''+menuObj[i].onPic+'\',1); MM_showHideLayers(\'Layer'+i+'\',\'\',\'show\',0)" onMouseOut="changeLayerPic(\'pic'+i+'\',\''+menuObj[i].offPic+'\',1);MM_showHideLayers(\'Layer'+i+'\',\'\',\'hide\',0)">');
			 }else{
				document.writeln('<div id="Layer'+i+'" style="position:absolute; z-index:1; left: 165; top: 266px; width: 158; visibility: hidden" onMouseOver="changeLayerPic(\'pic'+i+'\',\''+menuObj[i].onPic+'\',1); MM_showHideLayers(\'Layer'+i+'\',\'\',\'show\',0)" onMouseOut="changeLayerPic(\'pic'+i+'\',\''+menuObj[i].offPic+'\',1);MM_showHideLayers(\'Layer'+i+'\',\'\',\'hide\',0)">');
			 }
		}

		document.writeln("<table border=0 cellpadding=0 cellspacing=0>");
		if (subMenuObj){	
			var c=subMenuObj.length;
			for (j=1;j<c;j++){
				if (subMenuObj[j].menuID==i && subMenuObj[j].navigationMenu=="Y"){
					document.write("<Tr><TD>");
					var omv;
					if (i>9){
						omv=" onMouseOver=\"changeLayerPicPi("+i+");changeLayerPic('subpic_"+i+"_"+j+"','"+locationPath+"/common/images/"+ getImagePath(tmpImgPath[langID]) +"/menu/nav_"+i+"_0"+subMenuObj[j].id+"_on.gif" +"',i);\"";
						omv=omv+" onMouseOut=\"changeLayerPic('subpic_"+i+"_"+j+"','"+locationPath+"/common/images/"+ getImagePath(tmpImgPath[langID]) +"/menu/nav_"+i+"_0"+subMenuObj[j].id+".gif" +"',"+i+","+subMenuObj[j].id+");\"";
						document.write("<a href="+subMenuObj[j].url+" "+omv+"><img name=subpic_" +i+"_"+j+ " src="+locationPath+"/common/images/"+ getImagePath(tmpImgPath[langID]) +"/menu/nav_"+i+"_0"+subMenuObj[j].id+getSubPic(subMenuObj[j].menuID,subMenuObj[j].id)+".gif border=0 title='"+ chgCaptionLang("subMenuObj["+j+"].caption") +"' alt='"+ chgCaptionLang("subMenuObj["+j+"].caption") +"'></a>");
					}else{
						omv=" onMouseOver=\"changeLayerPicPi("+i+");changeLayerPic('subpic_"+i+"_"+j+"','"+ locationPath+"/common/images/"+ getImagePath(tmpImgPath[langID]) +"/menu/nav_0"+i+"_0"+subMenuObj[j].id+"_on.gif" +"',i);\"";
						omv=omv+" onMouseOut=\"changeLayerPic('subpic_"+i+"_"+j+"','"+ locationPath+"/common/images/"+ getImagePath(tmpImgPath[langID]) +"/menu/nav_0"+i+"_0"+subMenuObj[j].id+".gif" +"',"+i+","+subMenuObj[j].id+");\"";
						document.write("<a href="+subMenuObj[j].url+" "+omv+"><img name=subpic_" +i+"_"+j+ " src="+locationPath+"/common/images/"+ getImagePath(tmpImgPath[langID]) +"/menu/nav_0"+i+"_0"+subMenuObj[j].id+getSubPic(subMenuObj[j].menuID,subMenuObj[j].id)+".gif border=0 title='"+ chgCaptionLang("subMenuObj["+j+"].caption") +"' alt='"+ chgCaptionLang("subMenuObj["+j+"].caption") +"'></a>");
					}
					document.write("</td></tr>");
				}
			}
		}
	
		document.writeln("</table>");
		if (document.layers) document.writeln('</layer>'); else document.writeln('</div>');
	}
}

}

//Change Left Menu Pic
function changeLayerPic(org,src,p1,p2){

if (changeLayerPic.arguments.length>3 && p1==Selected_ID && p2==Selected_Sub){

}else{
  eval("document."+org+".src='"+src+"'");
}


}

function delayAction(v){}

function changeLayerPicPi(pi){
	if (pi>9)
	 eval("document.pic"+pi+".src='"+locationPath+"/common/images/"+ getImagePath(tmpImgPath[langID]) +"/nav_"+pi+"_on.gif'");
	else
	 eval("document.pic"+pi+".src='"+locationPath+"/common/images/"+ getImagePath(tmpImgPath[langID]) +"/nav_0"+pi+"_on.gif'");
 }

 //set Sub Left Menu Pic
function setSubPic(i,j){
if (i<=9) pi="0"+i; else pi=i;
if (j<=9) pj="0"+j; else pj=j;

for (x=1;x<subMenuObj.length;x++){
if (subMenuObj[x].id==j && subMenuObj[x].menuID==i){
if(eval("document.subpic_"+i+"_"+x))
 eval("document.subpic_"+i+"_"+x+".src='"+locationPath+"/common/images/"+getImagePath(tmpImgPath[langID])+"/menu/nav_"+pi+"_"+pj+"_on.gif'");

}
}


}

//get  Left Menu Pic
function getSubPic(i,j){
if (i==Selected_ID && j==Selected_Sub)
  return "_on";
 else
  return "";
}

//Get Top Banner
function getTopBanner(v){
 if (!isText){
	if(!printPage){
	// document.write('<td width=90%><img src="'+locationPath+'/common/images/en/topbanner_02.jpg" border=0 align=top title="'+arClfTopMenu[langID][3]+'" alt="'+arClfTopMenu[langID][3]+'"></td>');
	 document.write('<td><img src="'+locationPath+'/common/images/'+getImagePath(tmpImgPath[langID])+'/topbanner_02.jpg" border=0 align=top title="'+arClfTopMenu[langID][3]+'" alt="'+arClfTopMenu[langID][3]+'">');
 document.write('<table border=0 cellspacing=0 cellpadding=0>');
 document.write('<tr>');
	}
	else
	 document.write('<br>');
 }	 
}

//Change Url  to difference language
function chgUrlLang(s){
	if(isSearch || isGdns){
	  var tmp_textPath=prodUrl;				
	   if(isText)
	    tmp_textPath=prodUrl+cgiPath+cgiName+"/";				
	 
		 if (langID==1)
		   return tmp_textPath+"internet/e"+s.substring(1,s.length);
		 else
			if((document.URL.toString().search('/sc/') != -1)||isGB)
		   return tmp_textPath+"sc/c"+s.substring(1,s.length);
		   else
			return tmp_textPath+"cinternet/c"+s.substring(1,s.length);
	}else{
			 if (isText){
				var currentPath=s;		
				if (langID==1)
				 currentPath="/internet/e"+currentPath.substring(1,currentPath.length);
				else
				if((document.URL.toString().search('/sc/') != -1)||isGB)
				 currentPath="/sc/c"+currentPath.substring(1,currentPath.length);
				 else
				 currentPath="/cinternet/c"+currentPath.substring(1,currentPath.length);
				currentPath=cgiName+currentPath;
				return currentPath;
			 }else{
				if (langID==1)
				 return "e"+s.substring(1,s.length);
				else
				 return "c"+s.substring(1,s.length);
			 }
	 }
}


function printChangedUrl(s){
 if (langID==1){
  document.writeln(s);
 }else{
  document.writeln(s.replace('<a href="eh','<a href="ch'));
 }
}


function chgCaptionLang(s){
if (langID==1)
 return eval(s);
else
 return eval(s.replace(".caption",".chiCaption"));
}

//Create Object in Lower Left Links Section
function addLowerLeftLinks(linksID, caption, chi_caption,url,chi_url,Pic,chi_Pic,popup,prompt)
{
	lowerleftObj[lf] = new Object();
	lowerleftObj[lf].id = linksID;
	lowerleftObj[lf].caption = caption;
	lowerleftObj[lf].chi_caption = chi_caption;
	lowerleftObj[lf].url = url;
	lowerleftObj[lf].chi_url = chi_url;
	lowerleftObj[lf].Pic = locationPath + "/common/images/en/" + Pic;
	if (isGB){
			lowerleftObj[lf].chi_Pic = locationPath + "/common/images/sc/" + chi_Pic;
	}else{
		lowerleftObj[lf].chi_Pic = locationPath + "/common/images/tc/" + chi_Pic;
	}
  	lowerleftObj[lf].popup = popup;
	lowerleftObj[lf].prompt = prompt;
	lf++;
}


//Create Object in Links Section
function addLinks(linksID, caption, chi_caption,url,chi_url,Pic,chi_Pic,popup)
{
	linksObj[lc] = new Object();
	linksObj[lc].id = linksID;
	linksObj[lc].caption = caption;
	linksObj[lc].chi_caption = chi_caption;
	linksObj[lc].url = url;
	linksObj[lc].chi_url = chi_url;
	linksObj[lc].Pic = locationPath + "/internet/" + Pic;
	if (isGB){
			linksObj[lc].chi_Pic = locationPath + "/sc/" + chi_Pic;
	}else{
		linksObj[lc].chi_Pic = locationPath + "/cinternet/" + chi_Pic;
	}
    linksObj[lc].popup = popup;
	lc++;
}

//Change the image path
function getImagePath(path){
 if(location.href.toString().search('/gb/')!=-1)
  path=path.replace("tc","sc");  
return path;
}

//All external link with sc version.
	function externalLinkSC(vernum, url, sc_url){
		if (isGB)
		url = sc_url;

		externalURL = url;
		
	 	if (vernum == 1){
			window.open(url);
		}else{
			if (externalURL.toString().search('gov.hk')==-1){
				if(isText)
				{
					disclaimer ="ehdisclaimer.html&externalurl="+externalURL;
				}else{

					disclaimer ="ehdisclaimer.html?externalurl="+externalURL;
				}
				if (langID==1){
					disclaimer = locationPath+langPath+disclaimer;
				}else{
					disclaimer = locationPath+langPath+disclaimer;
					disclaimer = disclaimer.replace("/eh","/ch");
				}
					eval("nw = window.open(disclaimer,'disclaimer','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,pageXOffset=300,pageYOffset=500,top=0,left=0,width=" + 310 + ",height=" + 150 + "')");
			
			}else{
				window.open(externalURL);
			}
		}
	}

//All external link must use this function to run
	function externalLink(vernum, url){
		externalURL = url;
	 	if (vernum == 1){
			window.open(url);
		}else{
			if (externalURL.toString().search('gov.hk')==-1){
				if(isText)
				{
					disclaimer ="ehdisclaimer.html&externalurl="+externalURL;
				}else{

					disclaimer ="ehdisclaimer.html?externalurl="+externalURL;
				}
				if (langID==1){
					disclaimer = locationPath+langPath+disclaimer;
				}else{
					disclaimer = locationPath+langPath+disclaimer;
					disclaimer = disclaimer.replace("/eh","/ch");
				}
					eval("nw = window.open(disclaimer,'disclaimer','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,pageXOffset=300,pageYOffset=500,top=0,left=0,width=" + 310 + ",height=" + 150 + "')");
			
			}else{
				window.open(externalURL);
			}
		}
	}
		
	//The external link will popup without checking
	function acceptedExternalLink(){
		window.open(externalURL);
	}

	// For publication and archive section
	function internalLink(url){
	 location.href=url;
	}
	

/*
    function ns4Check(){ 
	  return true;
	 if (navigator.appName=="Netscape" && navigator.appVersion.substring(0,1)=="4"){
      if(location.href.toString().search('#scode=ns4Printing')!=-1)
	   return false;
	  else 
	   return true;
	 }else{
	  return true;
	 }
	}
*/

/*
	function setNs6PrintPos(){
	 if(printPage){
		document.writeln(' 			<td width=1%>&nbsp;</td>');
		document.writeln('			<td width="530">');
	 }else{
		document.writeln(' 			<td width=3>&nbsp;</td>');
		document.writeln('			<td width="572">');
	 }		
	}
*/	
//Output Lower Left Links Section
function getLowerLeftLinks(){
var strbuffer=new Array();
var linksTmpLang=new Array();

 linksTmpLang[1]="";
 linksTmpLang[2]="chi_";
	document.writeln(' <tr valign=top>');
	document.writeln(' <td align=left style="background: url('+locationPath+'/common/images/'+ getImagePath(tmpImgPath[langID]) +'/nav_bglightblue.gif) repeat-y; border:none;">');
	document.writeln('<table width=164 border=0 cellpadding=0 cellspacing=0>');
	document.writeln(' <tr valign=top>');
	for (i=1;i<lowerleftObj.length;i++)
	{
	    if (lowerleftObj[i].popup==0){
	     var linksTmp="javascript:externalLink("+lowerleftObj[i].prompt+",'"+ eval("lowerleftObj["+i+"]."+linksTmpLang[langID]+"url") +"');";
		}else{
	     var linksTmp="'"+ eval("lowerleftObj["+i+"]."+linksTmpLang[langID]+"url") +"'";
		}
	   if(langID=="1")
	    strbuffer=" <td width=159 align=center><br><a href="+ linksTmp +"><img src='"+lowerleftObj[i].Pic+"' title='"+lowerleftObj[i].caption+"'alt='"+lowerleftObj[i].caption+"' border='0' align=center></a></td> <td width=5>&nbsp</td></tr>";
	   else
	    strbuffer=" <td width=159 align=center><br><a href="+ linksTmp +"><img src='"+lowerleftObj[i].chi_Pic+"' title='"+lowerleftObj[i].chi_caption+"'alt='"+lowerleftObj[i].chi_caption+"' border='0' align=center></a></td> <td width=5>&nbsp</td></tr> ";
 
  	 document.writeln(strbuffer);
      	}
	document.writeln(' </td>');
	document.writeln(' </tr>');
	document.writeln(' </table>');
	
	
}
	
	
//Output Links Table for Links Section
function getLinksTable(){
var strbuffer=new Array();
var linksTmpLang=new Array();
 linksTmpLang[1]="";
 linksTmpLang[2]="chi_";
for (i=1;i<linksObj.length;i++)
{
document.writeln("<tr>");
 for (j=0;j<3;j++)
 {
  if(i<linksObj.length){
	if (linksObj[i].popup==0){
     var linksTmp="javascript:externalLink(1,'"+ eval("linksObj["+i+"]."+linksTmpLang[langID]+"url") +"');";
	}else{
     var linksTmp="'"+ eval("linksObj["+i+"]."+linksTmpLang[langID]+"url") +"'";
	}
   if(langID=="1")

    if (isText)
     strbuffer="<Td align='center'><kanhanbypass><a href="+ linksTmp +">"+linksObj[i].caption+"</a></kanhanbypass></td>";
	else
     strbuffer="<Td align='center'><kanhanbypass><a href="+ linksTmp +"><img src='"+linksObj[i].Pic+"' title='"+linksObj[i].caption+"' alt='"+linksObj[i].caption+"' border='0'></a></kanhanbypass></td>";

   else

    if (isText)
     strbuffer="<Td align='center'><kanhanbypass><a href="+ linksTmp +">"+linksObj[i].chi_caption+"</a></kanhanbypass></td>";
	else
    strbuffer="<Td align='center'><kanhanbypass><a href="+ linksTmp +"><img src='"+linksObj[i].chi_Pic+"' title='"+linksObj[i].chi_caption+"' alt='"+linksObj[i].chi_caption+"' border='0'></a></kanhanbypass></td>";

  }else{
   strbuffer="";
  }
  if (strbuffer=="")
   document.writeln("   <Td align='center'>&nbsp;</td>");
  else
   document.writeln("   "+ strbuffer);
  i++;
 }

i--; 
document.writeln("</tr>"); 
}
}

/*
function getContentWidth(){
	if (isIE5)
	 document.write("<td width=550>");
	else
	 document.write("<td width=400>");			
}
*/	 

//For clear last  word in url 
function clearLastWord(url){
return url.substring(0,url.length-1);
}

//For clear "http://"  in url 
function clearFirstWord(url){
return url.substring(7,url.length);
}


//For gdns linking
function accessGdns(s){
if(isText)
 s=s+"#text=1";
 location=s;
}

// Compare Date
function getLatestDate(firstDate, secondDate){
	var firstDateArray = firstDate.split("/")
	var secondDateArray = secondDate.split("/")
	
	if(firstDateArray[2] > secondDateArray[2]){	//If firstDate's Year is latest, return firstDate
		return firstDate;
	}else if(firstDateArray[2] < secondDateArray[2]){ //If secondDate's Year is latest, return secondDate
		return secondDate;
	}else{
		if(firstDateArray[0] > secondDateArray[0]){	//If firstDate's Month is latest, return firstDate
			return firstDate;
		}else if(firstDateArray[0] < secondDateArray[0]){ //If secondDate's Month is latest, return secondDate
			return secondDate;
		}else{
			if(firstDateArray[1] > secondDateArray[1]){	//If firstDate's Day is latest, return firstDate
				return firstDate;
			}else if(firstDateArray[1] < secondDateArray[1]){	//If secondDate's Day is latest, return secondDate
				return secondDate;
			}else{	//If firstDate is equal to secondDate, return firstDate
				return firstDate;
			}
		}
	}
}
