jQuery(document).ready(function(){
    var currentPosition = 0;
    var animationTime = 700;
    var container = jQuery('#content_left .image_slider');
    var items = container.find('dl, li');
    var images = container.find('dt, li');
    var caption = container.find('dd');
    var length = items.length;
    var heights = [];
    var widths = [];
    var innerHeights = [];
    var i = 0;

    if (length > 1) {
        jQuery.each(items, function() {

            heights[i] = jQuery(this).outerHeight(true);
            widths[i] = jQuery(this).outerWidth(true);

            $image = jQuery(this).find('img');

            innerHeights[i] = $image.outerHeight(true);
            $image.removeClass('hidden');

            i++;

        });

        maxH = Math.max.apply( Math, heights );
        maxW = Math.max.apply( Math, widths );

        maxImageH = Math.max.apply( Math, innerHeights );

        container.css({            'position': 'relative',
            'height': maxH + 'px',
            'width': maxW + 'px'
        })

        images.css({        	'position': 'absolute',
        	'top': 0 + 'px',
        	'left': 0 + 'px'
        })

        caption.css({
        	'position': 'absolute',
        	'top': maxImageH + 'px',
        	'left': 0 + 'px'
        })

        images.css({
            'z-index': 1,
            'opacity' : 1.00
        }).not(':eq(0)').css({
        	'opacity' : 0.00
        })

        setInterval(function() {            oldPosition = currentPosition
            currentPosition = currentPosition+1;

            if (currentPosition > length-1) {
                currentPosition = 0;
            }

            images.eq(oldPosition).animate({
                'opacity' : 0.00
            }, animationTime, 'linear', function() {                images.eq(currentPosition).animate({
                    'opacity' : 1.00
                }, animationTime, 'linear');
            });
        }, 9000);
    }
})