﻿var WatermarkLabel = Class.create({
	initialize: function(id) {
	this.textbox = $(id);
	this.text = '';

	var labels = $$('label[for="' + id + '"]');
	if(labels.length) {
		this.text = labels[0].innerHTML;
		Element.hide(labels[0]);
	}

	this.textbox.observe('focus', this.focus.bindAsEventListener(this));
	this.textbox.observe('blur', this.blur.bindAsEventListener(this));
	this.blur();
	},

	focus: function(event) {
	if(this.empty)
	this.textbox.value = '';
	this.empty = false;
	this.textbox.removeClassName('inside');
	},

	blur: function(event) {
	if(this.textbox.value == '') {
		this.textbox.value = this.text;
		this.textbox.addClassName('inside');
		this.empty = true;
		}
	}
});

