function showRating(userRating, poemId)
{
    // get the average rating for the poem
    var url = baseUrl+'/ajax/poem/get.rating/format/json';
    new Ajax.Request(url, {
        parameters: {poemId: poemId},
        method:'post',
       onSuccess: function(transport){

           //get the response
           var res = transport.responseJSON;
           
           var update = '<h4>Average user rating:'+res.currentAverage+' <span class="your-rating">Your rating: '+userRating+'</span></h4>';
       
           $('rate-area').update(update);
       }  
   });
}

function ratePoem(vars)
{
    // make the Ajax request
   url = baseUrl + '/ajax/poem/rate/format/json';
   params = vars;
   //Object.toJSON(params);

   new Ajax.Request(url, {
   parameters: params,
   onSuccess: function(transport){
       //get the response
       var res = transport.responseJSON;
           
       var update = '<dt class="leave-comment">Please Rate This Poem:</dt><dd class="after-submit"><h4>Average user rating:'+res.newAverage+' <span class="your-rating">Your rating: '+vars.rating+'</span></h4></dd>';
       
       $('rate-area').update(update);
       
   }
   
   });
}