﻿function mood(mood_id) {
	var ajax = new AJAXRequest;
	if (mood_id == "start") {
		url = "Plugins/mood/mood.asp?action=show&id=" + g_logID + "&m=" + Math.random();
	} else {
		url = "Plugins/mood/mood.asp?action=mood&id=" + g_logID + "&typee=" + mood_id + "&m=" + Math.random();
	};
	ajax.get(url,
	function(obj) {
		var TempStr = obj.responseText;
		if (TempStr == 1) {
			alert("您已经投过票，请不要重复投票！");
		} else if (TempStr == 1) {
			alert("此文章不存在请联系博主！");
		} else {
			moodinner(TempStr);
		};
	});
};

function moodinner(moodtext) {
	var imga = "Plugins/mood/images/pre_02.gif";
	var imgb = "Plugins/mood/images/pre_01.gif";
	var color1 = "#666666";
	var color2 = "#EB610E";
	var heightz = "80";
	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 = "<span style='color: #555555;padding-left: 20px;'>您看完此刻的感受是！ 已有<font color='#FF0000'>" + moodzs + "</font>人表态：</span>";
	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 + "' style='width:20;height:"+ heightarr[j] + "'>";
		};
		else {
			document.getElementById("moodinfo" + j).innerHTML = "<span style='color: " + color1 + ";'>" + moodarr[j] + "</span><br><img src='" + imga + "' style='width:20;height:"+ heightarr[j] + "'>";
		};
	};
};

function startmood() {
	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=\"Plugins\/mood\/images\/0.gif\" width=\"40\" height=\"40\"><\/td>");
	document.writeln("<td><img src=\"Plugins\/mood\/images\/1.gif\" width=\"40\" height=\"40\"><\/td>");
	document.writeln("<td><img src=\"Plugins\/mood\/images\/2.gif\" width=\"40\" height=\"40\"><\/td>");
	document.writeln("<td><img src=\"Plugins\/mood\/images\/3.gif\" width=\"40\" height=\"40\"><\/td>");
	document.writeln("<td><img src=\"Plugins\/mood\/images\/4.gif\" width=\"40\" height=\"40\"><\/td>");
	document.writeln("<td><img src=\"Plugins\/mood\/images\/5.gif\" width=\"40\" height=\"40\"><\/td>");
	document.writeln("<td><img src=\"Plugins\/mood\/images\/6.gif\" width=\"40\" height=\"40\"><\/td>");
	document.writeln("<td><img src=\"Plugins\/mood\/images\/7.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=\"mood(\'1\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
	document.writeln("<td><input onClick=\"mood(\'2\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
	document.writeln("<td><input onClick=\"mood(\'3\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
	document.writeln("<td><input onClick=\"mood(\'4\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
	document.writeln("<td><input onClick=\"mood(\'5\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
	document.writeln("<td><input onClick=\"mood(\'6\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
	document.writeln("<td><input onClick=\"mood(\'7\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
	document.writeln("<td><input onClick=\"mood(\'8\')\" type=\"radio\" name=\"radiobutton\" value=\"radiobutton\"><\/td>");
	document.writeln("<\/tr>");
	document.writeln("<\/table>");
	mood('start')
};
startmood();
