﻿$(function() {

    $.ajax({
        url: '/ajax/news.aspx',
        cache: false,
        dataType: 'html',
        success: function(data) {
            var content = $(data).find('#content');
            $('#newsticker').html($(content).html());
            showNews();
        }
    });

    $.ajax({
        url: '/ajax/topNews.aspx',
        cache: false,
        dataType: 'html',
        success: function(data) {
            var content = $(data).find('#content');
            $('#newstickertop').html($(content).html());
            showTopNews();
        }
    });

});

function showNews() {
    var newsCount = $("#search .news ul li").length;
    if (newsCount == 1)
        $("#search .news ul").show();
    else if (newsCount > 0) {
        $("#search .news ul").show();
        $("#newsticker").newsTicker(6000);
    }
}

function showTopNews() {
    var topNewsCount = $("#search .topnews ul li").length;
    if (topNewsCount == 1)
        $("#search .topnews ul").show();
    else if (topNewsCount > 0) {
        $("#search .topnews ul").show();
        $("#newstickertop").newsTicker(6000);
    }
}
