var banners, numBanners, curBanner, next, slide;

$(document).ready(function() {
	banners = $("#banners").children("div");
	numBanners = banners.length;
	curBanner = 0;
	if (numBanners>0)
		slide = setInterval("banner_switch()", 7000);
});

//This function is what goes to the next banner after the timeout is reached
	function banner_switch(){
		//Get the next banner in line, or go back to the first one if there isn't a next one in line
		curBanner++;
		if (curBanner>(numBanners-1))
			curBanner = 0;

		next = banners[curBanner];
		$(next).css("z-index", 1);
		$(".current").css("z-index", 2);
		$(next).show();
		$(".current").fadeOut().removeClass("current");
		$(next).addClass("current");
		set_new_interval(7000);
	}

	function set_new_interval(interval){ //Sets the new timeout
		clearInterval(slide); //Clears the old one
		slide = setInterval("banner_switch()", interval);
	}
