function Placeholder(input, cssHolder) {
	var thisCopy = this;
	
	this.input = input;
	this.value = input.getAttribute("placeholder");
	this.cssDefault = input.className;
	this.cssHolder = cssHolder;
	input.className = this.cssDefault + ' ' + this.cssHolder;
	this.saveOriginal = (input.value == this.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;
}

Placeholder.prototype.setupEvent = function(elem, eventType, handler) {
	if(elem.attachEvent) elem.attachEvent('on' + eventType, handler);
	if(elem.addEventListener) elem.addEventListener(eventType, handler, false);
}

Placeholder.prototype.onFocus = function() {
	if (!this.saveOriginal && this.input.value == this.value) {
		this.input.value = '';
	} else {
		this.input.className = this.cssDefault;
	}
}

Placeholder.prototype.onBlur = function() { 
	if (this.input.value == '' || this.input.value == this.value) {
		this.input.value = this.value
		this.input.className = this.cssDefault + ' ' + this.cssHolder;
	} else {
		this.input.className = this.cssDefault;
	}
}

Placeholder.prototype.onKeyDown = function() { this.input.className = this.cssDefault; }

function menu($id) {
	var c = document.getElementById("category_" + $id);
	if(c.className == "") {
		c.className = "hide";
	} else {
		c.className = "";
	}
}

function pmenu($id) {
	var c = document.getElementById("pcategory_" + $id);
	if(c.className == "") {
		c.className = "hide";
	} else {
		c.className = "";
	}
}

window.onload = function() {
	if(document.getElementById) {
		var phSearch = new Placeholder(document.getElementById('search-field'), 'placeholder');
		if(document.getElementById('mailbox-field')) {
			var phMailbox = new Placeholder(document.getElementById('mailbox-field'), 'placeholder');
		}
	}
}