// On DOM Load...
$(function(){
	$("#BannerflowPreloader").load("/site/_bannerflow/",BannerflowStartup);
});

function BannerflowStartup() {
	var jDisplay   = $("#BannerflowDisplay");
	var jPreloader = $("#BannerflowPreloader");
	
	jPreloader.children("img").error(function(){
		$(this).remove();
	});
	
	var img1,img2,img3,img4,img5,imgOld;
	imgOld = jPreloader.children("img:last").remove();
	imgOld.css({
		opacity: 0.0,
		width:   "0px",
		height:  "92px"
	});
	img1 = jPreloader.children("img:first").remove();
	img1.css({
		opacity: 0.0,
		width:   "4px",
		height:  "92px"
	});
	img2 = jPreloader.children("img:first").remove();
	img2.css({
		opacity: 0.0,
		width:   "8px",
		height:  "92px"
	});
	img3 = jPreloader.children("img:first").remove();
	img3.css({
		opacity: 0.0,
		width:   "12px",
		height:  "92px"
	});
	img4 = jPreloader.children("img:first").remove();
	img4.css({
		opacity: 0.0,
		width:   "8px",
		height:  "92px"
	});
	img5 = jPreloader.children("img:first").remove();
	img5.css({
		opacity: 0.0,
		width:   "4px",
		height:  "92px"
	});
	jDisplay.append(imgOld);
	jDisplay.append(img1);
	jDisplay.append(img2);
	jDisplay.append(img3);
	jDisplay.append(img4);
	jDisplay.append(img5);
	img1.animate({opacity:0.3,width:"40px"},1000);
	img2.animate({opacity:0.7,width:"80px"},1000);
	img3.animate({opacity:1.0,width:"122px"},1000);
	img4.animate({opacity:0.7,width:"80px"},1000);
	img5.animate({opacity:0.3,width:"40px"},1000);
	setTimeout("BannerflowAdvance()",3000);
}

function BannerflowAdvance() {
	var jDisplay   = $("#BannerflowDisplay");
	var jPreloader = $("#BannerflowPreloader");
	
	var imgOld, img1, img2, img3, img4, img5, imgNew;
	imgOld = jDisplay.children("img:eq(0)");
	img1   = jDisplay.children("img:eq(1)");
	img2   = jDisplay.children("img:eq(2)");
	img3   = jDisplay.children("img:eq(3)");
	img4   = jDisplay.children("img:eq(4)");
	img5   = jDisplay.children("img:eq(5)");
	
	jPreloader.append(imgOld.remove());
	
	imgNew = jPreloader.children("img:first").remove();
	imgNew.css({
		opacity: 0.0,
		width: "4px",
		height: "92px"
	});
	
	jDisplay.append(imgNew);
	
	img1.animate({opacity:0.0,width:"0px"},1000);
	img2.animate({opacity:0.3,width:"40px"},980);
	img3.animate({opacity:0.7,width:"80px"},960);
	img4.animate({opacity:1.0,width:"122px"},940);
	img5.animate({opacity:0.7,width:"80px"},920);
	
	imgNew.animate({opacity:0.3,width:"40px"},900);

	setTimeout("BannerflowAdvance()",4000);
}
