﻿// 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/", "/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("tela");
//alert(redirect_lang_url);
//redirect_lang_url = redirect_lang_url.substr(url_start_index, url_length);

// print out the redirect url;

if(location.href.toString().search('www0.hkba.hk/en/') != -1)
{
	url_base = 'ht'+'tp://www0.hkba.hk/en/';
}
else
{
	var url_base = 'ht'+'tp://www.hkba.hk/en/';
}
//url_base = "http://www.hkba.hk/en/";
//url_base = "http://www.hkba.hk/en/";

imagebase = url_base + "images/";
flashbase = url_base + "flash/";
//gb_url = "//sc.info.gov.hk/gb/www.hkba.hk"+redirect_lang_url;
/*
if(location.href.toString().search('www0.hkba.hk/') != -1)
{
	//	alert("Simplified_testsite");
	gb_url = "//sc.info.gov.hk/gb/www0.hkba.hk"+redirect_lang_url;


}
else
{
	//	alert("Simplified_livesite");
	gb_url = "//sc.info.gov.hk/gb/www.hkba.hk"+redirect_lang_url;

}
*/
gb_url = location.href.replace("/en/","/sc/");

if (existing_lang_url.search("news.html") != -1) {
	flashfile="top01_news.swf";
} else if(existing_lang_url.search("aboutus/") != -1){
	flashfile="top01_about.swf";
} else if(existing_lang_url.search("press/") != -1){
	flashfile="top01_press.swf";
} else if(existing_lang_url.search("policy/") != -1){
	flashfile="top01_policy.swf";
} else if(existing_lang_url.search("tv/") != -1){
	flashfile="top01_tv.swf";
} else if(existing_lang_url.search("radio/") != -1){
	flashfile="top01_radio.swf";
} else if(existing_lang_url.search("complaints/") != -1){
	flashfile="top01_complaints.swf";
} else if(existing_lang_url.search("download/") != -1){
	flashfile="top01_download.swf";
} else if(existing_lang_url.search("events/") != -1){
	flashfile="top01_events.swf";
} else if(existing_lang_url.search("links/") != -1){
	flashfile="top01_links.swf";
} else if(existing_lang_url.search("faq/") != -1){
	flashfile="top01_faq.swf";
} else if(existing_lang_url.search("contact/") != -1){
	flashfile="top01_contact.swf";
} else if(existing_lang_url.search("sitemap.html") != -1){
	flashfile="top01_sitemap.swf";
} else if(existing_lang_url.search("important.html") != -1){
	flashfile="top01_important.swf";		
} else if(existing_lang_url.search("privacy.html") != -1){
	flashfile="top01_Privacy.swf";
	
}
else {
	flashfile="top01_welcome.swf";
	
}




/*
document.write("<table  background=\"" + imagebase + "bkgdtexture.gif\" width=\"760\" height=\"87\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
document.write("<form action=http://search.info.gov.hk/cgi-bin/se.cgi method=get name=search target=mainframe id=search><INPUT TYPE=\"hidden\" NAME=\"fu\"  VALUE=\"-/edb/chi/ -/edb/simp/\"><INPUT TYPE=\"hidden\" NAME=\"gr_1\"  VALUE=\"edlb\"><INPUT name=mode type=hidden value=1>");
document.write("  <tr align=\"left\" valign=\"top\"> ");
document.write("    <td height=\"66\" colspan=\"6\" background=\"" + imagebase + "bkgdtexture.gif\"><a href=\"/hkba/\" target=\"_top\"><img src=\"/hkba/en/images/ba.jpg\" alt=\"Broadcasting Authority\" width=\"484\" height=\"63\" border=\"0\"></a></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=\"qu\" size=\"6\">");
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=\"2\" 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=\"93\" height=\"60\" border=\"0\" alt=\"Brand Hong Kong\"></a></div></td>");
document.write("  </tr>");
document.write("  <tr align=\"left\" valign=\"top\"> ");
document.write("	<td height="19" width="1" background="../Library/engimages/bkgdtexture.gif"><a href="#" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage('mainbar111','','../images/mainbar1_f2.gif',1)" ></a></td>
document.write("    <td align="left" valign="top" height="19" width="51"><a href="../../tc/index.html" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage('mainbar31','','../images/mainbar3_f2.gif',1)" ><img src="../images/mainbar3.gif" alt="Traditional Chinese" name="mainbar31" width="51" height="20" border="0" id="mainbar31"></a></td> 
document.write("    <td align="left" valign="top" height="19" width="50"><a href="#" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage('mainbar411','','../images/mainbar4_f2.gif',1)" ><img src="../images/mainbar4.gif" alt="Simplified Chinese" name="mainbar411" width="50" height="20" border="0" id="mainbar41"></a></td>
document.write("    <td align="left" valign="top" height="19" width="302"><img src="../images/mainbar2_t.gif" name="mainbar21" width="67" height="20" border="0" id="mainbar21"></td>
document.write("     <td width="80" height="19"><img name="mainbar5" src="../images/mainbar5.gif" width="80" height="20" border="0"></td>
document.write("    <td height="19" width="54" background="../Library/images/bkgdtexture.gif"><a href="javascript:window.document.search.submit()" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage('mainbar611','','../images/mainbar6_f2.gif',1)" ><img src="../images/mainbar6.gif" alt="Search" name="mainbar611" width="54" height="20" border="0" id="mainbar61"></a></td>
document.write("      <td height="19" width="22" background="../Library/images/bkgdtexture.gif"><a href="javascript:window.document.search.submit()" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage('mainbar81','','../images/mainbar8_f2.gif',1)" ><img src="../images/mainbar8.gif" alt="Search" name="mainbar81" width="22" height="20" border="0" id="mainbar81"></a></td>
document.write("       <td height="19" width="65" background="../Library/images/bkgdtexture.gif"><a href="#" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage('mainbar911','','../images/mainbar9_f2.gif',1)" ><img src="../images/mainbar9.gif" alt="Site map" name="mainbar911" width="65" height="20" border="0" id="mainbar91"></a></td>
document.write("    <td height="19" width="36" background="../Library/images/bkgdtexture.gif"><a href="#" onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage('mainbar1011','','../images/mainbar10_f2.gif',1)" ><img src="../images/mainbar10.gif" alt="Contact us" name="mainbar1011" width="36" height="20" border="0" id="mainbar101"></a></td>
document.write("  </tr>");
document.write("  <tr align=\"left\" valign=\"top\"> ");
document.write("    <td height=\"2\" colspan=\"10\" bgcolor=\"#BB3333\"><img src=\"" + imagebase + "reddot.gif\" width=\"700\" height=\"2\"></td>");
document.write("  </tr>");
document.write("  </FORM>");
document.write("</table>");
*/
/*
document.write("<table  background=\"" + imagebase + "bkgdtexture.gif\" width=\"760\" height=\"87\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
document.write("<form action=http://search.info.gov.hk/cgi-bin/se.cgi method=get name=search  id=search><INPUT TYPE=\"hidden\" NAME=\"gr_1\"  VALUE=\"hkba\"><INPUT TYPE=\"hidden\" NAME=\"ma\"  VALUE=\"100\"><INPUT TYPE=\"hidden\" NAME=\"ft_1\"  VALUE=\"alltype\"><INPUT name=mode type=hidden value=70>");
document.write("  <tr align=\"left\" valign=\"top\"> ");
document.write("    <td height=\"66\" colspan=\"6\" background=\"" + imagebase + "bkgdtexture.gif\"><a href=\""+ url_base +"\"><img src=\"" + imagebase + "ba.jpg\" alt=\"Broadcasting Authority\" width=\"484\" height=\"63\" border=\"0\"></a></td>");
document.write("      <td height=\"66\" rowspan=\"2\" valign=\"bottom\" background=\"" + imagebase + "bkgdtexture.gif\" width=\"99\"> ");
document.write("        <div align=\"left\">");
if (document.all) {
	// IE or NS6
	if(navigator.appName.indexOf("Internet Explorer")) {
	document.write("          <INPUT class=\"search\" type=\"text\" name=\"qu\" size=\"10\">");
	} else {
	//NS6
	document.write("          <INPUT class=\"search\" type=\"text\" name=\"qu\" size=\"5\">");
	}
} else {
	document.write("          <INPUT class=\"search\" type=\"text\" name=\"qu\" size=\"5\">");
}
//document.write("          <INPUT class=\"search\" type=\"text\" name=\"qu\" size=\"4\">");

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\" colspan=\"2\" 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=\"93\" height=\"60\" border=\"0\" alt=\"Brand Hong Kong\"></a></div></td>");
document.write("  </tr>");
document.write("  <tr align=\"left\" valign=\"top\"> ");
document.write("      <td align=\"left\" valign=\"top\" height=\"19\" width=\"51\"><a href=\""+ redirect_lang_url +"\" onMouseOut=\"MM_swapImgRestore()\"  onMouseOver=\"MM_swapImage('mainbar31','','" + imagebase + "mainbar3_f2.gif',1)\" ><img src=\"" + imagebase + "mainbar3.gif\" alt=\"Traditional Chinese\" name=\"mainbar31\" width=\"51\" height=\"20\" border=\"0\" id=\"mainbar31\"></a></td>  ");
document.write("      <td align=\"left\" valign=\"top\" height=\"19\" width=\"50\"><a href=\""+gb_url+"\" onMouseOut=\"MM_swapImgRestore()\"  onMouseOver=\"MM_swapImage('mainbar411','','" + imagebase + "mainbar4_f2.gif',1)\" ><img src=\"" + imagebase + "mainbar4.gif\" alt=\"Simplified Chinese\" name=\"mainbar411\" width=\"50\" height=\"20\" border=\"0\" id=\"mainbar41\"></a></td>  ");
document.write("      <td align=\"left\" valign=\"top\" height=\"19\" width=\"302\"><img src=\"" + imagebase + "mainbar2_t.gif\" name=\"mainbar21\" width=\"67\" height=\"20\" border=\"0\" id=\"mainbar21\"></td>");
document.write("    <td width=\"80\" height=\"19\"><img name=\"mainbar5\" src=\"" + imagebase + "mainbar5.gif\" width=\"80\" height=\"20\" border=\"0\"></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=\"Search\" name=\"mainbar611\" width=\"54\" height=\"20\" 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=\"Search\" name=\"mainbar81\" width=\"22\" height=\"20\" border=\"0\" id=\"mainbar81\"></a></td>");
document.write("    <td height=\"19\" width=\"65\" background=\"" + imagebase + "bkgdtexture.gif\"><a href=\"/hkba/en/sitemap.html\" onMouseOut=\"MM_swapImgRestore()\"  onMouseOver=\"MM_swapImage('mainbar911','','" + imagebase + "mainbar9_f2.gif',1)\" ><img src=\"" + imagebase + "mainbar9.gif\" alt=\"Site map\" name=\"mainbar911\" width=\"65\" height=\"20\" border=\"0\" id=\"mainbar91\"></a></td>");
document.write("    <td height=\"19\" width=\"36\" background=\"" + imagebase + "bkgdtexture.gif\"><a href=\"/hkba/en/contact/index.html\" onMouseOut=\"MM_swapImgRestore()\"  onMouseOver=\"MM_swapImage('mainbar1011','','" + imagebase + "mainbar10_f2.gif',1)\" ><img src=\"" + imagebase + "mainbar10.gif\" alt=\"Contact us\" name=\"mainbar1011\" width=\"36\" height=\"20\" border=\"0\" id=\"mainbar101\"></a></td>");
document.write("  </tr>");
document.write("  <tr align=\"left\" valign=\"top\"> ");
document.write("    <td height=\"2\" colspan=\"10\" bgcolor=\"#BB3333\"><img src=\"" + imagebase + "reddot.gif\" width=\"700\" height=\"2\"></td>");
document.write("  </tr>");
document.write("  </FORM>");
document.write("</table>");
*/




document.write("<table width=\"773\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
document.write("  <tr> ");
document.write("    <td width=\"250\"> <object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"250\" height=\"65\">");
document.write("        <param name=\"movie\" value=\"" + flashbase + "logo.swf\">");
document.write("        <param name=quality value=high>");
document.write("        <embed src=\"" + flashbase + "logo.swf\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"250\" height=\"65\"></embed> ");
document.write("      </object> </td>");
document.write("    <td valign=\"bottom\"> <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
document.write("        <tr> ");
document.write("          <td><div align=\"right\"> ");
document.write("              <object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/ca" + flashbase + "swflash.cab#version=6,0,29,0\" width=\"27\" height=\"29\">");
document.write("                <param name=\"movie\" value=\"" + flashbase + "sound.swf\">");
document.write("                <param name=\"quality\" value=\"high\">");
document.write("                <embed src=\"" + flashbase + "sound.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"27\" height=\"29\"></embed></object>");
document.write("              <img src=\"" + imagebase + "top/02.gif\" width=\"5\" height=\"29\"><a href=\""+ redirect_lang_url +"\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image9','','" + imagebase + "top/01_over.gif',1)\"><img src=\"" + imagebase + "top/01.gif\" name=\"Image9\" width=\"27\" height=\"29\" border=\"0\" alt=\"Traditional Chinese\"></a><img src=\"" + imagebase + "top/02.gif\" width=\"5\" height=\"29\"><a href=\""+gb_url+"\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image10','','" + imagebase + "top/03_over.gif',1)\"><img src=\"" + imagebase + "top/03.gif\" name=\"Image10\" width=\"31\" height=\"29\" border=\"0\" alt=\"Simplified Chinese\"></a></div></td>");
document.write("        </tr>");
document.write("        <tr> ");
document.write("          <td align=\"right\" valign=\"bottom\">");

document.write('<FORM name="search"  action="http://search.gov.hk/search.html" method=get onsubmit="if( document.getElementById(\'search\').query.value.length == 0 ) {alert(\'Please enter keyword\');}  else { document.getElementById(\'search\').submit();} return false;">             <input type=hidden name=ui_lang value="en">             <input type=hidden name=ui_charset value="en">             <input type=hidden name=gp0 value="hkba_home">             <input type=hidden name=gp1 value="hkba_home">             <input type=hidden name=tpl_id value="hkba">             <input type=hidden name=web value="this">');


document.write("              <table border=\"0\" align=\"right\" cellpadding=\"0\" cellspacing=\"0\">");
document.write("                <tr> ");
document.write("                  <td><a href=\""+ url_base +"contact/index.html\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image11','','" + imagebase + "top/04_over.gif',1)\"><img src=\"" + imagebase + "top/04.gif\" name=\"Image11\" width=\"85\" height=\"27\" border=\"0\" alt=\"contact\"></a></td>");
document.write("                  <td><a href=\""+ url_base +"sitemap.html\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image12','','" + imagebase + "top/05_over.gif',1)\"><img src=\"" + imagebase + "top/05.gif\" name=\"Image12\" width=\"73\" height=\"27\" border=\"0\" alt=\"sitemap\"></a></td>");
document.write("                  <td><A href=\"javascript:submit_search_form()\" onclick=\"if( document.getElementById(\'search\').query.value.length == 0 ) {alert(\'Please enter keyword\');}  else { document.getElementById(\'search\').submit();} return false;\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image13','','" + imagebase + "top/06_over.gif',1)\"><img src=\"" + imagebase + "top/06.gif\" name=\"Image13\" width=\"59\" height=\"27\" border=\"0\" alt=\"search\"></a></td>");
document.write("                  <td background=\"" + imagebase + "top/07.gif\">");

if (document.all) {
	// IE or NS6
	if(navigator.appName.indexOf("Internet Explorer")) {
	document.write("          <INPUT class=\"search\" type=\"text\" name=\"query\" size=\"10\">");
	} else {
	//NS6
	document.write("          <INPUT class=\"search\" type=\"text\" name=\"query\" size=\"5\">");
	}
} else {
	document.write("          <INPUT class=\"search\" type=\"text\" name=\"query\" size=\"5\">");
}


document.write("                  </td>");

document.write("                  <td><input name=\"imageField\" type=\"image\" src=\"" + imagebase + "top/08.gif\" width=\"31\" height=\"27\" border=\"0\" alt=\"search\"></td>");
document.write("                </tr>");
document.write("              </table>");
document.write("            </form></td>");
document.write("        </tr>");
document.write("      </table></td>");
document.write("  </tr>");
document.write("</table>");
document.write("<table width=\"760\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
document.write("  <tr> ");
document.write("    <td><img src=\"" + imagebase + "spacer.gif\" width=\"1\" height=\"1\"></td>");
document.write("  </tr>");
document.write("</table>");
document.write("<table width=\"773\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");



document.write("  <tr> ");
document.write("    <td width=\"153\"><img src=\"" + imagebase + "top/1.jpg\" width=\"153\" height=\"60\"></td>");
document.write("    <td><img src=\"" + imagebase + "spacer.gif\" width=\"1\" height=\"1\"></td>");
document.write("    <td width=\"439\"> <object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/" + flashbase + "swflash.cab#version=6,0,29,0\" width=\"439\" height=\"60\">");
document.write("        <param name=\"movie\" value=\"" + flashbase + flashfile +"\">");
document.write("        <param name=quality value=high>");
document.write("        <embed src=\"" + flashbase + flashfile +"\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"439\" height=\"60\"></embed> ");
document.write("      </object></td>");
document.write("    <td><img src=\"" + imagebase + "spacer.gif\" width=\"1\" height=\"1\"></td>");
document.write("    <td width=\"165\"><img src=\"" + imagebase + "top/2.jpg\" width=\"179\" height=\"60\"></td>");
document.write("  </tr>");
document.write("</table>");