			/*
			 * stickyfixed - jQuery plugin for verticaly floating anything in a constrained area
			 * 
			 * Example: jQuery('#menu').stickyfixed();
			 * parameters:
			 *		startOffset - the amount of scroll offset after it the animations kicks in
			 *		offsetY		- the offset from the top when the object is animated
			 *		lockBottom	- 'true' by default, set to false if you don't want your floating box to stop at parent's bottom
			 * $Version: 01.0.2010 r1
			 * Copyright (c) 2009 Jib, adapted for theJorid.net from the stickyfloat plugin by Yair Even-Or
			 */
 
			$.fn.stickyfixed = function(options) {
				var $obj 				= this;
				var parentPaddingTop 	= parseInt($obj.parent().css('padding-top'));
				var startOffset 		= $obj.parent().offset().top;
				var opts 				= $.extend({ startOffset: startOffset, offsetY: parentPaddingTop, lockBottom:true }, options);
				if(opts.lockBottom){
					var bottomPos = $obj.parent().height() - $obj.height() + startOffset + parentPaddingTop
						- parseInt($obj.parent().css('margin-bottom')) - parseInt($obj.css('margin-bottom')); //get the maximum scrollTop value
					if( bottomPos < 0 )
						bottomPos = 0;
				}
				$(window).scroll(function () { 
					$obj.stop(); // stop all calculations on scroll event

					var pastStartOffset			= $(document).scrollTop() > opts.startOffset - opts.offsetY;	// check if the window was scrolled down more than the start offset declared.
					var objFartherThanTopPos	= $obj.offset().top > opts.startOffset;	// check if the object is at it's top position (starting point)
					var objBiggerThanWindow 	= $obj.outerHeight() < $(window).height();	// if the window size is smaller than the Obj size, then do not animate.
					var objFartherThanBottomPos	= $(document).scrollTop() > bottomPos - opts.offsetY;
					var isRelative 				= ($obj.css('position')=="relative");
					var isFixed					= ($obj.css('position')=="fixed");
					// if window scrolled down more than startOffset OR obj position is greater than
					// the top position possible (+ offsetY) AND window size must be bigger than Obj size
					if( (pastStartOffset || objFartherThanTopPos) && !objFartherThanBottomPos && objBiggerThanWindow && !isFixed) {
						$obj.css({position:'fixed',top:opts.offsetY});
					}
					if ( objFartherThanBottomPos && (isRelative||isFixed))
							$obj.css({position:'absolute',top:bottomPos});
					if ( !pastStartOffset && !isRelative ) 
					// if window scrolled < starting offset, then reset Obj position (opts.offsetY);
							$obj.css({position:'relative',top:'0'});
				});
			};
			
/* JQuery plugin smoothAnchor, slightly adapted for theJorid.net */

(function($){
	
	$.extend({
			 
		smoothAnchors : function(speed, easing, redirect){
				
			speed = speed || "fast";
			easing = easing || null;
			redirect = (redirect === true || redirect == null) ? true : false;
			var urlpath = window.location.pathname.length;

			$("a").each(function(i){
							
				var url = $(this).attr("href");
				
				if(url){
					if(url.indexOf("#") != -1 && url.indexOf("#") == urlpath){
		
						var aParts = url.split("#",2);
						var anchor = $("a[name='"+aParts[1]+"']");
						
						if(anchor){
																					
							$(this).click(function(){
												   
								if($(document).height()-anchor.offset().top >= $(window).height()
								 || anchor.offset().top > $(window).height()
								 || $(document).width()-anchor.offset().left >= $(window).width()
								 || anchor.offset().left > $(window).width()){
												   
									$('html, body').animate({
										scrollTop: anchor.offset().top,
										scrollLeft: anchor.offset().left
									}, speed, easing, function(){
										if(redirect){ 
											window.location = url 
										}
									});
								}
								return false;
							});
						}
					}
				}
			});
		}
	});
})(jQuery);