/*
  (C) by KSI media sp. z o.o. ( www.ksimedia.pl )  
  Description : EditBox class.
  Author      : MS
  Create date : 2010-08-22
  Comment     :
*/

function classEditBox ()
{
  this.itemsLoaded = new Array() ;
  
  //
  // funckcje obsługi komponentu
  //
  this.onClickAjaxReady = function ( name )
  {
    this.itemsLoaded [ name ] = 'yes' ;
    ExtComponents.updateValue( name ) ;    
  }
  
  this.onClick = function ( name, ajaxContentUrl )
  {
    if ( document.getElementById('itemsList_'+name).style.display == 'block' )
    {
      this.itemsHideWindow ( name ) ;
    }
    else
    {     
      this.itemsShowWindow ( name ) ;
      
      if ( ajaxContentUrl != '' ) 
      {
        if ( this.itemsLoaded[ name ] !=  'yes' ) { // jeśli coś nie będzie działać należy zakomentować
          document.getElementById ( 'itemsList_'+name ).innerHTML = "<table style='width:100%;height:100%;background-color:#ffffff;'><tr><td style='vertical-align:middle;text-align:center;'><img src='data/images/load.gif' alt='loading ...' /></td></tr></table>";
          
          $('#itemsList_'+name).load( ajaxContentUrl, function() {
            EditBox.onClickAjaxReady( name );
          });
        } else { // jeśli coś nie będzie działać należy zakomentować
          document.getElementById('itemsList_'+name).style.display == 'block';
          ExtComponents.updateValue( name ) ;  
        } // jeśli coś nie będzie działać należy zakomentować
      }
    }    
    return null ;
  }  
  
  this.itemsShowWindow = function ( name )
  {
    $('div.classEditBox_default_ajax').css('display','none');
    $('div.classEditBox_terminy_ajax').css('display','none');
    document.getElementById('itemsList_'+name).style.display='block';
  }
  
  this.itemsHideWindow = function ( name )
  {
    document.getElementById('itemsList_'+name).style.display='none';
  }
  
  this.updateValue = function ( name )
  {
    document.getElementById('vis_'+name).value = ExtComponents.getValue( name ) ;
  }

}

EditBox = new classEditBox () ;
