/*global window, rJS, RSVP, console, $, jQuery */
/*jslint  nomen: true */


(function (window, rJS, $) {
  "use strict";
  var gk = rJS(window);
  gk.declareMethod('setValue', function (value) {
    this.bar.value = value;
  })
    .declareMethod('setMax', function (max) {
      this.bar.max = max;
    })
    .declareMethod('getValue', function () {
      return this.bar.value;
    })
    .declareMethod('getMax', function () {
      return this.bar.max;
    })
    .declareMethod('display', function (attachment) {
      this.bar.style.display = "";
    })
    .declareMethod('noDisplay', function (attachment) {
      this.bar.style.display = "none";
    })
    .declareAcquiredMethod("setVolume", "setVolume")
    .declareAcquiredMethod("getVolume", "getVolume");   //xxxx
  gk.ready(function (g) {
    g.bar = g.__element.getElementsByTagName('progress')[0];
    g.bar.max = 1000;
   // g.bar.style.width =  + "px";
    g.bar.onclick = function (e) {
      var posY = e.clientY,
        targetTop = $(g.bar).offset().top;
      posY = (($(g.bar).width() - posY + targetTop)
              / $(g.bar).width()) * g.bar.max;
      g.setValue(posY);
      g.setVolume(posY);
    };
  });
}(window, rJS, jQuery));
