﻿// ### RETURN ABS. PATH

if (top.location != self.location) {
top.location = self.location.href
}

function changeVer(plang){
	var purl;
	var b_aspx;
	var href_sc_url = "sc.yes.labour.gov.hk/TuniS/";
	purl = "/"+self.location.href.replace(local_path, "");
	purl = purl.replace("www.ywets.labour.gov.hk"+url_base, "");
	purl = purl.replace("http://", "");
	purl = purl.replace(href_sc_url, "");
	purl = purl.replace("?lang=tc&", "?");
	purl = purl.replace("?lang=en&", "?");
	purl = purl.replace("?lang=sc&", "?");
	purl = purl.replace("?lang=tc", "");
	purl = purl.replace("?lang=en", "");
	purl = purl.replace("?lang=sc", "");
	purl = purl.replace("&lang=tc", "");
	purl = purl.replace("&lang=en", "");
	purl = purl.replace("&lang=sc", "");
	purl = purl.replace("&lang=", "");
	if (purl.indexOf("#")>=0)
		purl = purl.substring(0, purl.indexOf("#"))
	b_aspx = (purl.indexOf(".aspx")==-1)?false:true;
	if (self.location.href.indexOf("/tc/")>=0 || self.location.href.indexOf("/en/")>=0) b_aspx = false;
	switch(plang){
		case "tc":
			if (lang == "sc"){
				purl = purl.replace(href_sc_url, "");
				purl = purl.replace("/sc/", "/tc/");
			}else{
				if (b_aspx && purl.indexOf("?")==-1) purl = purl +"?lang=tc";
				if (b_aspx && purl.indexOf("?") >=0 && purl.indexOf("?lang=tc")==-1) purl = purl +"&lang=tc";
				if (b_aspx) purl = url_base.substring(0, url_base.length-1) + purl;
				if (b_aspx == false)
				purl = url_base + "redirect.aspx?lang=tc&path="+purl;
			}
			break;
		case "sc":
			if (lang == "tc" && b_aspx)
				purl =  "http://"+href_sc_url+"www.ywets.labour.gov.hk"+ url_base.substring(0, url_base.length-1) + purl;
			if (lang == "tc" && b_aspx == false)
				purl = "http://"+href_sc_url+"www.ywets.labour.gov.hk"+ url_base.substring(0, url_base.length-1) + purl;
			if (lang == "en" && b_aspx)
				purl =  "http://"+href_sc_url+"www.ywets.labour.gov.hk"+ url_base.substring(0, url_base.length-1) + purl;
			if (lang == "en" && b_aspx == false)
				purl = "http://"+href_sc_url+"www.ywets.labour.gov.hk"+ url_base.substring(0, url_base.length-1) + purl;
				purl = purl.replace("/en/", "/tc/");
			break;
		case "en":
			if (b_aspx && purl.indexOf("?")==-1) purl = purl +"?lang=en";
			if (b_aspx && purl.indexOf("?") >=0 && purl.indexOf("?lang=en")==-1) purl = purl +"&lang=en";
			if (b_aspx) purl = url_base.substring(0, url_base.length-1) + purl;
			if (b_aspx == false)
				purl = url_base + "redirect.aspx?lang=en&path="+escape(purl);
			break;
	}
	// ### Translation precaution
	if (self.location.href.indexOf(href_sc_url)>=0) purl = "h"+"ttp://www.ywets.labour.gov.hk"+purl;
	//alert(purl);
	if (self.location.href.indexOf("pagenotfound.htm") >0 && (lang == "tc" || lang == "en"))
		history.back();
	else
		self.location = purl;		
} 
function goURL(url){
	if (url.indexOf("ywetsonline")>-1){
		if (document.getElementById("iframe_searchresult")){
			window.open(url, "iframe_searchresult");
		}else{
			//self.location = url_base + lang +"/js_redirect.htm#"+escape(url);
			self.location = "https://www.ywets.labour.gov.hk/" + lang +"/js_redirect.htm#"+escape(url);
		}
	}else{
		self.location = url;
	}
}
function winpop (url,w,h,scroll,resize,center) {
	if (center) {
		var winPos = ',top='+((screen.height - h) / 2)+',left='+((screen.width - w) / 2);
	}
	var scrollArg = (scroll == false) ? '' : ',scrollbars=1';
	var resizeArg = (resize == false) ? '' : ',resizable=1';
	flyout = window.open (url,"datagrid","status=yes, width=" + w + ",height=" + h + scrollArg + resizeArg + winPos);
	flyout.resizeTo(w,h);
	flyout.focus();
}


// common function for utf8 url encoding
function utf8(wide) {
  var c, s;
  var enc = "";
  var i = 0;
  while(i<wide.length) {
    c= wide.charCodeAt(i++);
    // handle UTF-16 surrogates
    if (c>=0xDC00 && c<0xE000) continue;
    if (c>=0xD800 && c<0xDC00) {
      if (i>=wide.length) continue;
      s= wide.charCodeAt(i++);
      if (s<0xDC00 || c>=0xDE00) continue;
      c= ((c-0xD800)<<10)+(s-0xDC00)+0x10000;
    }
    // output value
    if (c<0x80) enc += String.fromCharCode(c);
    else if (c<0x800) enc += String.fromCharCode(0xC0+(c>>6),0x80+(c&0x3F));
    else if (c<0x10000) enc += String.fromCharCode(0xE0+(c>>12),0x80+(c>>6&0x3F),0x80+(c&0x3F));
    else enc += String.fromCharCode(0xF0+(c>>18),0x80+(c>>12&0x3F),0x80+(c>>6&0x3F),0x80+(c&0x3F));
  }
  return enc;
}

var hexchars = "0123456789ABCDEF";

function toHex(n) {
  return hexchars.charAt(n>>4)+hexchars.charAt(n & 0xF);
}

var okURIchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";

function encodeURL(s) {
  var s = utf8(s);
  var c;
  var enc = "";
  for (var i= 0; i<s.length; i++) {
    if (okURIchars.indexOf(s.charAt(i))==-1)
      enc += "%"+toHex(s.charCodeAt(i));
    else
      enc += s.charAt(i);
  }
  return enc;
}

function remove_url_pre(url_input, str_start, str_end){
  var tmp_str;
  var str_len;

  url_input = url_input.replace("http://", "");
  url_input = url_input.replace("https://", "");
  url_input = url_input.replace(sc_server+"/", "");
	url_input = url_input.replace(yes_url+yes_url_base+lang, "");
	url_input = url_input.replace(yes_url+yes_url_base+link_lang, "");
  url_input = url_input.replace(yptp_url+yptp_url_base+lang, "");
  url_input = url_input.replace(yptp_url+yptp_url_base+link_lang, "");
  url_input = url_input.replace(ywets_url+ywets_url_base+lang, "");
  url_input = url_input.replace(ywets_url+ywets_url_base+link_lang, "");

  url_input = url_input.replace(ywets_url+ywets_url_base, ywets_url_base.substring((ywets_url_base.length-1), ywets_url_base.length));

  url_input = url_input.replace(yes_url+yes_url_base, yes_url_base.substring((yes_url_base.length-1), yes_url_base.length));

  url_input = url_input.replace(yptp_url+yptp_url_base, yptp_url_base.substring((yptp_url_base.length-1), yptp_url_base.length));

  if (str_start >= 0 && str_end >= 0 && str_end >= str_start) {
	  url_input = url_input.substring(str_start, str_end);
  }
//document.write(url_input);
  return (url_input);
}


var local_path = "http://"+ self.location.host + url_base;
// ### PERSONAL SETTING

if (typeof js_loca != 'undefined') {
//document.write(js_loca);
document.write("<script src='"+ url_base +js_loca+"\/custom_setting.js'><\/script>");
}else{
document.write("<script src='"+ url_base +"js\/custom_setting.js'><\/script>");
}

function print_header() {
if (lang && arr_hdr_string){
// ### PRINT HTML HEADER
document.write('<table width="100%" border="0" cellpadding="0" cellspacing="0" background="'+local_path+'images/headerbg.gif">');
document.write('<tr><td align="center">');
document.write('<table width="780" border="0" cellpadding="0" cellspacing="0">');
document.write('<form name="frmSearch" action="#" onSubmit="return false" method="get">');
document.write('  <tr> ');
document.write('    <td><a href="http://www.ywets.labour.gov.hk"><img src="'+local_path+'images/ywets_logo.gif" width="91" height="63" border="0" alt="'+arr_hdr_string[0]+'" align="left"><br><img src="'+local_path+'images/'+lang+'/ywets_text.gif" border="0" alt="'+arr_hdr_string[0]+'" align="abmiddle"></a></td>');
document.write('    <td align="right"><a href="http://www.brandhk.gov.hk/brandhk/eindex.htm" target="_blank"><img src="'+local_path+'images/'+lang+'/brandhk.gif" alt="'+arr_hdr_string[6]+'" border="0"></a><img src="'+local_path+'images/spacer.gif" width="10" height="38"></td>');
document.write('    <td width="2" rowspan="2"><img src="'+local_path+'images/spacer.gif" width="2" height="84"></td>');
document.write('  </tr>');
document.write('  <tr> ');
document.write('    <td><a href="'+arr_hdr_string[9]+'" target="_blank"><img src="'+local_path+'images/govhk_text.gif" border="0" alt="'+arr_hdr_string[1]+'" onmouseover="this.style.filter=\'alpha(opacity=70)\'" onmouseout="this.style.filter=\'alpha(opacity=100)\'"></a>');
if (lang != "tc") document.write('<a href="javascript:changeVer(\'tc\')"><img src="'+local_path+'images/tc_text.gif" width="63" height="21" border="0" alt="'+arr_hdr_string[3]+'" onmouseover="this.style.filter=\'alpha(opacity=70)\'" onmouseout="this.style.filter=\'alpha(opacity=100)\'"></a>');
if (lang != "sc") document.write('<a href="javascript:changeVer(\'sc\')"><img src="'+local_path+'images/sc_text.gif" width="63" height="21" border="0" alt="'+arr_hdr_string[2]+'" onmouseover="this.style.filter=\'alpha(opacity=70)\'" onmouseout="this.style.filter=\'alpha(opacity=100)\'"></a>');
if (lang != "en") document.write('<a href="javascript:changeVer(\'en\')"><img src="'+local_path+'images/en_text.gif" width="63" height="21" border="0" alt="'+arr_hdr_string[4]+'" onmouseover="this.style.filter=\'alpha(opacity=70)\'" onmouseout="this.style.filter=\'alpha(opacity=100)\'"></a>');
document.write('</td>');
document.write('    <td align="right"><table width="290" border="0" cellspacing="0" cellpadding="0">');
document.write('        <tr>');
document.write('          <td width="50" align="right" class="txtStandard">'+arr_hdr_string[7]+' </td>');
document.write('          <td width="130" align="center">');
document.write('<input name="txtSearch" type="text" class="txtStandard" style="width:120px;background-color:#FFFFEF">');
document.write('          </td>');
document.write('          <td class="txtStandard"><a href="javascript:goURL(\''+arr_hdr_string[10]+'\')"><img src="'+local_path+'images/search_icon.gif" width="17" height="16" align="absmiddle" border="0" alt="'+arr_hdr_string[7]+'"></a> ');
document.write('            | <a href="'+local_path+lang+'/sitemap.htm" class="txtStandard">'+ arr_hdr_string[8] +'</a> | <a href="'+local_path+lang+'/contactus.htm" class="txtStandard"><img src="'+local_path+'images/mail_icon.gif" width="17" height="19" align="absmiddle" border="0" alt="'+arr_hdr_string[5]+'"></a>');
// ### PAGE COUNTER
document.write('<img src="'+local_path+'pagecounter.aspx?url='+escape(self.location.href)+'" width="0" height="0">');
document.write('</td>');
document.write('        </tr>');
document.write('      </table></td>');
document.write('  </tr>');
document.write('</form>');
document.write('</table>');
document.write('</td></tr>');
document.write('</table>');
// ### PRINT MENU
var myurl = self.location.href;
document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
document.write('  <tr>');
document.write('    <td align="center" background="'+local_path+'images/background.gif"> ');
document.write('      <table width="780" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">');
document.write('        <tr> ');
document.write('          <td width="175" bgcolor="#E8EEC0" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">');
document.write('              <tr> ');
document.write('                <td colspan="2" background="images/mnu_spacer.gif"><img src="'+local_path+'images/spacer.gif" width="10" height="22">');
if (lang=="tc" || lang=="sc")
   document.write('<a href="javascript:goURL(\'https://www.ywets.labour.gov.hk/ywetsonline/\')"><img src="'+local_path+'images/'+lang+'/btn_tb_logon.gif" width="73" height="16" align="absmiddle" border="0" onmouseover="this.style.filter=\'invert\'" onmouseout="this.style.filter=\'\'"></a>');
document.write('</td>');
document.write('              </tr>');
document.write('              <tr> ');
document.write('                <td><img src="'+local_path+'images/spacer.gif" width="7" height="19"><a href="http://www.ywets.labour.gov.hk"><img src="'+local_path+'images/'+lang+'/home_text.gif" border="0"></a></td>');
document.write('                <td align="right"><img src="'+local_path+'images/arrowbtn_icon.gif" width="17" height="17"></td>');
document.write('              </tr>');
for (i=0;i<arr_mnu.length;i++){
   if (arr_mnu[i]["name"]=="") break;
   if (arr_mnu[i]["name"] && arr_mnu[i]["url"] && arr_mnu[i]["image"][0] && arr_mnu[i]["image"][1]){
      document.write('              <tr> ');
//removed URL after combined as YPYT
//      document.write('                <td colspan="2" align="center"><a href="'+local_path+arr_mnu[i]["url"]+'">');
      document.write('                <td colspan="2" align="center">');
      if ((myurl.indexOf(arr_mnu[i]["url"].replace(lang+"/", "").substring(0,4))!=-1 && arr_mnu[i]["url"].replace(lang+"/", "").substring(3,4) == "_") || (myurl.indexOf(arr_mnu[i]["url"])>0)) {
         document.write('<img src="'+local_path+arr_mnu[i]["image"][1]+'" width="165" height="22" border="0">');
      }else{
         document.write('<img src="'+local_path+arr_mnu[i]["image"][0]+'" width="165" height="22" border="0" onmouseover="this.src=\''+local_path+arr_mnu[i]["image"][1]+'\'" onmouseout="this.src=\''+local_path+arr_mnu[i]["image"][0]+'\'">');
      }
//removed URL after combined as YPYT
//      document.write('</a></td>');
      document.write('</td>');
      document.write('              </tr>');
   }
}
document.write('              <tr> ');
document.write('                <td colspan="2" align="center"><img src="'+local_path+'images/spacer.gif" width="165" height="10"></td>');
document.write('              </tr>');
var arr_banner_length=arr_banner.length;
if (self.location.href.indexOf("home.aspx")>0){
for (i=0;i<arr_banner_length;i++){
   document.write('              <tr> ');
   document.write('                <td colspan="2" align="center">');
   if (arr_banner[i]["url"] && arr_banner[i]["image"] && arr_banner[i]["name"]){
     document.write('<a href="'+arr_banner[i]["url"]+'" target="_blank">');
     document.write('<img src="'+local_path+arr_banner[i]["image"]+'" alt="'+arr_banner[i]["name"]+'" border="0" onmouseover="this.style.filter=\'alpha(opacity=50)\'" onmouseout="this.style.filter=\'alpha(opacity=100)\'">');
     document.write('</a>');
   }
   document.write('                </td>');
   document.write('              </tr>');
   document.write('              <tr> ');
   document.write('                <td colspan="2" align="center"><img src="'+local_path+'images/spacer.gif" width="165" height="10"></td>');
   document.write('              </tr>');
}
}else{
   document.write('              <tr> ');
   document.write('                <td colspan="2" align="center">');
   document.write('<a href="'+arr_banner[0]["url"]+'" target="_blank">');
   document.write('<img src="'+local_path+arr_banner[0]["image"]+'" alt="'+arr_banner[0]["name"]+'" border="0" onmouseover="this.style.filter=\'alpha(opacity=50)\'" onmouseout="this.style.filter=\'alpha(opacity=100)\'">');
   document.write('</a>');
   document.write('                </td>');
   document.write('              </tr>');
//Kevin Kwan 18/08/2008, Herman modified 19/8/2008

   if (self.location.href.indexOf("/cmg_")!=-1){
     if (lang=='tc')
     {
	      document.write('        <tr>');
		  //document.write('          <td align="center"><img src="'+local_path+'images/spacer.gif" heigth="10" width="165"</td>');
		  document.write('        <td colspan="2" align="center"><img src="'+local_path+'images/spacer.gif" width="165" height="10"></td>');
		  document.write('        </tr>');
	      document.write('        <tr>');
		  document.write('          <td colspan="2" align="center"><a href="http://www.td.gov.hk/transport_in_hong_kong/public_transport/ferries/free_ferry_rides/index_tc.htm" target="_blank"><img src="/images/ffrs_logo.gif" onmouseover="this.style.filter=\'alpha(opacity=70)\'" onmouseout="this.style.filter=\'alpha(opacity=100)\'" border="0" alt=""></a></td>');
		  document.write('        </tr>');
     }
     else
	{
	   if (lang=='en')
		{
	      document.write('        <tr>');
		  //document.write('          <td align="center"><img src="'+local_path+'images/spacer.gif" heigth="10" width="165"</td>');
		  document.write('        <td colspan="2" align="center"><img src="'+local_path+'images/spacer.gif" width="165" height="10"></td>');
		  document.write('        </tr>');
	   	  document.write('        <tr>');
		  document.write('          <td colspan="2" align="center"><a href="http://www.td.gov.hk/transport_in_hong_kong/public_transport/ferries/free_ferry_rides/index.htm" target="_blank"><img src="/images/ffrs_logo.gif" onmouseover="this.style.filter=\'alpha(opacity=70)\'" onmouseout="this.style.filter=\'alpha(opacity=100)\'" border="0" alt=""></a></td>');
		  document.write('        </tr>');
		}
		else
		{
	      document.write('        <tr>');
		  //document.write('          <td align="center"><img src="'+local_path+'images/spacer.gif" heigth="10" width="165"</td>');
		  document.write('        <td colspan="2" align="center"><img src="'+local_path+'images/spacer.gif" width="165" height="10"></td>');
		  document.write('        </tr>');
		  document.write('        <tr>');
		  document.write('          <td colspan="2" align="center"><kanhanbypass><a href="http://sc.info.gov.hk/gb/www.td.gov.hk/transport_in_hong_kong/public_transport/ferries/free_ferry_rides/index_tc.htm" target="_blank"><img src="/images/ffrs_logo.gif" onmouseover="this.style.filter=\'alpha(opacity=70)\'" onmouseout="this.style.filter=\'alpha(opacity=100)\'" border="0" alt=""></a></kanhanbypass></td>');
		  document.write('        </tr>');
		}
	}
   }

// end 18/08/2008
   document.write('              <tr> ');
   document.write('                <td colspan="2" align="center"><img src="'+local_path+'images/spacer.gif" width="165" height="10"></td>');
   document.write('              </tr>');
   document.write('              <tr> ');
   document.write('                <td colspan="2" align="center">');
   document.write('<a href="http://www.yptp.labour.gov.hk" target="_blank">');
   document.write('<img src="/images/'+lang+'/banner_yptp.gif" alt="" border="0" onmouseover="this.style.filter=\'alpha(opacity=50)\'" onmouseout="this.style.filter=\'alpha(opacity=100)\'">');
   document.write('</a>');
   document.write('                </td>');
   document.write('              </tr>');
   document.write('              <tr> ');
   document.write('                <td colspan="2" align="center"><img src="'+local_path+'images/spacer.gif" width="165" height="10"></td>');
   document.write('              </tr>');
}
document.write('            </table></td>');
document.write('          <td valign="top" class="TdLineRight">');
document.write("<script src='"+ url_base +"js/integrate_msg.js'></script>");
}
}

function print_header_new(){
if (lang && arr_hdr_string){
// ### PRINT HTML HEADER
document.write('<table width="100%" border="0" cellpadding="0" cellspacing="0" background="'+local_path+'images/headerbg.gif">');
document.write('<tr><td align="center">');
document.write('<table width="780" border="0" cellpadding="0" cellspacing="0">');
document.write('<form name="frmSearch" action="#" onSubmit="return false" method="get">');
document.write('  <tr><td> ');
document.write('<table width="100%" border="0" cellpadding="0" cellspacing="0">');
document.write('  <tr> ');
document.write('    <td width="335"><a href="http://www.yes.labour.gov.hk"><img src="'+local_path+'images/'+lang+'/ypyt_logo.gif" width="335" height="63" border="0" alt="'+arr_hdr_string[0]+'" align="left"></a></td>');
document.write('    <td><br><a href="http://www.yes.labour.gov.hk"><img src="'+local_path+'images/'+lang+'/ypyt_text.gif" border="0" alt="'+arr_hdr_string[0]+'" align="absmiddle"></a></td>');
document.write('    <td align="right"><a href="http://www.brandhk.gov.hk/brandhk/eindex.htm" target="_blank"><img src="'+local_path+'images/'+lang+'/brandhk.gif" alt="'+arr_hdr_string[6]+'" border="0"></a><img src="'+local_path+'images/spacer.gif" width="10" height="38"></td>');
//document.write('    <td width="2" rowspan="2"><img src="'+local_path+'images/spacer.gif" width="2" height="84"></td>');
document.write('  </tr>');
document.write('</table>');
document.write('<table width="100%" border="0" cellpadding="0" cellspacing="0">');
document.write('  <tr> ');
document.write('    <td><a href="'+arr_hdr_string[9]+'" target="_blank"><img src="'+local_path+'images/govhk_text.gif" border="0" alt="'+arr_hdr_string[1]+'" onmouseover="this.style.filter=\'alpha(opacity=70)\'" onmouseout="this.style.filter=\'alpha(opacity=100)\'"></a>');
if (lang != "tc") document.write('<a href="javascript:changeVer(\'tc\')"><img src="'+local_path+'images/tc_text.gif" width="63" height="21" border="0" alt="'+arr_hdr_string[3]+'" onmouseover="this.style.filter=\'alpha(opacity=70)\'" onmouseout="this.style.filter=\'alpha(opacity=100)\'"></a>');
if (lang != "sc") document.write('<a href="javascript:changeVer(\'sc\')"><img src="'+local_path+'images/sc_text.gif" width="63" height="21" border="0" alt="'+arr_hdr_string[2]+'" onmouseover="this.style.filter=\'alpha(opacity=70)\'" onmouseout="this.style.filter=\'alpha(opacity=100)\'"></a>');
if (lang != "en") document.write('<a href="javascript:changeVer(\'en\')"><img src="'+local_path+'images/en_text.gif" width="63" height="21" border="0" alt="'+arr_hdr_string[4]+'" onmouseover="this.style.filter=\'alpha(opacity=70)\'" onmouseout="this.style.filter=\'alpha(opacity=100)\'"></a>');
document.write('</td>');
document.write('    <td align="right"><table width="290" border="0" cellspacing="0" cellpadding="0">');
document.write('        <tr>');
document.write('          <td width="50" align="right" class="txtStandard">'+arr_hdr_string[7]+' </td>');
document.write('          <td width="120" align="right">');
document.write('<input name="txtSearch" type="text" class="txtStandard" style="width:115px;background-color:#FFFFEF">');
document.write('          </td>');
document.write('          <td class="txtStandard" align="center"><a href="javascript:goURL(\''+arr_hdr_string[10]+'\')"><img src="'+local_path+'images/search_icon.gif" width="17" height="16" align="absmiddle" border="0" alt="'+arr_hdr_string[7]+'"></a> ');
//document.write('          | <a href="http://'+yes_url+yes_url_base+link_lang+'/sitemap.htm" class="txtStandard">'+ arr_hdr_string[8] +'</a> ');
document.write('            | <a href="http://'+yes_url+yes_url_base+link_lang+'/contactus.htm" class="txtStandard"><img src="'+local_path+'images/mail_icon.gif" width="17" height="19" align="absmiddle" border="0" alt="'+arr_hdr_string[5]+'"></a>');
// ### PAGE COUNTER
document.write('<img src="'+local_path+'pagecounter.aspx?url='+escape(self.location.href)+'" width="0" height="0">');
document.write('</td>');
document.write('        </tr>');
document.write('      </table></td>');
document.write('  </tr>');
document.write('</table>');

document.write('  </td></tr>');
document.write('</form>');
document.write('</table>');
document.write('</td></tr>');
document.write('</table>');
// ### PRINT MENU
var myurl = self.location.href;
//document.write(myurl);

document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
document.write('  <tr>');
document.write('    <td align="center" background="'+local_path+'images/background_ypyt.jpg"> ');
//document.write('    <td align="center" background="'+local_path+'images/background_ypyt.gif"> ');

if (self.location.pathname.indexOf("home.aspx") != -1) {
document.write('<table width="780" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFF00">');
document.write('  <tr><td height="137" bgcolor="#FFFFDD" align="center" valign="middle"> ');
document.write('  <img src="images/banner_ypyt_yr_rnd_tc.jpg" width="760" align="absmiddle">');
document.write('  </td></tr> ');
document.write('</table>');
}

document.write('      <table width="780" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">');
document.write('        <tr> ');
document.write('          <td width="175" bgcolor="#fef7d3" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">');
//document.write('              <tr> ');
//document.write('                <td colspan="2" background="images/mnu_spacer.gif"><img src="'+local_path+'images/spacer.gif" width="10" height="22">');
//if (lang=="tc" || lang=="sc")
//   document.write('<a href="javascript:goURL(\'https://www.yes.labour.gov.hk/ywetsonline/\')"><img src="'+local_path+'images/'+lang+'/btn_tb_logon.gif" width="73" height="16" align="absmiddle" border="0" onmouseover="this.style.filter=\'invert\'" onmouseout="this.style.filter=\'\'"></a>');
//document.write('</td>');
//document.write('              </tr>');
document.write('              <tr> ');
document.write('                <td><img src="'+local_path+'images/spacer.gif" width="7" height="19"><a href="http://www.yes.labour.gov.hk"><img src="'+local_path+'images/'+lang+'/home_text.gif" border="0"></a></td>');
document.write('                <td align="right"><img src="'+local_path+'images/arrowbtn_icon.gif" width="17" height="17"></td>');
document.write('              </tr>');
for (i=0;i<arr_mnu.length;i++){
//document.write(arr_mnu[i]["url"]);
   if (arr_mnu[i]["name"]=="") break;
   if (arr_mnu[i]["name"] && arr_mnu[i]["url"] && arr_mnu[i]["image"][0] && arr_mnu[i]["image"][1]){
      document.write('              <tr> ');
//      document.write('                <td colspan="2" align="center"><a href="'+local_path+arr_mnu[i]["url"]+'">');
      document.write('                <td colspan="2" align="center"><a href="'+arr_mnu[i]["url"]+'">');
      if  (
				(myurl.indexOf("pagenotfound") == -1) &&
				((myurl.indexOf(remove_url_pre(arr_mnu[i]["url"], 0, 5))!=-1 && remove_url_pre(arr_mnu[i]["url"], 4, 5) == "_") ||
				((myurl.indexOf(remove_url_pre(arr_mnu[i]["url"], -1, -1)))>0) ||
				((myurl.indexOf(remove_url_pre(arr_mnu[i]["url"], 0, 8))) > -1)) ||
				((remove_url_pre(arr_mnu[i]["url"], 0, 5) == "/job_") && (myurl.indexOf("/tm_") != -1)) ||
				((remove_url_pre(arr_mnu[i]["url"], 0, 5) == "/job_") && (myurl.indexOf("/update_placement.aspx") != -1)) 
				) {
		 document.write('<img src="'+local_path+arr_mnu[i]["image"][1]+'" width="165" height="22" border="0">');
      }else{
         document.write('<img src="'+local_path+arr_mnu[i]["image"][0]+'" width="165" height="22" border="0" onmouseover="this.src=\''+local_path+arr_mnu[i]["image"][1]+'\'" onmouseout="this.src=\''+local_path+arr_mnu[i]["image"][0]+'\'">');
      }
      document.write('</a></td>');
      document.write('              </tr>');
   }
}
document.write('              <tr> ');
document.write('                <td colspan="2" align="center"><img src="'+local_path+'images/spacer.gif" width="165" height="10"></td>');
document.write('              </tr>');
var arr_banner_length=arr_banner.length;
if (self.location.href.indexOf("home.aspx")>0){
for (i=0;i<arr_banner_length;i++){
   document.write('              <tr> ');
   document.write('                <td colspan="2" align="center">');
   if (arr_banner[i]["url"] && arr_banner[i]["image"] && arr_banner[i]["name"]){
     document.write('<a href="'+arr_banner[i]["url"]+'" target="_blank">');
     document.write('<img src="'+local_path+arr_banner[i]["image"]+'" alt="'+arr_banner[i]["name"]+'" border="0" onmouseover="this.style.opacity=0.5;this.style.filter=\'alpha(opacity=50)\'" onmouseout="this.style.opacity=1;this.style.filter=\'alpha(opacity=100)\'">');
     document.write('</a>');
   }
   document.write('                </td>');
   document.write('              </tr>');
   document.write('              <tr> ');
   document.write('                <td colspan="2" align="center"><img src="'+local_path+'images/spacer.gif" width="165" height="10"></td>');
   document.write('              </tr>');
}
}else{
   document.write('              <tr> ');
   document.write('                <td colspan="2" align="center">');
   document.write('<a href="'+arr_banner[0]["url"]+'" target="_blank">');
   document.write('<img src="'+local_path+arr_banner[0]["image"]+'" alt="'+arr_banner[0]["name"]+'" border="0" onmouseover="this.style.opacity=0.5;this.style.filter=\'alpha(opacity=50)\'" onmouseout="this.style.opacity=1;this.style.filter=\'alpha(opacity=100)\'">');
   document.write('</a>');
   document.write('                </td>');
   document.write('              </tr>');
//Kevin Kwan 18/08/2008, Herman modified 19/8/2008

   if (self.location.href.indexOf("/cmg_")!=-1){
     if (lang=='tc')
     {
	      document.write('        <tr>');
		  //document.write('          <td align="center"><img src="'+local_path+'images/spacer.gif" heigth="10" width="165"</td>');
		  document.write('        <td colspan="2" align="center"><img src="'+local_path+'images/spacer.gif" width="165" height="10"></td>');
		  document.write('        </tr>');
	      document.write('        <tr>');
		  document.write('          <td colspan="2" align="center"><a href="http://www.td.gov.hk/transport_in_hong_kong/public_transport/ferries/free_ferry_rides/index_tc.htm" target="_blank"><img src="/images/ffrs_logo.gif" onmouseover="this.style.opacity=0.7;this.style.filter=\'alpha(opacity=70)\'" onmouseout="this.style.opacity=1;this.style.filter=\'alpha(opacity=100)\'" border="0" alt=""></a></td>');
		  document.write('        </tr>');
     }
     else
	{
	   if (lang=='en')
		{
	      document.write('        <tr>');
		  //document.write('          <td align="center"><img src="'+local_path+'images/spacer.gif" heigth="10" width="165"</td>');
		  document.write('        <td colspan="2" align="center"><img src="'+local_path+'images/spacer.gif" width="165" height="10"></td>');
		  document.write('        </tr>');
	   	  document.write('        <tr>');
		  document.write('          <td colspan="2" align="center"><a href="http://www.td.gov.hk/transport_in_hong_kong/public_transport/ferries/free_ferry_rides/index.htm" target="_blank"><img src="/images/ffrs_logo.gif" onmouseover="this.style.opacity=0.7;this.style.filter=\'alpha(opacity=70)\'" onmouseout="this.style.opacity=1;this.style.filter=\'alpha(opacity=100)\'" border="0" alt=""></a></td>');
		  document.write('        </tr>');
		}
		else
		{
	      document.write('        <tr>');
		  //document.write('          <td align="center"><img src="'+local_path+'images/spacer.gif" heigth="10" width="165"</td>');
		  document.write('        <td colspan="2" align="center"><img src="'+local_path+'images/spacer.gif" width="165" height="10"></td>');
		  document.write('        </tr>');
		  document.write('        <tr>');
		  document.write('          <td colspan="2" align="center"><kanhanbypass><a href="http://sc.info.gov.hk/gb/www.td.gov.hk/transport_in_hong_kong/public_transport/ferries/free_ferry_rides/index_tc.htm" target="_blank"><img src="/images/ffrs_logo.gif" onmouseover="this.style.opacity=0.7;this.style.filter=\'alpha(opacity=70)\'" onmouseout="this.style.opacity=1;this.style.filter=\'alpha(opacity=100)\'" border="0" alt=""></a></kanhanbypass></td>');
		  document.write('        </tr>');
		}
	}
   }

// end 18/08/2008
/*
   document.write('              <tr> ');
   document.write('                <td colspan="2" align="center"><img src="'+local_path+'images/spacer.gif" width="165" height="10"></td>');
   document.write('              </tr>');
   document.write('              <tr> ');
   document.write('                <td colspan="2" align="center">');
   document.write('<a href="http://www.yptp.labour.gov.hk" target="_blank">');
   document.write('<img src="/images/'+lang+'/banner_yptp.gif" alt="" border="0" onmouseover="this.style.opacity=0.5;this.style.filter=\'alpha(opacity=50)\'" onmouseout="this.style.filter=\'alpha(opacity=100)\'">');
   document.write('</a>');
   document.write('                </td>');
   document.write('              </tr>');
   document.write('              <tr> ');
   document.write('                <td colspan="2" align="center"><img src="'+local_path+'images/spacer.gif" width="165" height="10"></td>');
   document.write('              </tr>');
*/
}
document.write('            </table></td>');
document.write('          <td valign="top" class="TdLineRight">');
//document.write(yes_url);
//document.write(yptp_url);
//document.write(ywets_url);
//document.write(local_path + "<br>");
//document.write(url_base + "<br>");
//document.write(self.location.href + "<br>");
//document.write(self.location.protocol + "<br>");
//document.write(self.location.host + "<br>");
//document.write(self.location.pathname + "<br>");
//document.write(self.location.pathname.indexOf("home.aspx"));
}

}

if(typeof def_style != 'undefined'){
  switch (def_style) {
    case 'ypyt':
      print_header_new();
      break;

    case 'ywets':
      print_header();
      break;

    default:
      print_header();
  }
}else{
  print_header();
}