﻿/// <reference path="jquery/jquery126.js" />
/// <reference path="jquery/JQuery.Intellisense.js" />

$(function() {
    var parentId = GetQuery("parentId");
    if (parentId == "") parentId = "79";
    showchannel.json("Sys/GetDic/DicId=" + parentId);
    showarticles.json("Article/GetArticleTop/kindId=" + parentId + "&top=20");
});

function showchannel(json) {
    $("#leftchannel .setitle").html(json.DicName);
}
function showarticles(json) {
    var html = '<ul>';
    $.each(json, function(i, item) {
		html+='<li>';
		if(item.Http=="")
			html += '<a href="javascript:;" onclick="changearticle(' + item.ArticleID + ',\'' + item.Title + '\')">' + item.Title + '</a>';
		else
			html += '<a href="'+item.Http+'">' + item.Title + '</a>';
		html+='</li>';
    });
    html += '</ul>';
    $("#leftchannel .content").html(html);

    if (json.length > 0) {
        var defaultId = GetQuery("articleId");
        var article = json[0];
        if (defaultId != "") {
            $.each(json, function(i, item) {
                if (item.ArticleID == defaultId) {
                    article = item;
                    return false;
                }
            });
        }
        changearticle(article.ArticleID, article.Title);
    }
}
function changearticle(articleId, title) {
    $("#articlecontent").html('<img src="images/wait.gif" />');
    $("#articletitle .mtitle").html(title);
    showcontent.json("Article/GetArticleContent/articleId=" + articleId);
}
function showcontent(json) {
    $("#articlecontent").css("height", "auto");
    $("#articlecontent").html(json.Content);
    if ($("#articlecontent")[0].offsetHeight < 600)
        $("#articlecontent").css("height", 580);

    if ($("#orgmap")[0] != null) {
        $("#articlecontent area").tooltip({ showURL: false });
        $("#articlecontent area").focus(function() { if (this.blur) this.blur() });
    }

}
