/*
 * Parking lot site Javascript
 * SPJ 2/09
 */


jQuery(document).ready(function() {
	
	// Todo: navigation mouseovers
	
	
var homePageSlideshow = function() {
	
	var slideContainer = '#portfolio';  // Parent element 
	var numSlides = 52; 
	var startSlide = Math.floor(Math.random() * numSlides); // Or 0 for first
	var slideLink = "trailer.html"; 
	var imageDir = "img/main_slideshow/";
	
	
	$(slideContainer).empty(); 	// Empty the placeholder

	for(i=1; i<numSlides; i++) { // Add our slides to the document

		$(slideContainer).append('<a href='+slideLink+'><img src="'+imageDir+i+'.jpg" border="0" /></a>');
	}
	
	$(slideContainer).cycle({   // JQuery cycle plugin
		fx:	'fade',
		random: 1,
		timeout: 5000,
		speed: 1000,
		startingSlide: startSlide,
		next: "a.next",
		prev: "a.prev"
	});

}
	
var attendantDisplay = function() {
	
	$("#gallery p:last").remove(); // Remove the extra <p>
	
	$("#gallery-nav ul li").each(function(){ // Add hover to the thumbnails
		$(this).mouseout(function(){
			$(this).removeClass("hover");
		}).mouseover(function(){
			$(this).addClass("hover");
		});
	});
	
	$("div.attendant:eq(0)").show(); // Show the first Attendant

	// Highlight the first thumbnail and remove href="#"
	$("#gallery-nav ul").find("li:eq(0)").addClass("on").end().find("a").attr("href","javascript:void(0)");

	
	$("div.attendant").attr("id", function (arr) { // Assign an ID to each attendant LARGE photo
		return "large-id" + arr;
	});

	$("#gallery-nav ul li").attr("id", function (arr) { // Assign an ID to each attendant THUMB photo
		return "id" + arr;
	});

	// Clicking on THUMB hides current and shows respective LARGE
	$("#gallery-nav ul li").click(function(){

		$('div.attendant').hide();
		$('#gallery-nav li').removeClass('on');
		$('#large-'+ $(this).attr('id') ).fadeIn(300);
		$(this).addClass("on")
	
	});
	
}

attendantDisplay(); 
homePageSlideshow();
	
});
