SearchFixer = Class.create();
SearchFixer.prototype = {

 	initialize: function(item, placeholder) {
		this.item = item;
		this.placeholder = placeholder || 'Search';
		
		this.item.value = this.placeholder;
		this.item.style.color = '#a6a6a6';
		
		Event.observe(this.item,'blur',this.LostFocus.bindAsEventListener(this));
		Event.observe(this.item,'focus',this.GotFocus.bindAsEventListener(this));
	},

	GotFocus: function () {
		if (this.item.value == this.placeholder) {
			this.item.value = '';
			this.item.style.color = 'black';
		}
	},
	LostFocus: function () {
		if (this.item.value == '') {
			this.item.value = this.placeholder;
			this.item.style.color = '#a6a6a6';
		}
	}
	
};

if(! Browser.IsWebKit() )
	Event.observe(window, 'load', function() {
		var inputs = document.getElementsByTagName('input');
	
		for (var i = 0; i < inputs.length; i++) {
			if(inputs[i].getAttribute('type') == 'search') {
				new SearchFixer(inputs[i], inputs[i].getAttribute('placeholder'));
			}
		
		}
	}, false);

