/// <summary>
/// The Image Gallery class adds the javascript logic for the cycling through images.
/// </summary>
var IMAGETIMEOUTLENGTH;
var cycleTimer;

$(document).ready(function(){   	
	//Set our global timeout.
    IMAGETIMEOUTLENGTH = 7000;
    
	//Start cycling through images.
	cycleImage();
	
	$("div#divGallery > a:visible").hover(
		function() {
			clearTimeout(cycleTimer);
		},
		function() {
			cycleTimer = setTimeout("cycleImage()", IMAGETIMEOUTLENGTH);
		}
	);
});
function cycleImage() 
{
	var activeImage = $("div#divGallery > a:visible");
	var nextImage = (!activeImage.next().attr("id")) ? $("div#divGallery > a.imgAnchor:first") : (activeImage.next(".imgAnchor"));
	activeImage.fadeOut("slow");
	nextImage.fadeIn("slow", function(){
		activeImage.attr({
			style: "display:none;"
		});
		cycleTimer = setTimeout("cycleImage()", IMAGETIMEOUTLENGTH);
	});	
}
