function handleHttpResponseNews(xmlHttp) {
    if (xmlHttp.readyState == 1) {
        setGetting();
    }
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
    		var xmlDoc = xmlHttp.responseXML;
    		if (xmlDoc.documentElement) {
    			var getData = xmlDoc.documentElement.childNodes;
    			setNewsInfo(getData);
    		}
		}
	}
}

function setNewsInfo(data) {
    
    div = document.getElementById('doing');
    div.style.display = 'none';
    
    news = data[0];
    url = data[1].childNodes;
    evaluate = data[2].childNodes;
    
    //////////////////////////////////////////////////////
    // 设置News正文信息
    // 文章标题
    div = document.getElementById('main_topic');
    html = news.childNodes[2].firstChild.nodeValue;
    div.innerHTML = html;
    // 分类
    div = document.getElementById('main_category');
    category_id = news.childNodes[1].firstChild.nodeValue;
    if (category_id == 5) {html = '<img src="/common/image/prt_news_01.gif" border="0">';}
    if (category_id == 6) {html = '<img src="/common/image/prt_news_02.gif" border="0">';}
    if (category_id == 7) {html = '<img src="/common/image/prt_news_03.gif" border="0">';}
    div.innerHTML = html;
    // 作者
    div = document.getElementById('main_author');
    html = news.childNodes[6].firstChild.nodeValue;
    div.innerHTML = html;
    // 作者所在城市
    div = document.getElementById('main_district');
    html = news.childNodes[7].firstChild.nodeValue;
    div.innerHTML = html;
    // 评分
    div = document.getElementById('main_points');
    html = news.childNodes[8].firstChild.nodeValue;
    div.innerHTML = html;
    // 评论
    div = document.getElementById('main_comments');
    html = news.childNodes[9].firstChild.nodeValue;
    div.innerHTML = html;
    // 正文
    html = news.childNodes[3].firstChild.nodeValue;
    editor = document.getElementById("MsgFrame").contentWindow;
    editor.document.charset = "UTF-8";
    editor.document.body.innerHTML = html;
    // 设置图片
    div = document.getElementById('main_image');
    image1 = news.childNodes[11].firstChild.nodeValue;
    image2 = news.childNodes[12].firstChild.nodeValue;
    html = "";
    if (image1 != 'null') {
        html += '<p><img src="' + image1 + '" border="0" width="200"></p>';
    }
    if (image2 != 'null') {
        html += '<p><img src="' + image2 + '" border="0" width="200"></p>';
    }
    if (image1 == 'null' && image2 == 'null') {
        html += '<p><img src="/common/image/prt_printing.jpg" border="0"></p>';
    }
    div.innerHTML = html;
    // 设置news_id
    input = document.getElementById('news_id');
    news_id = news.childNodes[0].firstChild.nodeValue;
    input.value = news_id;
    
    //////////////////////////////////////////////////////
    // 设置相关链接
    div = document.getElementById('trunk_back_url');
    html = '';
    for (i=0;i<url.length;i++) {
        html += '<p style="margin-top:10px; margin-left:10px;"><a target="_blank" href="' + url[i].childNodes[1].firstChild.nodeValue + '" class="news_link">' + url[i].childNodes[0].firstChild.nodeValue + '</a></p>'
    }
    div.innerHTML = html;
    
    //////////////////////////////////////////////////////
    // 设置评论
    // 评论统计
    div = document.getElementById('comment_level');
    if (news.childNodes[8].firstChild.nodeValue == 0) {
        html = '还没有网友参与评论';
    } else {
        html = '<p style="margin-top:10px"><strong><span style="color: #f8707b;font-size:14px;">网友留言&nbsp;&nbsp;&nbsp;</span></strong>目前的评价是：<span style="color: #DD0000;font-size:14px;"><strong>' + news.childNodes[8].firstChild.nodeValue + '</strong></span> 位网友中有<span style="color: #DD0000;font-size:14px;"><strong>' + news.childNodes[10].firstChild.nodeValue + '</strong></span> 位选择“很有参考价值”';
    }
    div.innerHTML = html;
    // 评论列表
    div = document.getElementById('comment_list');
    html = '';
    for (i=0;i<evaluate.length;i++) {
        html += '<p style="border-top: #CCCCCC dashed 1px; margin-bottom:5px;"></p>';
        html += '<div style="width:120px;float:left;">';
        if (evaluate[i].childNodes[0].firstChild.nodeValue == 1) html += '<img src="/common/image/ico_news_01.gif" border="0">';
        if (evaluate[i].childNodes[0].firstChild.nodeValue == 3) html += '<img src="/common/image/ico_news_02.gif" border="0">';
        if (evaluate[i].childNodes[0].firstChild.nodeValue == 5) html += '<img src="/common/image/ico_news_03.gif" border="0">';
        html += '</div>';
        html += '<div>';
        html += '<span>reviewer:</span>';
        if (evaluate[i].childNodes.length != 5) {
            html += '该评论用户已经退会';
        } else {
            html += '<span style="margin-left:13px;">' + evaluate[i].childNodes[3].firstChild.nodeValue + '</span>';
            html += '<span style="margin-left:8px;">[' + evaluate[i].childNodes[4].firstChild.nodeValue + ']</span>';
        }
        html += '</div>';
        html += '<div>';
        html += evaluate[i].childNodes[2].firstChild.nodeValue;
        html += '</div>';
    }
    div.innerHTML = html;
    document.all.MsgFrame.height=MsgFrame.document.body.scrollHeight;
    scroll.scrollTo(0, 'top');
}

function setGetting() {
    div = document.getElementById('doing');
	frame_obj = document.getElementById('doing');
	with(frame_obj.style) {   
		left = (document.body.clientWidth-parseInt(width));
		top = document.body.scrollTop;
        display = 'block';
	}
    
}
function pause() {
}

function sendHttpRequestNews(xmlHttp, url, id) {
    xmlHttp.open('GET', url+"?id="+id, true);
    xmlHttp.onreadystatechange = function() {
        handleHttpResponseNews(xmlHttp)
    }
    xmlHttp.send(null);
}

function setNews(id) {
    var xmlHttp = getXmlHttpObject();
    sendHttpRequestNews(xmlHttp, '/news/get_news.html', id);
}