    function swapImages(){

	// define active image

	var $active = $('#bg .active');

	// get next image (if none after, get first)

	var $next = ($('#bg .active').next().length > 0) ? $('#bg .active').next() : $('#bg div:first');    

	// ensure that active is in front and that the next image is second

	$active.css({'z-index':'2'});

	$next.show().css({'z-index':'1'});

	// since we know active is in front we can simply fadeout the active one

	$active.fadeOut('slow',function(){

	    // remove the active class from the old image

	    $active.removeClass('active');

	    // add it to the new one

	    $next.addClass('active');	    

	});

    }

    $(document).ready(function(){

	// Run our swapImages() function every 5secs

	setInterval('swapImages()', 5000);

    });
