function ratingLoad(eventUID)
{
	new Ajax.Request("/content/rating.do",
	{
	    method:'get',
	    parameters: {method:'load', 
	    			 event:eventUID,
	    			 junk:(new Date()).valueOf() },
	    onSuccess: function(transport){
	      var response = transport.responseText || "new Starbox('rating', 3 , {indicator: 'Rating is not available', rerate: true});";
	      eval(response);
	    },
	    onFailure: function()
	    {
	    	new Starbox('rating', 0 , {indicator: 'Rating is not available', rerate: false, rated:true});
	    }
	});
}

function reviewsLoad(eventUID) 
{
	new Ajax.Updater($('reviewsPlaceholder'), '/content/rating.do',
					 { parameters: 
					 	{ method: 'getReviews', 
					 	  event:eventUID
					    }
					 ,
					 onComplete:function()
							    {
							    	eval($('code_to_eval').innerHTML);
							    }
							    
					});
}

function voteUp(ratingId, eventUID)
{
	new Ajax.Request("/content/vote.do",
	{
	    method:'get',
	    parameters: {method:'voteUp', 
	    			 eventRatingId: ratingId,
	    			 junk:(new Date()).valueOf() },
	    onSuccess: function(transport, json)
	    {
	    	updateVotes(ratingId, json, eventUID);		 	
	    }
	});
}

function voteDown(ratingId, eventUID)
{
	new Ajax.Request("/content/vote.do",
	{
	    method:'get',
	    parameters: {method:'voteDown', 
	    			 eventRatingId: ratingId,
	    			 junk:(new Date()).valueOf() },
	    onSuccess: function(transport, json)
	    {
	    	updateVotes(ratingId, json, eventUID);	
	    }
	});
}
	
function updateVotes(ratingId, json, eventUID)
{
	if(json.login)
   	{
   		location.href="/content/vote.do?method=requestLogin&eventUID="+eventUID;
   	}
	else
	{
		$("votes_pos_"+ratingId).innerHTML=" "+json.pos+" ";
		$("votes_neg_"+ratingId).innerHTML=" "+json.neg+" ";
	}
}	
