$(document).ready(function()
{
	// thumbnail scrollable 
    $("div.scenes .thumbnails").each(function()
	{
		$(this).scrollable({size: 4, clickable: false}).mousewheel().find("img").each(function(index) 
		{ 
	 		var $imagegroup = $(this).closest(".imagegroup");

	        // thumbnail images trigger the overlay 
	        $(this).overlay({ 

	            effect: 'apple', 
	            target: $imagegroup.find('.overlaybox'), 
	            expose: {maskId: 'mask'}, 

	            /* 
	                when box is opened, scroll to correct position (in 0 seconds) 
	            */ 
	            onLoad: function() { $imagegroup.find(".images").scrollable().seekTo(index,0); } 
	        }); 
	    });
	});


	// scrollable inside the box. Its API is assigned to the "images" variable 
   $("div.scenes .images").scrollable(
	{
		size: 1,
		// when scrollable moves ... 
		onSeek: function(e,i)
		{
	        // grab previous/current/next items and place the image inside them 
			this.getItems().slice(Math.max(i-2, 0),i+2).each(function()
			{
				var el = $(this);
			
	            // if image has not already been created ... 
				if (!el.find('img').length)
				{
	                // create it 
					var img = $("<img/>");
					img.attr("src",el.attr("title"));
					el.prepend(img).removeAttr("title");
				}
			});
		}
	}).mousewheel();

	$(".showlate").show();

	// enable reflections 
    $("div.scenes .thumbnails img").reflect({height: 0.5, opacity: 0.3});
});