(function($) {
	window.isIE6 = /msie 6/i.test(navigator.userAgent)? true:false;
	$(function() {
		// Scroll initially if there's a hash (#something) in the url 
		$.localScroll.hash({
			target: '#slider', //could be a selector or a jQuery object too.
			axis:'x',//the default is 'y'
			queue:true,
			duration:0
		});
	
		var $last = $([]);//save the last link
		/**
		 * NOTE: I use $.localScroll instead of $('#navigation').localScroll() so I
		 * also affect the >> and << links. I want every link in the page to scroll.
		 */
		$('#interview-navigation').localScroll({
			target: '#slider', //could be a selector or a jQuery object too.
			axis:'xy', //the default is 'y'
			queue:true,
			duration:2500,
			hash:true,
			onBefore:function( e, anchor, $target ){//'this' is the clicked link
				$last.removeClass('scrolling');
				$last = $(this).addClass('scrolling');
				if( this.blur )
					this.blur(); //remove the awful outline
			},
			onAfter:function( anchor ){
				//$last.removeClass('scrolling');
			}
		});
		
		var equalizeBoxes = {
			init: function(root) {
				var self = this;
				if(!root) root = $(document);
				$(".equalize", root).each(function() {
					equalizeBoxes.setHeight($(".equal", $(this)));
				});
			},
			setHeight: function(obj) {
				var h = 0;
				obj.each(function() { h = Math.max(h, $(this).get(0).offsetHeight); });
				obj.each(function() {
					var p = parseInt($(this).css("paddingTop")) + parseInt($(this).css("paddingBottom"));
					$(this).css({ minHeight: (h - p) + "px" });
					// compensate for stubborn IE6
					if(window.isIE6) $(this).css({ height: (h - p) + "px" });
				});
				// tickle DOM, for some browser
				$("body").toggleClass("tickled");
			}
		};
		
		window.setTimeout(function() { equalizeBoxes.init(); }, 100);
		
		// clickable boxes
		$('a', '.clickable').click(function(e){
			
		});
		
		// hoverable boxes
		$(".clickable li").hover(
     		function () {
		    	$(this).toggleClass("hover");
		    }, 
		    function () {
		    	$(this).toggleClass("hover");
		  	}
		 );
		
		//Tooltips
		$("#interview-navigation li").hover(
	      function () {
	        $('.meta', this).append("<div class='arrow'></div>").fadeIn(50);
	      }, 
	      function () {
	        $('.meta', this).fadeOut(50)
	      }
	    );
	
	});
})(jQuery);