jQuery(function($) {
	
	$("body").addClass("js");
	
	// Make TaxAid tips into mid-article floated panels
	$('.tip').remove().insertAfter('.article .content p:eq(0)');
	
	// Make the magic glossary work
	$('.glossary-term').each(function() {
		var $target = $(this.hash);
		var target_id = $target.attr("id");
		var tooltip_id = target_id + "_tooltip";
		
		var $definition = $('<dl id="' + tooltip_id + '" class="glossary tooltip"></dl>').append( $target.clone().add( $target.next("dd").clone() ) );
		
		var $tooltip = $definition.appendTo( $("#content") );
		
		$tooltip.css({
			"top": $(this).offset()["top"] - $tooltip.height() - 32,
			"left": $(this).offset()["left"] + $(this).width() - 56
		});
		
		$(this).hover(function() {
			$tooltip.show();
		}, function() {
			$tooltip.hide();
		}).click(function() {
			return false;
		});
	});
	
	$('.glossary').hide();
	
	// Olly's folly
	/*
	$('.page-template-page-guide-php #logo, .page-template-page-information-php #logo').clone().attr("id","logo-reverse").appendTo("body");
	if ( $("body").is('.page-template-page-guide-php, .page-template-page-information-php') ) {
		$(window).scroll(function() {
			if ( $(window).scrollTop() < 50) {
				$('.sidebar').css({ position: "absolute", top: "180px" });
			} else {
				$('.sidebar').css({ position: "fixed", top: "130px" });
			}
		});
	}
	*/
	
});

