// JavaScript Document

		// Script for handling goto's and prev and next
		var SlideDeckAssistant = {
			innerSlideCount: 0,
			/** prevSlide, nextSlide and goToSlide are all custom functions to control progress of the SlideDeck */
			prevSlide: function(theIndex){
				SlideDeckAssistant.goToSlide(theIndex - 1);
			},
			nextSlide: function(theIndex){
				SlideDeckAssistant.goToSlide(theIndex + 1);
			},
			goToSlide: function(theIndex){        
				$('ul.galleryNav li').removeClass('active');
				$('ul.galleryNav li:eq('+ theIndex +')').addClass('active');
				myDeck.goTo(theIndex+1);
			},
			init: function(){
				SlideDeckAssistant.innerSlideCount = $('#slidedeck_frame dl.slidedeck dd').length;
				// create navigation element with next and previous buttons
				$('#slidedeck_frame').append('<ul class="galleryNav"><\/ul>');
				// create bullet navigation element
				for (i=0 ; i < SlideDeckAssistant.innerSlideCount ; i++ ) {
					$('ul.galleryNav').append('<li><a href="goto#' + (i+1) + '">' + (i+1) + '<\/a><\/li>');
				}
				// create navigation bullets based on number of slides
				var goToDots = $('ul.galleryNav li a');
				$('ul.galleryNav').css({marginLeft: '-' + (goToDots.outerWidth(true)*goToDots.length / 2) + 'px'});
				// position navigation bullets
				$('ul.galleryNav li:first').addClass('active');
				$('ul.galleryNav li a').click(function(e){
					e.preventDefault();
					var theIndex = $('ul.galleryNav li a').index($(this));
					SlideDeckAssistant.goToSlide(theIndex);
					return false;
				});
				// assign click function to navigation bullets
				$('ul.galleryArrows li.prev a').click(function(e){
					e.preventDefault();
					if($(this).parent('li').hasClass('disabled')){
						return false;
					}else{
						var theIndex = $('ul.galleryNav li').index($('ul.galleryNav li.active'));
						SlideDeckAssistant.prevSlide(theIndex);
					}
					return false;
				});
				// assign click function for previous button
				$('ul.galleryArrows li.next a').click(function(e){
					e.preventDefault();
					if($(this).parent('li').hasClass('disabled')){
						return false;
					}
					else{
						var theIndex = $('ul.galleryNav li').index($('ul.galleryNav li.active'));
						SlideDeckAssistant.nextSlide(theIndex);
					}
					return false;
				});
				//assign click function for next button
		}
		};
		
		$(document).ready(function(){
			SlideDeckAssistant.init();
		});
			
		/** Initiate the SlideDeck */
		var myDeck = $('#slidedeck_frame dl.slidedeck').slidedeck({
			hideSpines: true,
            autoPlay: true,
            cycle: true,
			autoPlayInterval: 11000,
			scroll: false,
            /**
             * The complete function is executed after each slide animation.
             * here we are using it to upate the navigation dots.
             */
            complete: function(deck){
				$('ul.galleryNav li').removeClass('active');
				$('ul.galleryNav li:eq('+ ( deck.current - 1 ) +')').addClass('active');
				/** Update current slide indicator after each slide animation completes */
            }
		}) 
