

var Overlay = Class.create({
   defaults : {
      className   : 'overlay'
   },
   options : {},
   
   initialize : function(options) {
      Object.extend(this.options, this.defaults); // this.options naplnime defaultnimi hodnotami
      Object.extend(this.options, options); // this.options naplnime zmenami oproti defaultu 
      
      this.bound = {
         onScroll : this.setDimensions.bind(this),
         onResize : this.setDimensions.bind(this)
      }
   },
   
   create : function() {
      this.structure = {
         window : new Element('div', {'class' : this.options.className})
      }
      
      this.markup = this.structure.window;
      this.addEvents();
      this.setDimensions();
      
      return this.markup;
   },
   
   destroy : function() {
      this.markup.remove();
      this.removeEvents();
   },
   
   addEvents : function() {
      Event.observe(window, 'resize', this.bound.onResize);
      Event.observe(window, 'scroll', this.bound.onScroll);
   },
   
   removeEvents : function() {
      Event.stopObserving(window, 'resize', this.bound.onResize);
      Event.stopObserving(window, 'scroll', this.bound.onScroll);
   },
   
   setDimensions : function() {
      var vSize   = document.viewport.getDimensions();
      /*var offsets = document.viewport.getScrollOffsets();*/
      this.structure.window.setStyle({
         width   : vSize.width  + 'px',
         height  : vSize.height + 'px'/*,
         left    : offsets.left + 'px',
         top     : offsets.top  + 'px'*/
      });
   }
});
