
function zCarousel(speed, container, scrollState, next, prev) {
	var numSlides = container.children().size();
	var slideWidth = container.children(1).outerWidth();
	var totalSize = slideWidth * numSlides;
	var incSlide = slideWidth * scrollState;
	var slideCount = 0;
	var slidePositionLeft = scrollState;
	var slidePositionRight = 1;
	container.css('width', '');
	var containerWidth = container.width();

	$(container.children()).click(function() {
		sliderClick(container, $(this));
		var active = $(this)
	});
	
	container.css('width', totalSize);
	prev.click(function() {
		move('left');
	});
	
	next.click(function() {
		move('right');
	});
	
	function move(direction) {
		if (direction == 'left') {
			if ((slideCount + incSlide) >= (totalSize-containerWidth)) {
				slideCount = (totalSize-containerWidth);
			}
			else {
				slideCount += incSlide;
			}
		}
		else if (direction == 'right') {
			if (slideCount < 0 || slideCount < containerWidth) {
				slideCount = 0;
			}
			else {
				slideCount -= incSlide;
			}
		}
		
		
		container.animate({
			left: "-" + slideCount
		}, speed);
	}
}



