MM_preloadImages(+image_str+'images/mainbar1_f2.gif',+image_str+'images/mainbar3_f2.gif',+image_str+'images/mainbar4_f2.gif',+image_str+'images/mainbar6_f2.gif',+image_str+'images/mainbar8_f2.gif',+image_str+'images/mainbar9_f2.gif',+image_str+'images/mainbar10_f2.gif',+image_str+'images/mainbar2_f2.gif',+image_str+'images/link_chi_press2_11.jpg',+image_str+'images/link_chi_press2_13.jpg',+image_str+'images/link_chi_press2_15.jpg',+image_str+'images/link_chi_speech2_11.gif',+image_str+'images/link_chi_leg2_08.jpg',+image_str+'images/link_chi_leg2_11.jpg',+image_str+'images/link_chi_leg2_13.jpg',+image_str+'images/link_chi_service2_13.jpg',+image_str+'images/link_chi_service2_11.jpg',+image_str+'images/link_chi_public2_08.jpg',+image_str+'images/link_chi_public2_11.jpg',+image_str+'images/link_chi_public2_13.jpg',+image_str+'images/link_chi_contact2_11.jpg',+image_str+'images/link_chi_about2_08.jpg',+image_str+'images/link_chi_about2_11.jpg',+image_str+'images/link_chi_about2_13.jpg',+image_str+'images/link_chi_about2_15.jpg',+image_str+'images/link_chi_press2_09.jpg',+image_str+'images/link_chi_press2_17.jpg',+image_str+'images/link_chi_press2_19.jpg',+image_str+'images/link_chi_contact2_09.jpg',+image_str+'images/link_chi_legco2_09.jpg',+image_str+'images/link_chi_service2_09.jpg',+image_str+'images/link_chi2_05.jpg',+image_str+'images/link_chi2_06.jpg',+image_str+'images/link_chi2_07.jpg',+image_str+'images/link_chi2_10.jpg',+image_str+'images/link_chi2_12.jpg',+image_str+'images/link_chi2_14.jpg',+image_str+'images/link_chi2_15.jpg',+image_str+'images/link_chi2_19.jpg',+image_str+'images/link_chi2_18.jpg',+image_str+'images/link_chi2_20.jpg',+image_str+'images/link_chi2_21.jpg',+image_str+'images/link_chi2_25.jpg')


// JavaScript Document
// Create Date: 2003-12-23
// file name: header_01st.js
// version: 1.0
// Author: CL
//
// Purpose: use the following chinese and english wording replacment in the current URL to 
//	    redirect to chinese language version in english version page by page; otherwise, 
//	    redirect to english language version in chinese version page by page.
//
var existing_lang_url = "";
var redirect_lang_url = "";
var redirect_lang_url_gb = "";
var url_start_index = 0;
var url_length = 0;

// define the existing URL.
existing_lang_url = document.location.pathname;

// find the "english" wording in english page URL and replace is by "chinese";
if (existing_lang_url.search("en/") != -1) {
	redirect_lang_url = existing_lang_url.replace(/en/i, "cn" );
	redirect_lang_url_gb = existing_lang_url.replace(/en/i, "chs" );
} 
else {
// find the "chinese" wording in english page URL and replace is by "english";
	redirect_lang_url = existing_lang_url.replace(/cn/i, "en" );
	redirect_lang_url_gb = existing_lang_url.replace(/cn/i, "chs" );
}

// define the absolute path of the redirect URL and ignore the HTTP:// and C:/;
//url_length = redirect_lang_url.length;
//url_start_index = redirect_lang_url.indexOf("202.123.196.213:8080");
//redirect_lang_url = redirect_lang_url.substr(url_start_index, url_length);
//redirect_lang_url = redirect_lang_url.substr(url_start_index, url_length);

// print out the redirect url;

var existing_lang_href = "";
var text_url_str="";
var text_str="";
var image_str ="";
existing_lang_href = document.location.href;
text_ver_url = existing_lang_url.replace(/cn/i, "cn_txt" );
if(existing_lang_href.search("sc.info.gov.hk") != -1){
//	alert("Simplified");
	text_url_str = "//"+existing_lang_href.substring((25));
	text_str="繁體版";
	text_ver_str="簡體純文字";
	redirect_lang_url = redirect_lang_url.replace(/gb/i, "" );
	image_str = "http://www.fhb.gov.hk/gb/images/";
	url_base="//sc.info.gov.hk/gb/www.fhb.gov.hk/cn/";
} else {
//	alert("Big5");
	//text_url_str = "//sc.info.gov.hk/gb/www.fhb.gov.hk"+document.location.pathname;
	text_url_str = document.location.pathname;
	text_url_str = text_url_str.replace("/cn/","/chs/");
	text_str="簡體版";
	text_ver_str="繁體純文字";
	image_str = "/cn/images/";
	redirect_lang_url = redirect_lang_url;
	url_base="/cn/";
}

//alert("      <td height=66 colspan=6 class=sidebar background="+image_str+"bkgdtexture.gif><a href=/><img src="+image_str+"ebs.jpg alt='香港特別行政區政府─ 食物及壎竻' border=0></a></td>");


document.write("  <table width=760 border=0 height=87 cellpadding=0 cellspacing=0 background="+image_str+"bkgdtexture.gif>");
document.write("    <form action=http://search.gov.hk/search.html method=get name=search id=search>");
document.write("	<input type=hidden name=ui_lang value=zh-hk>");
document.write("	<input name=gp0 type=hidden value=fhb_home>");
document.write("	<input name=gp1 type=hidden value=fhb_home>");
document.write("	<input type=hidden name=web value=this>");
document.write("	<input type=hidden name=ui_charset value=big5>");
document.write("	<input type=hidden name=tpl_id value=fhb>");
document.write("	<tr align=left valign=top> ");
document.write("      <td height=66 colspan=6 class=sidebar background="+image_str+"bkgdtexture.gif><kanhanbypass><a href=/><img src="+image_str+"ebs.jpg alt='香港特別行政區政府─ 食物及壎竻' border=0></a></kanhanbypass></td>");
document.write("      <td height=66 rowspan=2 valign=bottom background="+image_str+"bkgdtexture.gif width=99> ");
document.write("        <div align=center> ");
document.write("          <input class=search type=text name=query size=10>");
document.write("        </div></td>");
//document.write("      <td height=66 background="+image_str+"bkgdtexture.gif width=22>&nbsp;</td>");
document.write("      <td height=66 background="+image_str+"bkgdtexture.gif width=97 colspan=3 valign=bottom> ");
document.write("        <div align=right><a href=http://www.brandhk.gov.hk/brandhk/index.htm target=_top><img name=BrandHK src="+image_str+"Brandhk.gif width=190 height=60 border=0 alt='香港品牌形象 - 亞洲國際都會'></a></div></td>");
document.write("    </tr>");
document.write("    <tr align=left valign=top> ");
document.write("      <td height=19 width=153 background="+image_str+"bkgdtexture.gif><a href=http://www.gov.hk/tc/residents/ onMouseOut=\"MM_swapImgRestore()\"  onMouseOver=\"MM_swapImage('mainbar111','','"+image_str+"mainbar1_f2.gif',1)\" ><img src="+image_str+"mainbar1.gif alt='GovHK 香港政府一站通' name=mainbar111 width=170 height=19 border=0 id=mainbar11></a></td>");



document.write("      <td align=left valign=top height=19 width=78><a href="+text_ver_url+" onMouseOut=MM_swapImgRestore()  onMouseOver=MM_swapImage('mainbar21','','"+image_str+"mainbar2_f2.gif',1) ><img src="+image_str+"mainbar2.gif alt='"+text_ver_str+"' name=mainbar21 width=78 height=19 border=0 id=mainbar21></a></td>");




document.write("      <td align=left valign=top height=19 width=51><a href='"+text_url_str+"' onMouseOut=MM_swapImgRestore()  onMouseOver=MM_swapImage('mainbar31','','"+image_str+"mainbar3_f2.gif',1) ><img src="+image_str+"mainbar3.gif alt='"+text_str+"' name=mainbar31 width=51 height=19 border=0 id=mainbar31></a></td>");
document.write("      <td align=left valign=top height=19 width=50><a href='"+redirect_lang_url+"' onMouseOut=MM_swapImgRestore()  onMouseOver=MM_swapImage('mainbar411','','"+image_str+"mainbar4_f2.gif',1) ><img src="+image_str+"mainbar4.gif alt='English' name=mainbar411 width=50 height=19 border=0 id=mainbar41></a></td>");
document.write("      <td height=19><img name=mainbar5 src="+image_str+"mainbar5.gif width=80 height=19 border=0></td>");
document.write("      <td height=19 width=54 background="+image_str+"bkgdtexture.gif><a href=javascript:window.document.search.submit() onMouseOut=MM_swapImgRestore()  onMouseOver=MM_swapImage('mainbar611','','"+image_str+"mainbar6_f2.gif',1) ><img src="+image_str+"mainbar6.gif alt=搜尋 name=mainbar611 width=54 height=19 border=0 id=mainbar61></a></td>");
document.write("      <td height=19 width=22 background="+image_str+"bkgdtexture.gif><a href=javascript:window.document.search.submit() onMouseOut=MM_swapImgRestore()  onMouseOver=MM_swapImage('mainbar81','','"+image_str+"mainbar8_f2.gif',1) ><img src="+image_str+"mainbar8.gif alt=搜尋 name=mainbar81 width=22 height=19 border=0 id=mainbar81></a></td>");
document.write("      <td height=19 width=50 background="+image_str+"bkgdtexture.gif><a href='"+url_base+"sitemap.html' onMouseOut=MM_swapImgRestore()  onMouseOver=MM_swapImage('mainbar911','','"+image_str+"mainbar9_f2.gif',1) ><img src="+image_str+"mainbar9.gif alt='網頁指南' name=mainbar911 width=65 height=19 border=0 id=mainbar91></a></td>");
document.write("      <td height=19 width=36 background="+image_str+"bkgdtexture.gif><a href='"+url_base+"contact_us/enquiry/' onMouseOut=MM_swapImgRestore()  onMouseOver=MM_swapImage('mainbar1011','','"+image_str+"mainbar10_f2.gif',1) ><img src="+image_str+"mainbar10.gif alt='聯絡我們' name=mainbar1011 width=36 height=19 border=0 id=mainbar101></a></td>");
document.write("    </tr>");
document.write("    <tr align=left valign=top bgcolor=#BB3333> ");
document.write("      <td height=2 colspan=10><img src=cn/images/reddot.gif width=1 height=2></td>");
document.write("    </tr>");
document.write("	</form>");
document.write("  </table>");


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


