/* input placeholder */

function field_input(input, value) {
	var thisCopy = this;
	this.Input = input;
	this.Value = value;
	this.SaveOrig = (input.value == value);
	this.setupEvent (this.Input, 'focus', function() { return thisCopy.onFocus() } );
	this.setupEvent (this.Input, 'blur',  function() { return thisCopy.onBlur() } );
	this.setupEvent (this.Input, 'keydown', function() { return thisCopy.onKeyDown() } );
	if (input.value == '') this.onBlur();
	return this;
}

field_input.prototype.setupEvent = function (elem, eventType, handler) {
	if (elem.attachEvent) elem.attachEvent ('on' + eventType, handler);
	if (elem.addEventListener) elem.addEventListener (eventType, handler, false);
}

field_input.prototype.onFocus = function() {
	if (!this.SaveOrig && this.Input.value == this.Value) {
		this.Input.value = '';
	} else {
		this.Input.style.color = 'black';
	}
}

field_input.prototype.onKeyDown = function() {
	this.Input.style.color = 'black';
}

field_input.prototype.onBlur = function()
{
	if (this.Input.value == '' || this.Input.value == this.Value) {
		this.Input.value = this.Value
		this.Input.style.color = 'gray';
	} else {
		this.Input.style.color = 'black';
	}
}

/* init */

window.onload = function() {

	if(document.getElementById) {
		/* search form */
		var ph = new field_input(document.getElementById('searchFormInput'), 'search input area');
	}

}
