$(document).ready(function()
{
    var imgArray = $('.imageHolder img').get();
    var margin = $(imgArray[0]).width()/2;
    var width=$(imgArray[0]).width();
    var height=$(imgArray[0]).height();
    var firstImage = -1;
    var secondImage = 0;

    $(imgArray).each(function(){
        $(this).stop().css({width:'0px',height:''+height+'px',marginLeft:''+margin+'px',opacity:'0.5'});
    });

    flipImage();
    
    function flipImage()
    {
        firstImage++;
        secondImage++;
        
        if(firstImage == imgArray.length)
        {
            firstImage = 0;
        }
        if(secondImage == imgArray.length)
        {
            secondImage = 0;
        }
      
        $(imgArray[firstImage]).stop().animate({width:'0px',height:''+height+'px',marginLeft:''+margin+'px',opacity:'0.5'},{duration:500});
        window.setTimeout(function() {
        $(imgArray[secondImage]).stop().animate({width:''+width+'px',height:''+height+'px',marginLeft:'0px',opacity:'1'},{duration:500});
        t = setTimeout(function(){
        flipImage()},6000);
        },500);
    }
});
