
$(document).ready(function(){
current = 1;
//button = 1;
images = 5;
width = 510;

$('#p1').animate({"left": "0px"}, 400, "swing");
$('#b1').css("backgroundPosition", "left bottom")
$('#b1 b').css("color","#fff");

$("#next").click(function() {
		button = current;
		current++
	if (current == (images+1) ) {current = 1}
animateLeft(current,button)
});

$("#previous").click(function() {
		button = current;
		current--
	if (current == 0 ) {current = images}
animateRight(current,button)
});



function animateLeft(current) {
	$('#p'+current).css("left",width +"px");
	$('#p'+current).animate({"left": "0px"}, 400, "swing");
	$('#p'+button).animate({"left": -width+"px"}, 400, "swing");
	setbutton()
}

function animateRight(current) {
	$('#p'+current).css("left",-width+"px");
	$('#p'+current).animate({"left": "0px"}, 400, "swing");
	$('#p'+button).animate({"left": width+"px"}, 400, "swing");
	setbutton()
}

});


