
$(function() {
    var n = $('#quick-news');
    var nc = n.clone();
    var wh = window.innerHeight || (document.documentElement && document.documentElement.clientHeight) || document.body.clientHeight;
    var ww = (window.innerWidth || (document.documentElement && document.documentElement.clientWidth) || document.body.clientWidth)-55;
    nc.css({
    'position': 'absolute',
    'top': ((wh-n.height())/2)+'px',
    'left': ((ww-n.width())/2)+'px',
    'background-color': '#fff',
    'border': '3px double #fccb86',
    'padding': '15px',
    'box-shadow': '3px 3px 3px #999',
    '-moz-box-shadow': '3px 3px 3px #999',
    '-webkit-box-shadow': '3px 3px 3px #999',
    'text-align': 'left'
    });
    $('body').append(nc);

    var o = n.offset();
    var left = o.left;
    var top = o.top;
    if((left <= 0) || (top <= 0)) {
        var o = n.parent().offset();
        left = left + o.left;
        top = top + o.top;
    }
    window.setTimeout(function() {
        nc.animate({'left': left, 'top': top}, 2000, function() {nc.fadeOut('slow', function() {nc.remove()})});
    }, 3000);

    var mess = $('div.message');
    if(mess.length) {
        window.setTimeout(function() {
            mess.fadeOut('slow', function() {mess.remove()});
        }, 4000);
    }
});
