﻿jQuery.jQueryRandom = 0;
jQuery.extend(jQuery.expr[":"],
{
    random: function (a, i, m, r) {
        if (i == 0) {
            jQuery.jQueryRandom = Math.floor(Math.random() * r.length);
        };
        return i == jQuery.jQueryRandom;
    }
});

function randomImage() {
    $('#slideshow div:random').addClass('active')
}

function slideSwitch() {
    var $active = $('#slideshow div.active');
    var $next = $active.next('div').length ? $active.next('div') : $('#slideshow div:first');
    $active.addClass('last-active');
    $next.css({ opacity: 0.0 })
            .addClass('active')
			
			// below is the transition 2sec
            .animate({ opacity: 1.0 }, 2000, function () {
                $active.removeClass('active last-active');
            });
}

$(function () {
    randomImage();
	// below is for the silde itself 8sec
    setInterval("slideSwitch()", 8000);
});
