$(function() {
    var aId = GetQuery("id");
    if (aId == "") { return false; }
    loadArticle(aId);
});

function showArticle(json) {

    var article = json[0];
    var next = json[1];
    var pre = json[2];

    $("#topchannel .dcchannel").html(article.Title);
    $("#article .title").html(article.Title);
    $("#article .from").html("来源：" + article.CopyFrom + "&nbsp;&nbsp;时间：" + article.AddDate);
    $("#article .content").html(article.Content);
	if($("#article .content")[0].offsetHeight<360)
		$("#article .content").css("height",360);

    if (next.ArticleID) {
        if (next.Http == "") {
            next.Http = '<a href="javascript:;" onclick=loadArticle(' + next.ArticleID + ')>'
        }
        else {
            next.Http = '<a href="' + next.Http + '" target="_blank">'
        }
        $("#article .next").html('下一篇：' + next.Http + next.Title + '</a>');
    }
    else {
        $("#article .next").html('下一篇：无');
    }


    if (pre.ArticleID) {
        if (pre.Http == "") {
            pre.Http = '<a href="javascript:;" onclick=loadArticle(' + pre.ArticleID + ')>'
        }
        else {
            pre.Http = '<a href="' + pre.Http + '" target="_blank">'
        }
        $("#article .pre").html('上一篇：' + pre.Http + pre.Title + '</a>');
    }
    else {
        $("#article .pre").html('上一篇：无');
    }

}

function loadArticle(id) {
    window.scrollTo(0,0);
    $("#article .title").html('<img src="images/wait.gif" />');
    $("#article .next").empty();
    $("#article .pre").empty();
    showArticle.json("Article/GetArticle/ArticleID=" + id);
}
