$(document).ready(function() {
    imageBoxInit();
});

function imageBoxInit()
{
    $('.imageBox').each(function() {
        $(this).css('position', 'relative');
        var p = 0;
        var o = parseInt($(this).children('div').eq(0).css('height'));
        o += 10;
        $(this).children('div').each(function() {
            var h = $(this).children('p').eq(0).children('a').eq(0).attr('href');
            $(this)
                .css('position', 'absolute')
                .css('left', '0px')
                .css('top', p + 'px')
                .css('cursor', 'pointer')
                .click(function() { document.location = h; });
            p += o;
        });
    });
    setTimeout('imageBoxRun();', 5000);
}

function imageBoxRun()
{
    $('.imageBox').each(function() {
        var o = parseInt($(this).children('div').eq(0).css('height'));
        o += 10;
        var t = $(this).children('div').length;
        $(this).children('div').animate(
            {'top': '-=' + o + 'px'},
            500,
            false,
            function() { if (parseInt($(this).css('top')) < 0) { $(this).css('top', (o * (t - 1)) + 'px'); } }
        );
    });
    setTimeout('imageBoxRun();', 5000);
}