/*
 * jdMenu 1.4.0 (2008-01-25)
 */

(function($){
	$.jdMenu = {
		settings: 	[],
		getSettings: 	function( element ) {
							var t = $(element).parents('ul.ul_jd_menu:eq(0)')[0];
							return this.settings[ t && t.$jdSettings ? t.$jdSettings : 0 ];
						}
	};

	function activateMenu(ul) {
		var ul = $(ul);
		var li = ul.parent();
		ul	.trigger('jdMenuShow')
			.positionBy({ 	target: 	li[0],
							targetPos: 	( li.parent().is('.ul_jd_menu') ? 3 : 1 ),
							elementPos: 0
							});
		li	.addClass('jdm_active')
			// Hide any adjacent menus
			.siblings('li').find('ul:eq(0):visible')
				.each(function(){
					hideMenu( this );
				});
	}

	function hideMenu(ul) {
		$(ul)
			.filter(':not(.ul_jd_menu)')
			.find('> li ul:eq(0):visible')
				.each(function() {
					hideMenu( this );
				})
			.end()
			.hide()
			.trigger('jdMenuHide')
			.parents('li:eq(0)')
				.removeClass('jdm_active jdm_hover')
			.end()
				.find('> li')
				.removeClass('jdm_active jdm_hover');
	}

	function getSettings(element) {
		return $.data( $(element).is('.ul_jd_menu') ? element : $(element).parents('ul.ul_jd_menu')[0], 'jdMenuSettings');;
	}

	// Public methods
	$.fn.jdMenu = function(settings) {
		var settings = $.extend({	activateDelay: 	500,
					showDelay: 		450,
					hideDelay: 		1000
					}, settings);
		return this.filter('ul.ul_jd_menu').each(function() {
			$.data(this, 'jdMenuSettings', settings);
			$('li', this)
				.bind('mouseenter.jdmenu', function() {
					$(this).addClass('jdm_hover');
					var ul = $('ul:eq(0)', this);
					if ( ul.length == 1 ) {
						var me = this;
						clearTimeout( this.$jdTimer );
						this.$jdTimer = setTimeout(function() {
							activateMenu( ul );
						}, getSettings(this).showDelay );
					}
				})
				.bind('mouseleave.jdmenu', function(){
					$(this).removeClass('jdm_hover');
					var ul = $('ul:eq(0)', this);
					if ( ul.length == 1 ) {
						var settings = $.jdMenu.getSettings( this );
						var me = this;
						clearTimeout( this.$jdTimer );
						this.$jdTimer = setTimeout(function() {
							hideMenu( ul );
						}, getSettings(this).hideDelay );
					}
				})
				.bind('click.jdmenu', function(evt) {
					var ul = $('> ul', this);
					if ( ul.length == 1 ) {
						activateMenu( ul );
						return false;
					}

					// The user clicked the li and we need to trigger a click for the a
					if ( evt.target == this ) {
						var link = $('> a', evt.target).not('.accessible');
						if ( link.length > 0 ) {
							var a = link[0];
							if ( !a.onclick ) {
								window.open( a.href, a.target || '_self' );
							} else {
								$(a).trigger('click');
							}
						}
					}
					$(this).parent().jdMenuHide();
					evt.stopPropagation();
				})
				.bind('keydown.jdmenu', function(e) {
					if ( e.which == 27 ) {
						if ( !$(this).parent().is('.ul_jd_menu') ) {
							hideMenu( $(this).parent()[0] );
						}
						$(this).parents('li:eq(0)').find('a:eq(0)').trigger('focus');
						return false;
					}
				})
				.find('> a')
					.bind('focus.jdmenu', function() {
						$(this).parents('li:eq(0)').addClass('jdm_hover');
					})
					.bind('blur.jdmenu', function() {
						$(this).parents('li:eq(0)').removeClass('jdm_hover');
					})
					.filter('.accessible')
						.bind('click.jdmenu', function(evt) {
							evt.preventDefault();
						});
		});
	};

	$.fn.jdMenuUnbind = function() {
		$('li', this)
			.unbind('mouseenter.jdmenu mouseleave.jdmenu click.jdmenu keydown.jdmenu')
			.find('> a').unbind('focus.jdmenu blur.jdmenu click.jdmenu');
		return this;
	};

	$.fn.jdMenuHide = function() {
		return this.filter('ul').each(function(){ hideMenu( this ); });
	};

	// Private methods and logic
	$(window)
		// Bind a click event to hide all visible menus when the document is clicked
		.bind('click.jdmenu', function(){
			$('ul.ul_jd_menu ul:visible').jdMenuHide();
		});
})(jQuery);

/*///////////////////////////////////////////////////////////////////////*/

/*JQUERY DIMENSIONS*/

(function($){

$.dimensions = {
	version: '@VERSION'
};

// Create innerHeight, innerWidth, outerHeight and outerWidth methods
$.each( [ 'Height', 'Width' ], function(i, name){

	// innerHeight and innerWidth
	$.fn[ 'inner' + name ] = function() {
		if (!this[0]) return;

		var torl = name == 'Height' ? 'Top'    : 'Left',  // top or left
		    borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right

		return this.is(':visible') ? this[0]['client' + name] : num( this, name.toLowerCase() ) + num(this, 'padding' + torl) + num(this, 'padding' + borr);
	};

	// outerHeight and outerWidth
	$.fn[ 'outer' + name ] = function(options) {
		if (!this[0]) return;

		var torl = name == 'Height' ? 'Top'    : 'Left',  // top or left
		    borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right

		options = $.extend({ margin: false }, options || {});

		var val = this.is(':visible') ?
				this[0]['offset' + name] :
				num( this, name.toLowerCase() )
					+ num(this, 'border' + torl + 'Width') + num(this, 'border' + borr + 'Width')
					+ num(this, 'padding' + torl) + num(this, 'padding' + borr);

		return val + (options.margin ? (num(this, 'margin' + torl) + num(this, 'margin' + borr)) : 0);
	};
});

// Create scrollLeft and scrollTop methods
$.each( ['Left', 'Top'], function(i, name) {
	$.fn[ 'scroll' + name ] = function(val) {
		if (!this[0]) return;

		return val != undefined ?

			// Set the scroll offset
			this.each(function() {
				this == window || this == document ?
					window.scrollTo(
						name == 'Left' ? val : $(window)[ 'scrollLeft' ](),
						name == 'Top'  ? val : $(window)[ 'scrollTop'  ]()
					) :
					this[ 'scroll' + name ] = val;
			}) :

			// Return the scroll offset
			this[0] == window || this[0] == document ?
				self[ (name == 'Left' ? 'pageXOffset' : 'pageYOffset') ] ||
					$.boxModel && document.documentElement[ 'scroll' + name ] ||
					document.body[ 'scroll' + name ] :
				this[0][ 'scroll' + name ];
	};
});

$.fn.extend({
	position: function() {
		var left = 0, top = 0, elem = this[0], offset, parentOffset, offsetParent, results;

		if (elem) {
			// Get *real* offsetParent
			offsetParent = this.offsetParent();

			// Get correct offsets
			offset       = this.offset();
			parentOffset = offsetParent.offset();

			// Subtract element margins
			offset.top  -= num(elem, 'marginTop');
			offset.left -= num(elem, 'marginLeft');

			// Add offsetParent borders
			parentOffset.top  += num(offsetParent, 'borderTopWidth');
			parentOffset.left += num(offsetParent, 'borderLeftWidth');

			// Subtract the two offsets
			results = {
				top:  offset.top  - parentOffset.top,
				left: offset.left - parentOffset.left
			};
		}

		return results;
	},

	offsetParent: function() {
		var offsetParent = this[0].offsetParent;
		while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && $.css(offsetParent, 'position') == 'static') )
			offsetParent = offsetParent.offsetParent;
		return $(offsetParent);
	}
});

function num(el, prop) {
	return parseInt($.curCSS(el.jquery?el[0]:el,prop,true))||0;
};

})(jQuery);

/*/////////////////////////////////////////////////////////////////////////////////////*/

/*JQUERY POSITIONBY*/
(function($){var A=function(a,b,c,d){this.x1=a;this.x2=c;this.y1=b;this.y2=d};A.prototype.contains=function(a){return(this.x1<=a.x1&&a.x2<=this.x2)&&(this.y1<=a.y1&&a.y2<=this.y2)};A.prototype.transform=function(x,y){return new A(this.x1+x,this.y1+y,this.x2+x,this.y2+y)};$.fn.positionBy=function(q){var r=new Date();if(this.length==0){return this}var q=$.extend({target:null,targetPos:null,elementPos:null,x:null,y:null,positions:null,addClass:false,force:false,container:window},q);if(q.x!=null){var s=q.x;var t=q.y;var u=0;var v=0}else{var w=$($(q.target)[0]);var u=w.outerWidth();var v=w.outerHeight();var x=w.offset();var s=x.left;var t=x.top}var y=s+u;var z=t+v;return this.each(function(){var c=$(this);if(!c.is(':visible')){c.css({left:-3000,top:-3000}).show()}var d=c.outerWidth();var e=c.outerHeight();var f=[];var g=[];f[0]=new A(y,t,y+d,t+e);g[0]=[1,7,4];f[1]=new A(y,z-e,y+d,z);g[1]=[0,6,4];f[2]=new A(y,z,y+d,z+e);g[2]=[1,3,10];f[3]=new A(y-d,z,y,z+e);g[3]=[1,6,10];f[4]=new A(s,z,s+d,z+e);g[4]=[1,6,9];f[5]=new A(s-d,z,s,z+e);g[5]=[6,4,9];f[6]=new A(s-d,z-e,s,z);g[6]=[7,1,4];f[7]=new A(s-d,t,s,t+e);g[7]=[6,0,4];f[8]=new A(s-d,t-e,s,t);g[8]=[7,9,4];f[9]=new A(s,t-e,s+d,t);g[9]=[0,7,4];f[10]=new A(y-d,t-e,y,t);g[10]=[0,7,3];f[11]=new A(y,t-e,y+d,t);g[11]=[0,10,3];f[12]=new A(y-d,t,y,t+e);g[12]=[13,7,10];f[13]=new A(y-d,z-e,y,z);g[13]=[12,6,3];f[14]=new A(s,z-e,s+d,z);g[14]=[15,1,4];f[15]=new A(s,t,s+d,t+e);g[15]=[14,0,9];if(q.positions!==null){var h=q.positions[0]}else if(q.targetPos!=null&&q.elementPos!=null){var h=[];h[0]=[];h[0][0]=15;h[0][1]=7;h[0][2]=8;h[0][3]=9;h[1]=[];h[1][0]=0;h[1][1]=12;h[1][2]=10;h[1][3]=11;h[2]=[];h[2][0]=2;h[2][1]=3;h[2][2]=13;h[2][3]=1;h[3]=[];h[3][0]=4;h[3][1]=5;h[3][2]=6;h[3][3]=14;var h=h[q.targetPos][q.elementPos]}var i=f[h];var j=h;if(!q.force){$window=$(window);var k=$window.scrollLeft();var l=$window.scrollTop();var m=new A(k,l,k+$window.width(),l+$window.height());var n;if(q.positions){n=q.positions}else{n=[h]}var o=[];while(n.length>0){var p=n.shift();if(o[p]){continue}o[p]=true;if(!m.contains(f[p])){if(q.positions===null){n=jQuery.merge(n,g[p])}}else{i=f[p];break}}}c.parents().each(function(){var a=$(this);if(a.css('position')!='static'){var b=a.offset();i=i.transform(-b.left,-b.top);return false}});c.css({left:i.x1,top:i.y1});if(q.addClass){c.removeClass('positionBy0 positionBy1 positionBy2 positionBy3 positionBy4 positionBy5 '+'positionBy6 positionBy7 positionBy8 positionBy9 positionBy10 positionBy11 '+'positionBy12 positionBy13 positionBy14 positionBy15').addClass('positionBy'+p)}})}})(jQuery);

