var RatingEditor = Class.create();
RatingEditor.prototype = {

  initialize: function() {
  },
  
  submitRating: function(form, value, url) {
    new Ajax.Request(form.action, {
      method: "post",
      parameters: "value=" + value + "&secretKey=" + form.secretKey.value,
      onSuccess: function(transport) {
        new Ajax.Updater(form.down('.star-rating'), url);
      }
    });
  },

  ratingHover: function(form, value) {
    var stars = form.getElementsBySelector('li img');
    var activeStars = stars.slice(0, value);
    activeStars.each(function(star) {
      star.src = "http://www.op-online.de/community/static//modRating/star_active.gif";
    });
  
    var emptyStars = stars.slice(value, stars.length);
    emptyStars.each(function(star) {
      star.src = "http://www.op-online.de/community/static//modRating/star_empty.gif";
    });
  },

  ratingBlur: function(form) {
    this.ratingHover(form, form.value.value);
  }
  
};

var ratingEditor = new RatingEditor();
