// change the scrollbar position when we switch sections
function setScrollPosition(project,section,speed)
{
	var totalProjects = $('#sec-'+section).siblings('.section-collection').children().length;
	var pRatio = project/(totalProjects-1);
	
	var barWidth = $('#scroll-region').width();
	
	var pos = Math.round(pRatio * 750);
	$("#scroll-region").slider('animate',speed);
	$("#scroll-region").slider('value',pos);
}

// sets the scrollbar width; used when switching sections
function setScrollbarWidth(secID)
{
	var newW = $("#scroll-container").width() / $('.section-collection').eq(secID).children().length;
	
	
	// also change the width of the scroll region
	$("#scroll-region").css('width',$("#scroll-container").width()-Math.round(newW));
	$("#scroll-bar").css('margin-left',-1*(Math.round(newW)/2));
	$("#scroll-bar").animate({'width':Math.round(newW)},'fast' );
}

function initScroll()
{
	$("#scroll-region").slider({ 
		orientation: 'horizontal',
		max: 750,
		min: 0,
		animate:400,
		slide: function(event, ui) 
		{
			// take the ratio of the scroll bar value, 
			// and multiply it by the width of the section-container (minus a single project)
			var scrollLeft = ui.value / 750 * ($('.section-container').eq(getCurSection()).width() - $('.single-project').width());
			$('.section-container').eq(getCurSection()).css('left', Math.round(-1 * scrollLeft)+'px');
			lazyScroll(getCurSection());
		}
	});	
}


