﻿//加载页面
jQuery(document).ready(function() {
    var catalogid = jQuery("#rootcatalogid").val();

    jQuery.ajax({
        url: "/Web/getMenu1?r=" + Math.random(),
        type: 'get',
        data: { catalogid: catalogid },
        dataType: 'json',
        //async: (false),
        beforeSend: function(XMLHttpRequest) {
            jQuery("#menu1").html("加载中...");
            jQuery("#menu2").html("加载中...");
            jQuery("#title").html("加载中...");
            jQuery("#date").html("加载中...");
            jQuery("#textbody").html("加载中...");
        },
        success: function(json) {
            jQuery("#menu1").html(json.menu1);
            if (json.menu2 != '') {
                jQuery("#menu2").html(json.menu2);
            }
            else {
                jQuery("#menu2").remove();
            }
            jQuery("#title").html(json.title);
            jQuery("#date").html(json.date);
            jQuery("#textbody").html(json.body);
        }
    });
});


function getMenu2(catalogid) {
    jQuery.ajax({
        url: "/Web/getMenu2?r=" + Math.random(),
        type: 'get',
        data: { catalogid: catalogid },
        dataType: 'json',
        //async: (false),
        beforeSend: function(XMLHttpRequest) {
            jQuery("#menu2").html("加载中...");
            jQuery("#title").html("加载中...");
            jQuery("#date").html("加载中...");
            jQuery("#textbody").html("加载中...");
        },
        success: function(json) {
            if (json.menu2 != '') {
                jQuery("#menu2").html(json.menu2);
            }
            else {
                jQuery("#menu2").remove();
            }
            jQuery("#title").html(json.title);
            jQuery("#date").html(json.date);
            jQuery("#textbody").html(json.body);
            setMenu1(catalogid);
        }
    });
}

function getContent(catalogid) {
    jQuery.ajax({
        url: "/Web/getContent?r=" + Math.random(),
        type: 'get',
        data: { catalogid: catalogid },
        dataType: 'json',
        //async: (false),
        beforeSend: function(XMLHttpRequest) {
            jQuery("#title").html("加载中...");
            jQuery("#date").html("加载中...");
            jQuery("#textbody").html("加载中...");
        },
        success: function(json) {
            jQuery("#title").html(json.title);
            jQuery("#date").html(json.date);
            jQuery("#textbody").html(json.body);
            setMenu2(catalogid);
        }
    });
}

function setMenu1(catalogid) {
    jQuery("#menu1").find("span").each(function() {
        jQuery(this).attr("class", "orange");
    });
    jQuery("#menu1").find("#" + catalogid).attr("class", "orange_14b")
}

function setMenu2(catalogid) {
    jQuery("#menu2 ul li").find("a").each(function() {
        jQuery(this).attr("class", "into");
    });
    jQuery("#menu2 ul li").find("#" + catalogid).attr("class", "bold")
}