//Page Status var:
var printPage;
var isText;
var isGB;
var isProd;
var isProds;
var isTest;
var isTest2;
var isSearch;
var gb_img_prefix="";

/******** Global setting ********/

var textOnly_pl="text_only.pl";
var gdns_pl="gdne.pl";
var gdns_pl2="hcoll_gdne.html";
var search_pl="se.cgi";
var gbUrl="/gb/";

//Difference Server's URL
var htmlurl = ""; //Test site  folder
var test3Url="http://www0.cms.protocol.gov.hk/"; //The internal test site domain.
var testUrl="http://www0.protocol.gov.hk/";
var test2Url="http://protocol_revamp.westcomzivo.com/"; //The internal test site domain.
var prodUrl="http://www.protocol.gov.hk/";
var textonlyUrl="http://www0.protocol.gov.hk/"; //The textonly program domain.
var gb_urlPath="common.westcomzivo.com/gb/";  //Use this domain when the current url not equal to www/www0


//Perl Program Var:
var cgiPath1 = "cgi-bin"; //Cgi Folder Part 1
var cgiPath2 = "/protocol/"; //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='11/07/2005';
/******** End of Global setting ********/

//Gdns Var:




//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


//Menu, Link, other Object
var menuObj = new Array();
var subMenuObj = new Array();
var subSubMenuObj = 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 "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)
	 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 "isTest2":
	if(document.URL.toString().search("www0.cms")!=-1)
	 return true;
	else
	 return false;
   break;
   
  case "isTest":
	if(document.URL.toString().search("www0.protocol")!=-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_cso.html")!=-1 || document.URL.toString().search("resultes_cso.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('/eng/')!=-1 || location.href.toString().search("297")!=-1 || location.href.toString().search("e"+gdns_pl2)!=-1)
	  return 1;
	 if(document.URL.toString().search('/chi/')!=-1 || location.href.toString().search("298")!=-1 || location.href.toString().search("c"+gdns_pl2)!=-1)
	  return 2;
   break;

	case "langPath":
	 if(document.URL.toString().search('/eng/')!=-1 || location.href.toString().search("297")!=-1 || location.href.toString().search("e"+gdns_pl2)!=-1)
	  return "/eng/";
	 else
	  return "/chi/";
   break;
 
  default:
  return false;
 }
}




//Set status to var:
printPage=getPageStatus("printPage");
isText=getPageStatus("isText");
isGB=getPageStatus("isGB");
isProd=false;
isProds=getPageStatus("isProd");
isTest2=getPageStatus("isTest2");
isTest=getPageStatus("isTest");
isInternal=getPageStatus("isInternal");
isSearch=getPageStatus("isSearch");
langPath=getPageStatus("langPath");
langID=getPageStatus("langID");


//Set textonly domain;
	if(isProds || isSearch)
		textonlyUrl="http://www.protocol.gov.hk/"; //The textonly program domain.	
	
//Set  gb var.
	if(!isInternal)
		gb_urlPath='sc.info.gov.hk/gb/';

	if (isGB){
		gb_img_prefix="imgb_";
		imagePath = locationPath+'/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<=7;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<=7;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]="eng";
	  tmpImgPath[2]="chi";
	  tmpImgPath[3]="gb";

	 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('/eng/')!=-1){
		targetString=location.href.search('/eng/');
		subPath=locPath.substring(0, targetString);
	}
	if(location.href.toString().search('/chi/')!=-1){
		targetString=location.href.search('/chi/');
		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('/chi/');
		subPath=locPath.substring(0, targetString);
	}

	if(location.href.toString().search('/eng/')!=-1){
		if(isText){
		 targetString=location.href.search('eng/');
		}else{
		 targetString=location.href.search('/eng/');
		subPath=locPath.substring(0, targetString);
	    }
	}
	if(location.href.toString().search('/chi/')!=-1){
		if(isText){
		 targetString=location.href.search('chi/');
		}else{
		 targetString=location.href.search('/chi/');
		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(isTest){
	 if(isText)
		subPath=textonlyUrl+cgiPath+cgiName;			
	 else	
		subPath=clearLastWord(testUrl);	
	}
	
	if(isTest2){
	 if(isText)
		subPath=textonlyUrl+cgiPath+cgiName;			
	 else	
		subPath=clearLastWord(test3Url);	
	}
	
	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{ 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+'/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{ 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+'/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>');
	}

}

//function for Print Function
function PrintDocument(){
	var gt=getPath2Title();
	var s="The Treasury - "+gt;
	if (sitemap && sitemap=="Y")
	 s="Protocol Division Government Secretariat - Site Map";


 	  w=window.open(document.URL,'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+"/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+"/images/'+ getImagePath(tmpImgPath[langID]) +'/" + obj + ".gif'");
      }
}


function getAcrobat(){
	var StrText='Please note that viewing document in PDF Format requires Adobe Acrobat Reader. Please <a class="text_link" href="javascript:externalLink(1, \'http://www.adobe.com/prodindex/acrobat/readstep.html\');">click here</a> to download if necessary.';
	if(langID==2) StrText='如想觀看以上文件，請下載<a class="text_link" href="javascript:externalLink(1, \'http://www.chinese-t.adobe.com/products/acrobat/readstep2.html\');">Acrobat Reader</a> 。';
	var StrImg='<img src="'+locationPath+'/images/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 (url.charAt(0)=='/'){
		menuObj[x].url = locationPath+url;
	}else{
		menuObj[x].url = locationPath+langPath+url;
	}

	if(url.search('http://')!=-1){
//		menuObj[x].url = url;
		menuObj[x].popup = ' target="_blank"'
	}else if(url.search('.pdf')!=-1){
//		menuObj[x].url = url;
		menuObj[x].popup = ' target="_blank"'
	}else{
//		menuObj[x].url = locationPath+langPath+url;
		menuObj[x].popup = ''
	}
	
	menuObj[x].onPic = locationPath + "/images/"+getImagePath(tmpImgPath[langID])+"/" + onPic;
	menuObj[x].offPic = locationPath + "/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 (url.charAt(0)=='/'){
		subMenuObj[y].url = locationPath+url;
	}else{
		subMenuObj[y].url = locationPath+langPath+url;		
	}
	
	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 (url.charAt(0)=='/'){
		subSubMenuObj[z].url = locationPath+url;
	}else{
		subSubMenuObj[z].url = locationPath+langPath+url;		
	}	
	subSubMenuObj[z].sitemap = sitemap;
	subSubMenuObj[z].navigationMenu = navigationMenu;
	z++;
}


//function for generating the top menu
function getTopMenu(){
 if (!printPage){

 	if(langID==1){
		var extarSpacer = '<td bgcolor="#FAFAEB"><img name="mainbar5" src="'+locationPath+'/images/spacer.gif" border="0" height=1 width=98 alt=""></td>';
	}else{
		var extarSpacer = '<td bgcolor="#FAFAEB"><img name="mainbar5" src="'+locationPath+'/images/spacer.gif" border="0" height=1 width=33 alt=""></td>';
	}

	if(location.href.toString().search('/gb/')!=-1 && navigator.appName=="Netscape" && navigator.appVersion.substring(0,1)!="5")
	extarSpacer = '<td bgcolor="#FAFAEB"><img name="mainbar5" src="'+locationPath+'/images/spacer.gif" border="0" height=1 width=55 alt=""></td>';

	var gicSearchForm;
	
	gicSearchForm='<form onsubmit="javascript: frmSearch_onSubmit();" name="frmSearch" action="'+arClfTopMenu[langID][1]+'" method="get">\n';
	/*gicSearchForm=gicSearchForm+'<INPUT name="mode" type="hidden" value="'+arClfTopMenu[langID][2]+'">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="lmode" type="hidden" value="1">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="pq" type="hidden" value="">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="pg" type="hidden" value="">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="pn" type="hidden" value="0">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="qm" type="hidden" value="0">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="la" type="hidden" value="1">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="de" type="hidden" value="0">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="so" type="hidden" value="0">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="nu" type="hidden" value="10">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="ca" type="hidden" value="0">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="ta" type="hidden" value="all">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="fu" type="hidden" value="">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="fd" type="hidden" value="">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="ma" type="hidden" value="100">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="ft_1" type="hidden" value="alltype">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="gr_1" type="hidden" value="'+arClfTopMenu[langID][20]+'">';*/
	
	gicSearchForm=gicSearchForm+'<INPUT name="exact_q" type="hidden" value="">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="any_q" type="hidden" value="">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="none_q" type="hidden" value="">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="gp0" type="hidden" value="protocol_home">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="gp1" type="hidden" value="protocol_home">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="p_size" type="hidden" value="10">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="doc_type" type="hidden" value="all">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="last_mod" type="hidden" value="#-1">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="ui_lang" type="hidden" value="'+arClfTopMenu[langID][24]+'">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="r_lang" type="hidden" value="all">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="ui_charset" type="hidden" value="'+arClfTopMenu[langID][25]+'">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="tpl_id" type="hidden" value="protocol">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="a_submit" type="hidden" value="false">\n';
	gicSearchForm=gicSearchForm+'<INPUT name="web" type="hidden" value="this">\n';

	if(!isText){
//		document.writeln('<body bgcolor="#ffffff" background="'+locationPath+'/images/bg.gif" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="init();">');
	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+'/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif">');
		document.writeln(gicSearchForm);
		document.writeln('		<tr align="left" valign="top">');
		document.writeln('			<td colspan="6" class="sidebar" background="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif" bgcolor="#FAFAEB"><a href="'+locationPath+'/index.html"><img src="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/Protocol_logo.gif" border=0 title="'+arClfTopMenu[langID][3]+'"alt="'+arClfTopMenu[langID][3]+'"></a></td>');
//		document.writeln('			<td rowspan="2" valign="bottom" background="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif" align=center><input type="text" name="query" size="'+arClfTopMenu[langID][4]+'" class="search"></td>');
//		document.writeln('			<td background="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif" bgcolor="#FAFAEB">&nbsp;</td>');
		document.writeln('			<td background="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif" colspan="4" valign="bottom" align=right bgcolor="#FAFAEB"><a href="'+arClfTopMenu[langID][5]+'" target="_blank"><img name="BrandHK" src="'+locationPath+'/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><a href="'+arClfTopMenu[langID][23]+'" onMouseOut="outTopMenu(\'mainbar1\')" onMouseOver="overTopMenu(\'mainbar1\')"><img name="mainbar1" src="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar1.gif" border="0" title="'+arClfTopMenu[langID][7]+'" alt="'+arClfTopMenu[langID][7]+'"></a></td>');
		document.writeln('			<td align="left" valign="top"><a href="javascript:changeLanguage(\''+arClfTopMenu[langID][12]+'\')" onMouseOut="outTopMenu(\'mainbar3\')" onMouseOver="overTopMenu(\'mainbar3\')"><img name="mainbar3" src="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar3.gif" border="0" title="'+arClfTopMenu[langID][13]+'" alt="'+arClfTopMenu[langID][13]+'"></a></td>');
		document.writeln('			<td align="left" valign="top"><a href="javascript:changeLanguage(\''+arClfTopMenu[langID][15]+'\')" onMouseOut="outTopMenu(\'mainbar4\')" onMouseOver="overTopMenu(\'mainbar4\')"><img name="mainbar4" src="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar4.gif" border="0" title="'+arClfTopMenu[langID][16]+'" alt="'+arClfTopMenu[langID][16]+'"></a></td>');
		document.writeln('			<td align="left" valign="top"><img name="mainbar5" src="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar5.gif" border="0"></td>');
		document.writeln(extarSpacer);
		document.writeln('			<td background="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif"><a href="javascript:frmSearch_onSubmit(true);" onMouseOut="outTopMenu(\'mainbar6\')" onMouseOver="overTopMenu(\'mainbar6\')"><img name="mainbar6" src="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar6.gif" border="0" title="'+arClfTopMenu[langID][17]+'" alt="'+arClfTopMenu[langID][17]+'"></a></td>');
//------------------------
		document.writeln('			<td valign="bottom" background="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif" align=center><input type="text" name="query" size="'+arClfTopMenu[langID][4]+'" class="search" style="height: 17px;"></td>');
//------------------------
		document.writeln('			<td background="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif"><a href="javascript:frmSearch_onSubmit(true);" onMouseOut="outTopMenu(\'mainbar8\')" onMouseOver="overTopMenu(\'mainbar8\')"><img name="mainbar8" src="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar8.gif" border="0" title="'+arClfTopMenu[langID][17]+'" alt="'+arClfTopMenu[langID][17]+'"></a></td>');
		document.writeln('			<td background="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif"><a href="'+locationPath+langPath+'sitemap/index.html" onMouseOut="outTopMenu(\'mainbar9\')" onMouseOver="overTopMenu(\'mainbar9\')"><img name="mainbar9" src="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/mainbar9.gif" border="0" title="'+arClfTopMenu[langID][18]+'" alt="'+arClfTopMenu[langID][18]+'"></a></td>');
		document.writeln('			<td background="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/bkgdtexture.gif" bgcolor="#FAFAEB"><a href="'+locationPath+langPath+'enquiries/index.html" onMouseOut="outTopMenu(\'mainbar10\')" onMouseOver="overTopMenu(\'mainbar10\')"><img name="mainbar10" src="'+locationPath+'/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="10" height=2 width=100% background="'+locationPath+'/images/reddot.gif"><img src="'+locationPath+'/images/reddot.gif" width="740" height="2"></td>');
		document.writeln('		</tr>');
		document.writeln('		</form>');
		document.writeln('		</table>');
		document.writeln('		</td>');
		document.writeln('	</tr>');
		document.writeln('	<tr valign=top>');
		document.writeln('		<td colspan="2"><img src="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/top_banner.gif" border=0 align=top  title="'+arClfTopMenu[langID][3]+'" alt="'+arClfTopMenu[langID][3]+'"></td>');
		document.writeln('	</tr>');
	if(!isSearch)
		document.writeln('	</table>');

	}else{
		//Text-only
//		document.writeln('<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="init();">');
		document.writeln('<table border=0 cellspacing=0 cellpadding=1 width=100%>');
		document.writeln(gicSearchForm);
		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="http://www.info.gov.hk/" 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:frmSearch_onSubmit(true);">'+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();
	}
}
}
function frmSearch_onSubmit(isClick){
//	document.frmSearch.query.value = encodeURIComponent(document.frmSearch.query.value);
	if(isClick){	document.frmSearch.submit();	}
}
//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;
}




//Switch language
function changeLanguage(switchLang){

	var currentPath=location.href.toString();
	var switchTc='/chi/';
	var switchSc='/chs/';
	var switchEn='/eng/';
	var switchText='/text';

if(isSearch){
	currentPath=location.href.toString();
	switch (switchLang){
		case '/eng/':
		    currentPath=currentPath.replace(gb_urlPath,"");					
		 if(isText)
		    currentPath=currentPath.replace("mode=298","mode=297")+"&text=1";			
		 else
	 	    currentPath=currentPath.replace("mode=298","mode=297");			
		 break;

		case '/chi/':
		    currentPath=currentPath.replace("sc.info.gov.hk/gb/","");					
		 if(isText)
		    currentPath=currentPath.replace("mode=297","mode=298")+"&text=1";			
		 else
	 	    currentPath=currentPath.replace("mode=297","mode=298");			
		 break;

		case '/gb/':		 
	 	    currentPath=currentPath.replace("mode=297","mode=298");			
		 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(!isSearch){  
	switch (switchLang){
				case '/graphics/':

			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 if (isTest){
					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));			
				  }else{
					var tmp_Url=clearLastWord(test3Url);
						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 if(isTest)
					  currentPath=currentPath.replace(clearFirstWord(testUrl), clearFirstWord(textonlyUrl)+cgiPath+cgiName+"/");						  
				  else
					  currentPath=currentPath.replace(clearFirstWord(test3Url), clearFirstWord(textonlyUrl)+cgiPath+cgiName+"/");						  
			}
			  currentPath=currentPath.replace(switchEn, switchEn);
			  currentPath=currentPath.replace(switchTc, switchTc);

			break;
		case '/gb/':
			gb_urlPath="http://"+gb_urlPath;
			currentPath=currentPath.replace(switchEn, switchSc);
			currentPath=currentPath.replace(switchTc, switchSc);
			break;
		case '/eng/':
			currentPath=currentPath.replace(switchTc, switchEn);
			break;
		case '/chi/':
			currentPath=currentPath.replace(switchEn, switchTc);
			break;

		default:
	}
 }	
	document.location=currentPath;
}


//Get Image Caption in menu
function getCaption(menu, i){
	var showAlt;

		if(langID==1)
			eval('showAlt='+menu+'['+i+'].caption');
		else
			eval('showAlt='+menu+'['+i+'].chiCaption');

	return showAlt;
}


//Get Image Caption in menu
function getSubCaption(menu, menuID, subMenuID){
	for(var j=1;j<y;j++){
		if (subMenuObj[j].id==subMenuID && subMenuObj[j].menuID==menuID){
			return (getCaption('subMenuObj', j));
		}
	}
}

//Get Left Menu
function getLeftMenu(){
if(!isText) getLeftMenu2();
}

//Get Left Menu
function getLeftMenu2(){
if(!printPage){ 
	if(!isText){
		document.writeln('<td rowspan=4 background="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/nav_bg.gif">');
		document.writeln('	<table border=0 cellspacing=0 cellpadding=0 bgcolor=white>');
		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{					
					
						if (i==4){
							document.writeln("<tr><td><a href='"+menuObj[i].url+"' "+ outAction + " " + overAction + " target='_blank'><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 + menuObj[i].popup + "><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();
					}
*/					
				}
			}
		}

		
		document.writeln('	</table>');
		document.writeln('	<div align="center"><img src="'+locationPath+'/images/spacer.gif" height="20" border="0"></div>');
	if (langID == 1){
		document.writeln('	<div align="center" style="padding-bottom:10px;"><a href="javascript:PopWin(\''+locationPath+'/eng/5day.htm\',260,169)"><img src="'+locationPath+'/images/5_day_week.jpg" border="0" alt="5-day week"></a></div>');
	}
	else{
		document.writeln('	<div align="center" style="padding-bottom:10px;"><a href="javascript:PopWin(\''+locationPath+'/chi/5day.htm\',260,169)"><img src="'+locationPath+'/images/5_day_week.jpg" border="0" alt="5天工作周"></a></div>');
	}
	
	if (langID == 1){
		document.writeln('	<div align="center"><a href="http://www.policyaddress.gov.hk/09-10/eng/" target="_blank"><img src="'+locationPath+'/images/eng/policy_address_en.gif" border="0" alt="2009-10 Policy Address"></a></div>');
	}
	else{
		document.writeln('	<div align="center"><a href="http://www.policyaddress.gov.hk/09-10/chi/" target="_blank"><img src="'+locationPath+'/images/chi/policy_address_c.gif" border="0" alt="2009-10 施政報告"></a></div>');
	}

		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='"+cgiName+"/eng/index.html'>Home</a> ]&nbsp;&nbsp;");
								  else
								   document.writeln("[ <a href='"+cgiName+"/chi/index.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='"+cgiName+"/eng/index.html'>Home</a></b> ]&nbsp;&nbsp;");
								  else
								   document.writeln("[ <b><a href='"+cgiName+"/chi/index.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].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>";					   					 					   
					  }
					}
					 if(str_subMenu.search("General Demand Note Enquiry")==-1 && str_subMenu.search("一般繳款單查詢")==-1 ){
				      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){		
		if (Selected_Sub!=0){
			if(Selected_Sub<10)
				var subTitleNum="0"+Selected_Sub;
			else
				var subTitleNum=Selected_Sub;
		
			document.writeln('<td width=90%><img src="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/title/title_'+titleNum+'_'+subTitleNum+'.gif" border=0 align=top title="'+getSubCaption('subMenuObj', Selected_ID, Selected_Sub)+'" alt="'+getSubCaption('subMenuObj', Selected_ID, Selected_Sub)+'"></td>');
		}else{
		document.writeln('<td width=90%><img src="'+locationPath+'/images/'+ getImagePath(tmpImgPath[langID]) +'/title/title_'+titleNum+'.gif" border=0 align=top title="'+getCaption('menuObj', Selected_ID)+'" alt="'+getCaption('menuObj', Selected_ID)+'"></td>');		
		}
	}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(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+'" onmouseover="document.backtotopfoot.src=\''+locationPath+'/images/'+tmpImgPath[langID]+'/btn_top_o.gif\'" onmouseout="document.backtotopfoot.src=\''+locationPath+'/images/'+tmpImgPath[langID]+'/btn_top.gif\'"><img src="'+locationPath+'/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';
	if(langID!=1) altText='頁首';
	
	var altBack='Back';
	if(langID!=1) altBack='回上頁';
	
	var copyYear='2005';
	var noticesLink="important/index.html";
	var noticeText='Important notices';
	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 (langID==2){
		noticeText='重要告示';
		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) 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+'/images/spacer.gif" border=0></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+'/images/spacer.gif" name="backtotopspacer" width=55 height=20></td></tr>');
		document.writeln('	<tr>');
		document.writeln('		<td><img src="'+locationPath+'/images/spacer.gif" alt="" border="0" width=5 height=1></td>');
		document.writeln('		<td valign="top"> ');
		document.writeln('		<table width="570" border="0" cellspacing="0" cellpadding="0">');
		document.writeln('		<tr bgcolor="#FFFFFF">');
		document.writeln('			<td colspan="2" background="'+locationPath+'/images/botdot.jpg"><img src="'+locationPath+'/images/spacer.gif" alt="" width="585" height="3" border=0></td>');
		document.writeln('		</tr>');
		document.writeln('		<tr bgcolor="#FFFFFF">');
		document.writeln('			<td height="15" bgcolor="#FFFFFF" class="footer"><b>'+copyYear+'</b> <img src="'+locationPath+'/images/copy.gif" alt="'+tmp_copy_text+'" width="12" height="11"> | <b><a href="'+locationPath+langPath+noticesLink+'" class="footer">'+noticeText+'</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></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='<li>';
 tmp_bullet2='<li>';
 tmp_bullet3='<li>';
// tmp_bullet1='<img src='+locationPath+'/images/bullet1.gif'+bullet_alt+'>';
// tmp_bullet2='<img src='+locationPath+'/images/bullet2.gif'+bullet_alt+'>';
// tmp_bullet3='<img src='+locationPath+'/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="'+locationPath+"/index.html"+'" class=text_link>Home</a></td></tr>';
	else
     strSiteMap=strSiteMap+'	<tr><td valign=top>'+tmp_bullet1+'</td><td colspan=3><a href="'+locationPath+"/index.html"+'" class=text_link>主頁</a></td></tr>';
	
	for(var i=1;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+'"'+menuObj[i].popup+' 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 width="100%"><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("important.html")+'" class=text_link>Important Notices</a></td></tr>';
	else
	 strSiteMap=strSiteMap+'	<tr><td valign=top>'+tmp_bullet1+'</td><td colspan=3><a href="'+chgUrlLang("important.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+'/css/'+styleType+'.css" rel="STYLESHEET" type="text/css">';
	}else{
		cssTmp='<link href="'+locationPath+'/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";
 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";
 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='"+locationPath+arClfTopMenu[langID][8]+"index.html' class='pathlink'>"+rootCaption+"</a>";
else
strBuffer="<a href='"+locationPath+arClfTopMenu[langID][8]+"index.html' class='pathlink'>"+rootCaption+"</a> > "+strBuffer;


	//graphic version only
	if(!isText){
		document.writeln('<table border=0 cellpadding=0 width=580 cellspacing=0 background="'+locationPath+'/images/spacer.gif">');
		document.writeln('<tr valign=top>');
	    document.writeln('<td width=1><img src="'+locationPath+'/images/spacer.gif" alt="" border="0" height=1></td>'+'<td class="path" width=96%>');		   
		document.writeln(strBuffer+'</td>');
		document.writeln('</tr>');
		document.writeln('<tr><td colspan=2><img src="'+locationPath+'/images/spacer.gif" alt="" border="0" width=1 height=10></td></tr>');
		document.writeln('</table>');
	}
}

function getSpacer(w,h){
		document.write('<img name="mainbar5" src="'+locationPath+'/images/spacer.gif" border="0" height='+h+' width='+w+' alt="">');
}

//Create sub Menu Layer
function loadLeftLayer(){
if(!printPage){
	y=160;
	for (i=1;i<=7;i++){
		if (document.layers){
			document.writeln('<layer name="Layer'+i+'" top=212 left=540 width=158 height=1 visibility="hide" bgcolor="#2E2E2E" 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; background-color : #2E2E2E;" 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; background-color : #2E2E2E;" 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+"/images/"+ getImagePath(tmpImgPath[langID]) +"/menu/nav_"+i+"_0"+subMenuObj[j].id+"_o.gif" +"',i);\"";
						omv=omv+" onMouseOut=\"changeLayerPic('subpic_"+i+"_"+j+"','"+locationPath+"/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+"/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+"/images/"+ getImagePath(tmpImgPath[langID]) +"/menu/nav_0"+i+"_0"+subMenuObj[j].id+"_o.gif" +"',i);\"";
						omv=omv+" onMouseOut=\"changeLayerPic('subpic_"+i+"_"+j+"','"+ locationPath+"/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+"/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!=8&&pi!=9){
		if (pi>9)
		 eval("document.pic"+pi+".src='"+locationPath+"/images/"+ getImagePath(tmpImgPath[langID]) +"/nav_"+pi+"_o.gif'");
		else
		 eval("document.pic"+pi+".src='"+locationPath+"/images/"+ getImagePath(tmpImgPath[langID]) +"/nav_0"+pi+"_o.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+"/images/"+ getImagePath(tmpImgPath[langID]) +"/menu/nav_"+pi+"_"+pj+"_o.gif'");

		}
	}
}

//get  Left Menu Pic
function getSubPic(i,j){
if (i==Selected_ID && j==Selected_Sub)
  return "_o";
 else
  return "";
}

//Get Top Banner
function getTopBanner(v){
 if (!isText){
	if(!printPage)
	 document.write('<td width=90%><img src="'+locationPath+'/images/en/topbanner_02.jpg" border=0 align=top title="'+arClfTopMenu[langID][3]+'" alt="'+arClfTopMenu[langID][3]+'"></td>');
	else
	 document.write('<br>');
 }	 
}

//Change Url  to difference language
function chgUrlLang(s){
	if(isSearch){
	  var tmp_textPath=prodUrl;				
	   if(isText)
	    tmp_textPath=prodUrl+cgiPath+cgiName+"/";				
	 
		 if (langID==1)
		   return tmp_textPath+"eng/"+s.substring(1,s.length);
		 else
		   return tmp_textPath+"chi/"+s.substring(1,s.length);
			
	}else{
			 if (isText){
				var currentPath=s;		
				if (langID==1)
				 currentPath="/eng/"+currentPath.substring(0,currentPath.length);
				else
				 currentPath="/chi/"+currentPath.substring(0,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 Links Section
function addLinks(linksID, caption, chi_caption,url,chi_url,Pic,chi_Pic,gb_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 + "/eng/" + Pic;
	if (isGB){
		if (gb_Pic==""){
			linksObj[lc].chi_Pic = locationPath + "/chi/" + chi_Pic;
		}else{
			linksObj[lc].chi_Pic = locationPath + "/chi/" + gb_Pic;
		}
	}else{
		linksObj[lc].chi_Pic = locationPath + "/chi/" + 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){
				disclaimer = "disclaimer.html";
				if (langID==1){
					disclaimer = locationPath+langPath+disclaimer;
				}else{
					disclaimer = locationPath+langPath+disclaimer;
				}
					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){
				disclaimer = "ehdisclaimer.html";
				if (langID==1){
					disclaimer = locationPath+langPath+disclaimer;
				}else{
					disclaimer = locationPath+langPath+disclaimer;
				}
					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;
	}
	

	
//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);
}



// 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;
			}
		}
	}
}

function getBack(){
	backText = "Back";
	if (langID==2){
		backText = "返回上頁";
	}
	document.writeln('<p align="center"><a href="javascript:history.back();" onMouseOut="simg(back_btn, \''+locationPath+'/images/'+getImagePath(tmpImgPath[langID])+'/btn_back.gif\')" onMouseOver="simg(back_btn, \''+locationPath+'/images/'+getImagePath(tmpImgPath[langID])+'/btn_back_o.gif\')"><img src="'+locationPath+'/images/'+getImagePath(tmpImgPath[langID])+'/btn_back.gif" alt="'+backText+'" border="0" name="back_btn" id="back_btn"></a></p>');		

}

function PopWin(url,x,y) {
  eval("nw = window.open(url,'content1','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,pageXOffset=100,pageYOffset=100,top=0,left=0,width=" + x + ",height=" + y + "')");
  if ( nw.focus != null){
    nw.focus();
  }
}