// Requires: hasClass, addClass and removeClass from common.js
/*

Usage:
var i = new InputDefault({ 
	id : myid,
	text : 'some text',
	password : false
});

*/

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;
	addClass(this.input, '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 = '';
		removeClass(this.input, '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;
		addClass(this.input, 'blurred');
	}
}
