
  function windowSiteConfig(initOptions){
    var _self = this;
    this._settings = {};
    Ext.apply(this._settings, initOptions);

    this.tpl = new Ext.XTemplate(
      '<div class="cpThumbs">',
		    '<tpl for=".">',
          '<div class="thumb-wrap">',
      	    '<div class="thumb cp_{bigIcon}"></div>',
            '<span class="x-editable">{name}</span>',
          '</div>',
        '</tpl>',
        '<div class="x-clear"></div>',
      '</div>'
  	);
    
    var loadMode = this._settings.loadMode;
    var schoolID = this._settings.schoolID;
    var treenode = this._settings.treenode;
    var schoolEbus = isCyberSchool() ? "School" : "Site";
    var schoolEbus2 = isCyberSchool() ? "Schools" : "SubSite";
    var cpItems = [];
    //cpItems.push([8, "Home Page Manager", "homeicon", "new CS2.HomepageSettingManager", '{sc: _self, loadMode: false, schoolID: '+currentSchool.id+'}']);
    cpItems.push([0, schoolEbus + " Setup", isCyberSchool() ? "schoolInfo" : "ebusInfo", "windowSchoolSettingsEditor", '{sc: _self, loadMode: false, schoolID: '+currentSchool.id+'}']);
    cpItems.push([1, "Navigation Editor", "navigationEditor", "windowNavEditor", '{sc: _self, loadMode: false, schoolID: '+currentSchool.id+'}']);
    cpItems.push([2, schoolEbus2 + " Manager", isCyberSchool() ? "schoolManager" : "ebusManager", "windowSchoolEditor", '{sc: _self, loadMode: false}']);
    cpItems.push([3, "Department Manager", isCyberSchool() ? "departmentManager" : "ebusDepartmentManager", "windowGCDEditor", '{sc: _self, loadMode: false, gcdType: "dept", schoolID: '+currentSchool.id+'}']);
    if (isCyberSchool())
      cpItems.push([4, "Classes Manager", "classesManager", "windowGCDEditor", '{sc: _self, loadMode: false, gcdType: "class", schoolID: '+currentSchool.id+'}']);
    cpItems.push([5, "Forum Manager", "forumManager", "windowForumEditor", '{sc: _self, loadMode: false, schoolID: '+currentSchool.id+'}']);
    cpItems.push([6, "Category Manager", "categoryManager", "windowCategoryEditor", '{sc: _self, loadMode: false, schoolID: '+currentSchool.id+'}']);
    cpItems.push([9, "System Login", "ldapLogin", "windowLDAPEditor", '{sc: _self, loadMode: false, schoolID: '+currentSchool.id+'}']);
    cpItems.push([7, "Groups & Users", "userGroups", "windowUserGroupConfig", '{sc: _self, loadMode: false, schoolID: '+currentSchool.id+'}']);
    cpItems.push([10, "System Modules", "homeApps", "new CS2.ModuleManager", '{sc: _self, loadMode: false, schoolID: '+currentSchool.id+'}']);
    cpItems.push([11, "Site APIs", "myKeychain", "new CS2.APIManager", '{sc: _self, loadMode: false}']);
    cpItems.push([13, "Video Presets", "videoPresets", "new CS2.video.editVideoFormat", '{sc: _self, loadMode: false}']);
    //cpItems.push([888, "Help Topics", "helpTopics", "windowHelpTopics", '{sc: _self, loadMode: false}']);
    //cpItems.push([999, 'About '+CS2.cyberschoolVerbage()+' 2.0', "aboutCS2", "aboutCS2", '{sc: _self, loadMode: false}']);

    this.store = new Ext.data.ArrayStore({
        fields: ['id', 'name', 'bigIcon', 'fn', 'args'],
        data : cpItems
    });

    this.reloadWarning = new Ext.Panel({
      padding: 5,
      height: 35,
      hidden: true,
      bodyStyle: 'background: #ffa;',
      region: 'north',
      html: '<input type="button" value="Reload Now" onClick="window.location.reload()"/> to see the applied changes.'
    });

    this.triggerReload = function(){
      //_self.reloadWarning.setVisible(true);
     //_self.scItems.doLayout();
     window.location.reload(true);
    };
  
    this.dataView = new Ext.DataView({
            region: 'center',
            store: this.store,
            tpl: this.tpl,
            singleSelect: true,
            overClass:'x-view-over',
            itemSelector:'div.thumb-wrap',
            emptyText: 'No options to display',
            listeners: {
            	click: {
            		fn: function(dv,i,n,e){            		
                  var node = dv.getStore().getAt(i);
                  var funcCall = node.data.fn + "(" + node.data.args + ");";
                  eval(funcCall);
            		}
            	}
            }
        });

    this.scItems = new Ext.Panel({
      layout: 'border',
      border: false,
      items: [this.reloadWarning, this.dataView]
    });

    this.win = new Ext.Window({
      title: 'Site Config',
      iconCls: 'iconSiteConfig_notile',
      layout:'fit',
      resizable: false,
      padding: 5,
      width: 532,
      height: 300,
      modal: true,
      constrain:true,
      constrainHeader:true,
      listeners: {
        show: function(win){
          Ext.Msg.hide();
        }
      },
      items: this.scItems
    });
    this.win.show(this);
  }



  function windowUserGroupConfig(initOptions){
    var _self = this;
    this._settings = {};
    Ext.apply(this._settings, initOptions);

    this.tpl = new Ext.XTemplate(
      '<div class="cpThumbs">',
		    '<tpl for=".">',
          '<div class="thumb-wrap">',
      	    '<div class="thumb cp_{bigIcon}"></div>',
            '<span class="x-editable">{name}</span>',
          '</div>',
        '</tpl>',
        '<div class="x-clear"></div>',
      '</div>'
  	);
    
    var loadMode = this._settings.loadMode;
    var schoolID = this._settings.schoolID;
    var treenode = this._settings.treenode;
    var cpItems = [
      //[0, "User Manager", "ugUsers", "launchModule", "'userGroups'"],
      [1, "Group Manager", "ugGroups", "launchModule", "'userGroups'"],
      [2, "LDAP Import/Sync", "ugImport", "windowUserImporter", '{sc: _self, loadMode: false, schoolID: '+currentSchool.id+'}']
    ];

    this.store = new Ext.data.ArrayStore({
        fields: ['id', 'name', 'bigIcon', 'fn', 'args'],
        data : cpItems
    });

    this.reloadWarning = new Ext.Panel({
      padding: 5,
      height: 35,
      hidden: true,
      bodyStyle: 'background: #ffa;',
      region: 'north',
      html: '<input type="button" value="Reload Now" onClick="window.location.reload()"/> to see the applied changes.'
    });
    
    this.triggerReload = function(){
      _self.reloadWarning.setVisible(true);
      _self.scItems.doLayout();
    };
  
    this.dataView = new Ext.DataView({
            region: 'center',
            store: this.store,
            tpl: this.tpl,
            singleSelect: true,
            overClass:'x-view-over',
            itemSelector:'div.thumb-wrap',
            emptyText: 'No options to display',
            listeners: {
            	click: {
            		fn: function(dv,i,n,e){            		
                  var node = dv.getStore().getAt(i);
                  var funcCall = node.data.fn + "(" + node.data.args + ");";
                  eval(funcCall);
            		}
            	}
            }
        });

    this.scItems = new Ext.Panel({
      layout: 'border',
      border: false,
      items: [this.reloadWarning, this.dataView]
    });

    this.win = new Ext.Window({
      title: 'Groups & Users',
      iconCls: 'cpi_userGroups',
      layout:'fit',
      resizable: false,
      constrain: true,
      padding: 5,
      width: 195,
      height: 172,
      modal: true,
      constrainHeader:true,
      buttons: [
        {
          text: 'Cancel', 
          handler: function(){
            _self.win.close();
          }
        }
      ],
      listeners: {
        show: function(win){
          Ext.Msg.hide();
        }
      },
      items: this.scItems
    });
    
    this.win.show(this);

  }

reportingIn('siteConfig');

