/*	Please do not duplicate this document with out prior permission.
	This unique combination of code, functions, and variable are copyright to glrrin. */

/*	Form Hints Function List
	Consists of a function list to give hints on the signup page
	
	George Oommen (oommen.6@osu.edu)
	May 17 2007 */

/* Submit Form Once */

function submitonce(theform) {
	//if IE 4+ or NS 6+
	if (document.all || document.getElementById) {
		//screen thru every element in the form, and hunt down "submit" and "reset"
		for (i = 0; i < theform.length; i++) {
			var tempobj = theform.elements[i]
			if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
			//disable em
			tempobj.disabled=true
		}
	}
}

/* Dynamic Removal Of Topics */

function removeOptionsByValue(selectName, value) {
	for (var i = selectName.options.length-1; i >= 0; i--) {
		if (selectName.options[i].value == value) {
			selectName.options[i] = null;
		}
	}
}

/* Load Hints */
	
function addLoadEvent(func) {
	var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				oldonload();
				func();
			}
		}
}

function prepareInputsForHints() {
	var inputs = document.getElementsByTagName("input");
	for (var i=0; i<inputs.length; i++) {
		// test to see if the hint span exists first
		if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
			// the span exists!  on focus, show the hint
			inputs[i].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			// when the cursor moves away from the field, hide the hint
			inputs[i].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}
	// repeat the same tests as above for selects
	var selects = document.getElementsByTagName("select");
	for (var k=0; k<selects.length; k++) {
		if (selects[k].parentNode.getElementsByTagName("span")[0]) {
			selects[k].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
			selects[k].onblur = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "none";
			}
		}
	}
	var textareas = document.getElementsByTagName("textarea");
		for (var m=0; m<textareas.length; m++) {
			textareas[m].onfocus = function () {
				this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
			}
		textareas[m].onblur = function () {
			this.parentNode.getElementsByTagName("span")[0].style.display = "none";
		}
	}
}

addLoadEvent(prepareInputsForHints);