/**
 *	Forms Javascript (mootools)
 * 	@copyright 2008 Fluid Creativity
 */



/**
 * textInput()
 * grab input element's default value and hides it when the
 * user starts typing.
 *
 */
function textInput(input){
	
	/* Temporary (helpful) search phrase */
	var input = $(input);
	/* check search input exists */
	if(!input) return false;
	
	var phrase = input.value;
	
	input.addEvents({

		// On focus - user is ready to search 
		focus: function(){
			/* Remove temporary phrase on focus*/
			if(input.value == phrase){
				input.value = '';
			}			
		}, 
		// On blur - user leaves box
		blur: function() {
			/* Put temporary phrase back in on blur (if left empty) */
			if(input.value == ""){
				//input.value = phrase;
			}
		}
	});

}

/* On load */
window.addEvent('domready', function() {

		/* loop through all form elements and apply function to them */
		$$('form input[type="text"]').each(function(element, index) { 
			// element ID
			var id = element.getAttribute('id');
			textInput(id);
		});
		
		$$('form textarea').each(function(element, index) { 
			// element ID
			var id = element.getAttribute('id');
			textInput(id);
		});
});

