/**
 * @author Sascha
 */
tricos.ui.dialog = Class.create({
    
   name:null,
   url:null,
   containerEl:null,
   loaded:false,
   submitCallback:null,
   
   initialize:function()
   {
       /*
       Event.observe(window, 'load', function() { 
          
       }.bind(this));
       */
      this.containerEl = new Element('div', { id:'dialog_'+this.name });
      $(document.body).appendChild(this.containerEl);
      this.containerEl.setStyle({ position:'absolute', 'zIndex':99999999 });
      this.containerEl.hide();
      
      this.init();
   },
   
   onLoad:function()
   {
       //     
       console.log('ONLOAD');
   },
   
   load:function(callback)
   {
     new Ajax.Request(this.url, {
       onComplete:function(req){
           this.containerEl.update(req.responseText);
           this.loaded = true;
           this.onLoad();
           if (callback != null) {
               callback();
           }
       }.bind(this)
     });
   },
   
   pShow:function(callback)
   {
       tricos.ui.centerDivInDiv(this.containerEl, $('content').down('dialog'));
       new Effect.Appear(this.containerEl, { afterFinish:callback });
   },
   
   show:function(callback)
   {
       if (!this.loaded) {
           this.load(function() {
               this.pShow(callback).bind(this);
           }.bind(this));
       } else {
           this.pShow(callback).bind(this);
       }
   },
   
   hide:function()
   {
       new Effect.Fade(this.containerEl);
   }
   
});

//tricos.ui.dialog = new tricos_Ui_Dialog();
