function postRating(id,rate_val)  {
    $('starbar_post').innerHTML = "<img src='/photos/rating_images/process_spin.gif'>";
    
    var url = '/services/PhotoRating.ashx';
    var params = 'id=' + id + '&r=' + rate_val + '&tz=' + Math.random();
    
    var ajax = new Ajax.Request(
        url,
        {method: 'get', parameters: params, onSuccess: updateRatingBar, onFailure: reportError});
}

function updateRatingBar(response) {
    if (response.responseText.length > 0) { 
        update = response.responseText.split('|');
        $('starbar_post').innerHTML = "<span class='vote_level'>Thank you for your rating!</span>";
        $('vcnt_'+update[0]).innerHTML = update[2]; // vote_count
        $('vrating_'+update[0]).innerHTML = update[3];  // vote_rating
        $('starbar_'+update[0]).innerHTML = update[4].toString();   //starbar      
    }
}

function reportError(response) {
    
    alert("Remote access error.  Check your network connection." + response);
}
