	/*****
	 *
	 *	Enabling auto-advance.
	 *
	 ****/
	var savedHTML;	 
	//var current=1;
	var current=0;
	var captions = 	['Everybody Wins! DC featured on NBC Nightly News',
						'White House Domestic Policy Director visits Everybody Wins! Iowa',
						'Everybody Wins! overview video',
						'Education Secretary Arne Duncan Visits the Everybody Wins DC Program'];

	function autoAdvance()
	{
		var len = jQuery('#slideshowcontrols img').length;
		// I don't know how this could occur
		if(current==-1) return false;

		// When current mod #entries in the 
		
		jQuery('#slideshowcontrols img').eq(current%jQuery('#slideshowcontrols img').length).trigger('click',[true]);	// [true] will be passed as the keepScroll parameter of the click function on line 28
		current++;
	}
	// The number of seconds that the slider will auto-advance in:
	
jQuery(document).ready(function(){
	/* This code is executed after the DOM has been completely loaded */	
	var totWidth=0;
	var numImage = 0;
	var fadethis = false;
	var count = 4;
	
	var changeEvery = 10;
	var itvl = setInterval('autoAdvance()',changeEvery*1000);

	// Hide the restart button and set a click handler for it
	// So the restart animation button doesn't show when the animation runs
	
	jQuery('#restart').hide().click(  function () {
			current = 1;
			jQuery('#restart').hide();		// Hide the restart animation button
			itvl = setInterval('autoAdvance()',changeEvery*1000);	
	});

	jQuery('#slideshow').click( function() {
		clearInterval(itvl);
	});
	// Set a click handler for the thumbnails. When the animation is running, the autoAdvance
	// function triggers a fake click event to move to the next slide as if the next thumbnail
	//had been clicked. But that also passes the variable keepScroll as TRUE, whereas actually
	// clicking on a thumbnail leaves the variable UNDEFINED.
	
	jQuery('#slideshowcontrols img').click(function(e,keepScroll){
	
		/* On a thumbnail click */
		var src;
		// Get the position in the array of the control buttons
		var pos = jQuery(this).prevAll('img').length;
		
		// get a pointer into the corresponding div in the slides 
		var ptr = jQuery('#slides div').eq(pos);
		src = ptr.html();
		//jQuery('#slideshow').html(src);
		jQuery('#slideshow').hide().html(src).fadeIn(1000);
		jQuery('#slideshowcaption h5').text(captions[pos]);
		
		// If this is the last image and we are in slideshow mode, set fadethis to TRUE so we
		// hide the images when scrolling back to the first one
		if (pos == numImage-1) {
			if (keepScroll)
				fadethis = true;
		}
		/* Prevent the default action of the link */
		e.preventDefault();
		
		// Stopping the auto-advance if an icon has been clicked:
		// and show the restart animation button
		if(!keepScroll) {
			clearInterval(itvl);
			jQuery('#restart').show();
		}

	});
	
	/* On page load, mark the first thumbnail as active */
	//jQuery('#slideshow ul li.menuItem:first').addClass('act').siblings().addClass('inact');
	//jQuery('#slideshowcontrols img:first').addClass('act').siblings().addClass('inact');
	/* End of customizations */
});

