function addLoadEvent(func){
    var oldonload = window.onload;
    if(typeof window.onload != 'function'){
        window.onload = func;
    }else{
        window.onload = function(){
            oldonload();
            func();
        }
    }
}

function swapValues() {
  var hint = document.getElementsByClassName("hint");

  if(hint.length > 0) {
    for(var i = 0; i < hint.length; i++) {
			hint[i].className = "empty";
			hint[i].initialValue = hint[i].value;
			
			hint[i].onclick = hint[i].onfocus = function() {
				this.className = "hint";
				if(this.value == this.initialValue) {
					this.value = "";
				}
			}
			
			hint[i].onblur = function() {
				if(this.value == this.initialValue || this.value == "") {
					this.className = "empty";
					this.value = this.initialValue;
				} else {
					this.className = "hint";
				}
			}
    }
  } else {
	return;
  }
}
addLoadEvent(swapValues);