/*
 * Ext JS Library 2.1
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.ux.Portlet = Ext.extend(Ext.Panel, {
  anchor: '100%',
  frame:true,
  collapsible:true,
  draggable:true,
  cls:'x-portlet',
  tools: [{
    id:'close',
    handler: function(e, target, panel){
      panel.notifyVisible(false);
      var checkbox = Ext.ComponentMgr.get('c-'+panel.dbId);
      if(checkbox)checkbox.setValue(false)
      panel.hide();
    }
    }],
  
  notifyVisible: function(val){
    Ext.Ajax.request({
      url: '/widget/visible_widget',
      params: 'id='+this.dbId+'&visible='+(val?1:0)
    })
  }
});
Ext.reg('portlet', Ext.ux.Portlet);