// JavaScript Document


$(document).ready(function(){
	var isAnimating = false;
	var currentFrame = 0;
	var totalFrames = $('.presentation_box').size();
	
	var theTimer  = setInterval(nextFrame,4000);
	
	function nextFrame(){
		if ( isAnimating == false ) {
			isAnimating = true;
			currentFrame++;
	
			if ( currentFrame >= totalFrames ) currentFrame = 0;
	
			$('.presentation_container').animate({
				marginLeft: '-'+(950*currentFrame)+'px'
				  }, 600, function() {
				isAnimating = false;
			  });				
		}
	}
	function prevFrame(){
		if ( isAnimating == false ) {
			isAnimating = true;
			currentFrame--;
			if ( currentFrame == -1 ) currentFrame = totalFrames - 1;
			$('.presentation_container').animate({
				marginLeft: '-'+(950*currentFrame)+'px'
				  }, 600, function() {
				isAnimating = false;
			  });
		}	
	}
	
					
	
	$('.ps_prev').click(function(){
		clearInterval(theTimer);
		prevFrame();
		return false;
	});
	$('.ps_next').click(function(){
		clearInterval(theTimer);
		nextFrame();
		return false;
	});
	
	
});
