﻿function swapImages(imageName){
 	  var $active = $('#myGallery .active');
 	  if (imageName == 'auto')
 	   	  var $next = ($('#myGallery .active').next().length > 0) ? $('#myGallery .active').next() : $('#myGallery p:first');      
   	  else
 	   	  var $next = $('#' + imageName);
 	  $active.fadeOut(1000, function() { $active.removeClass('active');
 	  								  $next.fadeIn(3000).addClass('active');
 	  								});
	  clearTimeout(timerID);
	  timerID = setTimeout('swapImages("auto")', 10000);
}

var timerID;
$(document).ready(function(){
	// Run our swapImages() function every 5secs      
	timerID = setTimeout('swapImages("auto")', 10000);
})
