_clrd = null;
function _clrdSetup()
{
	if (_clrd != null)
		_clrd.setup();
}

ClearDefault = function()
{
	this.elements		= [];
	this.defaultValues	= new Array();
}

ClearDefault.prototype.init = function()
{
	_clrd = this;
	jQuery(document).ready(_clrdSetup);
}

ClearDefault.prototype.setup = function()
{
	this.elements = jQuery(".cleardefault");
	
	// Save the default values and add ID's if needed
	for (var i = 0; i < this.elements.length; i++)
	{
		var el = this.elements[i];

		// Get and set ID if needed
		var id = el.id;
		if (id == "" || typeof(id) == "undefined")
		{
			id = "ClearDefault" + Math.round(Math.random()*10000);
			el.id = id;
		}
		
		this.defaultValues[id] = el.value;
	}
	
	// Set what must happen on focus
	this.elements.focus(
		function() 
		{
			if (this.value == _clrd.defaultValues[this.id])
				this.value = "";
		}
	);
	
	// Set what must happen on blur
	this.elements.blur(
		function() 
		{
			// Only when empty
			if (this.value != "")
				return;
			
			this.value = _clrd.defaultValues[this.id];
		}
	);
}

new ClearDefault().init();