$(function()
{
	// Initialise each focus object.
	$('.clearInput').each(function()
	{
		$(this).data('init', getStartingValue(this, 'value'));
		if($(this).val() != $(this).data('init'))
		{
			$(this).addClass('focused');
		}
	});
	
	$('.clearInput').live('focus', function()
	{
		if($(this).val() == $(this).data('init'))
		{
			$(this).addClass('focused').val('');
		}
	});
	
	$('.clearInput').live('blur', function()
	{
		if($(this).val() == '')
		{
			$(this).removeClass('focused').val($(this).data('init'));
		}
	});
	
	// Prevent Default value getting submitted.
	$('.clearInput').parents('form').live('submit', function()
	{
		if($(this).val() == $(this).data('init'))
		{
			$(this).addClass('focused').val('');
		}
		return true;
	});
});

// Used as a way around for $(o).attr('value').
function getStartingValue(object, attrName)
{
	return $(object).attr('title') || object.getAttribute('value') || $(object).text() || null;
}
