function dispersionSearch(obj)
{
	function addInputCallbacks(obj, prompt_text)
	{
		obj.blur(function (e)
		{
			var i = $(this);
			if (i.val() === '')
			{
				i.val(prompt_text);
				i.addClass('empty');
			}
		});

		obj.focus(function (e)
		{
			var i = $(this);
			if (i.val() === prompt_text)
			{
				i.val('');
				i.removeClass('empty');
			}
		});


		obj.parent("form").submit(function (e)
		{
			if (obj.val() === prompt_text)
			{
				obj.val('');
				obj.removeClass('empty');
			}
			return true;
		});
	}


	obj.each(function (index)
	{
		var prompt_text = 'Search';
		var label = $("label[for='" + $(this).attr('id') + "']");
		if (label.length > 0)
		{
			prompt_text = label.html();
			label.hide();
		}
		addInputCallbacks($(this), prompt_text);
		$(this).blur();
	});

}


$(document).ready(function ()
{
	var search_obj = $('.dispersionSearch');
	dispersionSearch(search_obj);
});


