jQuery(function( $ ){
	/**
	 * Most jQuery.localScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
	 * @see http://flesler.demos.com/jquery/scrollTo/
	 * You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.LocalScroll.
	 */
	
	/**
	 * Restart the scroll position to ( 0, 0 ) (Firefox doesn't reset it)
	 * could use $(target).scrollTo( 0, {axis:'xy'));
	 * but this needs to be quick(synchronous), to reset before $.localScroll.hash() begins
	 */
	 // Reset to 2nd cell - Logo
//	$('#contentWindow').attr({scrollTop:0,scrollLeft:660});
	/* DR 16 Apr 09, Code to test for IE6 */
	//Test:    $("p").html("The browser version is: " + jQuery.browser.version + " ");
	if(jQuery.browser.msie && jQuery.browser.version.substr(0,1)=="6"){
		//IE6
		$('#contentWindow').attr({scrollTop:0,scrollLeft:704});
	}else{
		$('#contentWindow').attr({scrollTop:0,scrollLeft:660});	
	};
	
	// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		target: '#contentWindow', //could be a selector or a jQuery object too.
		axis:'xy',//the default is 'y'
		queue:false,
		duration:1500
	});
	
	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.
	 */
	$.localScroll({
		target: '#contentWindow', //could be a selector or a jQuery object too.
		axis:'xy', //the default is 'y'
		queue:false,
		duration:1250,
		hash:true,
		onBefore:function( e, anchor, $target ){//'this' is the clicked link
			
			// TODO: Test if this is #contact or another #
			// TODO: Get this happening Faster, maybe onBefore
			if(jQuery.url.attr("anchor") == "contact"){
				$("#contact-reveal").slideDown(1500);
			}

			$last.removeClass('scrolling');
			$last = $(this).addClass('scrolling');
			if( this.blur )
				this.blur();//remove the awful outline
		},
		onAfter:function( anchor ){
			$last.removeClass('scrolling');
			
			// DR: URL not updated until After scroll
			if(jQuery.url.attr("anchor") == "contact"){
				$("#contact-reveal").slideDown(1500);
			}	

		}
	});
});
