var LemurStars = {
  stars: [],
  add:function(id, opts){
    this.stars.push(new LemurStar(id,opts));
  }
};

var LemurStar = Class.create();
LemurStar.prototype = {
  initialize:function(id,opts){
    this.id = id;
    this.opts = opts;
    
    $(this.id).select("img").each(function(img){
      var ident = img.identify();
      
      img.observe("mouseover",(function(e){
        
        img.up().select("img").each(function(el,n){

          el.src = "/images/icon_star_full.png";
          
          this.n = (n+1) / 5.0;
          if(ident == el.id) throw $break;

        },this);
      
      }).bind(this)).observe("mouseout", (function(e){

        img.up().select("img").each(function(el,i){

          if(i < this.opts.n) el.src = "/images/icon_star_full.png";
          else el.src = "/images/icon_star_empty.png";

        },this);
      
      }).bind(this)).observe("click",(function(e){
        this.opts.n = this.n * 5;
        new Ajax.Request(this.opts.url, {method:'get', parameters:{n:this.n}});
      }).bind(this))
    },this);
  }  
};