// 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);

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") != -1){
	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 {
	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/";
}
//changing end

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_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];}
}



document.write("	<table width=\"117\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
document.write("        <tr> ");
document.write("           <td width=\"30\"><a href=\""+url_base+"About_Us/Introduction.html\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image3','','"+image_str+"main/main2_02.jpg',1)\"><img src=\""+image_str+"main/main_02.jpg\" alt=\"主頁\" name=\"Image3\" width=\"159\"  border=\"0\"></a></td>");
document.write("        </tr>");
document.write("        <tr> ");
document.write("          <td><a href=\"javascript:;\" onMouseOut=\"MM_swapImgRestore();popUp('aboutus',false)\" onMouseOver=\"MM_swapImage('Image4','','"+image_str+"main/main2_04.jpg',1);popUp('aboutus',true)\"><img src=\""+image_str+"main/main_04.jpg\" alt=\"關於我們\" name=\"Image4\" width=\"159\"  border=\"0\"></a></td>");
document.write("        </tr>");
document.write("        <tr> ");
document.write("          <td><a href=\""+url_base+"meeting/\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image5','','"+image_str+"main/main2_08.jpg',1)\"><img src=\""+image_str+"main/main_08.jpg\" alt=\"會議\" name=\"Image5\" width=\"159\" height=\"27\" border=\"0\"></a></td>");
document.write("        </tr>");
document.write("        <tr> ");
document.write("          <td><a href=\""+url_base+"programmes/index.html\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image6','','"+image_str+"main/main2_10.jpg',1)\"><img src=\""+image_str+"main/main_10.jpg\" alt=\"活動\" name=\"Image6\" width=\"159\"  border=\"0\"></a></td>");
document.write("        </tr>");
document.write("        <tr> ");
document.write("          <td><a href=\""+url_base+"library/\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image7','','"+image_str+"main/main2_12.jpg',1)\"><img src=\""+image_str+"main/main_12.jpg\" alt=\"資料庫\" name=\"Image7\" width=\"159\"  border=\"0\"></a></td>");
document.write("        </tr>");
document.write("        <tr> ");
document.write("          <td><a href=\""+url_base+"related_sites/\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image8','','"+image_str+"main/main2_15.jpg',1)\"><img src=\""+image_str+"main/main_15.jpg\" alt=\"相關網址\" name=\"Image8\" width=\"159\"  border=\"0\"></a></td>");
document.write("        </tr>");
document.write("        <tr> ");
document.write("          <td><a href=\""+url_base+"contact_us/\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image10','','"+image_str+"main/main2_18.jpg',1)\"><img src=\""+image_str+"main/main_18.jpg\" alt=\"聯絡我們\" name=\"Image10\" width=\"159\"  border=\"0\"></a></td>");
document.write("        </tr>");
document.write("        <tr> ");
document.write("          <td><img src=\""+image_str+"main/main_19.jpg\" width=\"159\" usemap=\"#Map\" border=0></td>");
document.write("        </tr>");
document.write("      </table>");
document.write(" 	<map name=\"Map\">");
document.write(" 	<area shape=\"rect\" coords=\"12,14,140,63\" href=\"http://www.info.gov.hk/elderly/index.htm\" target=\"_blank\" alt=\"長者健康服務\">");
document.write("  	<area shape=\"rect\" coords=\"10,74,138,126\" href=\"http://www.housingauthority.gov.hk/b5/residential/guidestools/seniorcitizens/0,,1-0-315--0,00.html\" target=\"_blank\" alt=\"長者住屋服務\">");
document.write("  	<area shape=\"rect\" coords=\"15,134,142,189\" href=\"http://www.swd.gov.hk/tc/index/site_pubsvc/page_elderly\" target=\"_blank\" alt=\"安老服務\">");
document.write("  	<area shape=\"rect\" coords=\"13,194,140,252\" href=\"http://www.elderacademy.org.hk\" target=\"_blank\" alt=\"長者學苑\">");
document.write(" 	</map>");

NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
ver4 = (NS4 || IE4) ? 1 : 0;

gotlayers = 1;

function popUp(menuName,on) {
	
	if (gotlayers) {
		if (on) {
			if (NS4) {
				document.layers[menuName].visibility = "show";
			} else {		
				document.all[menuName].style.visibility = "visible";
			}
		} else {
			if (NS4) {
				document.layers[menuName].visibility = "hide";
			} else {
				document.all[menuName].style.visibility = "hidden";
			}
		}
	}
}

if (NS4) {
	document.write("         <LAYER ID=\"aboutus\" VISIBILITY=\"hide\" TOP=\"122\" LEFT=\"152\" width=\"200\" height\"115\"> ");

} else {
	document.write("	  <div id=\"aboutus\" style=\"position:absolute; width:200px; height:115px; z-index:1; left: 152px; top: 122px; visibility: hidden;\"> ");
}

document.write("        <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" onMouseOut=\"popUp('aboutus',false)\" onMouseOver=\"popUp('aboutus',true)\">");
document.write("          <tr> ");
document.write("            <td><a href=\""+url_base+"About_Us/Introduction.html\" onMouseOut=\"MM_swapImgRestore();popUp('aboutus',false)\" onMouseOver=\"MM_swapImage('Image121','','"+image_str+"main/main2_05.jpg',1);popUp('aboutus',true)\"><img src=\""+image_str+"main/main_05.jpg\" alt=\"簡介\" name=\"Image121\" width=\"210\" height=\"20\" border=\"0\" id=\"Image121\"></a></td>");
document.write("          </tr>");
document.write("          <tr> ");
document.write("            <td height=\"20\"><a href=\""+url_base+"About_Us/Membership.html\" onMouseOut=\"MM_swapImgRestore();popUp('aboutus',false)\" onMouseOver=\"MM_swapImage('Image131','','"+image_str+"main/main2_07.jpg',1);popUp('aboutus',true)\"><img src=\""+image_str+"main/main_07.jpg\" alt=\"委員會名單\" name=\"Image131\" width=\"210\" height=\"20\" border=\"0\" id=\"Image131\"></a></td>");
document.write("          </tr>");
document.write("          <tr> ");
//document.write("            <td><a href=\""+url_base+"About_Us/Chairman_welcome_message.html\" onMouseOut=\"MM_swapImgRestore();popUp('aboutus',false)\" onMouseOver=\"MM_swapImage('Image141','','"+image_str+"main/main2_09.jpg',1);popUp('aboutus',true)\"><img src=\""+image_str+"main/main_09.jpg\" name=\"Image141\" width=\"210\" height=\"19\" border=\"0\" id=\"Image141\"></a></td>");
//document.write("          </tr>");
//document.write("          <tr> ");
document.write("            <td><a href=\""+url_base+"About_Us/Membership_and_TOR.html\" onMouseOut=\"MM_swapImgRestore();popUp('aboutus',false)\" onMouseOver=\"MM_swapImage('Image151','','"+image_str+"main/main2_11.jpg',1);popUp('aboutus',true)\"><img src=\""+image_str+"main/main_11.jpg\" alt=\"專責委員會及工作小組\" name=\"Image151\" width=\"210\" border=\"0\" id=\"Image151\"></a></td>");
document.write("          </tr>");
document.write("          <tr> ");
//document.write("            <td><a href=\""+url_base+"About_Us/Current_Members.html\" onMouseOut=\"MM_swapImgRestore();popUp('aboutus',false)\" onMouseOver=\"MM_swapImage('Image161','','"+image_str+"main/mainb2_13.jpg',1);popUp('aboutus',true)\"><img src=\""+image_str+"main/main_13.jpg\" name=\"Image161\" width=\"210\" height=\"20\" border=\"0\" id=\"Image161\"></a></td>");
//document.write("          </tr>");
//document.write("          <tr> ");
//document.write("            <td><a href=\""+url_base+"About_Us/Membership_and_TOR.html\" onMouseOut=\"MM_swapImgRestore();popUp('aboutus',false)\" onMouseOver=\"MM_swapImage('Image171','','"+image_str+"main/main2_14.jpg',1);popUp('aboutus',true)\"><img src=\""+image_str+"main/main_14.jpg\" name=\"Image171\" border=\"0\" id=\"Image171\"></a></td>");
//document.write("          </tr>");
document.write("        </table>");

if (NS4) {
	//document.write ("</table></LAYER>");
	document.write("            </LAYER>");

} else {
	document.write("            </div>");
	//document.write ("</table></DIV>");
}