var lightboxSlideOutSpeed = 400;
var lightBoxShown = false;
var lightBoxBackgroundOpacity = true;

function lightBoxShow(fadeOutBackground) {
	if (lightBoxShown) return;
	
	var slideOutWidth = jQuery("#lightbox img").width();
			
	// fadeout background image
	if (fadeOutBackground)
		jQuery("#page-photo").fadeTo(200,0.3);
	
	// slide in the light box from the right
	jQuery("#lightbox").fadeIn(lightboxSlideOutSpeed, function() { jQuery("#gallery-controls").fadeIn(2000) } );
	// jQuery("#lightbox").show("slide", { direction: "right" }, lightboxSlideOutSpeed)
	
	lightBoxShown = true;

}

function lightBoxHide() {
	
	// slide in the light box from the right
	// jQuery("#lightbox").hide("slide", { direction: "right" }, lightboxSlideOutSpeed)
	jQuery("#lightbox").fadeOut(lightboxSlideOutSpeed,
		function() {
			// fade back in background image
			jQuery("#page-photo").fadeTo(lightboxSlideOutSpeed,1.0);
		}
	);

	lightBoxShown = false;
}


jQuery(document).ready(function(){

	// Show the lightbox 
	// lightBoxShow(lightBoxBackgroundOpacity);	

	// Initialise the gallery			
	jQuery('#gallery').galleriffic('#carousel-area', {
        delay:                  3000, // in milliseconds
        numThumbs:              350, // The number of thumbnails to show page
        preloadAhead:           -1, // Set to -1 to preload all images
        enableTopPager:         false,
        enableBottomPager:      false,
        imageContainerSel:      '#gallery-photo', // The CSS selector for the element within which the main slideshow image should be rendered
        controlsContainerSel:   '#gallery-controls', // The CSS selector for the element within which the slideshow controls should be rendered
        captionContainerSel:    '#gallery-caption', // The CSS selector for the element within which the captions should be rendered
        loadingContainerSel:    '', // The CSS selector for the element within which should be shown when an image is loading
        renderSSControls:       true, // Specifies whether the slideshow's Play and Pause links should be rendered
        renderNavControls:      true, // Specifies whether the slideshow's Next and Previous links should be rendered
        playLinkText:           '&nbsp;',
        pauseLinkText:          '&nbsp;',
        prevLinkText:           'Previous',
        nextLinkText:           'Next',
        nextPageLinkText:       'Next &rsaquo;',
        prevPageLinkText:       '&lsaquo; Prev',
		syncTransitions:		true,
        enableHistory:          false, // Specifies whether the url's hash and the browser's history cache should update when the current slideshow image changes 
        autoStart:              false, // Specifies whether the slideshow should be playing or paused when the page first loads 
        onChange:               undefined, // accepts a delegate like such: function(prevIndex, nextIndex) { ... }
        onTransitionOut:        undefined, // accepts a delegate like such: function(callback) { ... }
        onTransitionIn:         undefined, // accepts a delegate like such: function() { ... }
        onPageTransitionOut:    undefined, // accepts a delegate like such: function(callback) { ... }
        onPageTransitionIn:     undefined  // accepts a delegate like such: function() { ... }
 	});
}); 

