﻿<!--
function Menu() {
	this.contentId = 0;
	this.text = "";
	this.alt = "";
	this.href = "";
	this.target = "";
	this.icon = "";
	this.menuType = "";
	this.childs = new Array();
}

Menu.prototype = {
	addChild : function(m) {
		this.childs[this.childs.length] = m;
	}
}

function checkURL(array)
{
	var url = window.top.location.href;
	var id;
	var va = [["/", "/"], ["=", ""]];
	
	for (var item=0; item<va.length; item++)
	{
		for (var i=0; i<array.length; i++)
		{
			if (url.indexOf((va[item][0] + array[i] + va[item][1])) >= 0)
			{
				id = array[i];
				break;
			}
		}
	}
	
	return id;
}

var iCurFotoIdx = 1;
var iCurFotoPg = 1;

function viewAlbumFoto(i) {
    if (i != iCurFotoIdx) {
        var oEf = document.getElementById("album_div" + iCurFotoIdx);
        var oEt = document.getElementById("album_div" + i);
        if (oEf && oEt) {
            oEf.style.display = 'none';
            oEt.style.display = '';
            
            oEf = document.getElementById("album_foto" + iCurFotoIdx);
            if (oEf) oEf.style.backgroundColor = '#76B900';
            oEf = document.getElementById("album_foto" + i);
            if (oEf) oEf.style.backgroundColor = '#4E7700';
            iCurFotoIdx = i;
        }
    }
}

function gotoAlbumPage(i) {
    var j = iCurFotoPg + i;
    if (j > 0 && j < 6) {
        var k = (j - 1) * 10 + 1;
        var oEf = document.getElementById("album_page" + iCurFotoPg);
        var oEt = document.getElementById("album_page" + j);
        if (oEf && oEt) {
            oEf.style.display = 'none';
            oEt.style.display = '';
            viewAlbumFoto(k);
            iCurFotoPg = j;
        }
    }
}

var iCurTabIdx = 1;
function showTabCnt(i) {
    if (i != iCurTabIdx) {
        var oEf = document.getElementById("tab_div_" + iCurTabIdx);
        var oEt = document.getElementById("tab_div_" + i);
        if (oEf && oEt) {
            oEf.style.display = 'none';
            oEt.style.display = '';
            
            oEf = document.getElementById("tab_a_" + iCurTabIdx);
            if (oEf) {
                oEf.style.backgroundColor = '#fff';
                oEf.style.color = '#000';
                oEf.style.fontWeight = "normal";
            }
            oEf = document.getElementById("tab_a_" + i);
            if (oEf) {
                oEf.style.backgroundColor = '#7CC242';
                oEf.style.color = '#fff';
                oEf.style.fontWeight = "bold";
            }
            iCurTabIdx = i;
        }
    }
}

var iCurNumTabIdx = 1;
function chuClickTab(i) {
if (i != iCurTabIdx) {
        var oEf = document.getElementById("chuClickList" + iCurTabIdx);
        var oEt = document.getElementById("chuClickList" + i);
        if (oEf && oEt) {
            oEf.style.display = 'none';
            oEt.style.display = '';
            iCurTabIdx = i;
        }
    }
}

function changeLanguage(target)
{
	var array = new Array("en", "tc");
	var nowL = checkURL(array);
	var va = [["/", "/"], ["=", ""]];
	var url = window.top.location.href;
	for (var item=0; item<va.length; item++)
	{
		if (url.indexOf((va[item][0] + nowL + va[item][1])) >= 0)
		{
			url = url.replace((va[item][0] + nowL + va[item][1]), (va[item][0] + target + va[item][1]));
			break;
		}
	}
	if (url.substring((url.length-1), url.length) == '#')	url = url.substring(0, (url.length-1))
	window.top.location.href = url;
}


function NewWindow(mypage, myname, w, h, scroll,resizable) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resizable+','
	win = window.open(mypage, myname, winprops)
	win.self.focus()
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

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_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_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_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_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_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 AdjustHeight2()
	{
		for (var i=0;i<$(".maxh").length;i=i+2)
		{
			//alert($(".tag_container:eq("+i+")").html());
			var maxheight_h=0;
			for (var j=0;j<2;j++)
			{
				if ((i+j)>=$(".maxh").length)
					break;
				if ($(".maxh:eq("+(i+j)+") .maxh_h").height()>maxheight_h)
					maxheight_h=$(".maxh:eq("+(i+j)+") .maxh_h").height();	
			}
			
			for (var j=0;j<2;j++)
			{
			$(".maxh:eq("+(i+j)+") .maxh_h").height(maxheight_h);
			}
		}
	}
	
function chgAddrDisp(o_e, s_fld) {

    var b_hk = (o_e.options[o_e.selectedIndex].value == "HKG");
    var o_s = document.getElementById("tb_" + s_fld + "_hkg");

    if (o_s) o_s.style.display = (b_hk ? "block" : "none");
        alert(o_s.style.display);
    var o_s = document.getElementById("tb_" + s_fld + "_oth");
    if (o_s) o_s.style.display = (b_hk ? "none" : "block");
        alert(o_s.style.display);
}


function NumFldOnly(o_e) {
    var re = /^[0-9 ]*$/;
    if (!re.test(o_e.value)) {
        o_e.value = o_e.value.replace(/[^0-9 ']/g,"");
    }
}

var mdFldList = '';
var mdFldChkFlag = true;

function chkEmail(s_email) {
    var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    return reg.test(s_email);
}

function noMDFldChk() {
    mdFldChkFlag = false;
    return true
}

function doCardChange(o_f) {
    o_f.dpboxchange.value = 2;
    o_f.action = '';
    noMDFldChk();
    o_f.submit();
}

function doDPChange(o_f) {
    o_f.dpboxchange.value = 1;
    o_f.action = '';
    noMDFldChk();
    o_f.submit();
}

function chkMDFld(o_e, i_lang) {
    var b_flag = true;
    var o_fld;
    if (mdFldList.length > 0 && mdFldChkFlag) {
        a_fld = mdFldList.split("`");
        for (var i = 1; i < a_fld.length - 2; i +=3) {
            var s_fld = a_fld[i + 2];
            if (s_fld.indexOf("(") > 0) {
                //Function call
            } else {
                var b_subflag = false;
                var o_f1;
                var s_err = "";
                s_fld = s_fld.replace(/^\^/, "")
                switch (a_fld[i]) {
                    case "T":
                        var a_oits = s_fld.split("^");
                        
                        for (j = 0; j < a_oits.length; j ++) {
                            eval("o_fld = o_e." + a_oits[j]);
                            eval("o_fldmin = o_e.minlength_" + a_oits[j]);
                            if (j == 0) o_f1 = o_fld;
                            
                            if (o_fldmin) i_mlen = parseInt(o_fldmin.value)
                            else i_mlen = 0
                            b_subflag = b_subflag || Trim(o_fld.value).length > i_mlen;
                        }
                       
                        if (b_subflag && s_fld.toLowerCase().indexOf("email") > -1) {
                            if (!chkEmail(Trim(o_f1.value))) {
                                b_subflag = false;
                                s_err = " - Wrong format";
                            }
                        }
                        break;
                     case "R":
                        eval("o_fld = o_e." + a_fld[i+2]);
                        if (o_fld) {
                            if (o_fld.length) {
                                o_f1 = o_fld[0];
                                for (j = 0; j < o_fld.length; j ++) {
                                    if (o_fld[j].checked) {
                                        b_subflag = true;
                                        o_f1 = o_fld[j];
                                    }
                                }
                            } else {
                                b_subflag = o_fld.checked;
                                o_f1 = o_fld;
                            }
                            
                            if (b_subflag && o_f1.value == 'others') {
                                eval("o_f1 = o_e." + a_fld[i+2] + "_othr");
                                if (o_f1) {
                                    b_subflag = Trim(o_f1.value).length > 0;
                                }
                            }
                            
                        } else {
                            b_subflag = true;
                        }
                        break;
                        
                     case "S":
                        eval("o_f1 = o_e." + a_fld[i+2]);
                        if (o_f1) {
                            b_subflag = o_f1.selectedIndex > 0;
                        } else {
                            b_subflag = true;
                        }
                        break;
                     default:
                        b_subflag = true;
                }
                b_flag = b_flag && b_subflag;
                if (!b_subflag && o_f1) {
                    if (a_fld[i + 1].length > 0) alert(sPlsFill + ": " + a_fld[i + 1] + s_err );
                    o_f1.focus();
                    break;
                }
            }
        }
    }
    return b_flag;
}

function Trim(s_str) {
    if (s_str == null) return "";
	else return s_str.replace(/(^\s+)|(\s+$)/g,"");
}

function chgFMAct(o_e, s_url) {
    var o_f = o_e.form;
    if (o_f) {
        o_f.action = s_url;
    }
}

function gotoDonation(o_f) {
    var o_e = o_f.donationtype;
    var s_dtype = o_e.options[o_e.selectedIndex].value;
    var o_e = o_f.dpincomecode;
    var s_incode = '';
    
    if (o_e[0]) {
        for (var i=0; i< o_e.length; i++) {
           if (o_e[i].checked) {
              s_incode = o_e[i].value;
              break;
           }
        }
     } else {
        if (o_e.checked) { s_incode = o_e.value;}
     }
     
     if (s_incode > '' && s_dtype > '') {
        window.location = s_dtype + '_' + s_incode + '.aspx';
     }
}

-->
