// 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(location.href.toString().search('sc.info.gov.hk/gb/www0.hkba.hk') != -1 )
{
	//	alert("Simplified_testsite");
	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://sc.info.gov.hk/gb/www0.hkba.hk/gb/images/";
	flashbase = "http://sc.info.gov.hk/gb/www0.hkba.hk/gb/flash/";	
	url_base="//sc.info.gov.hk/gb/www0.hkba.hk/cn/";
}
else if (location.href.toString().search('sc.info.gov.hk/gb/www.hkba.hk') != -1 )
{
	//	alert("Simplified_livesite");
	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://sc.info.gov.hk/gb/www.hkba.hk/gb/images/";
	flashbase = "http://sc.info.gov.hk/gb/www.hkba.hk/gb/flash/";	
	url_base="//sc.info.gov.hk/gb/www.hkba.hk/cn/";
}

else if (location.href.toString().search('www0.hkba.hk') != -1 )
{
	//	alert("Big5_testsite");
	text_url_str = "//sc.info.gov.hk/gb/www0.hkba.hk"+document.location.pathname;
	text_str="简体版";
	text_ver_str="繁体纯文字";
	image_str = "http://sc.info.gov.hk/gb/www0.hkba.hk/sc/images/";
	flashbase = "http://sc.info.gov.hk/gb/www0.hkba.hk/sc/flash/";
	redirect_lang_url = redirect_lang_url;
	url_base="//www0.hkba.hk/cn/";
}
*/
	// this is sc js
	text_url_str = location.href.replace("/sc/","/cn/");
	text_str="繁體版";
	text_ver_str="简体纯文字";
	image_str = "http://" + location.hostname + "/gb/images/";
	flashbase = "http://" + location.hostname + "/gb/flash/";
	redirect_lang_url = location.href.replace("/sc/","/en/");
	url_base="//" + location.hostname + "/sc/";


if(location.href.toString().search('sc.info.gov.hk/gb/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;
}


//imagebase = url_base + "images/";
//flashbase = url_base + "flash/";
//gb_url = "//sc.info.gov.hk/gb/www.hkba.hk"+redirect_lang_url;

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";
	
	
}


imagebase = image_str;//url_base + "images/";

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=\"" + "http://www.hkba.hk/en/flash/" + "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=\""+ text_url_str +"\" 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=\""+text_str+"\" ></a><img src=\"" + imagebase + "top/02.gif\" width=\"5\" height=\"29\"><a href=\""+ redirect_lang_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=\"English\"></a></div></td>");



document.write("        </tr>");
document.write("        <tr> ");
document.write("          <td align=\"right\" valign=\"bottom\">");
document.write('<FORM name=\"search\"  onsubmit=\"if( document.getElementById(\'search\').query.value.length == 0 ) {alert(\'请输入关键字。\');}  else { document.getElementById(\'search\').submit();} return false;\" action=\"http://search.gov.hk/search.html\" method=get>             <input type=hidden name=ui_lang value=\"zh-cnhk\">             <input type=hidden name=ui_charset value=\"utf-8\">             <input type=hidden name=gp1 value=\"hkba_home\">             <input type=hidden name=gp0 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=\"联络我们\"></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=\"网页指南\"></a></td>");
document.write("                  <td><A href=\"javascript:submit_search_form()\" onclick=\"if( document.getElementById(\'search\').query.value.length == 0 ) {alert(\'请输入关键字。\');}  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=\"搜寻\"></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=\"搜寻\"></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>");


//old
/*
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=71>");
document.write("  <tr align=\"left\" valign=\"top\"> ");
document.write("      <td height=\"66\" colspan=\"6\" background=\"" + imagebase + "bkgdtexture.gif\"><a href=\"/cn/\"><img src=\"" + imagebase + "ba.jpg\" alt=\"广播事务管理局\" 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=\"14\">");
	} 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=\"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\" colspan=\"2\" valign=\"bottom\"> ");
document.write("  </tr>");
document.write("  <tr align=\"left\" valign=\"top\"> ");
document.write("      <td align=\"left\" valign=\"top\" height=\"19\" width=\"51\"><a href=\""+ text_url_str +"\" onMouseOut=\"MM_swapImgRestore()\"  onMouseOver=\"MM_swapImage('mainbar31','','" + imagebase + "mainbar3_f2.gif',1)\" ><img src=\"" + imagebase + "mainbar3.gif\" alt=\""+text_str+"\" 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=\""+ redirect_lang_url +"\" onMouseOut=\"MM_swapImgRestore()\"  onMouseOver=\"MM_swapImage('mainbar411','','" + imagebase + "mainbar4_f2.gif',1)\" ><img src=\"" + imagebase + "mainbar4.gif\" alt=\"English\" 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=\"../Libra" + 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=\"20\" border=\"0\" id=\"mainbar61\"></a></td>");
document.write("      <td height=\"19\" width=\"22\" background=\"../Libra" + 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=\"20\" border=\"0\" id=\"mainbar81\"></a></td>");
document.write("      <td height=\"19\" width=\"65\" background=\"../Libra" + 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=\"20\" border=\"0\" id=\"mainbar91\"></a></td>");
document.write("      <td height=\"19\" width=\"36\" background=\"../Libra" + imagebase + "bkgdtexture.gif\"><a href=\"/cn/contact/index.html\" onMouseOut=\"MM_swapImgRestore()\"  onMouseOver=\"MM_swapImage('mainbar1011','','" + imagebase + "mainbar10_f2.gif',1)\" ><img src=\"" + imagebase + "mainbar10.gif\" alt=\"联络我们\" 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=\"../Library/engimages/reddot.gif\" width=\"700\" height=\"2\"></td>");
document.write("  </tr>");
document.write("  </FORM>");
document.write("</table>");
*/
