  var wu_videorating = new Class({
   createspan: function() {
    return new Element('span').addClass('wu_videorating').addClass('wu_vrw_10').setHTML('&nbsp;');
   },
   initialize: function(holder, id, csrf, label, working) {
    this.holder = holder;
    this.url = 'wuplayer/rate.php?id=' + id + '&wu_csrf=' + csrf + '&rating=';
    this.working = working;
    this.label = label;
    this.width = -1;
    this.init();
   },
   init: function() {
    this.parent = new Element('div').addClass('wu_videorating_control').setStyle('cursor', 'pointer');
    this.bg = this.createspan().setOpacity(0.3);
    this.meter = this.createspan();
    this.events = this.createspan().removeClass('wu_videorating').addClass('wu_videorating_event');
    this.parent.adopt(this.bg).adopt(this.meter).adopt(this.events);
    this.holder.setHTML(this.label + ' ').adopt(this.parent);
    if (this.width > -1) this.meter.setStyle('width', this.width + 'px'); else this.width = this.meter.getSize().size.x;
    this.events.addEvent('mousemove', this.mousemove.bind(this));
    this.events.addEvent('mouseout', this.mouseout.bind(this));
    this.events.addEvent('click', this.rate.bind(this));
   },
   rate: function(e) {
    var ev = new Event(e);
    if (window.event) this.curwidth = window.event.x + document.documentElement.scrollLeft;
    else this.curwidth = ev.page.x - this.events.getLeft();
    this.width = this.curwidth;
    var val = Math.round(parseInt(ev.page.x - this.parent.getLeft()) / this.parent.getSize().size.x * 100);
    this.parent.remove();
    this.holder.setHTML(this.working);
    new Ajax(this.url + val, { method: 'get', onComplete: this.init.bind(this)}).request();
   },
   mouseout: function(e) {
    this.meter.setStyle('width', this.width + 'px');
   },
   mousemove: function(e) {
    var ev = new Event(e);
    if (window.event) this.curwidth = window.event.x + document.documentElement.scrollLeft;
    else this.curwidth = ev.page.x - this.events.getLeft();
    if (this.curwidth < 0) this.curwidth = 0;
    this.meter.setStyle('width', this.curwidth + 'px');
   }
  });
