$(document).ready(function () {

		$(".sidenote").each(function(i) {
			pos = $('sup')[i].offsetTop;
			pos2 = 0;
			if (i > 0) { 
				ii = i - 1;
				pos2 = $('.sidenote')[ii].offsetTop + $('.sidenote')[ii].offsetHeight;
				}
			if (pos2 > pos) { pos = pos2; }
			$(this).css( {'width': '140px', 'line-height': '15px', 'position': 'absolute', 'left': '540px', 'margin-top': '0', 'top': pos + 'px'});

		});
		
		$("#sections ul li").each(function() {
			$(this).mouseover(function(){
				$(this).addClass("over");
				$(this).parent().addClass("over");
			});
			$(this).mouseout(function(){
				$(this).removeClass("over");
				$(this).parent().removeClass("over");
			});
		});
		
		$('h1,h2').each(
		    function(){
				$(this).html($(this).html().replace(/fl/g,'&#xFB02;'));
				$(this).html($(this).html().replace(/fi/g,'&#xFB01;'));				
    	}); 
		
 
		$('h1,h2,h3,li,p').each(
		    function(){
        		$(this).html($(this).html().replace(/\s([^\s<]{0,10})\s*$/,'&nbsp;$1'));
		    }
		);
		
		externalLinks();
		if (location.href.split("?")[1]) { 
			x = document.getElementById(location.href.split("?")[1]);
			if(x){$('body,html').animate({scrollTop: $(x).offset().top}, 1000); }
		}


});


function externalLinks() {

 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
  if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external") {
     anchor.target = "_blank"; 
     anchor.className = "offsite";
   }
 }


}