function isBlank(field, strBodyHeader) {
    strTrimmed = trim(field.value);
    if (strTrimmed.length > 0) return false;
    alert(strBodyHeader + " 必须填写");
    field.focus();
    return true;
}
function isEmail(field, strBodyHeader){
    emailStr = field.value;
    if(emailStr.length == 0) return false;
    if(!complexEmailCheck(emailStr)) {
        alert(strBodyHeader + " 电子邮件地址不正确");
        field.focus();
        return false;
    }
    return true;
}
function checkGoodName(str, desc) {
    s = trim(str);
    len = s.length; 
    for (i = 0; i < len; i++) {
        b = s.charCodeAt(i);
        if ((b >= toInt('a')) && (b <= toInt('z'))) { // not a cast, it's a function.
            // low chars
        } else if ((b >= toInt('A')) && (b <= toInt('Z'))) {
            // up chars
        } else if ((b >= toInt('0')) && (b <= toInt('9'))) {
            // numbers 
        //} else if (( (b==toInt('_')) || (b==toInt('.')) || (b==toInt('@')) ) && (i != 0)) {
        } else if (( (b==toInt('_')) || (b==toInt('.')) ) && (i != 0)) {
 /*       
		// very litte special chars
        } else if (b > 255){
            // for non-ascii #########################Add by iu###############
 */       
        } else {
            alert(desc + " \"" + s +  "\" " + "不是合法的用户名. 不合法的字符是 \"" + s.charAt(i) + "\""); 
            return false;
            // not good name error
        }
    }
    return true;
}

function toInt(c) {
  return c.charCodeAt(0);
}

function checkEnter(event) {
  var agt=navigator.userAgent.toLowerCase();
  if (agt.indexOf('opera') >= 0) return;
  if (getKeyCode(event) == 13)
	SubmitForm(document.getElementById("globalLoginForm"));
}

function SubmitGlobalLoginForm(f) {
  if (ValidateGlobalForm(f) == true) {
	pw2md52(f.memberPassword, f.md5pw);
	f.submit();
  }
}
function ValidateGlobalForm(f) {
  if (isBlank(f.memberName, "用户名")) return false;
  if (isBlank(f.memberPassword, "密码")) return false;
  //Check Password's length
  if (f.memberPassword.value.length < 3) {
	alert("密码长度至少应有6位");
	f.memberPassword.focus();
	return false;
  }
  return true;
}