var inpBox = new Object();

function boxGotFocus(e)
{
  myBox = (!window.event) ? e.target:window.event.srcElement;

  if (myBox.value == inpBox[myBox.id])
  {
    myBox.value = "";
        
    if (inpBox[myBox.id] == "Passwort") {
    
      if (window.event) {
      
        document.getElementById("pwd").innerHTML = "<input class=\"loginform\" name=\"Passwort\" id=\"Passwort\" type=\"password\" value=\"\" />";
        
      } else {
      
        myBox.type = "password";
      
      }
      
      setTimeout("document.getElementById('Passwort').focus();",1);
            
    }
        
  }
} 

function boxLostFocus(e)
{ 
  myBox = (!window.event) ? e.target:window.event.srcElement;

  if (myBox.value == "")
  {
    myBox.value = inpBox[myBox.id];
    
    if (inpBox[myBox.id] == "Passwort") {
      
      if (window.event) {
      
        document.getElementById("pwd").innerHTML = "<input class=\"loginform\" name=\"Passwort\" id=\"Passwort\" type=\"text\" value=\"Passwort\" />";
      
      } else {
      
        myBox.type = "text";
      
      }
      
    }
  }
} 

function initBoxes() {

  myElements = document.getElementsByTagName("input");
  for (x=0;x<myElements.length;x++) {
    if ( (myElements[x].className == "loginform") || (myElements[x].className == "searchInput") ) {
    
      //Saving the initial value
      inpBox[myElements[x].id] = myElements[x].value;
      
    	if (document.addEventListener) {
    	  myElements[x].addEventListener("focus",boxGotFocus,false);
    	  myElements[x].addEventListener("blur",boxLostFocus,false);
    	} else {
    	  window.event.cancelBubble = true;
    	  myElements[x].attachEvent("onfocus",boxGotFocus);
    	  myElements[x].attachEvent("onblur",boxLostFocus);
    	}
    }
  }
}

//
// addLoadEvent Function by Simon Williamson
// http://simonwillison.net/2004/May/26/addLoadEvent/
//
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
    	if (oldonload) {
    	  oldonload();
    	}
    	func();
    }
  }
}
			  
addLoadEvent(initBoxes);
