/*
This is a very handy function written by Simon Willison:
http://simon.incutio.com/archive/2004/05/26/addLoadEvent
*/

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

		}
	}
}


/*
This function loops through all the text inputs on a page and stores their default values.
When a text input is brought into focus, its current value is checked against its default value.
If they are the same, the value is cleared.

This allows you to add placeholder text to inputs (recommended for accessibility) but users don't have to manually delete the placeholder text.

Written by Jeremy Kieth http://adactio.com
*/

addLoadEvent(clearInputs);
function clearInputs() {
	if (!document.getElementsByTagName) return false;
	var all_inputs = document.getElementsByTagName('input');
	for (var i=0;i<all_inputs.length;i++) {
		var current_input = all_inputs[i];
		if (current_input.getAttribute('type') == 'text' && current_input.getAttribute('value') != '') {
			current_input.default_text = current_input.getAttribute('value');
			current_input.onfocus = function() {
				if (this.getAttribute('value') == this.default_text) {
					this.setAttribute('value','');
				}
			}
		}
	}
}

/* function for suckerfish dropdowns */

function menuFix() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
		this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		// event added to keep menu items from disappearing
		sfEls[i].onMouseDown=function() {
		this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		// event added to keep menu items from disappearing
		sfEls[i].onMouseUp=function() {
		this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		sfEls[i].onmouseout=function() {
		this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
		}
	}
}


addLoadEvent(menuFix);

