function MM_InitImage() {
    //var $j = jQuery.noConflict();
    var elem = document.getElementById("HomeAnimation");
    var elem_imgs = elem.getElementsByTagName("img");
    for (var i = 0; i < elem_imgs.length; i++) {
        elem_imgs[i].setAttribute('onclick', 'location.href = "#"');
        //elem_imgs[i].setAttribute('style', 'position:absolute;');
    }
    var randomnumber = (Math.floor(Math.random() * elem_imgs.length) + 1);
    //alert(randomnumber);
    $('div#HomeAnimation img').css({ opacity: 0.0 });
    $('div#HomeAnimation img:first').addClass('show');
    $('div#HomeAnimation img:first').css({ opacity: 1.0 });
    setInterval('rotate()', 4000);
}

function rotate() {
    //Get the first image
    var current = ($('div#HomeAnimation img.show') ? $('div#HomeAnimation img.show') : $('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')) ? $('div#HomeAnimation img:first') : current.next()) : $('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');

};
