function initForm() {
  var x = document.getElementById("reg_form");
  if (!x) return;

  var y = x.getElementsByTagName("input");
  for(var i = 0; i < y.length; i++) {
//    alert(y[i].name+":"+y[i].name.indexOf("map"));
    if ((y[i].type == 'text' || y[i].type == 'password' || y[i].type == "checkbox" || y[i].type == "radio")&&y[i].name.indexOf("map")>-1) {
      y[i].onfocus = getFocus;
      y[i].onblur = lostFocus;
//      alert(y[i].name+"---"+getInfobox(y[i]));
      getInfobox(y[i]).className = "normal";
      if (document.getElementById(y[i].name + '.errors')) {
        getInfobox(y[i]).className = "error";
      }
    }
  }

  var y = x.getElementsByTagName("select");
  for(var i = 0; i < y.length; i++) {
      y[i].onfocus = getFocus;
      y[i].onblur = lostFocus;
      getInfobox(y[i]).className = "normal";
  }
}

function getFocus(evnt) {
  var obj;
  if (isIE()) {
    obj = event.srcElement;
  } else {
    obj = evnt.target;
  }
  showInfo(obj,0);
}

function lostFocus(evnt) {
  var obj;
  if (isIE()) {
    obj = event.srcElement;
  } else {
    obj = evnt.target;
  }
  showInfo(obj,-1);
}

function showInfo(obj, errorCode) {
  var infobox = getInfobox(obj);
  if (infobox.className == "error") {return;}
  if (infobox) {
    if (errorCode == 0) {infobox.className = "warning";}
    if (errorCode > 0) {infobox.className = "error";}
    if (errorCode < 0) {infobox.className = "normal"}
  }
}

function getInfobox(obj){
  if(obj&&obj.name){
    var oi=obj.name + "_info";
    var o=document.getElementById(oi);
    if(o){return o;}
  }
  return;
}

function isIE() {
  if (document.all) return true;
  return false;
}

