﻿
function MostViewedPages(divId, count) {
    //var msg = '{"filename":"test", "mode":"1"}';
    $.ajax({
        type: "POST",
        url: '/ws/MostViewed.asmx/GetMostViewedPages',
        dataType: 'json',
        contentType: 'application/json',
        data: '{"count":"'+count+'"}',
        success: function(m) {
            $("#" + divId).empty();
            for (var v in m.d) {
                $("#" + divId).append("<div class='mostViwedLink'><a class='mostViewedPagelink' href='" + m.d[v].url + "'>" + m.d[v].name + "</a></div><div class='mostviewed-divider'><!-- --></div>");               
            
            }
        }
    });
    if (count > 5) {
        $("#mostViewedFlerPages").hide();
    }
    else {
        $("#mostViewedFlerPages").show();
    }       
    $("#mostViewedFlerNews").hide();
    $("#mostViewedFlerQueries").hide();

    $("#mostViewedButtonLeftPages").attr("class", "mostViewedButtonLeftActive");
    $("#mostViewedButtonLeftNews").attr("class", "mostViewedButtonLeft");
    $("#mostViewedButtonLeftQueries").attr("class", "mostViewedButtonLeft");

    $("#mostViewedButtonMiddlePages").attr("class", "mostViewedButtonMiddleActive");
    $("#mostViewedButtonMiddleNews").attr("class", "mostViewedButtonMiddle");
    $("#mostViewedButtonMiddleQueries").attr("class", "mostViewedButtonMiddle");

    $("#mostViewedButtonRightPages").attr("class", "mostViewedButtonRightActive");
    $("#mostViewedButtonRightNews").attr("class", "mostViewedButtonRight");
    $("#mostViewedButtonRightQueries").attr("class", "mostViewedButtonRight");
}

function MostViewedNewsPages(divId, count) {
    //var msg = '{"filename":"test", "mode":"1"}';
    $.ajax({
        type: "POST",
        url: '/ws/MostViewed.asmx/GetMostViewedNewsPages',
        dataType: 'json',
        contentType: 'application/json',
        data: '{"count":"' + count + '"}',
        success: function(m) {
            $("#" + divId).empty();
            for (var v in m.d) {
                $("#" + divId).append("<div class='mostViwedLink'><a class='mostViewedPagelink' href='" + m.d[v].url + "'>" + m.d[v].name + "</a></div><div class='mostviewed-divider'><!-- --></div>"); 
            }
        }
    });
    if (count > 5) {
        $("#mostViewedFlerNews").hide();
    }
    else {
        $("#mostViewedFlerNews").show();
    }
    
    $("#mostViewedFlerPages").hide();
    $("#mostViewedFlerQueries").hide();

    $("#mostViewedButtonLeftPages").attr("class", "mostViewedButtonLeft");
    $("#mostViewedButtonLeftNews").attr("class", "mostViewedButtonLeftActive");
    $("#mostViewedButtonLeftQueries").attr("class", "mostViewedButtonLeft");

    $("#mostViewedButtonMiddlePages").attr("class", "mostViewedButtonMiddle");
    $("#mostViewedButtonMiddleNews").attr("class", "mostViewedButtonMiddleActive");
    $("#mostViewedButtonMiddleQueries").attr("class", "mostViewedButtonMiddle");

    $("#mostViewedButtonRightPages").attr("class", "mostViewedButtonRight");
    $("#mostViewedButtonRightNews").attr("class", "mostViewedButtonRightActive");
    $("#mostViewedButtonRightQueries").attr("class", "mostViewedButtonRight");
    
}    
    function MostViewedQueries(divId, count) {
    //var msg = '{"filename":"test", "mode":"1"}';
    $.ajax({
        type: "POST",
        url: '/ws/MostViewed.asmx/GetMostViewedQueries',
        dataType: 'json',
        contentType: 'application/json',
        data: '{"count":"' + count + '"}',
        success: function(m) {
            $("#" + divId).empty();
            for (var v in m.d) {
                $("#" + divId).append("<div class='mostViwedLink'><a class='mostViewedPagelink' href='" + m.d[v].url + "'>" + m.d[v].name + "</a></div><div class='mostviewed-divider'><!-- --></div>");                
            }
        }
    });

    if (count > 5) {
        $("#mostViewedFlerQueries").hide();
    }
    else {
        $("#mostViewedFlerQueries").show();
    }

    $("#mostViewedFlerPages").hide();
    $("#mostViewedFlerNews").hide();

    $("#mostViewedButtonLeftPages").attr("class", "mostViewedButtonLeft");
    $("#mostViewedButtonLeftNews").attr("class", "mostViewedButtonLeft");
    $("#mostViewedButtonLeftQueries").attr("class", "mostViewedButtonLeftActive");

    $("#mostViewedButtonMiddlePages").attr("class", "mostViewedButtonMiddle");
    $("#mostViewedButtonMiddleNews").attr("class", "mostViewedButtonMiddle");
    $("#mostViewedButtonMiddleQueries").attr("class", "mostViewedButtonMiddleActive");

    $("#mostViewedButtonRightPages").attr("class", "mostViewedButtonRight");
    $("#mostViewedButtonRightNews").attr("class", "mostViewedButtonRight");
    $("#mostViewedButtonRightQueries").attr("class", "mostViewedButtonRightActive");

}
