// requires: hasClass, addClass and removeClass from common.js

var InputDefault = function(options)
{

	this.input = document.getElementById(options.id);
	this.defaultValue = options.text;
	this.password = options.password;
	
	if(!this.input || !this.defaultValue) { return false; }
	
	if(this.password == true) { this.input.type = 'text'; }
	this.input.value = this.defaultValue;
	$(this.input).addClass('blurred');
	
	var scope = this;
			
	this.input.onfocus = function() { scope.focus(); }
	this.input.onblur = function() { scope.blur(); }
}

InputDefault.prototype.focus = function()
{
	if(this.input.value == this.defaultValue)
	{
		if(this.password == true) { this.input.type = 'password'; }
		this.input.value = '';
		$(this.input).removeClass('blurred');
	}
}

InputDefault.prototype.blur = function()
{
	if(this.input.value == this.defaultValue || this.input.value == '')
	{
		if(this.password == true) { this.input.type = 'text'; }
		this.input.value = this.defaultValue;
		$(this.input).addClass('blurred');
	}
}

