$(document).ready(function(){
	
	active_banner = 1;
	busy = 0;
	function setActiveBanner(id,last) {
			busy = 1;
			$("#promo_"+last).removeClass("promo_"+last+"-active").addClass("promo_"+last);
			$("#promo_"+id).removeClass("promo_"+id).addClass("promo_"+id+"-active");
			$("#banner"+last).fadeOut('slow',function(){
				$("#banner"+id).fadeIn('slow',function(){
					busy = 0;		
				})
			});

	}
	
	$("#promo_1").click(function(){
		if(busy == 0 && active_banner != 1) {
			setActiveBanner(1,active_banner);
			active_banner = 1;
		}
	});
	$("#promo_2").click(function(){
		if(busy == 0 && active_banner != 2) {
			setActiveBanner(2,active_banner);
			active_banner = 2;
		}
	});
	$("#promo_3").click(function(){
		if(busy == 0 && active_banner != 3) {
			setActiveBanner(3,active_banner);
			active_banner = 3;
		}
	});
	$("#promo_4").click(function(){
		if(busy == 0 && active_banner != 4) {
			setActiveBanner(4,active_banner);
			active_banner = 4;
		}
	});
	
	$("#banner_go_left").click(function(){
		if(busy == 0) {
			if(active_banner == 1) {
				setActiveBanner(4,1);
				active_banner = 4;
			} else {
				active_banner = active_banner - 1;
				setActiveBanner(active_banner,active_banner+1);
			}
		}
	});
	$("#banner_go_right").click(function(){
		if(busy == 0) {
			if(active_banner == 4) {
				setActiveBanner(1,4);
				active_banner = 1;
			} else {
				active_banner = active_banner + 1;
				setActiveBanner(active_banner,active_banner-1);
			}
		}
	});
});
