/* xxx
 * create xxx
 * by xxx
 * autor @ Miroslav Kovar
 * developed for Pilot.cz
 * usage: xxxx
 */
var alert = new Class({
  Implements: Options,

  options: {
    dimensions: {
      x: 340,
      y: 114
    },
    modal: true,
    // type: 'prefwin',
    type: 'opacwin',
    title: 'upozornění',
    img: '/css/global/global/icons/big/alert.png',
    zIndex: 300,
    onClose: new Function()
  },
  
  initialize: function(options)
  {    
    this.setOptions(options);
    this.build();
  },
  build: function()
  {
    if (this.options.success)
    {
      document.addEvent('comfirm_success', function(){
        document.removeEvents('comfirm_success');
        this.options.success();
      }.bind(this));
    }
    
    if (this.options.failure)
    {
      document.addEvent('comfirm_failure', function(){
        document.removeEvents('comfirm_failure');
        this.options.failure();
      }.bind(this));
    }
    
    var title = '';
    var head = false;
    
    if (this.options.title)
    {
      var title = this.options.title;
      var head = true;
      this.options.dimensions.y += 20;
    }
    
    new pannel({  
      type: this.options.type,
      title: title,
      content: {text: this.options.text},
      dimensions: this.options.dimensions,
      resize: false,
      maximize: false,
      drag: false,
      modal: this.options.modal,
      footer: true,
      head: head,
      img: this.options.img,
      addClass: 'confirm',
      zIndex: this.options.zIndex,
      buttons: [
        {
          caption: 'ok',
          enter: true,
          active: true,
          click: function(){
            this.close();
            document.fireEvent('comfirm_success');
          }
        }
      ],
      onClose: this.options.onClose
    });
  }
});
