$( function() {
	$('#header .sitemenu ul li.current a').css( "border", "none" );

	var $el, leftPos, newWidth;

	/* Add Magic Line markup via JavaScript, because it ain't gonna work without */
	$("#nav").append("<li id='magic-line'></li>");

	/* Cache it */
	var $magicLine = $("#magic-line");

	$magicLine
	.width($(".current").width())
	.css("left", $(".current a").position().left)
	.data("origLeft", $magicLine.position().left)
	.data("origWidth", $magicLine.width());

	$("#nav li").find("a").hover( function() {
		$el = $(this);
		leftPos = $el.position().left;
		newWidth = $el.parent().width();

		$magicLine.stop().animate({
			left: leftPos,
			width: newWidth
		}, 400, "easeOutCirc" );
	}, function() {
		$magicLine.stop().animate({
			left: $magicLine.data("origLeft"),
			width: $magicLine.data("origWidth")
		}, 750, "easeOutBounce" );
	});
	
	
	// Simple amends from 26/05/2011
	
	$('#submenu:empty').hide(); 
	
	$('.sidebarImg').appendTo('#content');
	
	if($('#submenu').is(':visible')) { $('.sidebarImg').css('margin-top','20px') };
});
