function field_check(A, C, B) {
  if (C.indexOf("cpwd") > -1) {
    strTmp = C.split("#");
    if (strTmp[0].inc("cpwd", "/") == true && B.value != $(strTmp[1]).value) {
      return "The " + A + " must match your " + A.split(" Confirmation")[0]
    }
  }
  if (C.inc("eml", "/") == true && !/(\,|^)([\w+._]+@\w+\.(\w+\.){0,3}\w{2,4})/.test(B.value.replace(/-|\//g, "")) && !isNone(B.value)) {
    return "Is your " + A + " correct? Sorry, my system does not understand your email address."
  }
  if (C.inc("tel", "/") == true && !/(^[0-9+-]{3,30}$)/.test(B.value) && !isNone(B.value)) {
    return "Is your " + A + " correct? Sorry, my system does not understand your telephone format."
  }
  size = C.sub("min", "/");
  if (size > 0) {
    if (B.value.trim().length < size && B.value.trim().length > 0) {
      return "Is your " + A + " correct? Our system requires a minimum of " + size + " characters."
    }
  }
  size = C.sub("max", "/");
  if (size > 0) {
    if (B.value.trim().length > size) {
      return "Is your " + A + " correct? Our system requires a maximum of " + size + " characters."
    }
  }
  if (C.inc("nnull", "/") == true && isNone(B.value)) {
    return "Sorry, " + A + " information is required."
  }
  if (C.inc("ischeck", "/") == true && !B.checked) {
    return A
  }
  if (C.inc("isselect", "/") == true && B.value == "-1") {
    return 'Please Choose "' + A + '"'
  }
  return ""
}
function fmChk(E) {
  var A, F, D, C, B;
  if (E == null || E.tagName != "FORM") {
    alert("", null, "error");
    return
  }
  for (i = 0; i < E.length; i++) {
    var C = chkInput(E[i]);
    if (C != "success") {
      efocu(E[i]);
      msg(C);
      return false
    }
  }
  return true
}
function chkInput(D) {
  var A, C, B;
  A = D.getAttribute("chkName");
  C = D.getAttribute("chkRule");
  if (isNone(C) || isNone(A)) {
    return "success"
  }
  B = field_check(A, C, D);
  if (B != "") {
    return B
  } else {
    return "success"
  }
}
function msg(A) {
  alert(A)
}
function initForm(el, func) {
  var img_path = baseURL + "includes/templates/ndesign/images/checkout"; (new Image(10, 10)).src = img_path + "/ico_F.gif";
  var error_bg = "#FEDFDF",
  blur_bg = "",
  focus_bg = "#FFFEE1";
  var formId = $(el);
  if (formId == null || formId.tagName != "FORM") {
    alert("", null, "error");
    return
  }
  var addImage = '<img src="' + img_path + '/ico_T.gif" width="10" height="10" style="display:none;" class="pad_l"/>';
  var addDiv = '<div style="display:none;" class="red line_120"></div>';
  var elArr = formId.elements;
  var elLen = elArr.length;
  for (i = 0; i < elLen; i++) {
    var addHtml = elArr[i].getAttribute("chkRule");
    if (addHtml) {
      insHtm(elArr[i], addImage);
      insHtm(elArr[i], addDiv);
      elArr[i].onfocus = function() {
        if ((this.tagName === "INPUT" && (this.type === "text" || this.type === "password")) || this.tagName === "TEXTAREA") {
          this.style.backgroundColor = focus_bg
        }
      };
      elArr[i].onblur = function() {
        this.style.backgroundColor = blur_bg;
        var out_img = this.parentNode.getElementsByTagName("img")[0];
        var out_text = this.parentNode.getElementsByTagName("div")[0];
        var msg = chkInput(this);
        if (msg === "success") {
          out_img.src = img_path + "/ico_T.gif";
          out_img.style.display = "inline";
          out_text.style.display = "none"
        } else {
          out_img.src = img_path + "/ico_F.gif";
          out_img.style.display = "inline";
          out_text.innerHTML = msg;
          out_text.style.display = "block";
          if ((this.tagName === "INPUT" && (this.type === "text" || this.type === "password")) || this.tagName === "TEXTAREA") {
            this.style.backgroundColor = error_bg
          }
        }
        if (func != null) {
          try {
            eval(func)
          } catch(e) {}
        }
      }
    } else {
      if ((elArr[i].tagName === "INPUT" && (elArr[i].type === "text" || elArr[i].type === "password")) || elArr[i].tagName === "TEXTAREA") {
        elArr[i].onfocus = function() {
          this.style.backgroundColor = focus_bg
        };
        elArr[i].onblur = function() {
          this.style.backgroundColor = blur_bg;
          if (func != null) {
            try {
              eval(func)
            } catch(e) {}
          }
        }
      }
    }
  }
};