function RatingStars(name, val, enabled, callback)
{
	this.Name 			= name;
	this.Value 			= val;
	this.Max			  = 5;
	this.Enabled		= enabled;
	this.EmptyImg		= "images/_e.gif";
	this.FullImg		= "images/_f.gif";
	this.HoverImg		= "images/_h.gif";
	this.Descriptions 	= ratingStarDescriptions; //["Ok", "Good", "Very Good", "Outstanding", "Super"];
	this.DescStyle	= "rating";
	this.AlreadyVotedMsg = ratingStarThanks; //"Thanks for rating.";
	this.DefaultMsg	= ratingStarRateThis; //"Rate This Message";
	this.Callback		= callback;
	this.AbuseReported = abuseReported;
	this.Set			  = function(value)
						{
							if (this.Enabled)
							{
								this.Enabled = false;
								this.Value = value;
								eval(this.Callback.replace('{0}', value));
							}
						}
	this.Show			= function(value)
						{
							if (this.Enabled)
							{
								this.Reset();
								this.$changeLbl(this.Descriptions.length >= value ? this.Descriptions[value - 1] : '');
								for(var i=1;i<=value;i++)
								{
									this.$changePic(i, this.HoverImg);
								}
							}
							else
							{
								this.$changeLbl(this.AlreadyVotedMsg);
							}
						}
	this.Clear			= function()
						{
							this.$changeLbl(this.$getDefaultMsg())
							for(var i=1;i<this.Max+1;i++)
							{
								this.$changePic(i, i <= this.Value ? this.FullImg : this.EmptyImg);
							}
						}
	this.Reset			= function()
						{
							for(var i=1;i<this.Max+1;i++)
								this.$changePic(i, this.EmptyImg);
						}
	this.Render			= function()
						{
							if (this.Value > this.Max) { this.Value = this.Max; }
							/*
							document.write('&nbsp;<div id=\'label_'+this.Name+'_'+this.Id+'\' class=\''+this.DescStyle+'\' style=\'display:inline;\'>'+this.$getDefaultMsg()+'</div>');
		                    */
		                    document.write('<div id=\'label_'+this.Name+'\' class=\''+this.DescStyle+'\' style=\'display:inline;\'>'+this.$getDefaultMsg()+'</div><br />');
							for(var i=1;i<this.Max+1;i++)
							{
								var starPath = (i <= this.Value ? this.FullImg : this.EmptyImg);
								var description = this.Descriptions.length >= i ? this.Descriptions[i - 1] : "";
								document.write('<img id=\''+this.Name+'_'+i+'\' src=\''+starPath+'\' alt=\''+description+' : '+i+' / '+this.Max+'\' onmouseover=\''+this.Name+'.Show('+i+');\' onmouseout=\''+this.Name+'.Clear();\' onclick=\''+this.Name+'.Set('+i+');\' style=\'cursor:pointer;\' />');
							}
		
							
						}
	this.$changePic		= function(value, starPath)
						{
							document.getElementById(this.Name+'_'+value).src = starPath ;
						}
	this.$changeLbl 	= function(msg)
						{
							document.getElementById('label_'+this.Name).innerHTML = msg;
						}
	this.$getDefaultMsg = function()
	                    {
	                        if (this.Enabled)
	                            return this.DefaultMsg;
	                        else
	                            return this.AlreadyVotedMsg;
	                    }
}

function SubmitVote(name, msgId, val)
{
    document.getElementById('updatePanel').style.display = 'block';
    ServerRequest.Execute('server_request.aspx', 'POST', ["type", "VOTE", "ObjName", name, "MessageId", msgId, "Value", val], true);
}

function VoteSubmitted(name, newRating)
{
    document.getElementById('updatePanel').style.display = 'none';
    eval(name + '.Value = ' + newRating + '; ' + name + '.Clear();');
}

function FlagInappropriate(name, msgId)
{
    
    document.getElementById('updatePanel').style.display = 'block';
    ServerRequest.Execute('server_request.aspx', 'POST', ["type", "FLAG_INAPPROPRIATE", "ObjName", name, "MessageId", msgId], true);
}

function Flagged(name)
{
    document.getElementById('updatePanel').style.display = 'none';
    // var flg = document.getElementById('flg_'+name);
    // if (flg != null) flg.style.display = 'none';
    // if (flg != null) flg.innerHTML = '';
    var abuseReport = document.getElementById('abuseDiv_'+name);
    if(abuseReport != null)
    {
      //abuseReport.innerHTML = '<table><tbody><tr><td>Abuse reported<\/td><\/tr><\/tbody></table>';
      abuseReport.innerHTML = abuseReported;
    }
}