// Origami Carousel jQuery
/*

1) Set the width of the slides on the CSS (class .slide) and the #slides_wrappe
2) Add as many divs with the class slide as needed
3) DONE

*/
var cur_slide = 1;
var show = 6;

$(document).ready(function() {

	slides = $(".slide").size();
	width = $(".slide").width();
	total_width = width * slides;
	$("#slides_wrapper").css("width",(width * show) + "px");
	$("#slider").css("width",total_width + "px");
	// Next
	$("#next").click(function(event) {
		event.preventDefault();	
		if ((cur_slide + show) <= slides)
			{
			$("#slider").animate({"left" : "-=" + width + "px"}, "slow" );
			cur_slide = cur_slide + 1;
			}		
		else
			{
			left_pos = $("#slider").css("left");
			left_pos = parseFloat(left_pos);
			left_pos = left_pos * -1;
			$("#slider").animate({"left" : "+=" + left_pos + "px"}, "slow" );
			cur_slide = 1;
			}
	});
	
	//Previous
	$("#prev").click(function(event) {
		if (slides > show)
		{
		event.preventDefault();	
		if (cur_slide != 1)
			{
			$("#slider").animate({"left" : "+=" + width + "px"}, "slow" );
			cur_slide = cur_slide - 1;
			}		
		else
			{
			$("#slider").animate({"left" : "-=" + width * (slides - show) + "px"}, "slow" );
			cur_slide = slides - (show - 1);
			}
		}
	});
	
});



