//allgemeine javascript-anweisungen
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

// dom scripting, p. 285f
addLoadEvent(prepareForms);
function prepareForms(){
	for (var i=0; i<document.forms.length; i++) {
		var thisform = document.forms[i];
		resetFields(thisform);
		/* thisform.onsubmit = function() {
			return validateFields(this);
		} */
	}
}

/*
	fragt in jeder form die default-werte der input-felder ab, 
	macht bei onfocus das input-feld leer und 
	bei onblur wieder den alten text rein...
*/
function resetFields(whichform){
	for (var i=0; i<whichform.elements.length; i++) {
		var element = whichform.elements[i];
		if (element.type == "submit") continue;
		if (!element.defaultValue) continue;
		
		element.onfocus = function(){
			if (this.value == this.defaultValue) {
				this.value = "";
			}
		}
		
		element.onblur = function() {
			if (this.value == "") {
				this.value = this.defaultValue;
			}
		}
	}
}
