$(function () {
    $('.bubbleInfo').each(function () {
        var distance = 10;
        var time = 250;
        var hideDelay = 500;

        var hideDelayTimer = null;

        var opacity_start = ($.browser.msie)?1:0;
        var beingShown = false;
        var shown = false;
        var trigger = $('.trigger', this);
        var info = ($.browser.msie)? $('.popup', this) : $('.popup', this).css('opacity', 0);
        var animateParams = ($.browser.msie)
	            ?{bottom: '+=' + distance + 'px'}
	            :{bottom: '+=' + distance + 'px',opacity: 1};
        $([trigger.get(0), info.get(0)]).mouseover(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                if (beingShown || shown) {
                        // don't trigger the animation again
                        return;
                } else {
                        // reset position of info box
                        beingShown = true;
                        info.css({
                                bottom: -11,
                                left: -105,
                                display: 'block'
                        }).animate(animateParams, time, 'swing', function() {
                                beingShown = false;
                                shown = true;
                        });
                }
                return false;
        }).mouseout(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            hideDelayTimer = setTimeout(function () {
                hideDelayTimer = null;
                info.animate(animateParams, time, 'swing', function () {
                    shown = false;
                    info.css('display', 'none');
                });
            }, hideDelay);
            return false;
        });
    });
});
