var count = 1;
var slideshowImageCount = 8;

$(document).ready(function() {
	startSlideshow();
});

function startSlideshow() {
	$("#slideshow #slide").everyTime(8000, 'controlled', function() {
		$(this).fadeOut('slow', function() {
			var header = "";
			var description = "";
			
			switch(count) {
				case 1:
					header = "Extension completed at Holy Sepulchre Cemetery";
					description = "Take a <a href='http://www.catholiccemeterieschicago.org/panorama/walkthrough/test/' class='more'>virtual tour</a> of the new Mausoleum of the Archangels Extension.";
					
					break;
				case 2:
					header = "Glass-Front Niches Available at All Saints in Des Plaines";
					description = "Catholic Cemeteries offers a unique and limited opportunity to purchase our new softly lit glass-front niches. <a href='allsaintsglassfrontniches.php' class='more'>More...</a>";
					break;
					
				case 3:
					header = "Glass-Front Niches Available at Queen of Heaven in Hillside";
					description = "Catholic Cemeteries offers a unique and limited opportunity to purchase our new softly lit glass-front niches. <a href='glassfrontniches.php' class='more'>More...</a>";
					break;
					
				case 4:
					header = "Crypt and Niche Addition at St. Michael Cemetery";
					description = "in the Garden Mausoleum is now completed.  The new crypts and niches are located on the west side of the Office/Mausoleum. <a href='cemeterynews.php' class='more'>More...</a>";
					break;
			
				case 5:
					header = "Crypt and Niche Addition at St. Joseph Cemetery";
					description = "is now completed.  The crypts and niches are beautifully nestled in the courtyards of the Resurrection Garden Mausoleum. <a href='cemeterynews.php' class='More'>More...</a>";
					break;
					
				case 6:
					header = "Our Lady of the Rose Mausoleum at Maryhill Cemetery";
					description = "in Niles has been completed.  With over 4,000 units, it features an arch with stained glass depicting Saint Mary as the Mystic Rose. <a href='cemeterynews.php' class='more'>More...</a>";
					break;
					
				case 7:
					header = "Chapel Area Niche Addition at St. Michael Cemetery";
					description = "is completed.  The East Niche addition is in the Courtyard of St. Gabriel.  The West Niche addition is in the Courtyard of St. Raphael.  <a href='cemeterynews.php' class='more'>More...</a>";
					break;
					
				case 8:
					header = "Niche Addition Sales Continue at Queen of Heaven";
					description = "Cemetery in the Crucifixion Garden Mausoleum.  These niches are for the above ground entombment of cremated remains.  <a href='cemeterynews.php' class='more'>More...</a>";
					break;
			}
			
			$(this).find(".slideText .header").html(header);
			$(this).find(".slideText .description").html(description);
			
			$slideImage = $(this).find(".slideImage a");
			
			if(count == 1) {
				$slideImage.attr("href", "http://www.catholiccemeterieschicago.org/panorama/walkthrough/test/");
			} else if(count == 2) {
				$slideImage.attr("href", "allsaintsglassfrontniches.php");
			} else if(count == 3) {
				$slideImage.attr("href", "glassfrontniches.php");
			} else {
				$slideImage.attr("href", "cemeterynews.php");	
			}
			
			$(this).find(".slideImage img").attr("src", "Slideshows/images/slide" + count + "AB.jpg");
			$(this).fadeIn('slow');
		});
		
		if(count == slideshowImageCount) {
			count = 1;
		} else {
			count = count + 1;
		}
	});
}
