$(this).next(".toggle-content").slideToggle();
e.preventDefault();
});
/*
Tooltips
*/
$("#bodyContent").append("<div id='tooltip' style='position:fixed; z-index:150;'></div>");
var tooltipCache = {};
var $tooltip = $("#tooltip");
function tooltipPosition(e) {
var ttHeight = $tooltip.innerHeight() + 15, ttWidth = $tooltip.innerWidth(),
wHeight = $(window).height(), wWidth = $(window).width();
var newTop = e.clientY + ((e.clientY > (wHeight/2)) ? -ttHeight : 15);
newTop = Math.max(0, Math.min(wHeight - ttHeight, newTop));
if((e.clientX + ttWidth +15) < wWidth) {
var newLeft = e.clientX + ((e.clientX > (wWidth/2)) ? -(ttWidth + 15) : 15);
} else {
var newLeft = (wWidth -ttWidth)/2;
}
$tooltip.css({"top":newTop + "px", "left":newLeft + "px"});
}
$('#bodyContent span.tooltip').each( function() {
var $link = $(this).children('a');
var url = $link.attr('href');
$link.removeAttr('title');
$link.hover(function(e) {
if(tooltipCache[url]) {
$tooltip.html(tooltipCache[url]);
} else {
$tooltip.load(url + ' .tooltip', function() {
tooltipCache[url] = $tooltip.html();
tooltipPosition(e);
});
}
$tooltip.css('display','block');
}, function() {
$("#tooltip").css('display','none').empty();
}).mousemove(tooltipPosition);
});