var moodzt = "0";
var http_request = false;
function makeRequest(url, functionName, httpType, sendData)
{
	http_request = false;
	if (!httpType) httpType = "GET";
	
	if (window.XMLHttpRequest)
	{ // Non-IE...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/plain');
		}
	}
	else if (window.ActiveXObject)
	{ // IE
		try 
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{}
		}
	}

	if (!http_request)
	{
		alert('Cannot send an XMLHTTP request');
		return false;
	}

	var changefunc="http_request.onreadystatechange = "+functionName;
	eval (changefunc);
	http_request.open(httpType, url, true);
	http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	http_request.send(sendData);
}

function get_mood(mood_id)
{
	if(moodzt == "1") 
	{
		alert("囧，-_-|||，你不是表过态了嘛？");
	}
	else
	{
		
		var urltr = 'dispbbs_mood.asp?action=mood&id='+infoid+'&moid='+mood_id+'&m=' + Math.random();
		makeRequest(urltr,'return_review1','GET','');
		moodzt = "1";
	}
}

function remood()
{
	var urltr='dispbbs_mood.asp?action=show&id='+infoid+'&m='+Math.random();
	makeRequest(urltr,'return_review1','GET','');
}

function return_review1(ajax)
{
	if (http_request.readyState == 4)
	{
		if (http_request.status == 200)
		{
			var str_error_num = http_request.responseText;
			if(str_error_num=="error")
			{
				alert("信息不存在！");
			}
			else if(str_error_num==0)
			{
				alert("囧，-_-|||，你不是表过态了嘛？");
			}
			else
			{
				moodinner(str_error_num);
			}
		}
		else
		{
			alert('There was a problem with the request.');
		}
	}
}

function moodinner(moodtext)
{
	var imga = "images/mood/pre_02.gif";
	var imgb = "images/mood/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];
		}
	}
	document.getElementById("moodtitle").innerHTML = "<center><span style='color: #555555; padding-left:20px; font-weight:bold;'>您看完后的感受如何?已有<font color='#FF0000'>"+moodzs+"</font>人表态：</span></center>";
	for(j=0;j<8;j++)
	{
		if(moodarr[j]==hmaxpx && moodarr[j]!=0) {
			document.getElementById("moodinfo"+j).innerHTML = "<span style='color: "+color2+";'>"+moodarr[j]+"</span><br><img src='"+imgb+"' width='20' height='"+heightarr[j]+"'>";
		} else {
			document.getElementById("moodinfo"+j).innerHTML = "<span style='color: "+color1+";'>"+moodarr[j]+"</span><br><img src='"+imga+"' width='20' height='"+heightarr[j]+"'>";
		}
	}
}
document.writeln("<table width=\"500\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin:0px auto;\">");
document.writeln("<tr>");
document.writeln("<td colspan=\"8\" id=\"moodtitle\"><\/td>");
document.writeln("<\/tr>");
document.writeln("<tr align=\"center\" valign=\"bottom\">");
document.writeln("<td height=\"30\" id=\"moodinfo0\"><\/td>");
document.writeln("<td height=\"30\" id=\"moodinfo1\"><\/td>");
document.writeln("<td height=\"30\" id=\"moodinfo2\"><\/td>");
document.writeln("<td height=\"30\" id=\"moodinfo3\"><\/td>");
document.writeln("<td height=\"30\" id=\"moodinfo4\"><\/td>");
document.writeln("<td height=\"30\" id=\"moodinfo5\"><\/td>");
document.writeln("<td height=\"30\" id=\"moodinfo6\"><\/td>");
document.writeln("<td height=\"30\" id=\"moodinfo7\"><\/td>");
document.writeln("<\/tr>");
document.writeln("<tr align=\"center\">");
document.writeln("<td align=\"center\"><img onClick=\"get_mood(\'0\')\" style=\"cursor:pointer\" src=\"images\/mood\/0.gif\" width=\"35\" height=\"35\"><\/td>");
document.writeln("<td align=\"center\"><img onClick=\"get_mood(\'1\')\"  style=\"cursor:pointer\"src=\"images\/mood\/1.gif\" width=\"35\" height=\"35\"><\/td>");
document.writeln("<td align=\"center\"><img onClick=\"get_mood(\'2\')\"  style=\"cursor:pointer\"src=\"images\/mood\/2.gif\" width=\"35\" height=\"35\"><\/td>");
document.writeln("<td align=\"center\"><img onClick=\"get_mood(\'3\')\"  style=\"cursor:pointer\"src=\"images\/mood\/3.gif\" width=\"35\" height=\"35\"><\/td>");
document.writeln("<td align=\"center\"><img onClick=\"get_mood(\'4\')\"  style=\"cursor:pointer\"src=\"images\/mood\/4.gif\" width=\"35\" height=\"35\"><\/td>");
document.writeln("<td align=\"center\"><img onClick=\"get_mood(\'5\')\"  style=\"cursor:pointer\"src=\"images\/mood\/5.gif\" width=\"35\" height=\"35\"><\/td>");
document.writeln("<td align=\"center\"><img onClick=\"get_mood(\'6\')\"  style=\"cursor:pointer\"src=\"images\/mood\/6.gif\" width=\"35\" height=\"35\"><\/td>");
document.writeln("<td align=\"center\"><img onClick=\"get_mood(\'7\')\"  style=\"cursor:pointer\"src=\"images\/mood\/7.gif\" width=\"35\" height=\"35\"><\/td>");
document.writeln("<\/tr>");
document.writeln("<tr>");
document.writeln("<td align=\"center\" class=\"hui\" style=\"cursor:pointer\" onClick=\"get_mood(\'mood1\')\">惊讶<\/td>");
document.writeln("<td align=\"center\" class=\"hui\" style=\"cursor:pointer\" onClick=\"get_mood(\'mood2\')\">高兴<\/td>");
document.writeln("<td align=\"center\" class=\"hui\"  style=\"cursor:pointer\"onClick=\"get_mood(\'mood3\')\">支持<\/td>");
document.writeln("<td align=\"center\" class=\"hui\"  style=\"cursor:pointer\"onClick=\"get_mood(\'mood4\')\">无聊<\/td>");
document.writeln("<td align=\"center\" class=\"hui\"  style=\"cursor:pointer\"onClick=\"get_mood(\'mood5\')\">难过<\/td>");
document.writeln("<td align=\"center\" class=\"hui\"  style=\"cursor:pointer\"onClick=\"get_mood(\'mood6\')\">搞笑<\/td>");
document.writeln("<td align=\"center\" class=\"hui\"  style=\"cursor:pointer\"onClick=\"get_mood(\'mood7\')\">愤怒<\/td>");
document.writeln("<td align=\"center\" class=\"hui\"  style=\"cursor:pointer\"onClick=\"get_mood(\'mood8\')\">不解<\/td>");
document.writeln("<\/tr>");
document.writeln("<\/table>")
remood();