new MasterSearchUtils();   // This is needed to declare the static variables
function MasterSearchUtils()
{
	//-----------------------------------------------------------------------------------------------------------
	// Static functions
	//-----------------------------------------------------------------------------------------------------------

	MasterSearchUtils.init = init;
	
	//-----------------------------------------------------------------------------------------------------------
	// Functions
	//-----------------------------------------------------------------------------------------------------------
	
	function init()
	{
		var returnHTML = '';
		
		$('#master_search').autocomplete
		(
			BASE + '/ajax/search/',
			{
				resultsClass: 'ac_results ac_main_search_results',
				width: 252,
				minChars: 3,
				delay: 300,
				matchSubset: false,
				scrollHeight: 600,
				formatItem:function(item)
				{
					var returnhtml = '';
					
					// Separator between artists and products
					if (item.length > 3 && item[3] == 'first')
					{
						returnhtml += '<hr />';
					}
					
					returnhtml += item[1].length > 4 ? "<img class=\"right\" src=\"" + item[1] + "\" alt=\"\"/>\n" : "";
					
					return returnhtml + item[0];
				}
			}
		);
		
		$('#master_search').autocomplete().result
		(
			function(event, item, formatted)
			{
				if (item[2].length > 4)
				{
					location = item[2];
				}
			}
		);	
	}
}
