$.noConflict();
jQuery(document).ready(function($) {

    $images = $(".carouselImage");
    $imagesTotal = $images.size();
    var imageIndex = 0;
    var oldIndex = 0;
    if($imagesTotal > 1) {
        $images.css({ display : "none", zIndex : 0, opacity: 0 }).filter(":first").css({ display : "block", zIndex : 1, opacity : 1 });
        var timer = setInterval(function() {
            oldIndex = imageIndex;
            if(imageIndex == $imagesTotal-1)
                imageIndex = 0;
            else
                imageIndex++;
            $images.eq(imageIndex).css({opacity: 1, display : "block", zIndex : 1 });
            $images.eq(oldIndex).css({ zIndex : 2}).animate({ opacity : 0 }, 800, function() {
                $(this).css({ display : "none", zIndex : 0, opacity: 0 });
                //$images.eq(imageIndex).css({ zIndex : 1 });
            });
            
        }, 5000);
    }
});
