﻿// 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/") != -1) {
	redirect_lang_url = existing_lang_url.replace(/en/i, "cn" );
} 
else {
// find the "chinese" wording in english page URL and replace is by "english";
	redirect_lang_url = existing_lang_url.replace(/cn/i, "en" );
}

// 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("〲⸳㘸ㄮ㌸㈮㠰") != -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://"+location.host+"/gb/images/";
	url_base="//"+location.host+"/sc/";
} else {
//	alert("Big5");
	text_url_str = existing_lang_href.replace("/cn","/sc").replace("/en","/sc")
	text_str="簡體版";
	text_ver_str="繁體純文字";
	image_str = "/cn/images/";
	redirect_lang_url = redirect_lang_url;
	url_base="//"+location.host+"/cn/";
}

imagebase = image_str;//url_base + "images/";




document.write("  <table width=760 border=0 height=87 cellpadding=0 cellspacing=0 background=" + imagebase + "bkgdtexture.gif>");
//  Yahoo Search Form 
document.write(" <form action=http://search.gov.hk/search.html method=get name=search target=mainframe id=search>");
document.write("  <input type=hidden name=tpl_id value=stdsearch>");
document.write("  <input type=hidden name=gp0 value=elderlycom_home>"); 
document.write("  <input type=hidden name=gp1 value=elderlycom_home>");
document.write("  <input type=hidden name=web value=this>");
document.write("  <input type=hidden name=ui_lang value=zh-hk>");  
document.write("  <input type=hidden name=ui_charset value=big5>");

document.write("	<tr align=left valign=top> ");
document.write("      <td height=66 colspan=6 class=sidebar background=" + imagebase + "bkgdtexture.gif><kanhanbypass><a href=http://"+location.host+"/><img src=" + imagebase + "ebs.jpg alt='安老事務委員會' border=0></a></kanhanbypass></td>");
document.write("      <td height=66 rowspan=2 valign=bottom background=" + imagebase + "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=" + imagebase + "bkgdtexture.gif width=22>&nbsp;</td>");
document.write("      <td height=66 background=" + imagebase + "bkgdtexture.gif width=97 colspan=3 valign=bottom> ");
document.write("        <div align=right><a href=http://www.brandhk.gov.hk/brandhk/eindex.htm target=_top><img name=BrandHK src=" + imagebase + "BrandHK.gif width=190 height=60  border=0 alt='香港品牌形象 - 亞洲國際都會'></a></div></td>");
document.write("    </tr>");
document.write("    <tr align=left valign=bottom> ");
document.write("      <td height=19 width=153 background=" + imagebase + "bkgdtexture.gif><a href=http://www.gov.hk/tc/residents/ onMouseOut=MM_swapImgRestore()  onMouseOver=MM_swapImage('mainbar111','','" + imagebase + "mainbar1_f2.gif',1) ><img src=" + imagebase + "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=67><a href="+text_ver_url+" onMouseOut=MM_swapImgRestore()  onMouseOver=MM_swapImage('mainbar21','','" + imagebase + "mainbar2_f2.gif',1) ><img src=" + imagebase + "mainbar2.gif alt='Text Only' name=mainbar21 width=67 height=20 border=0 id=mainbar21></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','','" + imagebase + "mainbar2_f2.gif',1) ><img src=" + imagebase + "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('mainbar411','','" + imagebase + "mainbar3_f2.gif',1) ><img src=" + imagebase + "mainbar3.gif alt='"+text_str+"' name=mainbar411 width=51 height=19 border=0 id=mainbar41></a></td>");

document.write("      <td align=left valign=top height=19 width=50><a href='"+ redirect_lang_url +"' onMouseOut=MM_swapImgRestore()  onMouseOver=MM_swapImage('mainbar31','','" + imagebase + "mainbar4_f2.gif',1) ><img src=" + imagebase + "mainbar4.gif alt='English' name=mainbar31 width=50 height=19 border=0 id=mainbar31></a></td>");

document.write("      <td height=19><img name=mainbar5 src=" + imagebase + "mainbar5.gif width=80 height=19 border=0></td>");

//document.write("      <td align=left valign=top height=19 width=50 background=" + imagebase + "bkgdtexture.gif> &nbsp;</td>");

document.write("      <td height=19 width=54 background=" + imagebase + "bkgdtexture.gif><a href=javascript:window.document.search.submit() onMouseOut=MM_swapImgRestore()  onMouseOver=MM_swapImage('mainbar611','','" + imagebase + "mainbar6_f2.gif',1) ><img src=" + imagebase + "mainbar6.gif alt=搜尋 name=mainbar611 width=54 height=19 border=0 id=mainbar61></a></td>");
document.write("      <td height=19 width=22 background=" + imagebase + "bkgdtexture.gif><a href=javascript:window.document.search.submit() onMouseOut=MM_swapImgRestore()  onMouseOver=MM_swapImage('mainbar81','','" + imagebase + "mainbar8_f2.gif',1) ><img src=" + imagebase + "mainbar8.gif alt=搜尋 name=mainbar81 width=22 height=19 border=0 id=mainbar81></a></td>");
document.write("      <td height=19 width=50 background=" + imagebase + "bkgdtexture.gif><a href=/cn/sitemap.html onMouseOut=MM_swapImgRestore()  onMouseOver=MM_swapImage('mainbar911','','" + imagebase + "mainbar9_f2.gif',1) ><img src=" + imagebase + "mainbar9.gif alt='網頁指南' name=mainbar911 width=65 height=19 border=0 id=mainbar91></a></td>");
document.write("      <td height=19 width=36 background=" + imagebase + "bkgdtexture.gif><a href=/cn/contact_us/ onMouseOut=MM_swapImgRestore()  onMouseOver=MM_swapImage('mainbar1011','','" + imagebase + "mainbar10_f2.gif',1) ><img src=" + imagebase + "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=" + imagebase + "reddot.gif width=1 height=2></td>");
document.write("    </tr>");
document.write("	</form>");
document.write("  </table>");

