function slideSwitch(slideshow_id) {		
		var slideshow = '#' + slideshow_id;
    var $active = $(slideshow + ' div.active');
    if ( $active.length == 0 ) $active = $(slideshow + ' div:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next() : $(slideshow + ' div:first');

    $active.addClass('last-active');

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

/* Image Preloader */

jQuery.preloadImages = function() {
	for(var i = 0; i<arguments.length; i++) {
		jQuery("<img>").attr("src", arguments[i]);
	}
}


$(document).ready(function() {
	$.preloadImages("/images/main-1.jpg", "/images/main-2.jpg", "/images/main-3.jpg", "/images/main-4.jpg", "/images/main-5.jpg", "/images/main-6.jpg");
  setInterval( "slideSwitch('slideshow-main')", 5000 );
});