$(document).ready(function(){
	
	var current = "0";
	var anim_in_progress = false;
	
	// runs once, when the page is loaded
	$("#afss #content-"+current).toggle("blind", {direction:"vertical"}, 1250);
	$("#afss a#item-"+current).addClass("active");
	
	// attach Flash movies
	$("#afss #image-1").flash({
		src: "/resources/external/deckerdesign/flash/aiga-anim-1.swf",
		width: 400,
		height: 150,
		wmode: "transparent"
	});	
	$("#afss #image-2").flash({
		src: "/resources/external/deckerdesign/flash/aiga-anim-2.swf",
		width: 400,
		height: 200,
		wmode: "transparent"
	});	
	$("#afss #image-3").flash({
		src: "/resources/external/deckerdesign/flash/aiga-anim-3.swf",
		width: 400,
		height: 175,
		wmode: "transparent"
	});	
	$("#afss #image-4").flash({
		src: "/resources/external/deckerdesign/flash/aiga-anim-4.swf",
		width: 400,
		height: 175,
		wmode: "transparent"
	});
	
	
	$("#afss #image-5").flash({
		src: "/resources/external/deckerdesign/flash/aiga-anim-5.swf",
		width: 400,
		height: 400,
		wmode: "transparent"
	});
	$("#afss #image-6").flash({
		src: "/resources/external/deckerdesign/flash/aiga-anim-6.swf",
		width: 400,
		height: 200,
		wmode: "transparent"
	});
	$("#afss #image-7").flash({
		src: "/resources/external/deckerdesign/flash/aiga-anim-7.swf",
		width: 400,
		height: 175,
		wmode: "transparent"
	});
	$("#afss #image-8").flash({
		src: "/resources/external/deckerdesign/flash/aiga-anim-8.swf",
		width: 400,
		height: 175,
		wmode: "transparent"
	});
	
	
	$("#afss #image-9").flash({
		src: "/resources/external/deckerdesign/flash/aiga-anim-9.swf",
		width: 400,
		height: 175,
		wmode: "transparent"
	});
	$("#afss #image-10").flash({
		src: "/resources/external/deckerdesign/flash/aiga-anim-10.swf",
		width: 400,
		height: 200,
		wmode: "transparent"
	});
	$("#afss #image-11").flash({
		src: "/resources/external/deckerdesign/flash/aiga-anim-11.swf",
		width: 400,
		height: 250,
		wmode: "transparent"
	});
	
	
	
	// handles clicks on homepage number tile gfx
	$("#afss #home-links li > a").click(function(){
	
		id_number = $(this).text();
	
		// hide the old currently showing item
		$("#afss #content-"+current).hide("blind", {direction:"vertical"}, 750, function(){  
			// show the new one
			$("#afss #content-"+id_number).toggle("blind", {direction:"vertical"}, 1250);
		});

		// set the new one as the current one
		current = id_number;
	});
	
	
	// handles clicks on nav list items
	$("#afss a.btn").click(function(){

		// get the ID# of the new one to be shown
		var id_number = $(this).attr("id");
		id_number = id_number.replace("item-", "");
	
		if(current != id_number && anim_in_progress == false)
		{
			anim_in_progress = true;	
				
			// hide the old currently showing item
			$("#afss #content-"+current).hide("blind", {direction:"vertical"}, 750, function(){  
				// show the new one
				$("#afss #content-"+id_number).toggle("blind", {direction:"vertical"}, 1250, function(){ anim_in_progress = false; });
				
				// adjust the red highlighted link
				$("#afss a.btn").removeClass("active");
				$("#afss a#item-"+id_number).addClass("active");
			});
	
			// set the new one as the current one
			current = id_number;	
		}
		
		// minimize page jump
		return false;
	});
		
});