bh.associated_info = function() {

  var that = {},
      container = $('div.associated_content');

  if(container.length > 0) {

    (function() {

      container.find('li a').hover(function() {
        var link = $(this).clone(),
            text = $(this).closest('li').find('p').clone(),
            top, left, popout;

        if(bh.popout) bh.popout.remove();

        bh.popout = $('<div class="popout associated_info"></div>').css('position', 'absolute');

        popout = bh.popout;

        link.text(link.attr('title'));

        $('<div></div>').append(link).append(text).appendTo(popout);

        popout.appendTo('body');

        popout.hide().fadeIn();

        top = ($(this).offset().top - popout.height()) + 112;
        left = $(this).offset().left - popout.width();

        popout.css({
          top: top,
          left: left
        });

      }, function() {
        if(bh.popout) bh.popout.remove();
      });

    })();

    container.find('ul').each(function() {
      var lis = $(this).find('li');

      if(lis.length > 2) {
        var li = $(lis[2]),
            ul = lis.first().closest('ul');

        var link = $('<a></a>', {
          "class": "view_all",
          text: "Expand",
          click: function() {
            var height = ul.css("height");

            if(height === 'auto') {
              set_box_height();
            } else {
              ul.css('height', 'auto');
              $(this).text("Collapse");
            }
          }
        });

        var set_box_height = function() {
          var css    = {height: '25px', overflow: 'hidden'},
              height;

          ul.css(css);

          height = li.position().top;

          height = 50;
          ul.height(height);

          link.text("Expand");

          ul.css('position','');
        };

        link.appendTo(ul.closest('div'));

        set_box_height();
      }
    });

  }

  return that;
};

$(function() {
  bh.associated_info();
})

