<!--//--><![CDATA[//><!--

 
// arrange the boxes to be aligned in a row
function arrangeBoxes() {
    $('.box').each( function(i, item) {
        var position = $('#window').position().top + 3 + i * ( $(item).width() + 10 );
        $(item).css('top', position+'px')
    });
}
 
// shifts all the boxes to the top, then checks if any top the window
function shiftLeft() {
    $('.box').animate({'top' : "-=200px"}, 6000, 'linear', checkEdge());
}
 
// returns the new location for the box that exited the window
function getNewPosition() {
    return $('.box:last').position().top + $('.box:last').outerWidth() + 10;
}
 
// if the box is outside the window, move it to the end
function checkEdge() {
    var windowsLeftEdge = $('#window').position().top;
 
    $('.box').each( function(i, box) {
        // right edge of the sliding box
        var boxRightEdge = $(box).position().top + $(box).width();
 
        // position of last box + width + 10px
        var newPosition = getNewPosition();
 
        if ( parseFloat(boxRightEdge) < parseFloat(windowsLeftEdge) ) { 
            $(box).css('top', newPosition);
            $(box).remove().appendTo('#window');
            first = $('.box:first').attr('class');
        }
    });
}

//--><!]]>
