var slide_index = -1;
function slideSwitch() 
{
	slide_index++;
	var len = 0;
	len = jQuery('#slideshow IMG').length;
	if (slide_index == len)
	{
		slide_index = 0;
	}
    var $active = jQuery('#slideshow IMG').eq(slide_index);
	$active.show();
	if (len < 2) return false;
 
    // use this to pull the images in the order they appear in the markup
    var $next =  jQuery('#slideshow IMG').eq(slide_index+1);
	if (slide_index + 1 == len)
	{
		$next =  jQuery('#slideshow IMG').eq(0);
	} 
 
    $active.addClass('last-active');
 
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}
 
$(function() {
    setInterval( "slideSwitch()", 5000 );
});
