//<![CDATA[
// fake console.log if there's not firebug running
if (! window.console) {
	window.console = {log : function() {}};
}
function fixFloatingBoxPosition(event) {
	var floatingBoxHeight = jQuery("#floating").height();
	var containigBoxHeight = jQuery("#content").height();
	var containingBoxOffsetTop = jQuery("#content").offset().top;
	var currentDocumentScroll = jQuery(document).scrollTop();
	var top = Math.max(0, Math.floor(currentDocumentScroll - containingBoxOffsetTop));
	// avoid floating box overflows the containing box
	var maxTopValue = containigBoxHeight - floatingBoxHeight;
	top = Math.min(top, maxTopValue);
	jQuery("#floating").css('top', top + 'px');
}
jQuery(document).ready(
		function() {
			jQuery(window).resize(fixFloatingBoxPosition).scroll(fixFloatingBoxPosition);

			// actually, floating content can be not fully loaded yet
			// so this should be invoked by document onload handler
			fixFloatingBoxPosition();
		}
);
//]]>

