
	var refreshIntervalId;
	function slideSwitch(backwards) {
	    var $active = $('#slideshow IMG.active');
	    var $activeimg = $('#nav_bullets IMG.active');

	    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
	    if ( $activeimg.length == 0 ) $activeimg = $('#nav_bullets IMG:last');

	    // use this to pull the images in the order they appear in the markup

	    if (backwards) {
		    var $next =  $active.prev().length ? $active.prev()
		        : $('#slideshow IMG:last');
		    var $nextimage =  $activeimg.prev().length ? $activeimg.prev()
			        : $('#nav_bullets IMG:last');		    
	    } else {
		    var $next =  $active.next().length ? $active.next()
			        : $('#slideshow IMG:first');
		    var $nextimage =  $activeimg.next().length ? $activeimg.next()
			        : $('#nav_bullets IMG:first');		    
	    }	    
	    
	    $activeimg.attr('src','templates/images/slideshow_nav_circle.gif');
	    $activeimg.removeClass('active');
	    $nextimage.attr('src','templates/images/slideshow_nav_circle_over.gif');
	    $nextimage.addClass('active');
	    $active.addClass('last-active');

	    $next.css({opacity: 0.0})
	        .addClass('active')
	        .animate({opacity: 1.0}, 1000, function() {
	            $active.removeClass('active last-active');
	        });

	    var $currentText = $('#header_text div.display');
	    $currentText.addClass('hide');
	    $currentText.removeClass('display');

	    if (backwards) {
		    var $nextText =  $currentText.prev().length ? $currentText.prev()
			        : $('#header_text div:last');
	    } else {
		    var $nextText =  $currentText.next().length ? $currentText.next()
			        : $('#header_text div:first');
	    }	    


        if ($nextText.html() == '') { 
			$('#header_text').attr('style','display:none');
        } else {
        	$('#header_text').attr('style','display:block');
        }
            
	    $nextText.removeClass('hide');
	    $nextText.addClass('display');
	}

	function slideshowRight() { 
		clearInterval(refreshIntervalId);
		slideSwitch(false);
	}

	function slideshowLeft() { 
		clearInterval(refreshIntervalId);
		slideSwitch(true);
	}


	$(function() {
		refreshIntervalId = setInterval( "slideSwitch(false)", 20000 );
	});

