/*
 * When a user clicks on an internal hyperlink decorated with the 'highlight-fragment' class
 * the class 'highlighted-fragment' will be added to the referenced element.
 * 
 * Example:
 *  
 * <a href="#frid" class="highlight-fragment">link to fragment</a>
 * <span id="frid">fragment</span>
 * 
 * Author: geoffroy.noel@cch.kcl.ac.uk
 * v 1.0
 */
$(document).ready(function(){
	var lowlight_fragment = function() {
		$(document.highlighted_fragment).toggleClass("highlighted-fragment", false);
	}
	var highlight_fragment = function(event) {
		lowlight_fragment();
		var el_id = $(this).attr("href");
		if (el_id != null) {
			$(el_id).toggleClass("highlighted-fragment", true);
			document.highlighted_fragment = el_id;
		}
		return true;
	};
	$(".highlight-fragment").click(highlight_fragment);
	$(".highlight-fragment").mouseenter(highlight_fragment);
	//$(".highlight-fragment").mouseout(lowlight_fragment);
});

