jQuery.easing.def = "easeOutSine";

//var xPos = [ 59, 1312, 2566, 3880];

var xPos = [ 0, 650, 1300, 1950];
var x = 1; // The corner counter
var tspeed = 1750;

function slideMe(where) {
	$(".active").removeClass();
	$('.image_reel').animate({ left: -where }, tspeed, "swing");
}

function slideThem() {
	$(".active").removeClass();
	$(".image_reel").animate({ left: -xPos[x] }, tspeed, "swing", function(){
			$("#n"+x).addClass("active");
			++x;
			if (x == 4) { x = 0; }
	});  
}

function applyButtons(n){
	$("#n"+n).click(function(e){ 
		e.preventDefault();
		slideMe(xPos[n]);
		$(this).addClass("active"); 
		window.clearInterval(slideTimer); 
	});
}

//bind buttons
//for (i = 0; i < 4; i++) { applyButtons(i); }

// slideshow
var slideTimer = window.setInterval("slideThem()",5000); 

