/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

Waiting = {
  init: function(){
    d = Builder.node('img', {
      id: 'waitingImg',
      src: 'http://libs.abtera.cz/img/wait.gif',
      style: 'display:none;'
    });
    document.body.appendChild(d);

    d = Builder.node('div', {
      id: 'waitingText',
      style: 'display:none;'
    });
    document.body.appendChild(d);
  },


  start: function(text){
    if(Prototype.Browser.IE){
      x = Math.round(document.body.clientWidth/2);
      y = Math.round(document.body.clientHeight/2);
    } else {
      x = Math.round(window.innerWidth/2);
      y = Math.round(window.innerHeight/2) + window.pageYOffset;
    }
    x-=37;
    y-=40;
    BodyDisabler.start();
    $('waitingImg').setStyle({
      'position': 'absolute',
      'top': y+'px',
      'left': x+'px',
      'opacity': '0.5'
    });
    $('waitingImg').show();

    if(text){
      $('waitingText').innerHTML = text;

      y += 80;

      if(Prototype.Browser.IE){
        w = document.body.clientWidth;
      } else {
        w = window.innerWidth;
      }

      $('waitingText').setStyle({
        'position': 'absolute',
        'top': y+'px',
        'left': 0+'px',
        'width': w+'px',
        'textAlign': 'center',
        'opacity': '0.5',
        'fontSize': '15px',
        'fontWeight': 'bold'
      });
      $('waitingText').show();
    }

  },

  stop: function(){
    $('waitingImg').hide();
    $('waitingText').hide();
    BodyDisabler.stop();
  }
}

Event.observe(window, 'load', function(){
  Waiting.init();
  img = new Image;
  img.src = 'http://libs.abtera.cz/img/wait.gif';
});
