// goes to the corresponding English or Chinese page
function switchLang() {
	var url = new String(location.href);
	var url2 = '';
	var pos = -1;
	if ((pos = url.indexOf('/eng/')) >= 0) {
		if (pos >= 0) url2 = url.substring(0, pos) + '/chi/' + url.substring(pos + 5, url.length);
	} else if ((pos = url.indexOf('/chi/')) >= 0) {
		if (pos >= 0) url2 = url.substring(0, pos) + '/eng/' + url.substring(pos + 5, url.length);
	}
	if (url2 != '') location.replace(url2);
}

// obtain the current language preference
function getLang() {
	var url = new String(location.href);
	var pos = -1;
	if ((pos = url.indexOf('/eng/')) >= 0) {
		return 'eng';
	} else if ((pos = url.indexOf('/chi/')) >= 0) {
		return 'chi';
	} else {
		return 'eng';
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])?args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) { img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr) for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function before_search(f) {
	/*
	f.q.value = '';
	var q = new String(f.q2.value);
	var c = 0;
	for (var i = 0; i < q.length; i++) {
		c = q.charCodeAt(i);
		f.q.value += (c < 256 ? q.charAt(i): '&#' + c + ';');
	}
	*/
	f.q.value = f.q2.value;

	f.q2.value = '';
	return (f.q.value.length > 0);
}

function write_popup_notice() {
	return;
	var browserName = window.navigator.appName;
	var lang = getLang();
	if (browserName == 'Netscape' && parseFloat(window.navigator.appVersion) >= 5.0) {
		write_popup_notice_header(lang);
		write_popup_notice_netscape(lang);
	} else if (browserName == 'Microsoft Internet Explorer' && window.navigator.userAgent.indexOf('SV1') != -1) {
		/* only display the notice at Windows XP SP2 */
		write_popup_notice_header(lang);
		write_popup_notice_ie(lang);
	}
}

function write_popup_notice_header(lang) {
	return;
	if (lang == 'chi') {
		document.writeln('<p class="arial12boldred">在使用瀏覽器時封鎖快顯視窗</p>');
	} else {
		document.writeln('<p class="arial12boldred">Block Pop-up Windows</p>');
	}
}

function write_popup_notice_netscape(lang) {
	return;
	if (lang == 'chi') {
		document.writeln("<p class=\"arial12\">Mozilla 及 Netscape 的彈出視窗阻擋功能被大幅增強。Mozilla 或 Netscape 的使用者，您可以由<b>「工具＞Popup Manager」</b>選單中的<b>「Show」</b>來解除某些彈出視窗的封鎖狀態。若要了解詳細資訊，請參閱<a href=\"http://www.mozilla.org/start/1.0/faq/browser.html#2.4\" target=\"_blank\">Mozilla 網頁</a>。</p>");
	} else {
		document.writeln("<p class=\"arial12\">Mozilla and Netscape 7 come with a great Popup Manager which allows you to block popups that open automatically when you either enter (onload) or exit (onunload) a page. After you've enabled popup blocking, you can still allow specific sites to display popups. Browse to the web site, and then from the Tools menu, choose <b>Popup Manager</b>, and then choose <b>Allow Popups From This Site</b>. For more details, please refer <a href=\"http://www.mozilla.org/start/1.0/faq/browser.html#2.4\" target=\"_blank\">Mozilla web site</a>.</p>");
	}
}

function write_popup_notice_ie(lang) {
	return;
	if (lang == 'chi') {
		document.writeln("<p class=\"arial12\">有了 Windows XP Service Pack 2 (SP2)，Internet Explorer 可以讓您在使用網際網路時，避免大部分的快顯視窗出現在您要檢視的網頁上。當您安裝 SP2 時，會啟動 Internet Explorer 中的「快顯封鎖程式」，並且設定成中級設定，而能封鎖大部分自動出現的快顯視窗。快顯封鎖程式的預設設定會讓您在按網站上的連結或按鈕時，可以看見開啟的快顯視窗。另外，當快顯封鎖程式封鎖了快顯視窗時，會播放音效，並顯示 [資訊列]。您可以自行調整這些設定，讓快顯封鎖程式依照您想要的方式運作。若要暫時允許網站顯示快顯視窗，請在 [資訊列] 告知您有快顯視窗被封鎖時按一下 <b>[資料列]</b>，再按 <b>[暫時允許快顯]</b>。若要了解詳細資訊，請參閱<a href=\"http://www.microsoft.com/taiwan/windowsxp/using/web/sp2_popupblocker.mspx\" target=\"_blank\">Microsoft 網頁</a>。</p>");
	} else {
		document.writeln("<p class=\"arial12\">With Windows XP Service Pack 2 (SP2) Internet Explorer allows you to prevent most pop-up windows from appearing over pages you want to view while you're using the Internet. When you install SP2, Pop-up Blocker is turned on in Internet Explorer and set to the medium setting, which means it will block most automatic pop-ups. The default settings for the pop-up blocker allow you to see pop-ups that are opened when you click a link or button on a Web site. If you want to see pop-up windows from a specific Web site, type the address (or URL) of the site in the <b>Address of Web site to allow</b> box, and then click <b>Add</b>. To temporarily allow a site to display pop-ups, click the Information Bar when it notifies you that a pop-up has been blocked. Then click <b>Temporarily Allow Pop-ups</b>. For more details, please refer <a href=\"http://www.microsoft.com/windowsxp/using/web/sp2_popupblocker.mspx\" target=\"_blank\">Microsoft web site</a>.</p>");
	}
}

function btn_click_ie() {
	if (event.button == 2) return false;
}

function btn_click_ns(e) {
	if (document.layers || document.getElementById && !document.all) {
		if (e.which == 2 || e.which == 3) return false;
	}
}

function checkResolution() {
	var maxW = 1152 - 16; /* minus scrollbar */
	var winW = 0;
	if (parseInt(navigator.appVersion) > 3) {
		if (navigator.appName == 'Netscape') winW = window.innerWidth - 16;
		if (navigator.appName.indexOf('Microsoft') != -1) winW = document.body.offsetWidth;
	}
	if (winW == 0 || winW <= maxW) return;
	var e = document.getElementsByTagName('body');
	if (e) e.item(0).style.width = maxW + 'px';
}

/*
if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
	document.captureEvents(Event.MOUSEUP);
	window.captureEvents(Event.MOUSEDOWN);
	window.captureEvents(Event.MOUSEUP);
	document.onmousedown = btn_click_ns;
	document.onmouseup = btn_click_ns;
	window.onmousedown = btn_click_ns;
	window.onmouseup = btn_click_ns;
} else if (document.all && !document.getElementById) {
	document.onmousedown = btn_click_ie;
	document.onmouseup = btn_click_ie;
	window.onmousedown = btn_click_ie;
	window.onmouseup = btn_click_ie;
}

document.oncontextmenu = new Function('return false;');
*/
MM_preloadImages(
	BaseHref+'image/common/lbtn_company_on.gif',
	BaseHref+'image/common/lbtn_products_on.gif',
	BaseHref+'image/common/lbtn_buzpartners_on.gif',
	BaseHref+'image/common/lbtn_dlarea_on.gif',
	BaseHref+'image/common/lbtn_press_on.gif',
	BaseHref+'image/common/lbtn_contact_on.gif',
	BaseHref+'image/common/lbtn_mortgage_calc_on.gif',
	BaseHref+'image/common/lbtn_quick_refer_on.gif',
	BaseHref+'image/common/lbtn_prelim_approval_on.gif',
	BaseHref+'image/common/lbtn_company_off.gif',
	BaseHref+'image/common/lbtn_products_off.gif',
	BaseHref+'image/common/lbtn_buzpartners_off.gif',
	BaseHref+'image/common/lbtn_dlarea_off.gif',
	BaseHref+'image/common/lbtn_press_off.gif',
	BaseHref+'image/common/lbtn_contact_off.gif',
	BaseHref+'image/common/lbtn_mortgage_calc_off.gif',
	BaseHref+'image/common/lbtn_quick_refer_off.gif',
	BaseHref+'image/common/lbtn_prelim_approval_off.gif',
	BaseHref+'image/common/btn_home_on.gif',
	BaseHref+'image/common/btn_sitemap_on.gif',
	BaseHref+'image/common/btn_chinese_on.gif'
);
/*
function showCopyright() {
	window.status = (getLang() == 'chi' ? "\u00a9 2005 年 香港按揭證券有限公司 版權所有": "\u00a9 2005 Hong Kong Mortgage Corporation Limited. All rights reserved.");
}

var status_timer = setInterval('showCopyright();', 1000);
*/