/* Stolen from Jeremy Keith at adactio.com (-KdB 2006.03.20)*/

/*

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.

This function is triggered when the page loads.
The addLoadEvent.js file is required for this.

*/

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','');

				}
			}
		}
	}
}