// JavaScript Document
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;
  newElm.onfocus = function() {
    if(this.hasFocus) return;
    var newElm = changeInputType(this,'password',
      (this.value=='Enter Password')?'':this.value);
    if(newElm) newElm.hasFocus=true;
  }
  newElm.onblur = function() {
    if(this.hasFocus)
    if(this.value=='' || this.value=='Enter Password') {
      changeInputType(this,'text','Enter Password',true);
    }
  }
  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[0].field1;
  if(document.getElementById) {
    try { // to keep IE from showing errors.
      fld1.type = 'text';
      if(fld1.type == 'text') fld1.value = 'Enter Password';
      else allowInputTypeChange = false;
    } catch(e) { allowInputTypeChange = false; }
  }
  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=='Enter Password')
        this.value = '';
      if(window.opera && iType != 'Enter Password') this.focus();
    }
    fld1.onblur = function() {
      if(this.type == 'password')
      if(this.value=='' || this.value=='Enter Password') {
        this.type = 'text';
        this.value = 'Enter Password';
      }
    }
  }
var ua = navigator.userAgent;
	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[0].password,'text','Enter Password',true);
}

function upSwitch1(input, defaultValue)
{
	if(defaultValue == "Enter Password" && input.type == "text")
	{	
		try
		{
			var type = input.getAttributeNode("type");
			type.nodeValue = "password";
		}
		catch (e)
		{
			var newInput = document.createElement("input");
			newInput.type = "password";
			input.replaceNode(newInput);
			newInput.id = "password"
			newInput.name = "password";
			newInput.className = "text";
			newInput.onblur = function() { upSwitch2(newInput, "Enter Password"); }
			newInput.focus();
			newInput.focus(); // needs double focus for some reason
			input = newInput;
		}
		input.focus();
	}
	if(input.value == defaultValue)
		input.value = "";
}

function upSwitch2(input, defaultValue)
{
	if(defaultValue == "Enter Password" && input.value == "")
	{
		try
		{
			input.type = "text";
		}
		catch (e)
		{
			var newInput = document.createElement("input");
			newInput.type = "text";
			input.replaceNode(newInput);
			newInput.id = "password"
			newInput.name = "password";
			newInput.className = "text";
			newInput.onfocus = function() { upSwitch1(newInput, "Enter Password"); }
			newInput.value = defaultValue;
			input = null;
			return;
		}
	}
	if(input.value == "")
		input.value = defaultValue;
}