﻿$(function() {
    var q = $('.quote');
    if (q.length > 0) {
        var qb = $('.quotes').show().eq(1),
            h = qb.height() / 2,
            c = null,
            nb = $('.home-newscontainer').height(143);
        q.each(function() {
            var o = $(this), t = h - (o.height() / 2);
            o.css('top', t < 0 ? function() {
                o.css('font-size', parseFloat(o.css('font-size')) - 1); return 0;
            } () : t);
        });
        var nextQ = function(time) {
            setTimeout(function() {
                if (c) c.animate({ opacity: 0 }, 1000);
                q = (q = q.not(c = q.eq(Math.floor(Math.random() * q.length)).animate({ opacity: 1 }, 1000))).length != 0 ? q : $('.quote');
                nextQ(6000);
            }, time);
        }
        nextQ(0);
        if (jQuery.browser.opera)
            $('.s-l-l, .line-left, .line-right', nb).height(nb.height() + 14);
    }
});