function searchProduct(theme, text, formId) {
	
	$("#globalSearch").autocomplete(
			{
				source : function(request, response) {
					$.ajax( {
						url : '/'+theme+'/productSearchAjax',
						dataType : "json",
						global : false,
						type : "POST",
						data : ( {
							text : text
						}),

						success : function(data) {
							if (data)
							response($.map(data.product, function(item) {

								if (item.id == "0") {
									return {

										label : item.message,
										value : text,
										id : "0"
									}
								}

								if (item.id == "-1") {
									return {

										label : item.message,
										value : text,
										id : "-1"
									}
								}
								
								return {

									label : item.name,
									value : text,
									url : item.url,
									id : item.id
								}
							}))
						}
					})
				},
				minLength : 3,
				select : function(event, ui) {
					if (ui.item && ui.item.id != "0" && ui.item.id != "-1")
						top.location.href = ui.item.url;
					if (ui.item && ui.item.id == "-1")
						document.getElementById(formId).submit();
				},
				open : function() {
					$(this).removeClass("ui-corner-all").addClass(
							"ui-corner-top");
				},
				close : function() {
					$(this).removeClass("ui-corner-top").addClass(
							"ui-corner-all");
				}
			});
}
