$(document).ready(function(){

var padding = 2;
//var left = -0.83*parseInt($('.slideShow .splash_blocks div').width());
var left = -( parseInt($('.slideShow .splash_blocks div').width()) - ( parseInt($('body').width())-parseInt($('.slideShow .splash_blocks div').width())-padding )/2 )-padding*4;
$('.slideShow .splash_blocks').css('left', left);

var child_count=parseInt($('.slideShow .splash_blocks div').length);

var max = (-(child_count-3)*parseInt($('.slideShow .splash_blocks div').width()))+left+padding;
var min = left+padding;

$('.arrow_right').click(function() {
	if($('.slideShow .splash_blocks:animated').length) return false;
	
	if( parseInt($('.slideShow .splash_blocks').css('left')) <= max ) {
		//alert("append");
		$('.slideShow .splash_blocks').append($('.slideShow .splash_blocks div:first'));
		$('.slideShow .splash_blocks').css('left',parseInt($('.slideShow .splash_blocks').css('left'))+parseInt($('.slideShow .splash_blocks div').width()));
	}
	
	var margin=parseInt($('.slideShow .splash_blocks').css('left'))-parseInt($('.slideShow .splash_blocks div').width());
		
	$('.slideShow .splash_blocks').animate({'left':margin});
	
});

$('.arrow_left').click(function(){
	if($('.slideShow .splash_blocks:animated').length) return false;
	
	if( parseInt($('.slideShow .splash_blocks').css('left')) >= left ) {
		//alert("prepend");
		$('.slideShow .splash_blocks').prepend($('.slideShow .splash_blocks div:last'));		
		$('.slideShow .splash_blocks').css('left',parseInt($('.slideShow .splash_blocks').css('left'))-parseInt($('.slideShow .splash_blocks div').width()));
	}
	
	var margin=parseInt($('.slideShow .splash_blocks').css('left'))+parseInt($('.slideShow .splash_blocks div').width());
	
	$('.slideShow .splash_blocks').animate({'left':margin});
	
});

});
