
// 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 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_txt/") != -1) {
	redirect_lang_url = existing_lang_url.replace(/en_txt/i, "cn_txt" );
} 
else {
// find the "chinese" wording in english page URL and replace is by "english";
	redirect_lang_url = existing_lang_url.replace(/cn_txt/i, "en_txt" );
}

// 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 gb_cn_url_str;
var text_str="";
var image_str ="";
existing_lang_href = document.location.href;
text_ver_url = existing_lang_url.replace(/chs_txt/i, "chs" );
if(existing_lang_href.search("/chs_txt/") != -1){
//	alert("Simplified");
	//gb_cn_url_str = "//"+existing_lang_href.substring((25));
	gb_cn_url_str = document.location.pathname;
	gb_cn_url_str = gb_cn_url_str.replace("chs_txt","cn_txt");
	text_str="简体";
	text_ver_str="繁体纯文字";
	redirect_lang_url = redirect_lang_url.replace(/chs_txt/i, "en_txt" );
	image_str = "/gb/images/";
	url_base="//sc.info.gov.hk/gb/www.fhb.gov.hk/cn_txt/";
} else {
//	alert("Big5");
	//gb_cn_url_str = "//sc.info.gov.hk/gb/www.fhb.gov.hk"+document.location.pathname;
	gb_cn_url_str = document.location.pathname;
	//gb_cn_url_str = "sss";
	text_str="繁体";
	text_ver_str="简体纯文字";
	image_str = "/chs/images/";
	redirect_lang_url = redirect_lang_url;
	url_base="/chs/";
}

function graphic_v() { 
	self.location.href = text_ver_url;
}

function gb_cn_v() { 	
	self.location.href = gb_cn_url_str;
}

function en_v() { 
	self.location.href = redirect_lang_url;
}



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;
}



document.write("<table width=\"760\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\">");
document.write("    <tr> ");
document.write("      <td colspan=\"2\" class=\"title\"><kanhanbypass><a href=\"/\">食物及卫生局<br>");
document.write("        香港特别行政区政府</a></kanhanbypass></td>");
document.write("    </tr>");
document.write("	    ");
document.write("    <tr> ");
document.write("      <td colspan=\"2\">&nbsp;</td>");
document.write("    </tr>");
document.write("    <tr valign=\"bottom\"> ");
document.write("      ");
document.write("    <td height=\"25\" colspan=\"2\" class=\"content\"><a href=\"/chs_txt/sitemap.html\">目录");
document.write("      </a> | <a href=\"javascript:gb_cn_v()\">"+text_ver_str+"</a> | <a href=\"javascript:en_v()\">English</a> ");
document.write("      | <a href=\"javascript:graphic_v()\">图像版本</a> | <a href=\"/chs_txt/sitemap.html\">网页指南</a> ");
document.write("      | <a href=\"/chs_txt/contact_us/enquiry/index.html\">联络我们</a></td>");
document.write("    </tr>");
document.write("    <tr> ");

document.write("      <td class=\"content\"><a href=\"http://www.gov.hk/sc/residents\">GovHK 香港政府一站通</a> ");
document.write("        | <a href=\"http://www.brandhk.gov.hk/brandhk/\">香港品牌形象 - 亚洲国际都会</a></td>");
document.write("      <td class=\"content\"><div align=\"right\">");
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-cnhk>");
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=utf-8>");
document.write("	<input type=hidden name=tpl_id value=fhb>");
document.write("          <input name=\"query\" type=\"text\" id=\"query\" size=\"15\">");
document.write("          <a href=\"javascript:window.document.search.submit()\">搜寻</a> </div></td>");
document.write("    </form>");
document.write("	</tr>");
document.write("    <tr> ");
document.write("      <td colspan=\"2\" class=\"content\"><hr>");
document.write("      </td>");
document.write("    </tr>");
document.write("  </table>");