
    function setupMultiSearch() {

        var iTimerId;

        $('#multisearch').each(function () {

            var oSelected     = $(this).find('.selectionlist > .selected:first');
            var oSelection    = $(this).find('.selectionlist > .selection:first');
            var oFormList     = $(this).find('form');

            oFormList.each(function () {
                $(this).hide();
                $(this).unbind('submit').submit(function (oEvent) {
                    var oValue = $(this).find('input[type=text]:first');
                    if (oValue.val().length == 0) {
                        alert('Please type something to search.');
                        oValue.focus();
                        return false;
                    } else {
                        return true;
                    }
                });
            });

            oSelected.unbind('mouseenter').mouseenter(function (oEvent) {
                oEvent.preventDefault();
                var oCss = {'position' : 'absolute', 'z-index' : '999'};
                var oOffset  = oSelected.offset();
                oCss['top']  = oOffset['top'] + oSelected.height();
                oSelection.css(oCss).slideDown('fast');
            }).unbind('mouseleave').mouseleave(function (oEvent) {
                var self = oSelection;
                iTimerId = setTimeout(function () {self.slideUp('fast')}, 250);
            });

            oSelection
                .unbind('mouseenter').mouseenter(function (oEvent) {
                    clearTimeout(iTimerId);
                    oSelection.show();
                })
                .unbind('mouseleave').mouseleave(function (oEvent) {
                    oSelection.slideUp('fast');
                })
                .hide();

            var oSelectionItemList = oSelection.find('li');
            oSelectionItemList.each(function () {
                var oItem = $(this);
                oItem
                .unbind('mouseenter').mouseenter(function (oEvent) {
                    oSelection.show();
                })
                .unbind('click').click(function (oEvent) {
                    oEvent.preventDefault();
                    oSelectionItemList.each(function () {
                        $(this).removeClass('chosen');
                    });
                    oItem.addClass('chosen');
                    var sSearchValue = '';
                    oFormList.each(function () {
                        var sValue = $(this).find('input[type=text]:first').val();
                        if (sValue.length) {
                            sSearchValue = sValue;
                        }
                        $(this).hide();
                    });
                    var oAnchor = oItem.find('a:first');
                    var oForm = $('#' + oAnchor.attr('href').split('#').pop());
                    oForm.find('input[type=submit]:first').val('');
                    oForm.show();
                    oForm.find('input[type=text]:first').val(sSearchValue);
                    oSelected.html('<img src="' + oAnchor.attr('rel') + '" alt="' + oAnchor.attr('title') + '" title="' + oAnchor.attr('title') + '" />');
                    oSelection.slideUp('fast');
                });

                if (oItem.hasClass('chosen')) {
                    oItem.triggerHandler('click');
                }
            });
        });
    }