/*
 * Project gallery
 * 
 * 2007 - Magic Wand
 */
ns('MagicWand.Gallery');

ns.MagicWand.Gallery.CompanyGallery = function(id, view_place, info_place, url) {
  this.info_place = info_place;
  this.url = url;
  this.loaded = 0;

  ns.MagicWand.Gallery.CompanyGallery.superclass.constructor.call(this, id, view_place);  
}

ns.utils.extend(ns.MagicWand.Gallery.CompanyGallery, ns.MagicWand.Gallery.BaseGallery, {
  
  activate: function(id) {
    ns.MagicWand.Gallery.CompanyGallery.superclass.activate.apply(this, arguments);
    this.loadInfoForActive();
  },
  
  loadInfo: function(id) {
    if(this.loaded == id) return;
    this.loaded = id;
    var _this = this;
    $(this.info_place).fadeOut('fast', function() { 
      /*$(_this.info_place).load(_this.url, {'id': id}, function(response_text) {
        $(_this.info_place).fadeIn('fast');
      })*/
      $.post(_this.url, {'id': id}, function(data) {
        if(data.indexOf('comp_info_' + _this.loaded) >= 0) {
          $(_this.info_place).html(data).fadeIn('fast');           
        }        
      }, 'html');    
    });
  },
  
  loadInfoForActive: function() {
    var id = this.extractId(this.act_pict);
    this.loadInfo(id);
  }
  
});

