// JavaScript Document

// Make sure the document is ready
$(document).ready(function() {
	
	/**
	* Adds the IE6 warning to the document
	*/
	if (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1) {
		
		$("body").prepend("<div id=\"ie6-warning\"></div>");
		$("#ie6-warning").load("/templates/default/templates/custom/ie6.php");
		
	}
	
	
	
	/**
	* Swaps the content for the home selection
	*/
	function swap_intro(count) {
		
		//alert($("#intro").children().size());
		
		for (c = 1; c <= $("#intro").children().size(); c++) {
			
			$("#intro-scene-" + c).fadeOut(300);
			
		}
		
		$("#intro-scene-" + count).fadeIn(300);
		
		$(document).stopTime("intro_loop");
		set_intro_loop(count);
		
	}
	
	
	
	/**
	* Loop through the home selection every x seconds (for the homepage only)
	*/
	function set_intro_loop(count) {
		
		if ($("#intro").attr("id")) {
			
			$(document).everyTime("5s", "intro_loop", function() {
												 
				count ++;
				if (count > $("#intro").children().size()) count = 1;
				
				swap_intro(count);
				
			}, 0);
			
		}
		
	}
	
	
	
	// Initialise
	swap_intro(1);
	
});
