     
      function windowSchoolEditor(initOptions){
        var _self = this;
        this._settings = {};
        Ext.apply(this._settings, initOptions);
        var loadMode = this._settings.loadMode;
        
        if (!canEdit)
          return false;

        var tree = new Ext.tree.TreePanel({                    
              useArrows:true,
              id: 'mainSchoolEditor',
              autoScroll:true,
              animate:true,
              region: 'center',
              enableDD:true,
              containerScroll: true,
              rootVisible: false,
              root: { nodeType: 'async'},
              dataUrl : '/ajax/siteconfig/schools/schoolNodes.cfm',
              listeners: {             
                contextmenu: function(node, e) {
                  node.select();
                  var c = new Ext.menu.Menu({
                    items: [{
                      menuID: 'mnu_item-edit_school',
                      iconCls: 'cpi_schoolInfo',
                      text: CS2.schoolVerbage() + ' Information...'
                    },{
                      menuID: 'mnu_item-edit_nav',
                      iconCls: 'cpi_navigationEditor',
                      text: CS2.schoolVerbage() + ' Navigation...'
                    }],
                    listeners: {
                      itemclick: function(item) {
                        var n = item.parentMenu.contextNode;
                        switch (item.menuID) {
                          case 'mnu_item-edit_school':
                            windowSchoolSettingsEditor({sc: _self._settings.sc, loadMode: false, schoolID: n.attributes.school_id});
                            break;
                          case 'mnu_item-edit_nav':
                            windowNavEditor({sc: _self._settings.sc, loadMode: false, schoolID: n.attributes.school_id});
                            break;
                        }
                      }
                    }
                  });
                  c.contextNode = node;
                  c.showAt(e.getXY());
                  //c.findById('mnu_item-edit_school').setVisible(node.getUI().isChecked());
                },
                beforenodedrop: function(e){
                  if(e.dropNode.attributes.data_type=="header" && e.target.getDepth() > 1){
                    e.cancel=true;
                    return false;
                  }else if(e.dropNode.attributes.data_type=="header" && e.target.getDepth() == 1 && e.point=="append"){
                    e.cancel=true;
                    return false;
                  }else if(e.dropNode.attributes.data_type!="header" && e.target.getDepth() == 1 && e.point!="append"){
                    e.cancel=true;
                    return false;
                  }
                },
                checkchange: function(node, checked){
                  if(checked){
                    node.getUI().addClass('complete');
                  }else{
                    node.getUI().removeClass('complete');
                  }
                }
              }
          });
        var treeLeft = new Ext.Panel({
          border: false,
          margins: '0 0 0 0',
          region: 'center',
          layout: 'border',
          items: [
            {
              region: 'north', 
              margins:'0 0 -1 0',
              baseCls: 'siteConfigHeaderTab',
              cmargins:'3 3 3 3', 
              border: true, 
              html: '<strong>Current '+CS2.schoolsVerbage()+' Configuration</strong>'
            },tree]
        });
        var navInfo = 'Changes will be applied when you click \'Save\' below.';
        this.treeHolder = new Ext.Panel({
          border: false,          
          layout: 'fit',
          bodyStyle: 'background: #DFE8F6',
          id: 'tabSchoolEditor',
          items: new Ext.Panel({
              border: false,     
              ref : 'borderLayout', 
              layout: 'border',
              items: [
                {
                  region: 'south',
                  collapsible: true,
                  margins:'5 0 0 0',
                  cmargins: '5 0 0 0',
                  title: 'Help',
                  collapsed: true,
                  border: true, 
                  html: '<div class="siteConfigInfo"><div class="siteConfigHeader">Organize your '+CS2.schoolsVerbage()+' here.</div><div class="siteConfigText">'+navInfo+'</div></div>'
                },
                treeLeft]
            })
        });
          
        var winSchoolEdit = new Ext.Window({
              width:500,
              height:550,
              padding: 5,
              title: CS2.schoolsVerbage()+' Manager',
              iconCls: CS2.isCyberSchool() ? 'cpi_schoolManager' : 'cpi_ebusManager',
              constrainHeader:true,
              layout:'fit',
              tools:[{
                id:'help',
                handler: function(event, toolEl, panel){
                  //alert(_self.treeHolder.borderLayout.layout.south.panel.toSource());
                  _self.treeHolder.borderLayout.layout.south.panel.toggleCollapse(true);
                }
              }],
              closeAction:'close',
              modal:true,
              closable:true,
              border:true,
              resizable: false,
              items: this.treeHolder,
              buttons: [{
                text: 'Save',
                handler: function(){
                  var tmpSerial = new Ext.tree.JsonTreeSerializer(tree, { nodeFilter: function(node) {
                      //node.Text = encodeURIComponent(node.Text);
                      // node.text = htmlentities(node.text);
                      //node.attributes.text = encodeURIComponent(node.attributes.text);
                      //node.attributes.linkName = encodeURIComponent(node.attributes.linkName);
                      //node.attributes.linkURL = encodeURIComponent(node.attributes.linkURL);
                      //node.attributes.linkTarget = encodeURIComponent(node.attributes.linkTarget);
                      return true;
                    }});
                  //alert(tmpSerial.toString());
                  Ext.Msg.wait('Please wait...', 'Saving '+CS2.schoolsVerbage()+' Categorization');
                  new Ajax.Request('/ajax/siteconfig/schools/updateSchools.cfm', {
                    postBody: 'schoolData=' + tmpSerial,
                    onSuccess: function(transport){
                      if (this._settings.sc)
                        this._settings.sc.triggerReload();
                      winSchoolEdit.close();
                      if (loadMode=='refresh'){
                        Ext.Msg.wait('Reloading page...', 'Data Saved');
                        window.location.reload(false);
                      }else{
                        Ext.Msg.hide();
                      }
                    }
                  });
                }
              },{ text: 'Cancel', handler: function(){ winSchoolEdit.close(); } }]
          });
        tree.getRootNode().expand(true);
        winSchoolEdit.show(this);
      }
      
reportingIn('schoolTab');
