var bannerTimeOut = 10000;

function beginBannerRotation() {
	rotating = true;
	setTimeout('changeBanner()', bannerTimeOut);
}

function changeBanner() {
	if(!rotating) return;
	
	displayBanner(idx);
	
	idx++;
	if(idx >= banners.length) idx = 0;
	
	setTimeout('changeBanner()', bannerTimeOut);
}

function displayBanner(id) {
	$("#bannerCont").fadeOut(1000, function() {
		$('#bannerCont').html(banners[id][0]);
		
		for(i = 0; i < banners.length; i++) {
			if(i == id) {
				$('#digit' + i).addClass('tactive');
			} else {
				$('#digit' + i).removeClass('tactive');
			}
		}
		
		$('#bannerCont').fadeIn(1000);
	});
}

function showBanner(id) {
	rotating = false;
	
	displayBanner(id);
	idx = id + 1;
	if(idx >= banners.length) idx = 0;
	
	setTimeout('beginBannerRotation()', bannerTimeOut);
	return false;
}

function redirect() {
	if(idx == 0)	id = banners.length - 1;
	else			id = idx - 1;
	
	if(banners[id][1].length > 0) {
		window.open(banners[id][1]);
	}
	return false;
}