/*

	@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 (no new data entered), if value is blank the default text is placed back in
	@Example: <input type="text" name="firstname" id="firstname" value="" class="clear_replace" />
			
*/

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 ];
				
			}
			
		});
		
	}

});

window.addEvent( 'load', function() {
							  
	var InputList = new InputClearAndReplace(); 
	
});