var x = 0;
var curPage = 0;  
var thumbWidth = 	83;  
var thumbsVis = 5;

$(document).ready(function() {
 
	
  //Work Scroller
	
	if(($("#work-scroll img").length)%5 == 0) {
		var numThumbs =  $("#work-scroll img").length;
	} else {
		var numThumbs = 5 - (($("#work-scroll img").length)%5) + $("#work-scroll img").length;	
	}
	
	$("#next").click(function() { 
		updateOffset(1,numThumbs);
		$("#work-scroll").animate({ left: x }, 1000, "expoinout");	
		return false;
	});
	$("#prev").click(function() { 
		updateOffset(0,numThumbs);
		$("#work-scroll").animate({ left: x }, 1000, "expoinout");
		return false;
	});	


	if(($("#work-scroll2 img").length)%5 == 0) {
		var numThumbs2 =  $("#work-scroll2 img").length;
	} else {
		var numThumbs2 = 5 - (($("#work-scroll2 img").length)%5) + $("#work-scroll2 img").length;	
	}
	
	$("#next2").click(function() { 
		updateOffset(1,numThumbs2);
		$("#work-scroll2").animate({ left: x }, 1000, "expoinout");	
		return false;
	});
	$("#prev2").click(function() { 
		updateOffset(0,numThumbs2);
		$("#work-scroll2").animate({ left: x }, 1000, "expoinout");
		return false;
	});	

	
});// end doc ready


function updateOffset(next,thumbs) {
	if(next == 1) {
		if (x == (0 - ((thumbs - thumbsVis) * thumbWidth))) {
			x = 0;
		} else {
			x = x - (thumbWidth*thumbsVis);
		}
	}
	if(x <= 0 && next != 1) {
		if (x == 0) {
			x = (0 - ((thumbs - thumbsVis) * thumbWidth));
		} else {
			x = x + (thumbWidth*thumbsVis);
		}
	}
	
}// end updateOffset