$(function(){
	$("div.seasonUnit").each(function(i){
		var $this = $(this),
			 $main = $("#allContentFrame"),
			 $lightboxOpener = $this.find("div.collectionCover > a"),
			 $slideshow = $this.find("ol.galleryLinks"),
			 $title = $this.find("h3").clone(),
			 SlideShowId = "SlideShow" + i;
		
		$lightboxOpener
			.attr("href", "#" + SlideShowId)
			.openDOMWindow({ 
				eventType:'click',
				width: $main.width(),
				windowBGColor: 'transparent',
				windowPadding: '0',
				borderSize: '0',
				borderColor: 'transparent'
			})
			.click(function(){ $(this).blur(); });
			
		$slideshow.each(function(){ 
			var $this = $(this);
			$this
				.wrap("<div>")
				.parent()
					.attr("id", SlideShowId)
					.prepend($title)
					.append(
						"<div class='controls'>" +
							"<a class='prev' href='#prev'>Prev</a>" +
							"<a class='next' href='#next'>Next</a>" +
							"<a class='close' href='#close'>Close</a>" +
						"</div>"
					)
					.find("a.close")
						.closeDOMWindow({ eventType: 'click' })
					.end()
					.hide()
				.end()
				.cycle({ 
					prev: $this.parent().find(".prev"),
					next: $this.parent().find(".next"),
					speed: 800,
					timeout: 0
				})
				.show();	// END $this
				
			$this.find("ol > li > a").each(function(){
				var $this = $(this);
				$this.empty().append($("<img>").attr("src", $this.attr("href")));
			});
			
		});	// END $slideshow.each()
		
	});	// END $("div.seasonUnit").each()
});	// END $(document).ready()

