var index = 0;
var totalimages;

function slide(direction){
	if(direction == "next"){
		if(index > 0){
			index--;
		}
	} else {
		if(index < (totalimages-1)){
			index++;
		}
	}

	if($('body').hasClass('mobile')){
		if((index + 1) >= totalimages) {
			$('.arrow.nextPromo').hide();	
		}
		else {
			$('.arrow.nextPromo').show();		
		}
		
		if(index <= 0){
			$('.arrow.prevPromo').hide();	
		}
		else {
			$('.arrow.prevPromo').show();	
		}
	}
	
	var slideamount = -1*index*$('.promobox').outerWidth(false);
	$('.promoinfo ul, .slideshow').animate({
		left: slideamount
	},200);
}

$(document).ready(function(){
	totalimages = $('.slideshow img').size();

	if(totalimages > 1){
		$('.promobox .arrow').click(function(){
			slide($(this).attr('data-direction'));
		});
		
		$('.promobox .arrow').fadeTo(0,0.5);

		if($('body').hasClass('mobile')){
			$('.arrow.prevPromo').hide();
		} else {
			$('.promobox .arrow').hover(function(){
				$(this).fadeTo(50,1);
			},function(){
				$(this).fadeTo(50,0.5);
			});
		}
	}
	else {
		$('.promobox .arrow').hide();
	}
});
