(function($){
	
	// jQEm v0.2: http://davecardwell.co.uk/geekery/javascript/jquery/jqem/
	eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(c/a))+String.fromCharCode(c%a+161)};while(c--){if(k[c]){p=p.replace(new RegExp(e(c),'g'),k[c])}}return p}('× ¢(){¿ ¾={\'²\':¢(»){£ »!=¤?¡.²=»:¡.²},\'¬\':¢(){£ ¡.¬()},\'«\':¢(¥){£ ¡.«(¥)},\'¯\':¢(¥){£ ¡.¯(¥)},\'¨\':¢(­,¶){£ ¡.¨(­,¶)},\'ª\':¢(){£ ¡.ª},\'³\':¢(¸){£ ¸?¡.³=¸:¡.³},\'©\':¢(){£ ¡.©()},\'°\':¢(){£ ¡.°()},\'§\':¢(){£ ¡.§},\'±\':¢(){£ ¡.±}};$.Ã=¾;¿ ¡={\'e\':$(Á.Ç(\'i\')),\'ª\':·,\'´\':¤,\'§\':¤,\'³\':È,\'½\':¤,\'±\':¤,\'²\':Å,\'¬\':¬,\'«\':«,\'¯\':¯,\'¨\':¨,\'º\':¢(){¡.¨(·);£\'¼\'},\'©\':©,\'°\':°};$(Á).É(¢(){¦(¡.²)¬()});¢ ¬(){$(\'Ê\').Ë(¡.e.Ì({\'Í\':\'Î\',\'Ï\':\'-¼\',\'Ð\':\'Ñ\',\'Ó\':\'Ô\',\'®\':\'¼\'}));¡.´=(¡.e.µ!=¤&&¡.e.µ.Â!=¤);¡.©()};¢ «(¥){¡.e.«(\'¹\',¥)};¢ ¯(¥){¡.e.¯(\'¹\',¥)};¢ ¨(­,¶){¦(­==¤)­=·;¦(­||¡.e.®()!=¡.§){¡.±=¡.§;¡.§=¡.e.®();$.Æ.¨(\'¹\',¶)}};¢ ©(){¦(¡.ª)£;¡.§=¡.±=¡.e.®();¦(¡.´){¡.e.µ.Â(\'®\',\'$.Ã.º();\')}À{¡.½=Ä.Ò(¡.º,¡.³)}¡.ª=Å};¢ °(){¦(!¡.ª)£;¦(¡.´){¡.e.µ.Õ(\'®\')}À{Ä.Ö(¡.½)}}}();',55,55,'Private|function|return|undefined|callback|if|current|trigger|start|active|bind|init|force|width|unbind|stop|previous|auto|delay|canExp|style|args|false|milliseconds|emchange|update|bool|1em|iid|Public|var|else|document|setExpression|jqem|window|true|event|createElement|100|ready|body|prepend|css|display|block|left|position|absolute|setInterval|visibility|hidden|removeExpression|removeInterval|new'.split('|')));

	/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
	 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
	 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
	 * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
	 */
	$.fn.bgIframe = $.fn.bgiframe = function(o) {
		// This is only for IE6
		if ( !($.browser.msie && typeof XMLHttpRequest == 'function') ) return this;
		o = $.extend({
			top     : 'auto', // auto == .currentStyle.borderTopWidth
			left    : 'auto', // auto == .currentStyle.borderLeftWidth
			width   : 'auto', // auto == offsetWidth
			height  : 'auto', // auto == offsetHeight
			opacity : true,
			src     : 'javascript:false;'
		}, o || {});
		var prop = function(n){return n&&n.constructor==Number?n+"px":n;},
		    html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+o.src+'"'+
		               'style="display:block;position:absolute;z-index:-1;'+
			               (o.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+
					       'top:'+(o.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(o.top))+';'+
					       'left:'+(o.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(o.left))+';'+
					       'width:'+(o.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(o.width))+';'+
					       'height:'+(o.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(o.height))+';'+
					'"/>';
		return this.each(function() {
			if ( !$('iframe.bgiframe', this)[0] )
				this.insertBefore( document.createElement(html), this.firstChild );
		});
	};

	/* scrollTo taken from the Interface plugin for jQuery
	 * Copyright (c) 2006 Stefan Petre - http://interface.eyecon.ro
	 */
	eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('3.R=6(e){7 l=0;7 t=0;7 w=3.a(3.X(e,\'1e\'));7 h=3.a(3.X(e,\'1f\'));7 m=e.L;7 B=e.F;1a(e.S){l+=e.T+(e.8?3.a(e.8.W):0);t+=e.V+(e.8?3.a(e.8.10):0);e=e.S}l+=e.T+(e.8?3.a(e.8.W):0);t+=e.V+(e.8?3.a(e.8.10):0);c{x:l,y:t,w:w,h:h,m:m,B:B}};3.1d=6(e){b(e){w=e.k;h=e.C}f{w=(d.Y)?d.Y:(1.4&&1.4.k)?1.4.k:1.9.L;h=(d.H)?d.H:(1.4&&1.4.C)?1.4.C:1.9.F}c{w:w,h:h}};3.U=6(e){b(e){t=e.i;l=e.A;w=e.r;h=e.D}f{b(1.4&&1.4.i){t=1.4.i;l=1.4.A;w=1.4.r;h=1.4.D}f b(1.9){t=1.9.i;l=1.9.A;w=1.9.r;h=1.9.D}}c{t:t,l:l,w:w,h:h}};3.a=6(v){v=12(v);c 14(v)?0:v};3.16.E=6(s){o=3.17(s);c u.18(6(){n 3.P.E(u,o)})};3.P.E=6(e,o){7 z=u;z.o=o;z.e=e;z.p=3.R(e);z.s=3.U();z.J=6(){1b(z.j);z.j=1c};z.t=(n N).Z();z.M=6(){7 t=(n N).Z();7 p=(t-z.t)/z.o.I;b(t>=z.o.I+z.t){z.J();11(6(){z.q(z.p.y,z.p.x)},13)}f{G=((-g.O(p*g.Q)/2)+0.5)*(z.p.y-z.s.t)+z.s.t;K=((-g.O(p*g.Q)/2)+0.5)*(z.p.x-z.s.l)+z.s.l;z.q(G,K)}};z.q=6(t,l){d.19(l,t)};z.j=15(6(){z.M()},13)};',62,78,'|document||jQuery|documentElement||function|var|currentStyle|body|intval|if|return|window||else|Math||scrollTop|timer|clientWidth||wb|new|||scroll|scrollWidth|||this||||||scrollLeft|hb|clientHeight|scrollHeight|ScrollTo|offsetHeight|st|innerHeight|duration|clear|sl|offsetWidth|step|Date|cos|fx|PI|getPos|offsetParent|offsetLeft|getScroll|offsetTop|borderLeftWidth|css|innerWidth|getTime|borderTopWidth|setTimeout|parseInt||isNaN|setInterval|fn|speed|each|scrollTo|while|clearInterval|null|getClient|width|height'.split('|'),0,{}));

	/* apply the scroll */
	$.fn.scrollToHash = function(){
		return this.each(function(){
			$(this).click(function(){
				$(this.hash).ScrollTo(1500,'easeout')[0].blur();
				return false;
			});
		});
	};
	
	$.fn.hoverIntent = function(f,g) {
		var t = null;    // timer
		var s = 4;       // sensitivity
		var cX = null;   // currentX
		var cY = null;   // currentY
		var pX = 10000;  // previousX
		var pY = 10000;  // previousY

		// A private function for getting mouse position
		function getMousePosition(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		}

		// A private function for comparing current and previous mouse position
		function compareMouseCoordinates( ev, ob ) {
			// compare x and y positions to see if they've both crossed the threshold
			if ( ( Math.abs(pX-cX) < s ) && ( Math.abs(pY-cY) < s ) ) {
				$(ob).unbind("mousemove",getMousePosition);
				if (t) { clearInterval(t); t = null; }
				return f.apply(ob, [ev]);
			}
			pX = cX;
			pY = cY;
		}

		// A private function for handling mouse 'hovering'
		function handleHover(e) {
			var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
			while ( p && p != this ) try { p = p.parentNode } catch(e) { p = this; };
			if ( p == this ) return false;

			// else e.type == "onmouseover"
			if (e.type == "mouseover") {
				cX = e.pageX;
				cY = e.pageY;
				$(this).bind("mousemove",getMousePosition);

				// copy event object to another object to be passed into t (for IE)
				var ev = $.extend({},e);

				// store this in variable to be passed into t
				var ob = this;
				t = setInterval( function(){compareMouseCoordinates(ev, ob)} , 100 );

			// else e.type == "onmouseout"
			} else {
				$(this).unbind("mousemove",getMousePosition);
				if (t) { clearInterval(t); t = null; }
				return g.apply(this, [e]);
			}
		}

		// Bind the function to the two event listeners
		return this.mouseover(handleHover).mouseout(handleHover);
	};

	$.fn.hoverSwitch = function(over,out,altHover){
		return (altHover) ?
			this.hoverIntent(over,out) :
			this.hover(over,out);
	};
	
	/* a basic contents menu plugin by Joel Birch. Demo page to come. */
	$.cm=[]; //store menu jQ objects
	$.fn.contentMenu = function(o){
		o = $.extend({
			"head"		: "<h3>Navigate this page:</h3>",
			"beforeLink": "Skip to ",
			"divClass"	: "contentMenu",
			"aClass"	: "inPage",
			"insertMethod"	: "insertBefore",
			"insertTarget"	: this.eq(0) }, o || {});
		var $list = $("<ul>");
		var lastInd = this.length-1;
		var lis = '';
		var s = $.cm.length;
		var $menu = $.cm[s] = $('<div class="'+o.divClass+'"></div>').append(o.head,$list);
		$menu[0].serial = s;
		switch (o.insertMethod){
			case "insertAfter":
				$menu.insertAfter(o.insertTarget);
				break;
			case "append":
				o.insertTarget.append($menu);
				break;
			case "prepend":
				o.insertTarget.prepend($menu);
				break;
			default :
				$menu.insertBefore(o.insertTarget);
		}
		return this.each(function(i){
			this.id = this.id || "menu"+s+"-el"+i;
			lis += '<li><a href="#'+this.id+'" class="'+o.aClass+'">'+o.beforeLink+'<em>'+$(this).text()+'</em></a></li>';
			if (i==lastInd){ $list.append(lis); }
		});
	};
	
/*	contentMenuDrawer depends on contentMenu and hoverSwitch
 *	and is optionally enhanced by hoverIntent (not necessary),
 *	jQem (recommended) and scrollTo with scrollToHash (recommended).
 */
	$.fn.contentMenuDrawer = function(o){
		if ($.browser.msie && typeof XMLHttpRequest == 'function') { return false; } //no fixed positioning support in IE6
		o = $.extend({
			head			: '<h3>Navigate this page:</h3>',
			divClass		: 'contentMenuDrawer',
			topPos			: '1em',
			leftAlign		: false,
			hoverIntent		: false
		}, o || {});

		o = $.extend(o, {
			insertMethod	: 'append',
			insertTarget	: $('body')
		});

		this.contentMenu(o);
		
	var $menu = $.cm[$.cm.length-1],
		getMove = function(){
			return ($menu[0].offsetWidth)*-1;
		},
		activateMenu = function(pos,speed,callback){
			if (o.leftAlign) {
				$menu.animate({left:pos},speed,callback);
			} else {
				$menu.animate({right:pos},speed,callback);
			}
		},
		showMenu = function(speed,callback){
			speed = speed || 'normal';
			activateMenu(0,speed,callback);
		},
		hideMenu = function(speed,callback){
			speed = speed || 'normal';
			activateMenu(getMove()+25,speed,callback);
		},
		c = {	position : 'fixed',
					top : o.topPos };
		c[o.leftAlign ? 'left' : 'right' ] = getMove()+'px';
		$menu.css(c);
		showMenu(1000,function(){
			hideMenu(1000,function(){
				$menu.hoverSwitch(showMenu,hideMenu,o.hoverIntent);
				if ($.jqem){
					$menu.bind('emchange',function() {
						clearTimeout($menu[0].timer);
						$menu[0].timer = setTimeout(function() {
							activateMenu(getMove()+25,500);
						},500);
					});
				}
			})
		});
		return this;
	};

/************************* end plugins ****************************/
	
	$(window).load(function() {
		
		$("h3").contentMenuDrawer({
			head		: '<h4>Navigate this page:</h4>',
			divClass 	: 'contentMenu',
			topPos		: '3.5em',
			leftAlign	: false,
			hoverIntent	: true
		});
		
		$("body>.contentMenu")
		.find("a.inPage")
			.scrollToHash();
	});

})(jQuery);