
// Example 2
function changeInputType(oldElm,iType,iValue,noFocus) {
  if(!oldElm || !oldElm.parentNode || (iType.length<4) ||
    !document.getElementById || !document.createElement) return;
  var newElm = document.createElement('input');
  newElm.type = iType;
  if(oldElm.name) newElm.name = oldElm.name;
  if(oldElm.id) newElm.id = oldElm.id;
  if(oldElm.className) newElm.className = oldElm.className;

  newElm.onfocus = function() {
    if(this.hasFocus) return;
    var newElm = changeInputType(this,'password',
      (this.value.toLowerCase()=='wachtwoord')?'':this.value);
    if(newElm) newElm.hasFocus=true;
  }

  newElm.onblur = function() {
    if(this.hasFocus)
    if(this.value=='' || this.value.toLowerCase()=='wachtwoord') {
      changeInputType(this,'text','wachtwoord',true);
    }
  }
 // hasFocus is to prevent a loop where onfocus is triggered over and over again
  newElm.hasFocus=false;
  oldElm.parentNode.replaceChild(newElm,oldElm);
  if(iValue) newElm.value = iValue;
  if(!noFocus || typeof(noFocus)=='undefined') {
    window.tempElm = newElm;
    setTimeout("tempElm.hasFocus=true;tempElm.focus();",1);
  }
  return newElm;
}

window.onload = function() {
  // Example 1
  var allowInputTypeChange = true;
  var fld1 = document.forms['login'].field1;
  if(document.getElementById) {
    try { // to keep IE from showing errors.
      fld1.type = 'text';
      if(fld1.type == 'text') fld1.value = 'password';
      else allowInputTypeChange = false;
    } catch(e) { allowInputTypeChange = false; }
  }

  document.forms['login'].email.onfocus = function() {
       if(this.value.toLowerCase()=='email')
        this.value = '';
    }

    document.forms['login'].email.onblur = function() {
      if(this.value=='' || this.value.toLowerCase()=='email') {
        this.value = 'email';
      }
    }

  if(allowInputTypeChange) {
    fld1.onfocus = function() {
      var tempVal = this.value; // NS6 fix.
      var iType = this.type; // Opera 7 fix.
      if(this.type != 'password') this.type = 'password';
      this.value = tempVal; // NS6 fix.
      if(this.value.toLowerCase()=='wachtwoord')
        this.value = '';
      if(window.opera && iType != 'password') this.focus();
    }
    fld1.onblur = function() {
      if(this.type == 'password')
      if(this.value=='' || this.value.toLowerCase()=='wachtwoord') {
        this.type = 'text';
        this.value = 'password';
      }
    }
  }

  // Example 2
  // Normally I use object detection, however, in this case since I need to
  // detect Konqueror and Safari which don't have unique objects,
  // I will use the user agent string to detect them. Only use this type of
  // detection as a last resort.
  // I'm doing this because example 2 crashes Konqueror and Safari and
  // generates errors in IE5/Mac
  var ua = navigator.userAgent.toLowerCase();
  if(!((ua.indexOf('konqueror')!=-1) && (document.all ||
    (ua.indexOf('khtml/3.4')!=-1))) && !(((ua.indexOf('safari')!=-1) &&
    !window.print) || (document.defaultCharset && !window.print)))
      changeInputType(document.forms['login'].wachtwoord,'text','wachtwoord',true);


}
// -->
