/* <script> */

	/* Simple jQuery Slideshow */
	$('#main_slideshow .slideset').each(function(){

	    var slides = $(this).find('.slide');
		var width  = $(this).width(), height = $(this).height();

		slides.css({
		    'width'  : width,
		    'height' : height
	    });

        slides.each(function() {
            $(this).find('img').each(function () {
                var $img = $(this);
                var img = new Image();
                img.src = $(this).attr('delayedsrc');
                $(img).bind('load', function() {
                    $img.attr('src', this.src).rewImgSizer({
                        'method' : 'crop',
                        'onAfterShow' : function () {
                            $(this).closest('.slide').not('.active').css('opacity', 0);
                        }
                    });
                });
            });
        });

//	    slides.each(function() {
//	        $(this).find('img').each(function () {
//		        $(this).rewImgSizer({
//                    'method' : 'crop',
//                    'onAfterShow' : function () {
//                        $(this).closest('.slide').not('.active').css('opacity', 0);
//                    }
//                });
//            });
//        });

		setInterval(function () {

            var slides = $('#main_slideshow').find('.slide');

            var active = slides.filter('.active');

            if (active.length == 0) active = slides.filter(':first');

            var next = active.next().length ? active.next() : slides.filter(':first');

            active.removeClass('active').animate({opacity: 0.0}, 500, function() {
                next.show().addClass('active').animate({opacity: 1.0}, 500);
            });

        }, 5000);

	});

/* </script> */
