// JavaScript Document to validate form fields

//This function enables the window-onload event to have more than one function see call on individual pages.
/*
function addLoadEvent(func) {
	var oldonload = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = func;
	} else {
		window.onload function() {
			oldonload();
			func();
		}
	}
}
*/


//This function removes the default value when a user focuses on the field to start entering a value

function resetFields(theForm){
	for (var i=0; i<theForm.elements.length; i++){
		var element = theForm.elements[i];
		if (element.type == "submit") continue;
		if (element.type == "reset") 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;
			}
		}
	}
}

// This function prepares the form object to send to resetFields function

function prepareForms() {
	for (var i=0; i<document.forms.length; i++){
		var thisForm = document.forms[i];
		resetFields(thisForm);
	}
}

//
