$(document).ready(function(){

	// The default axis is 'y', but in this demo, I want to scroll both
	// You can modify any default like this
	$.localScroll.defaults.axis='x';
	
	// Scroll initially if there's a hash (#something) in the url 
	/*$.localScroll.hash({
		target: '#scrollable', // Could be a selector or a jQuery object too.
		queue:true,
		duration:1500
	});*/
	
	/**
	 * NOTE: I use $.localScroll instead of $('#navigation').localScroll() so I
	 * also affect the >> and << links. I want every link in the page to scroll.
	 */

	$('.scrollablelistnav').localScroll({
		//target: '#scrollable', // could be a selector or a jQuery object too.
		target: '#scrollable',
		queue:true,
		duration:1000,
		onBefore:function( e, anchor, $target ){
			// The 'this' is the settings object, can be modified
			$('.scrollablelistnav').css('display','none');
			$('#'+anchor.id+'nav').css('display','block');
		},
		onAfter:function( anchor, settings ){
			// The 'this' contains the scrolled element (#content)
		}
	});

	/*
	$('#content #scrollable .list .item img').hover(function(){
		$(this).addClass('over');
	},function(){
		$(this).removeClass('over');
	});
	*/

});

function initFeatureList(strIDtoScroll,intRowWidth,intGutterWidth){
	var strIDtoScrollWithHash='#'+strIDtoScroll;

	var intRowCount=$(strIDtoScrollWithHash+' .row').length;

	if(intRowCount>1){

		$(strIDtoScrollWithHash).css({
			'overflow':'hidden',
			'clear':'left',
			'float':'left',
			'width':intRowWidth+'px'
		});

		if(intGutterWidth>0){
			$(strIDtoScrollWithHash+' .row').css('margin-right',intGutterWidth+'px');
		}

		var strPrevLink;
		var strNextLink;

		$(strIDtoScrollWithHash+' .row').each(function(i){
			$(this).attr('id','row'+strIDtoScroll+i);
			if((i-1)>-1){
				strPrevLink='<a href="#row'+strIDtoScroll+(i-1)+'" class="prev"><!--<img src="/images/'+strIDtoScroll+'/slider-prev.gif" alt="Prevous" />-->Previous</a>';
			}else{
				strPrevLink='';
			}

			if((i+1)<intRowCount){
				strNextLink='<a href="#row'+strIDtoScroll+(i+1)+'" class="next"><!--<img src="/images/'+strIDtoScroll+'/slider-next.gif" alt="Next" />-->Next</a>';
			}else{
				strNextLink='';
			}
			$(strIDtoScrollWithHash).after('<div id="row'+strIDtoScroll+i+'nav" class="'+strIDtoScroll+'listnav">'+strPrevLink+' '+strNextLink+'</div>');
		});
	
		$(strIDtoScrollWithHash+' .row').css({
			'clear':'none',
			'width':intRowWidth+'px'
		});
	
		$(strIDtoScrollWithHash+' .list').css('width',(intRowWidth*intRowCount)+(intGutterWidth*intRowCount));

	}
}

