jQuery(document).ready(function(){
	
	jQuery(".slider-box a.scroll-right").click(function() {
		
		var direction = this;
		jQuery(this).parent().children(".ContentFlow").children(".flow").children(":first-child").animate({width: '0px'}, 100, function() {
			jQuery(this).parent().children(":first-child").appendTo(jQuery(this).parent());
			jQuery(this).css('width', 'auto');
		
			jQuery(direction).parent().children(".ContentFlow").children(".flow").children(":first-child").animate({width: '0px'}, 100, function() {
				jQuery(this).parent().children(":first-child").appendTo(jQuery(this).parent());
				jQuery(this).css('width', 'auto');
				
				jQuery(direction).parent().children(".ContentFlow").children(".flow").children(":first-child").animate({width: '0px'}, 100, function() {
					jQuery(this).parent().children(":first-child").appendTo(jQuery(this).parent());
					jQuery(this).css('width', 'auto');
				});
			});
		});
	});
	jQuery(".slider-box a.scroll-left").click(function() {
		var direction = this;
		jQuery(direction).parent().children(".ContentFlow").children(".flow").children(":last-child").css('width', '0px');
		jQuery(direction).parent().children(".ContentFlow").children(".flow").children(":last-child").prependTo(jQuery(direction).parent().children(".ContentFlow").children(".flow"));
		jQuery(direction).parent().children(".ContentFlow").children(".flow").children(":first-child").animate({width: '185px'}, 100, function(){
			jQuery(this).css('width', 'auto');
			
			jQuery(direction).parent().children(".ContentFlow").children(".flow").children(":last-child").css('width', '0px');
			jQuery(direction).parent().children(".ContentFlow").children(".flow").children(":last-child").prependTo(jQuery(direction).parent().children(".ContentFlow").children(".flow"));
			jQuery(direction).parent().children(".ContentFlow").children(".flow").children(":first-child").animate({width: '185px'}, 100, function(){
				jQuery(this).css('width', 'auto');
				
				jQuery(direction).parent().children(".ContentFlow").children(".flow").children(":last-child").css('width', '0px');
				jQuery(direction).parent().children(".ContentFlow").children(".flow").children(":last-child").prependTo(jQuery(direction).parent().children(".ContentFlow").children(".flow"));
				jQuery(direction).parent().children(".ContentFlow").children(".flow").children(":first-child").animate({width: '185px'}, 100, function(){
					jQuery(this).css('width', 'auto');
				});
			});
		});
		
	});
	
	
	//scrollOneElement();
});


// Deprecated
function scrollOneElement(){
	jQuery(".flow a:first-child").animate({width: '0px'}, 2000, function() {
		jQuery(this).parent().children(":first-child").appendTo(jQuery(this).parent());
		jQuery(this).css('width', 'auto');
	});
	window.setTimeout(scrollOneElement, 5000);
}

