
var delegate = {
	willShow: function(overlayPanel, outgoing, incoming) {
		overlayPanel.setOverlayShadowImageSrc('http://images.apple.com/euro/macbookpro/images/overlay-designbg20081014.png');
	}
}

Event.onDOMReady(function() {

	AC.OverlayPanel.overlay.setDelegate(delegate);

	var gallerySections = $$('.unibodyStep');

	var unibodyGalleryViewMaster = new AC.ViewMaster.SlideshowViewer(gallerySections, 'unibodySwapView', 'unibody-trigger', '', {
		willEnd: true,
		delay: 1000,
		parentSectionId: 'unibody',
		parentTriggerClassName: 'overlaythumb',
		silentTriggers: true,
        animationDuration: 0.8
	});

	var parentViewMasterListener = {
		willShow: function(viewMaster, outgoing, incoming) {
			if (incoming.id === 'unibody') {
				this.reset();
			}
		}
	}

	Object.extend(parentViewMasterListener, Event.Listener);
	parentViewMasterListener.listenForEvent(AC.ViewMaster, 'ViewMasterDidShowNotification', false, function(evt) {
		var data = evt.event_data.data;
		if (data.outgoingView && data.outgoingView.id === 'unibody') {
			unibodyGalleryViewMaster.stop();
			unibodyGalleryViewMaster.reset();
		} else if (data.incomingView && data.incomingView.id === 'unibody') {
			unibodyGalleryViewMaster.reset();
			unibodyGalleryViewMaster.start();
		}
	});
});
