﻿$(function() {
    $('.outbox .inbox .content').each(function(i) {
        var _outbox = $(this).parent().parent();
        var _inbox = $(this).parent();
        var _content = $(this);
        var _text = _content.attr("text");
        var _color = _content.attr("color");
        var _size = _content.attr("size");
        var _url = _content.attr("url");
        var _linkstr = "";
        if (_url != null) { _linkstr += '<a href="' + _url + '" style="text-decoration:none;" target="_blank">'; }
        _linkstr += '<font';
        if (_size != null) { _linkstr += ' size="' + _size + '"'; }
        if (_color != null) { _linkstr += ' color="' + _color + '"'; }
        _linkstr += '>';
        _linkstr += _text;
        _linkstr += '</font>';
        if (_url != null) { _linkstr += '</a>'; }
        _inbox.append('<table cellpadding="0" cellspacing="0" width="' + _outbox.width() + '"><tr><td height="' + _outbox.height() + '" align="center" valign="middle">' + _linkstr + '</td></tr></table>');
    });
    setTimeout("nextpic()", 2500);
});
function nextpic() {
    $('.outbox').each(function(i) {
        var height = $(this).attr('offsetHeight');
        var nowheight = $(this).find('.inbox').attr('offsetHeight');
        var nowtop = $(this).find('.inbox').offset().top - $(this).offset().top;
        if (Math.abs(nowtop) + height >= nowheight) {
            $(this).find('.inbox').animate({ top: 0 });
        }
        else {
            $(this).find('.inbox').animate({ top: nowtop - height });
        }
    });
    setTimeout("nextpic()", 2500);
}
