/*
	Rotates the background on the homepage
*/

$( document ).ready( function() {
	
	// Define the images
	var aImages = new Array();
	aImages[0] = "0001.gif";
	aImages[1] = "0002.gif";
	aImages[2] = "0003.gif";
	aImages[3] = "0004.gif";
	
	// Define variable to track the current image
	var iCurrentImage = 0;
	
	function rotate() {
		// Construct the path to the image
		var sFilepath = '../images/homepage_backgrounds/' + aImages[ iCurrentImage ];
		// Change the css
		$( 'body.home #site_content_container' ).css( "background-image", "url( " + sFilepath + " )" );
		// Increment the current image
		iCurrentImage = ( ++iCurrentImage < aImages.length ) ? iCurrentImage : 0;
		// Call this function again in 8 seconds
		setTimeout( rotate, 8000 );
	}
	
	rotate();
	
} );
