
var msgbreq;
function initializeRatingReq(){msgbreq = null;try{msgbreq = new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{msgbreq = new ActiveXObject("Microsoft.XMLHTTP");}catch(oe){msgbreq = null;}}if(!msgbreq && typeof XMLHttpRequest != "undefined"){msgbreq = new XMLHttpRequest();}}
function submitRating(url){initializeRatingReq();if (msgbreq != null){msgbreq.onreadystatechange = processRatingChange;msgbreq.open("GET",url);msgbreq.send(null);}return false;}
function processRatingChange(){if (msgbreq.readyState == 4 && msgbreq.status == 200){xmlDoc = msgbreq.responseXML;postkey = xmlDoc.getElementsByTagName("postkey").item(0).firstChild.data;total = xmlDoc.getElementsByTagName("total").item(0).firstChild.data;document.getElementById("PostKey"+postkey+"Rating").innerHTML = total;}}
function fetchUserList(url){initializeRatingReq();if (msgbreq != null){msgbreq.onreadystatechange = processUserListChange;msgbreq.open("GET",url);msgbreq.send(null);}return false;}
function msgboardratingclick(pid){if($('PostKey'+pid+'UserList').style.display != 'none'){new Effect.toggle('PostKey'+pid+'UserList','slide',{duration:0.5});}else{fetchUserList('post_rating.php?PostKey='+pid);}}
function msgboardratingup(pid){submitRating('post_rating.php?PostKey='+pid+'&Rating=%2B');$('PostKey'+pid+'Icons').hide();$('PostKey'+pid+'IconsOff').style.display='inline';if($('PostKey'+pid+'UserList').style.display != 'none'){new Effect.toggle('PostKey'+pid+'UserList','slide',{duration:0.5});}}
function msgboardratingdown(pid){submitRating('post_rating.php?PostKey='+pid+'&Rating=-');$('PostKey'+pid+'Icons').hide();$('PostKey'+pid+'IconsOff').style.display='inline';if($('PostKey'+pid+'UserList').style.display != 'none'){new Effect.toggle('PostKey'+pid+'UserList','slide',{duration:0.5});}}
function processUserListChange()
{
	if (msgbreq.readyState == 4 && msgbreq.status == 200)
	{
		str = "";
		var blogstr = [];
		xmlDoc = msgbreq.responseXML;
		users = xmlDoc.getElementsByTagName("userkey");
		postkey = xmlDoc.getElementsByTagName("postkey").item(0).firstChild.data;
		for(i=0;i<users.length;i++)
		{
			count = xmlDoc.getElementsByTagName("count").item(i).firstChild.data;
			timestamp = xmlDoc.getElementsByTagName("timestamp").item(i).firstChild.data;
			userkey = xmlDoc.getElementsByTagName("userkey").item(i).firstChild.data;
			rating = xmlDoc.getElementsByTagName("rating").item(i).firstChild.data;
			uname = xmlDoc.getElementsByTagName("name").item(i).firstChild.data;
			mood = xmlDoc.getElementsByTagName("mood").item(i).firstChild.data;
			
			blogstr.push('<tr>');
			blogstr.push('<td valign="top" class="rt_count">'+count+'</td>');
			blogstr.push('<td valign="top" class="rt_uname">&nbsp;<img src="images/'+rating+'" /> <a href="index.php?UserKey='+userkey+'" title="'+uname+'" class="rt_unamelink">'+uname+'</a></td>');
			blogstr.push('<td valign="top" class="rt_mood">&nbsp;<a href="mood.php?UserKey='+userkey+'" title="Mood" class="rt_moodlink">'+mood+'</a></td>'); 
			blogstr.push('<td valign="top" class="rt_timestamp">&nbsp;'+timestamp+'</td>');
			blogstr.push('</tr>');
		}
		str = blogstr.join('');
		
		if(users.length == 0)
		{	str = "<table width='100%' border='0' cellspacing='5' cellpadding='0'><tr><td class=\"rt_none\">No ratings for this post.</td></tr></table>";	}
		else
		{
			str = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>"+str+"</table>";
			if ( users.length > 5 )
			{
				str = "<div id='PostKey"+postkey+"Scrollable' class='scrollable'>"+str+"</div>";
				str = "<table width='100%' border='0' cellspacing='5' cellpadding='0'><tr><td>"+str+"</td><td valign='top' width='15'><div id='track_postkey_"+postkey+"' class='track' style='display:none'><div id='handle_postkey_"+postkey+"' class='handle'></div></div></td></tr></table>";
				
				var ulcfn = function()
				{
					document.getElementById('track_postkey_'+postkey).style.display='inline';
					eval("var slider_postkey_"+postkey+" = new Control.Slider('handle_postkey_"+postkey+"','track_postkey_"+postkey+"',{axis:'vertical',onSlide:function(v){scrollVertical(v,$('PostKey"+postkey+"Scrollable'),slider_postkey_"+postkey+");},onChange:function(v){scrollVertical(v,$('PostKey"+postkey+"Scrollable'),slider_postkey_"+postkey+");}});");
				}
				setTimeout(ulcfn,1000);
			}
			else
			{
				str = "<div id='PostKey"+postkey+"Scrollable'>"+str+"</div>";
				str = "<table width='100%' border='0' cellspacing='5' cellpadding='0'><tr><td>"+str+"</td><td valign='top' style='width:15px'></td></tr></table>";
			}
		}
		
		$("PostKey"+postkey+"UserList").innerHTML = str;
		new Effect.toggle("PostKey"+postkey+"UserList","slide",{ duration: 0.5 });
	}
}

function rantmsgopen(postkey){$('rantTruncated_'+postkey).hide();$('rantFull_'+postkey).show();}
function rantmsgclose(postkey){$('rantTruncated_'+postkey).show();$('rantFull_'+postkey).hide();}
