$(document).ready(function() {
	// SLIDEDECK
	// $('.slidedeck').slidedeck();
	var tilteedDeck = $('.slidedeck').slidedeck().current;
				
	// SlideDeck controller *click* functionality
	$('a.goToSlide').click(function(event) {
		// ignore <a> tag's default behavior
		event.preventDefault();
		var navIndex = $('#sd-controller dt a').index($(this)) + 1;
		// code to be executed when the link is clicked
		// tilteedDeck.goTo(this.href.replace(/.+#/,''));
		$('.slidedeck').slidedeck().goTo(navIndex);
		sdExternalNavUpdate();
	});
	
/*
	// SlideDeck controller *hover* functionality
	$('a.goToSlide').hover(
		function() {
			// stuff
		},
		function () {
			// more stuff
		}
	);
*/
/* 	sdExternalNavUpdate(); */
	
	// MORE SLIDEDECK
	function sdExternalNavUpdate() {
		// query the deck & get the current slide number
		currentSlide = $('.slidedeck').slidedeck().current;

		// loop over the anchors and see what's changed
		$('#sd-controller dt a').each(function() {
			// get the number at the end of the href
			var navIndex = $('#sd-controller dt a').index($(this)) + 1
			// check and se if it matches the current slide...
			// if yes, style it
			if (navIndex == currentSlide) {
				$(this).addClass('active');
			// if no, reset it
			} else {
				$(this).removeClass('active');
			}
		});
	};
	
	
	
}); // end ready
