/// <summary>
/// The NewCars class adds the javascript logic for the processing images within this section.
/// </summary>
var IMAGETIMEOUTLENGTH;
var cycleLogoTimer;
var cycleRangeTimer;

$(document).ready(function(){
	//Set our global timeout.
    IMAGETIMEOUTLENGTH = 5000;

	//Start cycling through range.
	cycleLogos();

	//Start cycling through range.
	cycleRange();

	$("div.franchiseList > ul > li.franchiseLI").hover(
		function() {			
			$("div#franchiseLogoCollection > img").attr({
				style: "display:none;"
			});
			$("div#franchiseLogoCollection > img#franchiseLogo" + $(this).attr("id")).attr({
				style: "display:block;"
			});			
			clearTimeout(cycleLogoTimer);						
		},
		function() {
			cycleLogoTimer = setTimeout("cycleLogos()", IMAGETIMEOUTLENGTH);
		}
	);
	
	$("div.rangeList > ul > li.rangeLI").hover(
		function() {			
			$("div#rangeItemCollection > img").attr({
				style: "display:none;"
			});
			$("div#rangeItemCollection > img#rangeItem" + $(this).attr("id")).attr({
				style: "display:block;"
			});			
			clearTimeout(cycleRangeTimer);						
		},
		function() {
			cycleRangeTimer = setTimeout("cycleRange()", IMAGETIMEOUTLENGTH);
		}
	);
});
function cycleLogos() 
{
	var activeImage = $("div#franchiseLogoCollection > img:visible");
	var nextImage = (!activeImage.next().attr("id")) ? $("div#franchiseLogoCollection > img:first") : (activeImage.next());
	activeImage.fadeOut("slow");
	nextImage.fadeIn("slow", function(){
		activeImage.attr({
			style: "display:none;"
		});
		cycleLogoTimer = setTimeout("cycleLogos()", IMAGETIMEOUTLENGTH);
	});	
}
function cycleRange() 
{
	var activeImage = $("div#rangeItemCollection > img:visible");
	var nextImage = (!activeImage.next().attr("id")) ? $("div#rangeItemCollection > img:first") : (activeImage.next());
	activeImage.fadeOut("slow");
	nextImage.fadeIn("slow", function(){
		activeImage.attr({
			style: "display:none;"
		});
		cycleRangeTimer = setTimeout("cycleRange()", IMAGETIMEOUTLENGTH);
	});	
}