var gradebooktools = {
  regionTitle: 'Gradebook Tools',
  defaults: {autoHeight: true, cls: 'toolbox', frame: true},
  items:[
    {
      title: 'Gradebook Utilities',
      itemId: 'gradebook',
      tools: [
        {
          id:'help',
          handler: function(btn){
            ///////////////////////////////////////Finish///////
          }  
        }
      ],                   
      items: [
        {
          xtype: 'link',
          iconCls: 'calculator',
          text: 'Assign a calculation method:',
          listeners: {
            click: function(e, t) {
              console.log(this);
            }       
          }            
        },
        {
          xtype: 'combo',
          width: 150,
          editable: false,
          triggerAction: 'all',
          typeAhead: true,
          store: ['Percent Method', 'Points to Percent', 'True Points']
        },         
        {
          xtype: 'link',
          iconCls: '',
          itemId: 'assignments',
          text: 'Manage assignments',
          handler: function(btn){                      
            gradebookManageAssignmentsPopup.show(btn);
          } 
        },
        {
          xtype: 'link',
          iconCls: 'envelope_manage',
          text: 'Manage automated e-mails',
          handler: function(btn){                      
            gradebookemailpopup.show(btn);
          }          
        }/*,
        {
          xtype: 'link',
          iconCls: 'medal_red',
          text: 'Ability evaluations',          
          handler: function(){
            gradebookAbility.show();
          }          
        }*/
      ]
    },
    {
      title: 'Student Utilities',
      tools: [
        {
          id:'help',
          handler: function(btn){
            ///////////////////////////////////////Finish///////
          }  
        }
      ],
      items: [
        {
          xtype: 'link',
          iconCls: 'display_order',
          text: 'Student display order',
          handler: function(){
            studentOrderPopup.show();
          } 
        },
        {
          xtype: 'link',
          iconCls: 'chart_bar',
          text: 'Student summary',
          handler: function(){
               var popup = new gradebookSummary.window({
                  title:'Student Summary',
                  fieldHeader:'Tasks',
                  limitColumns: [0,5],
                  baseParams: { command: 'studentSummary', courseid:SchoolDynamics.currentCourseID},
                  requiredBaseParams: new Array('courseid', 'quarter', 'studentid')
               });
               popup.show();
          } 
        }
      ]
    },
    {
      title: 'Supervise',
      tools: [
        {
          id:'help',
          handler: function(btn){
            helppopup.loadHelpFile("supervise", 500, 455);
          }  
        }
      ],
      items: [
        {
          xtype: 'link',
          iconCls: 'magnifier',
          text: 'View the following teacher:' 
        },
        new SchoolDynamics.apprenticeCombo({
            storeArray: ['missinggradecourseid_store', 'gradebookcourseid_store', 'gradebookGrid_store'],
            id: 'gradebookteacherid'
        }),
        {
          xtype: 'link',
          iconCls: 'chart_bar',
          text: 'Teacher summary',
          handler: function(){
               var popup = new gradebookSummary.window({
                  title:'Teacher Summary',
                  fieldHeader:'Tasks',
                  limitColumns: [0,1,2,3,4,5,6],
                  baseParams: { command: 'teacherSummary'},
                  requiredBaseParams: new Array('quarter')
               });
               popup.show();
          } 
        }
      ]
    }
  ],
  listeners: {
      show: function(toolbox) {
         allow = SchoolDynamics.isAccessible("Gradebook Weight Form"); //Gradebook Admin Weight Form ??
         parentitem = toolbox.items.item('gradebook');
         parentitem.items.item('assignments')[allow?'show':'hide']();
      }
  }
}

var gradebook = {
  id: 'gradebook-panel',
  title: 'Gradebook',	
  layout : 'fit',
  border: true,
  hideMode: 'offsets',
  items: [
    {
      xtype: 'tabpanel',
      //activeTab: 0,
      border: false,
      items: [
        new gradebookGrid(),
        new gradebookMissingGrid()
      ]
    }
  ],
  listeners: {
    render: function(panel) {},
    show: function(panel) {
      panel.items.items[0].setActiveTab(0);
    },
    hide: function(panel) {
      var grid = panel.items.items[0].getActiveTab();
      if (grid != undefined) {
         grid.store.save();
      }
    }
  }                                        
};
