$(function(){

    $('.popupList').each(function(){

        var list = $(this);

        var popup = list.find('.popup');
        var popupContent = popup.find('.content');
        var driver = list.find('.driver');

        var currentItem = null;
        var timer = null;

        var hidePopup = function(){
            popup.hide();
        }

        list.find('.item').mouseover(function(){

            var $this = $(this);
            popupContent.html($this.find('.popupContent').html());

            var left = $this.position().left + driver.position().left - 25;
            popup.css('left',left);

            popup.show();

            currentItem = this;
            clearInterval(timer);

        }).mouseout(function(){
            if(this == currentItem){
                timer = setTimeout(hidePopup, 100);
            }
        });

        popup.mouseover(function(){
            clearInterval(timer);
        }).mouseout(function(){
            timer = setTimeout(hidePopup, 100);
        });
    });
})
