/**********************
 * set up forms so they auto-populate with the label, and clear the default text when clicked
 * @params: id of form, array of default values
 *********************/
function setup_form(theid, thedefaults){
	
	thelist = document.getElementById(theid);
	
	//thelist.onsubmit = check_form(thelist);
	
	if(!thelist){
		return false;
	}
	
	var thechildren = thelist.elements;
	var childrennodes = "";
	
	for(i = 0; i < thechildren.length; i++){
		if(thechildren[i].className == "text" || thechildren[i].nodeName == "TEXTAREA"){
			thechildren[i].thedefault = (thedefaults[thechildren[i].name] != "") ? thedefaults[thechildren[i].name] : "";
			thechildren[i].onfocus = clearform;
			thechildren[i].onblur = populatefield;
			thechildren[i].onblur();
		}
	}
}

/* called by seupform() - clears an input field when clicked */
function clearform(){
	if(this.value == this.thedefault){
		this.value = "";
	}
}

/* called by setupform() - populates default text in input field */
function populatefield(){
	if(this.value == ""){
		this.value = this.thedefault;
	}else{
		if(this.value != this.thedefault){
			
		}
	}
}

/********
 * Check all form fields and empty any that contain default values
 *******/
function check_form(theform){
	for (var i=0;i<theform.length;i++){
		if(theform.elements[i].thedefault){
			if(theform.elements[i].value == theform.elements[i].thedefault){
				theform.elements[i].value = "";
			}
		}
	}
}