slidesArray = new Array(
	['homepagePhoto_1.jpg','Sel de la Terre Back Bay'],
	['homepagePhoto_2.jpg','Sel de la Terre Long Wharf'],
	['homepagePhoto_3.jpg','Sel de la Terre Natick'],
	['homepagePhoto_4.jpg','Apple Street Farm'],
	['homepagePhoto_5.jpg','Apple Street Farm']
) 			

function homePageSlideshow(whichSlide){
	if ($("#SlideShowImg").attr("src") !== "/_common_images/home/" + slidesArray[whichSlide][0]){
		
		/*
		Need to append a random number query string or IE won't load the photos a second time.
		This is done in the below line that calls .attr()
		*/
		var randomnumber=Math.floor(Math.random()*1000);
		
		$("#SlideShowImg").fadeOut("slow", function() {
			$("#slideshowHomeNavigation > .description").fadeOut("fast");
			$("<img />")
				.attr("src", "/_common_images/home/" + slidesArray[whichSlide][0] + "?" + randomnumber )
				.load(function(){
					/*the following occur only after the image file has loaded*/
					$("#SlideShowImg").attr("src","/_common_images/home/" + slidesArray[whichSlide][0]);
					$("#SlideShowImg").fadeIn("slow");
					$("#slideshowHomeNavigation > .description").html(slidesArray[whichSlide][1]);
					$("#slideshowHomeNavigation > .description").fadeIn("fast");
				});
			});
		}
}

/*code for controlling the slideshow navigation buttons*/
$(document).ready(function(){ 
	$("#slideshowHomeNavigation a").click(function () { 
		$("#slideshowHomeNavigation a").each(function(){$(this).removeClass("activeNode");});
		$(this).addClass("activeNode");
	});
});

function loadRandomSlide(numberOfSlides){
	var numberOfSlides = numberOfSlides - 1;
	var randomnumber=Math.floor(Math.random()*numberOfSlides);
	homePageSlideshow(randomnumber);
	}
$(document).ready(function(){
	loadRandomSlide(5);
	setInterval ("loadRandomSlide(5)", 6000 );
	})