bannerIndex = 0;
bannerLast  = 1;

var rotatingBanners =$('#rotatingBanners');
rotatingBanners = rotatingBanners.children('.banner');
numBanners = rotatingBanners.length-1;

setTimeout("changeBanner()",100);
bannerAnimation = setInterval("changeBanner()",anotherDelay);		

$('#rotatingBanners').mouseover(function(){ $('#controlBar').stop(true).animate({bottom:0}, 400) } );
$('#rotatingBanners').mouseout(function(){ $('#controlBar').stop(true).animate({bottom:-40}, 400); } );

function playBanners(){
	$('#playControl').hide();
	$('#pauseControl').show();
	changeBanner();
	bannerAnimation = setInterval('changeBanner()',anotherDelay);
}

function pauseBanners(){
	$('#pauseControl').hide();
	$('#playControl').show();
	clearInterval(bannerAnimation);
}

function bannerPrev(){
	//pauseBanners();

	if (bannerLast == 0){
		bannerIndex = numBanners;
	}else{
		bannerIndex = bannerLast-1;
	}			
	
	$(rotatingBanners[bannerLast]).fadeOut(delay);
	$(rotatingBanners[bannerIndex]).fadeIn(delay);
	
	bannerLast = bannerIndex;

	if (bannerIndex == numBanners){
		bannerIndex = 0;
	}else{
		bannerIndex++;
	}	
	$('#showingBanner').text((bannerIndex==0?numBanners+1:bannerIndex)+' / '+(numBanners+1)); /*fix for numbering on back*/
		
}

function bannerNext(){
	//pauseBanners();
	changeBanner();
}

function changeBanner(){
	$(rotatingBanners[bannerLast]).fadeOut(delay);
	$(rotatingBanners[bannerIndex]).fadeIn(delay);
	
	$('#showingBanner').text((bannerIndex+1)+' / '+(numBanners+1));
	
	bannerLast = bannerIndex;

	if (bannerIndex == numBanners){
		bannerIndex = 0;
	}else{
		bannerIndex++;
	}

}
