$(document).ready(function(){

	/*--- Slide List Actions ---*/
	slideListInterval = setInterval("nextListSlide()",7000);
	$('#showcase_list .next').click(function(event){
		event.preventDefault();
		nextListSlide();
	});
	$('#showcase_list .prev').click(function(event){
		event.preventDefault();
		prevListSlide();
	});
	
	
	/*--- Slide Block Actions ---*/
	slideBlockStart();
	$('#showcase_block .next').click(function(event){
		event.preventDefault();
		nextBlockSlide();
	});
	$('#showcase_block .prev').click(function(event){
		event.preventDefault();
		prevBlockSlide();
	});
	
	
});

/*=== SLIDE LIST FNs ===*/
var slideListInterval;

function nextListSlide(){
	clearInterval(slideListInterval);
	$('#showcase_list .item:first-child').slideUp(400, function(){
		$('#showcase_list .item:last-child').after($('#showcase_list .item:first-child'));
		$('#showcase_list .item:last-child').show();
		slideListInterval = setInterval("nextListSlide()",7000);
	});
};
	
function prevListSlide(){
	clearInterval(slideListInterval);
	$('#showcase_list .item:last-child').slideUp(400, function(){
		$('#showcase_list .item:first-child').before($('#showcase_list .item:last-child'));
		$('#showcase_list .item:first-child').slideDown(400, function(){
			slideListInterval = setInterval("nextListSlide()",7000);
		});
	});
};


/*=== SLIDE BLOCK FNs ===*/
var slideBlockInterval;

function slideBlockStart(){
	$('#showcase_block .item').wrapAll('<div class="items_slider"></div>');
	var numbOfItems = $('#showcase_block .item').length;
	var widthOfSlide = $('#showcase_block .item').outerWidth(true);
	var sliderWidth = numbOfItems*widthOfSlide;
	$('#showcase_block .items_slider').css('width',sliderWidth+'px');
	slideBlockInterval = setInterval("nextBlockSlide()",6000);
};

function nextBlockSlide(){
	clearInterval(slideBlockInterval);
	$('#showcase_block .item:first-child').animate({'margin-left':'-295px'},400, function(){
		$('#showcase_block .item:last-child').after($('#showcase_block .item:first-child'));
		$('#showcase_block .item:last-child').css('margin-left','5px');
		slideBlockInterval = setInterval("nextBlockSlide()",6000);
	});
};
function prevBlockSlide(){
	clearInterval(slideBlockInterval);
	$('#showcase_block .item:last-child').css({'margin-left':'-295px'});
	$('#showcase_block .item:first-child').before($('#showcase_block .item:last-child'));
	$('#showcase_block .item:first-child').animate({'margin-left':'5px'},400, function(){
		slideBlockInterval = setInterval("nextBlockSlide()",6000);
	});
};
