function SwitchBox(id) {
	for(var i=1 ; i <= 5; i++) {
		$("#txt" + i).hide();
		$("#tab-" + i + " a:first-child").removeClass("selected-box");
		$("#tab-" + i + " a:first-child").removeClass("not-selected-box");
		if (id != i) {
			$("#tab-" + i + " a:first-child").addClass("not-selected-box");
		} else {
			$("#tab-" + i + " a:first-child").addClass("selected-box");				
		}				
	}
	$("#txt" + id).show();
}

var bannerIdx = 0;
var bannerCount = 0;
var timerCount = 0;

$.fn.delay = function(time, name) {
    return this.queue((name || 'fx'), function() {
        var self = this;
        setTimeout(function() { $.dequeue(self); } , time);
    });
};

function loadSlideShow(groupID) {
	$('a.slideshow-' + groupID).colorbox({
		slideshow: true,
		transition: 'elastic'
	});
}

function loadBanners() {
	bannerCount = $('#banners .banner').length;
	bannerIdx = 0;

	if (bannerCount > 1) {
		showBanner(+1);
	} else {
		$('#banners div.banner:eq(0)').fadeIn(300);
	}
}

function showBanner(increase) {
	$('#banners div.banner:eq(' + bannerIdx + ')').fadeOut(300);

	bannerIdx = (bannerIdx + increase + bannerCount) % bannerCount;

	$('#banners div.banner:eq(' + bannerIdx + ')').fadeIn(300, function() {
		timerCount++;
  		$.timer(10000, function() {
  			if(timerCount == 1) {
				showBanner(+1);
			}
			timerCount--;
		});
	});
}