// ShOptiFind JQuery UI overwrites
$.widget( "custom.catcomplete", $.ui.autocomplete, {
    _renderMenu: function( ul, items ) {
            var self = this,
                    currentCategory = "";
            $.each( items, function( index, item ) {
                    if ( item.category && item.category != currentCategory ) {
                            ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
                            currentCategory = item.category;
                    }
                    self._renderItem( ul, item );
            });
    },
    _renderItem: function( ul, item ) {
            var self = this;
            itemVal = item;
            if(typeof itemVal != "string") {
                itemVal = item.label;
            }
            if(itemVal.indexOf('*') < 0) {
                mlabel = itemVal;
                mvalue = itemVal;
            }
            else {// image!
                mlabel = "<span class='acimg'><img src='" + itemVal.split("*")[1] + "'/></span> " + itemVal.split("*")[0];
                mvalue = itemVal.split("*")[0];
            }
            item.label = mlabel;
            item.value = mvalue;
            return $( "<li></li>" )
                .data( "item.autocomplete", item )
                .append( "<a>" + item.label + "</a>" )
                .appendTo( ul );

    }
});

