/*

	@Class:	InputClearAndReplace
	@Author:	Brandon Gray for O3 World 2008
	@Brief:	Loops through all inputs/textareas with a class name of 'clear_replace' and clears the default text when focused
			when focus is lost it checks to see if the field is blank, if value is blank the default text is placed back in
			
*/

var InputClearAndReplace = new Class ({
	
	options:
	{
		
		InputElement: '.clear_replace'
		
	},
	
	initialize: function() 
	{
		
		var inputElementList = $$( this.options.InputElement );
		var originalValue = new Array();
		
		inputElementList.each( function( element, i ) {
			
			originalValue.push( inputElementList[ i ].value );
			
			element.onfocus = function() {
				
				if( this.value == originalValue[ i ] ) this.value = '';
				
			},
			
			element.onblur = function() {
				
				if( this.value == '' ) this.value = originalValue[ i ];
				
			}
			
		});
		
	}

});