function slideSwitch(id) {
    var $active = $('#header img.active');
    var $nextImage = $('#showcaseImage'+id);

    if ( $active.length == 0 ) $active = $('#header img:last');

    var $next =  $active.next().length ? $active.next() : $('#header img:first');


    $active.addClass('last-active');
	
	if(currentImageId != id) {
	
    $nextImage.css({opacity: 0.0})
		.addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
        
       	currentImageId = id;
       	window.clearTimeout(timeout);
		timeout = setTimeout("showcaseNextOrPrev('next')", time);   
    }
}

function showcaseNextOrPrev(direction) {
	if(direction == "next") {
		if(currentImageId < maxImages) {
			slideSwitch(currentImageId + 1);
		} else {
			slideSwitch(1);
		}
	} else {
		if(currentImageId == 1) {
			slideSwitch(maxImages);
		} else {
			slideSwitch(currentImageId - 1);
		}
	}
}
