$(document).ready(function(){
							   
		var location = document.location.hash;
		$( "#parentScrollerCanvas > div" ).fadeTo( 0, 0.2 );
		$( "#home" ).fadeTo( 0, 1.0 ).addClass( "current-panel" );
		
		if ( $.browser.msie < 7 ) {
			// for ie6 JS
		} 
							   
		/*$.localScroll.hash({
			target: '#parentScroller', // Could be a selector or a jQuery object too.
			queue:true,
			axis: 'x',
			margin:true,
			duration:1500
		});*/
		
		$.localScroll({
			target: '#parentScroller', // could be a selector or a jQuery object too.
			queue:true,
			duration:1500,
			margin: true,
			axis: 'x',
			hash:false,
			onBefore:function( e, anchor, $target ){
				location = document.location.hash;
				$( "#parentScrollerCanvas > div" ).fadeTo( "slow", 0.2 );
				$( location ).removeClass( "current-panel" );
				$( anchor ).addClass( "current-panel" );
			},
			onAfter:function( anchor, settings ){
				location = document.location.hash;
				$( location ).fadeTo( "fast", 1.0 );
			}
		});
		
		jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
			return -c * ((t=t/d-1)*t*t*t - 1) + b;
		};
		
		$( "div#parentScroller" ).scroll(function () { 
			var position = $( "#parentScroller" ).scrollLeft();
			
			var margin 	= 0;
			var homeWidth 		= $( "#home" ).width() + margin;
			var approachWidth 	= $( "#approach" ).width() + margin;
			var workWidth		= $( "#work" ).width() + margin;
			var servicesWidth 	= $( "#services" ).width() + margin;
			var teamWidth 		= $( "#team" ).width() + margin;
			var communityWidth 	= $( "#community" ).width() + margin;
			
			if( position <= homeWidth && position >= 0 )
			{
				$( "#home" ).fadeTo( 0, 1.0 );
				$( "#approach, #work, #services, #team, #community" ).fadeTo( 0, 0.2 );
			} else if( position <= homeWidth + approachWidth && position >= homeWidth )
			{
				$( "#approach" ).fadeTo( 0, 1.0 );
				$( "#home, #work, #services, #team, #community" ).fadeTo( 0, 0.2 );
			} else if( position <= homeWidth + approachWidth + workWidth && position >= homeWidth + approachWidth )
			{
				$( "#work" ).fadeTo( 0, 1.0 );
				$( "#home, #approach, #services, #team, #community" ).fadeTo( 0, 0.2 );
			} else if( position <= homeWidth + approachWidth + workWidth + servicesWidth && position >= homeWidth + approachWidth + workWidth )
			{
				$( "#services" ).fadeTo( 0, 1.0 );
				$( "#home, #approach, #work, #team, #community" ).fadeTo( 0, 0.2 );
			} else if( position <= homeWidth + approachWidth + workWidth + servicesWidth + teamWidth && position >= homeWidth + approachWidth + workWidth + servicesWidth )
			{
				$( "#team" ).fadeTo( 0, 1.0 );
				$( "#home, #approach, #work, #services, #community" ).fadeTo( 0, 0.2 );
			} else if( position <= homeWidth + approachWidth + workWidth + servicesWidth + teamWidth + communityWidth && position >= homeWidth + approachWidth + workWidth + servicesWidth + teamWidth )
			{
				$( "#community" ).fadeTo( 0, 1.0 );
				$( "#home, #approach, #work, #services, #team" ).fadeTo( 0, 0.2 );
			}
		});

		
		/*$( "a.globalNext" ).click( function()
		{
			var location = document.location.hash;
			var current = $( "div.current-panel" );
			var currentIndex = $( "#parentScrollerCanvas > div" ).index( $( current ) );
			if( currentIndex == 5 )
			{	
				var next = $( "#parentScrollerCanvas > div:first" );
			} else {
				var next = current.next();
			}
			var nextPanel;
			
			if( currentIndex == 5 )
			{
				nextPanel = "#" + $( "#parentScrollerCanvas > div:first" ).attr( "id" );
			} else {
				nextPanel = "#" + next.attr( "id" )	
			}
			
			$( "#parentScrollerCanvas > div" ).fadeTo( "slow", 0.2 );
			$( "#parentScroller" ).scrollTo( nextPanel, 800, { 
				onAfter:function(){
					$( nextPanel ).fadeTo( "fast", 1.0 );
					document.location.replace( nextPanel );
				}
			});
			
			current.removeClass( "current-panel" );
			next.addClass( "current-panel" );
		});
		
		$( "a.globalPrev" ).click( function()
		{
			var location = document.location.hash;
			var current = $( "div.current-panel" );
			var currentIndex = $( "#parentScrollerCanvas > div" ).index( $( current ) );
			if( currentIndex == 0 )
			{	
				var prev = $( "#parentScrollerCanvas > div:last" );
			} else {
				var prev = current.prev();
			}
			var prevPanel;
			
			if( currentIndex == 0 )
			{
				prevPanel = "#" + $( "#parentScrollerCanvas > div:last" ).attr( "id" );
			} else {
				prevPanel = "#" + prev.attr( "id" );	
			}
			
			$( "#parentScrollerCanvas > div" ).fadeTo( "slow", 0.2 );
			$( "#parentScroller" ).scrollTo( prevPanel, 800, { 
				onAfter:function(){
					$( prevPanel ).fadeTo( "fast", 1.0 );
					document.location.replace( prevPanel );
				}
			});
			
			current.removeClass( "current-panel" );
			prev.addClass( "current-panel" );
		});*/
		
		$('div#parentScroller').serialScroll({
			items:'div.parentPanel',
			prev:'#globalJog a.globalPrev',
			next:'#globalJog a.globalNext',
			offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
			start:0, //as we are centering it, start at the 2nd
			duration:2500,
			force:false,
			stop:true,
			lock:false,
			constant:false,
			cycle:true, //don't pull back once you reach the end
			easing:'easeOutQuart', //use this easing equation for a funny effect
			onBefore:function( e, elem, $pane, $items, pos ){
			 
			},
			onAfter:function( elem ){
			}
		});
		
		$('#workViewer').serialScroll({
			items:'li',
			prev:'#workJog a.childPrev',
			next:'#workJog a.childNext',
			navigation:'#workNav li a',
			offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
			start:0, //as we are centering it, start at the 2nd
			duration:1200,
			force:false,
			stop:true,
			lock:false,
			constant:false,
			cycle:true, //don't pull back once you reach the end
			easing:'easeOutQuart' //use this easing equation for a funny effect
		});
		
		$( "#workNav ul li a:first" ).addClass( "nav-active" );
		$( "#workNav ul li a" ).click( function()
		{
			$( "#workNav ul li a" ).removeClass( "nav-active" );
			$( this ).addClass( "nav-active" );
		});
		
		$('#teamViewer').serialScroll({
			items:'li',
			prev:'#teamJog a.childPrev',
			next:'#teamJog a.childNext',
			navigation:'#teamNav li a',
			offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
			start:0, //as we are centering it, start at the 2nd
			duration:1200,
			force:false,
			stop:true,
			lock:false,
			constant:false,
			cycle:true, //don't pull back once you reach the end
			easing:'easeOutQuart' //use this easing equation for a funny effect
		});
		
		$( "#teamNav ul li a:first" ).addClass( "nav-active" );
		$( "#teamNav ul li a" ).click( function()
		{
			$( "#teamNav ul li a" ).removeClass( "nav-active" );
			$( this ).addClass( "nav-active" );
		});
		
		$('#communityViewer').serialScroll({
			items:'li',
			prev:'#communityJog a.childPrev',
			next:'#communityJog a.childNext',
			navigation:'#communityNav li a',
			offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
			start:0, //as we are centering it, start at the 2nd
			duration:1200,
			force:false,
			stop:true,
			lock:false,
			constant:false,
			cycle:true, //don't pull back once you reach the end
			easing:'easeOutQuart' //use this easing equation for a funny effect
		});
		
		$( "#communityNav ul li a:first" ).addClass( "nav-active" );
		$( "#communityNav ul li a" ).click( function( e )
		{
			$( "#communityNav ul li a" ).removeClass( "nav-active" );
			$( this ).addClass( "nav-active" );
		});
	});