var moodzt = "0";
function getRequest() {
        http_request = false;
        if (window.XMLHttpRequest) {
                //对于Mozilla、Netscape、Safari等浏览器，创建XMLHttpRequest
                http_request = new XMLHttpRequest();
                if (http_request.overrideMimeType) {
                        //如果服务器响应的header不是text/xml，可以调用其它方法修改该header
                        http_request.overrideMimeType('text/xml');
                }
        } else if (window.ActiveXObject) {
                // 对于Internet Explorer浏览器，创建XMLHttpRequest
                try {
                        http_request = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                        try {
                                http_request = new ActiveXObject("Microsoft.XMLHTTP");
                        } catch (e) {}
                }
        }
        return http_request;
}

function getResponseText(url)
{
	http_request=getRequest();
	http_request.open('GET', url, false);
	http_request.send(null);

	if (http_request.readyState == 4)
		　　 {
			　　　// 收到完整的服务器响应
				　　　if (http_request.status == 200) {
					　　    //HTTP服务器响应的值OK
						　　　　  requestdoc = http_request.responseText;
					　　　　  //将服务器返回的字符串写到页面中ID为message的区域
				}
			　　　   else {
		　　　　  requestdoc = http_request.status;
	　　　   }
　　  }
	return requestdoc;
}



function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
}
function get_mood(moodId)
{

	url = "/info/mood.do?action=mood&id="+newsId+"&moodId="+moodId+"&m=" + Math.random();
	sta=getResponseText(url); 
	if (sta == 1)
	{
		alert("您已经投过票，请不要重复投票！")
		return false;

	}
	else
	{
		moodinner(sta)
	}
}

function remood()
{
	url = "/info/mood.do?action=show&id="+newsId+"&m=" + Math.random();
	
	sta=getResponseText(url); 
	moodinner(sta)
	
}

function moodinner(moodtext)
{
	var imga = "/info/images/pre_02.gif";
	var imgb = "/info/images/pre_01.gif";
	var color1 = "#666666";
	var color2 = "#EB610E";
	var heightz = "80";	//图片100%时的高
	var hmax = 0;
	var hmaxpx = 0;
	var heightarr = new Array();
	var moodarr = moodtext.split(",");
	var moodzs = 0;
	for(k=0;k<8;k++) {
		moodarr[k] = parseInt(moodarr[k]);
		moodzs += moodarr[k];
	}
	for(i=0;i<8;i++) {
		heightarr[i]= Math.round(moodarr[i]/moodzs*heightz);
		if(heightarr[i]<1) heightarr[i]=1;
		if(moodarr[i]>hmaxpx) {
		hmaxpx = moodarr[i];
		}
	}
	//已有<font color='#FF0000'>"+moodzs+"</font>人表态：
	
	$("moodtitle").innerHTML = "<span style='float:left'>您看完这篇文章此刻的感受是：</span>";
	
	for(j=0;j<8;j++)
	{
		if(moodarr[j]==hmaxpx && moodarr[j]!=0) {
			$("moodinfo"+j).innerHTML = "<span style='color: "+color2+";'>"+moodarr[j]+"</span><br><img src='"+imgb+"' width='20' height='"+heightarr[j]+"'>";
		} else {
			$("moodinfo"+j).innerHTML = "<span style='color: "+color1+";'>"+moodarr[j]+"</span><br><img src='"+imga+"' width='20' height='"+heightarr[j]+"'>";
		}
	}
}
document.writeln("<table width=\"528\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\" style=\"font-size:12px;margin-top: 20px;margin-bottom: 20px;\">");
document.writeln("<tr>");
document.writeln("<td colspan=\"8\" id=\"moodtitle\"  class=\"left\"><\/td>");
document.writeln("<\/tr>");
document.writeln("<tr align=\"center\" valign=\"bottom\">");
document.writeln("<td height=\"60\" id=\"moodinfo0\"><\/td><td height=\"30\" id=\"moodinfo1\">");
document.writeln("<\/td><td height=\"30\" id=\"moodinfo2\">");
document.writeln("<\/td><td height=\"30\" id=\"moodinfo3\">");
document.writeln("<\/td><td height=\"30\" id=\"moodinfo4\">");
document.writeln("<\/td><td height=\"30\" id=\"moodinfo5\">");
document.writeln("<\/td><td height=\"30\" id=\"moodinfo6\">");
document.writeln("<\/td><td height=\"30\" id=\"moodinfo7\">");
document.writeln("<\/td><\/tr>");
document.writeln("<tr align=\"center\" valign=\"middle\">");
document.writeln("<td><img src=\"/info/images/mood0.gif\" width=\"40\" height=\"40\"><\/td>");
document.writeln("<td><img src=\"/info/images/mood1.gif\" width=\"40\" height=\"40\"><\/td>");
document.writeln("<td><img src=\"/info/images/mood2.gif\" width=\"40\" height=\"40\"><\/td>");
document.writeln("<td><img src=\"/info/images/mood3.gif\" width=\"40\" height=\"40\"><\/td>");
document.writeln("<td><img src=\"/info/images/mood4.gif\" width=\"40\" height=\"40\"><\/td>");
document.writeln("<td><img src=\"/info/images/mood5.gif\" width=\"40\" height=\"40\"><\/td>");
document.writeln("<td><img src=\"/info/images/mood6.gif\" width=\"40\" height=\"40\"><\/td>");
document.writeln("<td><img src=\"/info/images/mood7.gif\" width=\"40\" height=\"40\"><\/td>");
document.writeln("<\/tr>");
document.writeln("<tr>");
document.writeln("<td align=\"center\" class=\"hui\">惊讶<\/td>");
document.writeln("<td align=\"center\" class=\"hui\">欠揍<\/td>");
document.writeln("<td align=\"center\" class=\"hui\">支持<\/td>");
document.writeln("<td align=\"center\" class=\"hui\">很棒<\/td>");
document.writeln("<td align=\"center\" class=\"hui\">愤怒<\/td>");
document.writeln("<td align=\"center\" class=\"hui\">搞笑<\/td>");
document.writeln("<td align=\"center\" class=\"hui\">恶心<\/td>");
document.writeln("<td align=\"center\" class=\"hui\">不解<\/td>");
document.writeln("<\/tr>");
document.writeln("<tr align=\"center\">");
document.writeln("<td><input onClick=\"get_mood(\'mood1\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<td><input onClick=\"get_mood(\'mood2\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<td><input onClick=\"get_mood(\'mood3\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<td><input onClick=\"get_mood(\'mood4\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<td><input onClick=\"get_mood(\'mood5\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<td><input onClick=\"get_mood(\'mood6\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<td><input onClick=\"get_mood(\'mood7\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<td><input onClick=\"get_mood(\'mood8\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
document.writeln("<\/tr>");
document.writeln("<\/table>")
remood();