function MM_InitImage() {
    var $j = jQuery.noConflict();
    var elem = document.getElementById("HomeAnimation");
    var elem_imgs = elem.getElementsByTagName("img");
    var randomnumber = (Math.floor(Math.random() * elem_imgs.length) + 1);
    $j('div#HomeAnimation img').css({ opacity: 0.0 });
    $j('div#HomeAnimation img:first').addClass('show');
    $j('div#HomeAnimation img:first').css({ opacity: 1.0 });
    setInterval('rotate()', 5000);
}

function rotate() {
    //Get the first image
    var $j = jQuery.noConflict();
    var current = ($j('div#HomeAnimation img.show') ? $j('div#HomeAnimation img.show') : $j('div#HomeAnimation img:first'));

    //Get next image, when it reaches the end, rotate it back to the first image
    var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $j('div#HomeAnimation img:first') : current.next()) : $j('div#HomeAnimation img:first'));

    //Set the fade in effect for the next image, the show class has higher z-index
    next.css({ opacity: 0.0 })
	.addClass('show')
	.animate({ opacity: 1.0 }, 2500);

    //Hide the current image
    current.animate({ opacity: 0.0 }, 2500)
	.removeClass('show');

};
