$(document).ready(function(){
	// Let's name the SlideDeck and store it somewhere. 
	var theSlideDeck = $('.slidedeck').slidedeck({hideSpines: true,cycle: true});
	theSlideDeck.vertical();
	
	//
	// Navigation for external PREV NEXT buttons
	//
	
	$('#navigation .prev').click(function(event){
		// Stuff to do when "Prev" is clicked.
		theSlideDeck.prev();
	});
	$('#navigation .next').click(function(event){
		// Stuff to do when "Next" is clicked.
		theSlideDeck.next();
	});
	$


	//
	// Navigation to link directly to specific slides
	// Usage: <a class="sd-nav" href="#2-3"> or <a class="sd-nav" href="#2">
	//
	
	$(document).ready(function() {
		// Check the URL hash
		var hash = document.location.hash;
		if(hash){
			hash = hash.split('#')[1];
			var slideIndex = hash.split('-');
			if(slideIndex.length > 1){
				// horiz & vert
				theSlideDeck.goToVertical(slideIndex[1],slideIndex[0]);
			}else{
				// horiz only
				theSlideDeck.goTo(slideIndex[0]);
			}
		}
	
		// Gather all the links with a class of sd-nav
		slideDeckLinks = $('a.sd-nav');
	
		// Process the links and add goTo commands
		slideDeckLinks.each(function(index){
	
			// Get the hashes
			var hash = this.href.split('#')[1];
	
			// Divide the hashes into horizontal-vertical array
			var slideIndex = hash.split('-'); 
	
			// Make each link do nothing when it's clicked.
			// Figure out if it should be vertical and horizontal navigation or just horizontal
			$(this).click(function(event){
				event.preventDefault(); // don't follow link
				if(slideIndex.length > 1){
					// horiz & vert
					theSlideDeck.goToVertical(slideIndex[1],slideIndex[0]);
				}else{
					// horiz only
					theSlideDeck.goTo(slideIndex[0]);
				}
			});
		});
	});
	
    $('.skin-slidedeck a.vertical-prev-next').bind('click', function(event){
        event.preventDefault();
        switch(this.href.split('#')[1]){
            case "previous":
                $('.skin-slidedeck .slidedeck').slidedeck().vertical().prev();
            break;
            case "next":
                $('.skin-slidedeck .slidedeck').slidedeck().vertical().next();
            break;
        }
    });
    
	$('.skin-slidedeck dl.slidedeck a.vertical-prev-next.previous').hide();

			
});
