//Variables that initialize the slider and keep track of the current slide
	var loadCount = 0;
	var theInt = null;
	var $crosslink, $navthumb;

		//Loads the slider after the page has been changed
		function loadSlider() {

			//Set the position to the first slide if this is the first time loaded
			if(loadCount==0)
				curclicked = 0;
		
			var theInterval = function(cur){
				//clearInterval(theInt);
			
				if( typeof cur != 'undefined')
					curclicked = cur;
			
				$crosslink.removeClass("active-thumb");
				$navthumb.eq(curclicked).parent().addClass("active-thumb");
				$(".stripNav ul li a").eq(curclicked).trigger('click');

				// Sets the interval for switching stories
				//Call once to keep it from creating multiple sliders within the same page
				if(theInt == null){
					theInt = setInterval(function(){
						//Crosslink sets the pane for thumbnail and slider pane
						$crosslink.removeClass("active-thumb");
						$navthumb.eq(curclicked).parent().addClass("active-thumb");
						
						//Sets the position after clicked
						$(".stripNav ul li a").eq(curclicked).trigger('click');
						curclicked++;
						// If at the end, go back to first story
						if( 6 == curclicked )
							curclicked = 0;
				
					}, 4000);  // Number of milliseconds to wait
				} 
			};
		
			$(function(){
			
				$("#main-photo-slider").codaSlider();
			
				$navthumb = $(".nav-thumb");
				$crosslink = $(".cross-link");
			
				$navthumb
				.click(function() {
					var $this = $(this);
					theInterval($this.parent().attr('href').slice(1) - 1);
					return false;
				});
				theInterval();
			});

		}
		