Ext.plucker = function(arr, prop)
{
    var oldPluck = function(arr, prop)
    {
        var ret = [];
        Ext.each(arr, function(v)
        {
            ret.push(v[prop]);
        });
        return ret;
    };

    var res = arr;
    Ext.each(prop.split('.'), function(v)
    {
        res = oldPluck(res, v);
    });
    return res;
};
Ext.app.FolderLoader = Ext.extend(Ext.tree.TreeLoader, {
    processAttributes : function(attr){
    }
});

CS2.Upload = {};
CS2.Upload.FileTypes = {};
CS2.Upload.FileTypes.normal = {name: 'File', title: 'File', extensions: 'jpg, gif, png, bmp, jpeg, notebook, doc, docx, pub, xls, zip, rar, ppt, txt, mp3, wav, avi, mpg, mpeg, wmv, mov, m4v, flv, pdf, xbk'};
CS2.Upload.FileTypes.image  = {name: 'Image', title: 'Images', extensions: 'jpg, gif, png, bmp, jpeg'};
CS2.Upload.FileTypes.video  = {name: 'Video', title: 'Video', extensions: 'mp3, wav, avi, mpg, mpeg, wmv, mov, m4v, flv'};
CS2.Upload.File = function(initOptions){
    var _self = this;
    this.settings = {uploadType: 'normal', contentType: 'normal', allowedTypes: '', editorID: 0};
    Ext.apply(this.settings, initOptions);
    this.settings.allowedTypes = CS2.Upload.FileTypes[this.settings.uploadType];
    var currentTypeName = this.settings.allowedTypes.name;
    var upPanel = new Ext.FormPanel({
                                      region: 'center',
                                      labelWidth: 75, // label settings here cascade unless overridden
                                      clientValidation: true,
                                      standardSubmit:false, 
                                      fileUpload: true,
                                      isUpload: true,
                                      method: 'POST',
                                      border: true,
                                      //bodyStyle: 'margin-bottom: 5px;',
                                      margins: '0 0 5 0',
                                      items: [{
                                          xtype:'fieldset',
                                          border: false,
                                          autoHeight:true,
                                          defaults: {
                                              anchor: '-20',
                                              msgTarget: 'side'
                                          },
                                          defaultType: 'textfield',
                                          items :[{
                                                    xtype: 'displayfield',
                                                    hideLabel: true,
                                                    html: '<strong>We currently support the following file extentions:</strong><br />'+this.settings.allowedTypes.extensions+'<br /><br />'
                                                  },{
                                                    xtype: 'fileuploadfield',
                                                    emptyText: 'Select a file',
                                                    fieldLabel: currentTypeName + ' #1',
                                                    name: 'eventFile_1',
                                                    allowBlank: false,
                                                    buttonText: '',
                                                    buttonCfg: {
                                                        iconCls: 'upload-icon'
                                                    }
                                                  },/*{
                                                    xtype: 'button',
                                                    hideLabel: true,
                                                    text: 'Upload More',
                                                    listeners: {
                                                      click: function(b,e ){
                                                        b.ownerCt.file2.setVisible(true);
                                                        b.ownerCt.file2.removeClass('hidden');
                                                        b.ownerCt.file3.setVisible(true);
                                                        b.ownerCt.file4.setVisible(true);
                                                      }
                                                    }
                                                  },*/{
                                                    xtype: 'fileuploadfield',
                                                    emptyText: 'Select a file',
                                                    fieldLabel: currentTypeName + ' #2',
                                                    name: 'eventFile_2',
                                                    ref: 'file2',
                                                    buttonText: '',
                                                    buttonCfg: {
                                                        iconCls: 'upload-icon'
                                                    }
                                                  },{
                                                    xtype: 'fileuploadfield',
                                                    emptyText: 'Select a file',
                                                    fieldLabel: currentTypeName + ' #3',
                                                    name: 'eventFile_3',
                                                    ref: 'file3',
                                                    buttonText: '',
                                                    buttonCfg: {
                                                        iconCls: 'upload-icon'
                                                    }
                                                  },{
                                                    xtype: 'fileuploadfield',
                                                    emptyText: 'Select a file',
                                                    fieldLabel: currentTypeName + ' #4',
                                                    name: 'eventFile_4',
                                                    ref: 'file4',
                                                    buttonText: '',
                                                    buttonCfg: {
                                                        iconCls: 'upload-icon'
                                                    }
                                                  },{
                                                    xtype: 'checkbox',
                                                    fieldLabel: '',
                                                    boxLabel: '<span style="color: red; font-weight: bold;">New!</span> Replace files on upload (Same name only)',
                                                    name: 'replaceFiles'
                                                  },{
                                                    xtype: 'displayfield',
                                                    style:'color: #66F',
                                                    html:'<strong style="color: black">Notice:</strong> Uploads over 100MB should be done with the Mass Uploader below.'
                                                  }
                                          ]
                                      }]
                                  });


    var mM = new Ext.XTemplate(
      '<span style="font-size: 14px">',
        '<a href="/uploader/?ut={type}&id={id}" class="massUpload" style="font-weight: bold;" target="_blank">Mass File Uploader</a> ',
        '(Requires Java)',
      '</span>',
      '<br />',
      '<strong>Features:</strong> ',
      'Crop, Rotate, Brightness/Contrast, Drag &amp; Drop from Desktop and more!'
    );

    var massMessage = {
      region: 'south',
      height: 55,
      padding: 10,
      border: true,
      html: mM.apply({type: _self.settings.contentType, id: _self.settings.editorID}),
      listeners: {
        'afterrender' : function(p){
          p.el.on('click', function(p1, e){
            p.ownerCt.ownerCt.close();
            Ext.Msg.alert('Mass Uploader', '<strong>The mass uploader opened in a different window or tab.</strong><br /><br />Please click OK to refresh the list once you have finished uploading.', function(){
              _self.settings.explorer.updateStore();
            });
          }, this, {
            delegate: 'a.massUpload'
          });
        }
      }
    };
    
    var upHolder = {
      layout: 'border',
      border: false,
      items: [upPanel, massMessage]
    };

    //if (!winUploadFiles)
    winUploadFiles = new Ext.Window({title: 'Upload '+this.settings.allowedTypes.title, width: 450, height: 350, resizable: false, modal: true, closeAction:'close', 
      layout: 'fit', 
      constrainHeader: true,
      border: false,
      constrainHeader: true,
      items: upHolder,
      buttons: [{
                  xtype: 'button',
                  text: 'Upload',
                  handler: function(){
                    upPanel.getForm().submit({
                      clientValidation: true, 
                      standardSubmit:false, 
                      fileUpload:true,        
                      isUpload: true,
                      method: 'POST',
                      url:'/ajax/explorer/actions/uploadFile.cfm', 
                      waitMsg:'Uploading, please wait...',
                      params: {
                        id: _self.settings.editorID,
                        max:4,
                        xtype: _self.settings.contentType
                      },
                      errorReader : new Ext.data.JsonReader({
                          root:'errors',
                          successProperty:'success'
                        }, ['id', 'msg']),
                      success: function(form, action) {
                          //Ext.getCmp('editPanel_win_'+_settings.winName).close();
                          _self.settings.explorer.updateStore();
                          winUploadFiles.close();
                      },
                      failure: function(form, action) {
                        _self.settings.explorer.updateStore();
                        switch (action.failureType) {
                            case Ext.form.Action.CLIENT_INVALID:
                                Ext.Msg.alert('Failure', 'Please verify fields are correct.');
                                break;
                            case Ext.form.Action.CONNECT_FAILURE:
                                Ext.Msg.alert('Failure', 'Ajax communication failed');
                                break;
                            case Ext.form.Action.SERVER_INVALID:
                            default:
                                Ext.Msg.alert('Failure', action.result.msg);
                        }
                      }
                    });
                  }
                },{
                  xtype: 'button',
                  text: 'Cancel',
                  handler: function(){
                    winUploadFiles.hide();
                  }
                }]
    });
    winUploadFiles.show(this);
        
};
CS2.Delete = {};
CS2.Delete.Gallery = function(initOptions){
    var _self = this;
    this.settings = {};
    Ext.apply(this.settings, initOptions);
    this.win = new Ext.Window({
        title: 'Delete Gallery',
        width:380,
        resizable: false,
        cls: 'x-window-dlg',
        constrainHeader: true,
        layout: 'fit',
        plain: true,
        bodyStyle: 'font-size: 13px; padding: 10px;',
        html: new Ext.XTemplate(
          '<div class="x-dlg-icon">',
            '<div class="ext-mb-icon ext-mb-warning"></div>',
            '<div class="ext-mb-content">',
              '<span class="ext-mb-text">',
                '<strong>Are you sure you want to delete this gallery, all sub-galleries and all photos in them?</strong><br /><br />Any references of inclusion to a Gallery or Slideshow module will also be removed.',
              '</span>',
            '</div>',
            '<div class="x-clear"></div>',
          '</div>'
        ).apply(),
        buttons: [{
            text:'Delete (3)',
            ref: '../DeleteButton',
            disabled:true,
            handler: function(){
              var params = {data: _self.settings.albumID};
              Ext.Ajax.request({
                url: '/ajax/delete_cat.cfm',
                method: 'POST',
                'params': params,
                success: function(response, opts) {
                  _self.win.hide();
                  if (initOptions.treeNode.parentNode)
                    _self.settings.treeNode.parentNode.reload()
                },
                failure: function(response, opts) {                
                  //Ext.Msg.alert('Current Gallery Shared!', 'This album is currently shared and selected for inclusion of a Gallery or Slideshow.<br /><br />');
                  Ext.Msg.alert('Error Deleting Gallery', 'There was a problem communicating with the server. Please check your internet connection and try again.');
                }
              });
              
            }
        },{
            text: 'Cancel',
            handler: function(){
                this.ownerCt.ownerCt.hide();
            }
        }]
    });
    this.win.show(this);
    setTimeout(function(){ _self.win.DeleteButton.setText('Delete (2)'); }, CS2.countDownSpeed * 1);
    setTimeout(function(){ _self.win.DeleteButton.setText('Delete (1)'); }, CS2.countDownSpeed * 2);
    setTimeout(function(){ _self.win.DeleteButton.setText('Delete'); _self.win.DeleteButton.enable(); }, CS2.countDownSpeed * 3);
};
CS2.Delete.TrashEmpty = function(initOptions){
    var _self = this;
    this.settings = {};
    Ext.apply(this.settings, initOptions);
    this.win = new Ext.Window({
        title: 'Empty Rubbish Bin',
        width:380,
        resizable: false,
        cls: 'x-window-dlg',
        constrainHeader: true,
        layout: 'fit',
        plain: true,
        bodyStyle: 'font-size: 13px; padding: 10px;',
        html: new Ext.XTemplate(
          '<div class="x-dlg-icon">',
            '<div class="ext-mb-icon ext-mb-warning"></div>',
            '<div class="ext-mb-content">',
              '<span class="ext-mb-text">',
                '<strong>Are you sure you want to empty the Rubbish Bin?</strong>',
                '<br /><br />',
                'This will permanently delete the items and cannot be undone!',
              '</span>',
            '</div>',
            '<div class="x-clear"></div>',
          '</div>'
        ).apply(),
        buttons: [{
            text:'Empty (3)',
            ref: '../DeleteButton',
            disabled:true,
            handler: function(){
              Ext.Ajax.request({
                url: '/ajax/explorer/actions/emptyTrash.cfm',
                method: 'GET',
                'params': params,
                success: function(response, opts) {
                  _self.win.hide();
                  if (initOptions.explorer)
                    _self.settings.explorer.updateStore();
                },
                failure: function(response, opts) {
                  Ext.Msg.alert('Error Emptying Trash', 'There was a problem communicating with the server. Please check your internet connection and try again.');
                }
              });
            }
        },{
            text: 'Cancel',
            handler: function(){
                this.ownerCt.ownerCt.hide();
            }
        }]
    });
    this.win.show(this);
    setTimeout(function(){ _self.win.DeleteButton.setText('Empty (2)'); }, CS2.countDownSpeed * 1);
    setTimeout(function(){ _self.win.DeleteButton.setText('Empty (1)'); }, CS2.countDownSpeed * 2);
    setTimeout(function(){ _self.win.DeleteButton.setText('Empty'); _self.win.DeleteButton.enable(); }, CS2.countDownSpeed * 3);
};

var trashMenuManager = function(item){
  var n = item.parentMenu.contextNode;
  var e = item.parentMenu.explorer;
  switch (item.menuID) {
    case 'emptyTrash':
      new CS2.Delete.TrashEmpty({treeNode: n, explorer: e});
      break;
      
    case 'refreshTrash':
      n.reload();
      break;
  }
};
var trashMenu = new Ext.menu.Menu({
                                items:[
                                        {
                                          menuID: 'emptyTrash',
                                          iconCls: 'iconEmptyTrash',
                                          text: 'Empty Rubbish Bin...'
                                        },'-',{
                                          menuID: 'refreshTrash',
                                          iconCls: 'file-refresh-icon',
                                          text: 'Refresh'
                                        }
                                      ],
                                listeners: { itemclick: trashMenuManager }
                              });
                              
function submitSharedData(n, shared){
  var params = {gID: n.attributes.galleryID, shared: shared};
  Ext.Ajax.request({
    url: '/ajax/explorer/actions/shareAlbum.cfm',
    method: 'POST',
    'params': params,
    success: function(response, opts) {
      n.attributes.shared = shared;
      n.getUI().setIconCls(shared ? 'iconGalleryShared' : 'iconGallery');
    },
    failure: function(response, opts) {
      Ext.Msg.alert('Error Sharing Album', 'There was a problem communicating with the server. Please check your internet connection and try again.');
    }
  });
}

var albumMenuManager = function(item){
  var n = item.parentMenu.contextNode;
  switch (item.menuID) {
    case 'createAlbum':
      var pID = 0;
      var gID = n.attributes.galleryID;
      AlbumCatEdit({photoID:pID, gcdID:0, albumID:gID, imageID:0, treeNode: n }); return false;
      break;
      
    case 'editAlbum':
      var pID = n.attributes.galleryID;
      var gID = n.attributes.galleryID;
      AlbumCatEdit({photoID:pID, gcdID:0, albumID:gID, imageID:0, treeNode: n }); return false;
      break;
      
    case 'deleteAlbum':
      var gID = n.attributes.galleryID;
      new CS2.Delete.Gallery({albumID: gID, treeNode: n});
      break;

    case 'emptyTrash':
      new CS2.Delete.Trash({treeNode: n});
      break;
      
    case 'refreshNode':
      n.reload();
      break;
      
    case 'shareAlbum':
      if (!n.attributes.shared){
        Ext.MessageBox.confirm('Confirm Sharing', '<strong>Are you sure you want to Share this Album?</strong><br /><br />Admins will be given the right to select this gallery for inclusion to <strong>public</strong> places such as the Gallery or Slideshows!', function(btn){
          if (btn=='yes')
            submitSharedData(n, true);
        });
      }else{
        Ext.MessageBox.confirm('Confirm Un-Sharing', '<strong>Are you sure you want to Un-Share this Album?</strong><br /><br />Any references of inclusion to a Gallery or Slideshow module will also be removed.', function(btn){
          if (btn=='yes')
            submitSharedData(n, !n.attributes.shared);
        });
      }
      break;
  }
};
var albumLockerMenu = new Ext.menu.Menu({
                                items:[
                                        {
                                          menuID: 'createAlbum',
                                          iconCls: 'iconGalleryAdd',
                                          text: 'Create Album...'
                                        },'-',{
                                          menuID: 'refreshNode',
                                          iconCls: 'file-refresh-icon',
                                          text: 'Refresh'
                                        }
                                      ],
                                listeners: { itemclick: albumMenuManager }
                              });
var albumMenu = new Ext.menu.Menu({
                                items:[
                                        {
                                          menuID: 'editAlbum',
                                          iconCls: 'iconGalleryEdit',
                                          text: 'Edit Album...'
                                        },{
                                          ref: 'shareAlbum',
                                          menuID: 'shareAlbum',
                                          text: 'Share Album...'
                                        },{
                                          menuID: 'deleteAlbum',
                                          iconCls: 'iconGalleryDelete',
                                          text: 'Delete Album...'
                                        },'-',{
                                          menuID: 'createAlbum',
                                          iconCls: 'iconGalleryAdd',
                                          text: 'Create Sub-Album...'
                                        },'-',{
                                          menuID: 'refreshNode',
                                          iconCls: 'file-refresh-icon',
                                          text: 'Refresh'
                                        }
                                      ],
                                listeners: { itemclick: albumMenuManager }
                              });
var moduleMenuManager = function(item){
  var n = item.parentMenu.contextNode;
  switch (item.menuID) {
    case 'createContent':
      callEditor({
          winName : n.attributes.actionType+'_win_0', 
          editorType: n.attributes.actionType,
          editorDataID: 0, 
          editorGCDID: 0, 
          titleMaxLen: 40, 
          dataTruncateLen: 0, 
          explorerNode: n
        });
      break;
      
    case 'refreshNode':
      n.reload();
      break;
  }
};
var moduleMenu = new Ext.menu.Menu({
                                items:[
                                        {
                                          ref: 'createContent',
                                          menuID: 'createContent',
                                          iconCls: 'iconContentAdd',
                                          text: 'New...'
                                        },'-',{
                                          menuID: 'refreshNode',
                                          iconCls: 'file-refresh-icon',
                                          text: 'Refresh'
                                        }
                                      ],
                                listeners: { itemclick: moduleMenuManager }
                              });
                              
var postMenuManager = function(item){
  var n = item.parentMenu.contextNode;
  switch (item.menuID) {      
    case 'editContent':
      callEditor({
          winName : n.attributes.actionType+'_win_'+n.attributes.dataID, 
          editorType: n.attributes.actionType,
          editorDataID: n.attributes.dataID, 
          editorGCDID: n.attributes.gcdID, 
          titleMaxLen: 40, 
          dataTruncateLen: 0, 
          explorerNode: n
        });
      break;
  }
};
var postMenu = new Ext.menu.Menu({
                                items:[
                                        {
                                          ref: 'editContent',
                                          menuID: 'editContent',
                                          iconCls: 'iconContentEdit',
                                          text: 'Edit...'
                                        }
                                      ],
                                listeners: { itemclick: postMenuManager }
                              });
                              
var refreshMenuManager = function(item){
  var n = item.parentMenu.contextNode;
  switch (item.menuID) {      
    case 'refreshNode':
      n.reload();
      break;
  }
};
var refreshMenu = new Ext.menu.Menu({
                                items:[
                                        {
                                          ref: 'refreshNode',
                                          menuID: 'refreshNode',
                                          iconCls: 'file-refresh-icon',
                                          text: 'Refresh'
                                        }
                                      ],
                                listeners: { itemclick: refreshMenuManager }
                              });
                              
CS2.FileManager = function(initOptions){
    var _self = this;
    this.settings = {currentView: 'list', currentMode: '', currentActionType: '', currentDataID: 0, currentAlbumID: 0};
    Ext.apply(this.settings, initOptions);
    
    this.tree = new Ext.tree.TreePanel({
        useArrows: true,
        autoScroll: true,
        animate: true,
        ddGroup: 'shareDDgroup',
        /*dropConfig : {
          appendOnly:true
        },*/
        enableDrop: true,
        containerScroll: true,
        border: false,
        loader: new Ext.app.FolderLoader({
          dataUrl:'/ajax/explorer/treeFolders.cfm'
        }),
        rootVisible: false,
        root: {
            nodeType: 'async',
            text: 'Ext JS',
            draggable: false,
            id: 'src'
        },
        listeners: {
          /*nodedragover: function(dE){
            if (dE.point != "append")
              return false;
          },
          beforenodedrop: function(dE){
            if (dE.point != "append"){
              dE.cancel=true;
              return false;
            }
          },*/  
          beforenodedrop: function(dE){
            if (dE.point != "append"){
              dE.cancel=true;
              return false;
            }
            var treeNode = dE.target;
            var fileSelections = dE.source.dragData.selections;
            var theIDs = Ext.plucker(fileSelections, "data.fileID");
            var toID = 0;  
            switch(treeNode.attributes.type){
              case "post":
                toID = treeNode.attributes.dataID;
                break;
              case "gallery":
                toID = treeNode.attributes.galleryID;
                break;
              default:
                dE.cancel=true;
                return false;
                break;
            }
            Ext.Msg.wait('Copying Files...', 'Please Wait');
            Ext.Ajax.request({
              url: '/ajax/explorer/actions/copyFile.cfm',
              method: 'POST',
              'params': {copyTo: toID, type: treeNode.attributes.type, fileIDs: theIDs},
              success: function(response, opts) {
                Ext.Msg.hide();
              },
              failure: function(response, opts) {
                Ext.Msg.alert('Error Copying Files', 'There was a problem communicating with the server. Please check your internet connection and try again.');
              }
            });
            
            /*
            var params = {gID: n.attributes.galleryID, shared: shared};
            Ext.Ajax.request({
              url: '/ajax/explorer/actions/shareAlbum.cfm',
              method: 'POST',
              'params': params,
              success: function(response, opts) {
                n.attributes.shared = shared;
                n.getUI().setIconCls(shared ? 'iconGalleryShared' : 'iconGallery');
              },
              failure: function(response, opts) {
                Ext.Msg.alert('Error Sharing Album', 'There was a problem communicating with the server. Please check your internet connection and try again.');
              }
            });
            */
          },
          render: function(t){
            if (_self.settings.jumpTo && _self.settings.jumpTo == "galleries"){
              t.selectPath('/src/galleryNode');
              t.expandPath('/src/galleryNode');
              _self.setupAlbumLockerLayout();
            }
          },
          contextmenu: function(node, e) {
            switch (node.attributes.type){
              case 'albumLocker':
                node.select();
                albumLockerMenu.contextNode = node;
                albumLockerMenu.showAt(e.getXY());
                break;
                
              case 'gallery':
                node.select();
                albumMenu.contextNode = node;
                albumMenu.shareAlbum.setIconClass(node.attributes.shared ? 'iconLightON' : 'iconLightOFF');
                albumMenu.shareAlbum.setText(node.attributes.shared ? 'Unshare this Album' : 'Share Album....');
                albumMenu.showAt(e.getXY());
                break;
                
              case 'trash':
                node.select();
                trashMenu.contextNode = node;
                trashMenu.explorer = _self;
                trashMenu.showAt(e.getXY());
                break;
                
              case 'module':
              case 'year':
              case 'month':
                node.select();
                moduleMenu.contextNode = node;
                moduleMenu.explorer = _self;
                moduleMenu.createContent.setText("New "+ucwords(node.attributes.actionType)+"...");
                moduleMenu.showAt(e.getXY());
                break;  

              case 'post':
                node.select();
                postMenu.contextNode = node;
                postMenu.explorer = _self;
                postMenu.editContent.setText("Edit "+ucwords(node.attributes.actionType)+"...");
                postMenu.showAt(e.getXY());
                break;  
                                
              default:
                node.select();
                refreshMenu.contextNode = node;
                refreshMenu.explorer = _self;
                refreshMenu.refreshNode.setDisabled(!node.reload);
                refreshMenu.showAt(e.getXY());
                //alert(node.attributes.toSource());
                break;
                
            }
          },
          dblclick: function(n) {
            
            switch(n.attributes.type){
              case 'gallery':
                AlbumCatEdit({photoID:n.attributes.galleryID, gcdID:0, albumID:n.attributes.galleryID, imageID:0, treeNode: n }); return false;
                break;
            }
            
          },
          click: function(n) {
            type="";
            id="";
            path="";
            dataID="";
            parentID="";
            actionType="";
            year="";
            month="";
            _self.setupNoLayout();
            _self.settings.currentMode = n.attributes.type;
            _self.settings.currentActionType = n.attributes.actionType || '';
            _self.settings.currentDataID = n.attributes.dataID || 0;
            switch(n.attributes.type){
              case 'filenode':
                type = n.attributes.type;
                id = n.attributes.id;
                _self.setupMyFilesLayout();
                break;
                
              case 'modules':
                type = n.attributes.type;
                id = n.attributes.id;
                _self.setupModulePickLayout();
                break;
                
              case 'module':
                type = n.attributes.type;
                id = n.attributes.id;
                actionType = n.attributes.actionType;
                _self.setupModuleLayout();
                break;
                
              case 'year':
                type = n.attributes.type;
                id = n.attributes.id;
                actionType = n.attributes.actionType;
                year=n.attributes.year;
                _self.settings.currentYear = year;
                _self.settings.currentMonth = '';
                if (year == "0000")
                  _self.setupModuleLegacyLayout();
                else
                  _self.setupModuleYearLayout();
                break;
                
              case 'month':
                type = n.attributes.type;
                id = n.attributes.id;
                actionType = n.attributes.actionType;
                year=n.attributes.year;
                month=n.attributes.month;
                _self.settings.currentYear = year;
                _self.settings.currentMonth = month;
                _self.settings.currentMonthStr = n.attributes.monthStr;
                _self.setupModuleMonthLayout();
                break;
              
              case 'post':
                type = n.attributes.type;
                id = 'post';
                dataID = n.attributes.dataID;
                actionType = n.attributes.actionType;
                _self.setupFilesLayout();
                _self.setupUploadButton();
                break;
              
              case 'fckeditor':
                type = n.attributes.type;
                id = 'fckeditor';
                dataID = n.attributes.dataID;
                path = n.attributes.path;
                actionType = n.attributes.actionType;
                _self.setupFCKLayout();
                break; 
                
              case 'gallery':
                type = n.attributes.type;
                id = n.attributes.id;
                dataID = n.attributes.dataID;
                parentID = n.attributes.parentID;
                actionType = n.attributes.actionType;
                _self.settings.currentAlbumID = n.attributes.galleryID;
                _self.setupUploadButton();
                _self.setupAlbumLayout();
                break;
                                
              case 'albumLocker':
                type = n.attributes.type;
                id = n.attributes.id;
                actionType = n.attributes.actionType;
                _self.setupAlbumLockerLayout();
                break;
                
              case 'trash':
                type = n.attributes.type;
                id = n.attributes.id;
                dataID = n.attributes.dataID;
                parentID = n.attributes.parentID;
                actionType = n.attributes.actionType;
                _self.setupTrashLayout();
                break;
                
              default:
                //alert(n.attributes.toSource());
                break;
            }
            
            _self.lastURL = '/ajax/explorer/listFiles.cfm?type='+type+'&id='+id+'&did='+dataID+'&parentid='+parentID+'&at='+actionType+'&year='+year+'&month='+month+'&path='+path;
            _self.updateStore();
          }
        }
    });
  /*
    this.storeGrid = new Ext.data.GroupingStore({
      reader : new Ext.data.JsonReader({
          id: 'fileID'
        },[
            {name: 'xtype', mapping: 'xtype'},
            {name: 'fileID', mapping: 'fileID'},
            {name: 'filetitle', mapping: 'filetitle'},
            {name: 'filedesc', mapping: 'filedesc'},
            {name: 'filename', mapping: 'filename'},
            {name: 'filetype', mapping: 'filetype'},
            {name: 'filesize', mapping: 'filesize', convert: Ext.util.Format.fileSize},
            {name: 'priority', mapping: 'priority', type: 'int'}
          ]
      ),
      sortInfo: {field: 'filename', direction: 'ASC'}
    });
    this.storeThumbs = new Ext.data.GroupingStore({
      reader : new Ext.data.JsonReader({
          id: 'fileID'
        },[
            {name: 'xtype', mapping: 'xtype'},
            {name: 'fileID', mapping: 'fileID'},
            {name: 'filetitle', mapping: 'filetitle'},
            {name: 'filedesc', mapping: 'filedesc'},
            {name: 'filename', mapping: 'filename'},
            {name: 'filetype', mapping: 'filetype'},
            {name: 'filesize', mapping: 'filesize', convert: Ext.util.Format.fileSize},
            {name: 'priority', mapping: 'priority', type: 'int'}
          ]
      ),
      sortInfo: {field: 'filename', direction: 'ASC'},
      listeners: {
        update : function(s, r, o){
        
        }
      }
    });
  */
    
    this.updateStore = function(){
      _self.store.proxy.conn.url = _self.lastURL;
      _self.store.reload();
      _self.grid.getSelectionModel().clearSelections();
      _self.thumbs.clearSelections();
    }
    this.lastURL = '/ajax/explorer/listFiles.cfm?type=modules&id=modulesNode&did=&at=';
    this.store = new Ext.data.GroupingStore({
      autoLoad: true,
      proxy: new Ext.data.HttpProxy ({
        url: _self.lastURL
      }),
      baseParams: {id: 0},
      reader : new Ext.data.JsonReader({
          id: 'fileID'
        },[
            {name: 'xtype', mapping: 'xtype'},
            {name: 'fileID', mapping: 'fileID'},
            {name: 'filetitle', mapping: 'filetitle'},
            {name: 'filedesc', mapping: 'filedesc'},
            {name: 'filename', mapping: 'filename'},
            {name: 'filetype', mapping: 'filetype'},
            {name: 'filesize', mapping: 'filesize', convert: Ext.util.Format.fileSize},
            {name: 'priority', mapping: 'priority', type: 'int'}
          ]
      ),
      sortInfo: {field: 'filename', direction: 'ASC'},
      listeners: {
        update: function(s, r, o){
          var params = r.data;
          Ext.Ajax.request({
            url: '/ajax/explorer/actions/updateFile.cfm',
            method: 'POST',
            'params': params,
            success: function(response, opts) {
              r.commit(true);
            },
            failure: function(response, opts) {
              r.reject(true);
              Ext.Msg.alert('Error Deleting File(s)', 'There was a problem communicating with the server. Please check your internet connection and try again.');
            }
          });
        }
      }
    });
    
    this.showFileURL = function(b,e){
      
      if (_self.settings.currentView == 'list'){
        var grid = _self.grid.getSelectionModel().getSelected();
        var fileID = grid.get('fileID');
        var fileName = grid.get('filename');
      }else{
        var thumb = _self.thumbs.getSelectedRecords()[0];
        var fileID = thumb.get('fileID');
        var fileName = thumb.get('filename');
      }
      
      var downloadTpl = new Ext.XTemplate(
        'URL:',
        '<tpl if="this.isImage(filename)">',
          '<strong>/images/getPhoto.cfm?id={fileID}</strong>',
          '<br /><br />',
          '<img src="/images/getPhoto.cfm?id={fileID}&_t={t}" width="100%" alt="Image Preview" title="Image Preview" style="margin-bottom: 10px"/>',
          '<center><a href="/images/getPhoto.cfm?id={fileID}" target="_blank">Image Test Link</a></center>',
        '</tpl>',
        '<tpl if="!this.isImage(filename)">',
          '<strong>/download.cfm?id={fileID}</strong>',
          '<br /><br />',
          '<center><a href="/download.cfm?id={fileID}" target="_blank">File Test Link</a></center>',
        '</tpl>',{
         isImage: function(fName){
           fName = fName.toLowerCase();
           var ext = fName.substring(fName.length-4);
           var ext2 = fName.substring(fName.length-5);
           return ext == ".jpg" || ext2 == ".jpeg" || ext == ".gif" || ext == ".png" || ext == ".bmp";
         }
      });
      
      var win = new Ext.Window({
        title: 'File URL',
        constrainHeader: true,
        width: 300,
        width: 300,
        autoScroll: true,
        padding: 10,
        modal: true,
        html: downloadTpl.apply({filename: fileName, fileID: fileID, t: new Date()})
      });
      win.show(this);
    }
    
    var editor = new Ext.ux.grid.RowEditor({ saveText: 'Update' });
    this.grid = new Ext.grid.GridPanel({
                                          ddGroup: 'shareDDgroup',
                                          enableDragDrop: true,
                                          border: false,
                                          store: this.store,
                                          stripeRows: true,
                                          view: new Ext.grid.GroupingView({
                                            markDirty: false
                                          }),
                                          plugins: [editor],
                                          columns: [//new Ext.grid.RowNumberer(),
                                                  {
                                                    header: 'File Title',
                                                    id: 'filetitle',
                                                    dataIndex: 'filetitle',
                                                    sortable: true,
                                                    width: 100,
                                                    editor: {
                                                      xtype: 'textfield',
                                                      maxLength: 200,
                                                      allowBlank: true
                                                    }
                                                  },{
                                                    header: 'File Description',
                                                    dataIndex: 'filedesc',
                                                    sortable: true,
                                                    width: 300,
                                                    editor: {
                                                      xtype: 'textarea',
                                                      maxLength: 1000,
                                                      allowBlank: true
                                                    }
                                                  },{
                                                    header: 'Filename',
                                                    dataIndex: 'filename',
                                                    sortable: true/*,
                                                    editor: {
                                                      xtype: 'textfield',
                                                      maxLength: 50,
                                                      allowBlank: false
                                                    }*/
                                                  },{
                                                    header: 'Type',
                                                    dataIndex: 'filetype',
                                                    width: 60,
                                                    sortable: true
                                                  },{
                                                    header: 'Filesize',
                                                    dataIndex: 'filesize',
                                                    width: 60,
                                                    sortable: true
                                                  },{
                                                    header: 'P.S.O.',
                                                    dataIndex: 'priority',
                                                    width: 40,
                                                    sortable: true
                                                  }],
                                          autoExpandColumn: 'filetitle',
                                          listeners: {
                                            render: function(gp){
                                              //new Ext.dd.DragZone(gp.getEl(),_self.subjectDragZoneConfig);
                                              //new Ext.dd.DropZone(gp.ownerCt.el,_self.subjectDropZoneConfig);
                                            }
                                          }
                                        });

    var tpl = new Ext.XTemplate(
      '<tpl for=".">',
        '<div class="thumb-wrap" id="{filename}">',
        '<div class="thumb"><img src="/images/thumber.cfm?id={fileID}&w=100&h=80" title="{filetitle}"></div>',
        '<span class="x-editable">{filename}</span></div>',
      '</tpl>',
      '<div class="x-clear"></div>'
    );


    this.thumbs = new Ext.DataView({
            store: this.store,
            cls:'soccer_field',
            tpl: tpl,
            autoHeight:true,
            multiSelect: true,
            overClass:'x-view-over',
            itemSelector:'div.thumb-wrap',
            emptyText: 'No images to display',
            selectRecord : function(r) {
              var index = this.store.indexOf(r);
              this.select(index);
            },
            prepareData: function(data){
                //data.shortName = Ext.util.Format.ellipsis(data.name, 15);
                //data.sizeString = Ext.util.Format.fileSize(data.size);
                //data.dateString = data.lastmod.format("m/d/Y g:i a");
                return data;
            },
            listeners: {
              render: function(dv){
                //new Ext.dd.DragZone(dv.getEl(),_self.subjectDragZoneConfig);
                //new Ext.dd.DropZone(dv.ownerCt.el,_self.subjectDropZoneConfig);
              }
            }
        });
    this.dragZoneOverrides = {
        containerScroll: true,
        getDragData: function(evtObj) {
            var dataView = this.dataView;
            var sourceEl = evtObj.getTarget(dataView.itemSelector, 10);

            if (sourceEl) {
                var selectedNodes = dataView.getSelectedNodes();
                var dragDropEl = document.createElement('div');

                if (selectedNodes.length < 1) {
                    selectedNodes.push(sourceEl);
                }

                Ext.each(selectedNodes, function(node) {
                    dragDropEl.appendChild(node.cloneNode(true));
                });
                return {
                    ddel: dragDropEl,
                    repairXY: Ext.fly(sourceEl).getXY(),
                    dragRecords: dataView.getSelectedRecords(),
                    sourceDataView: dataView
                };
            }
        },
        getRepairXY: function() {
            return this.dragData.repairXY;
        }
    };

    this.dropZoneOverrides = {
        containerScroll: true,
        onContainerOver: function(dropZone,evtObj,dragData) {
            if (this.dataView.locked)
              return false;
            return this.dropAllowed;
        },
        onContainerDrop: function(dropZone,evtObj,dragData) {
        
            //alert(dropZone.toSource());
            //alert(evtObj.toSource());
            //alert(dragData.toSource());
            
            var dragRecords = dragData.dragRecords;
            var store = this.dataView.store;
            var target = evtObj.getTarget(this.dataView.itemSelector);

            if (this.dataView.locked)
              return false;
              
            Ext.each(dragRecords, function(record) {
                dragData.sourceDataView.store.remove(record);
            });

            if (target) {
                targetIndex = this.dataView.indexOf(target);
                this.dataView.store.insert(targetIndex,dragRecords);
            } else {
                this.dataView.store.add(dragRecords);
            }
            return true;
        }
    };
    this.subjectDragZoneConfig = Ext.apply({}, {
        ddGroup: 'shareDDgroup',
        dataView: _self.thumbs
    }, this.dragZoneOverrides);

    this.subjectDropZoneConfig = Ext.apply({}, {
        ddGroup: 'shareDDgroup',
        dataView: _self.thumbs
    }, this.dropZoneOverrides);
    
    var changeViewports = function(b, s, a){
      if (a == 'list' && s){
        _self.settings.currentView = 'list';
        _self.gridSwitch.getLayout().setActiveItem(0);
        
        var curRecords = _self.thumbs.getSelectedIndexes();        
        var sm = _self.grid.getSelectionModel();
        sm.clearSelections();
        sm.selectRows(curRecords, true);
        
      }else if(a == 'thumb' && s){
        _self.settings.currentView = 'thumb';
        _self.gridSwitch.getLayout().setActiveItem(1);
        
        var curRecords = _self.grid.getSelectionModel().getSelections();        
        var thumb = _self.thumbs;
        thumb.clearSelections();
        for (var n=0; n<curRecords.length; n++){
          var index = _self.store.indexOfId(curRecords[n].id);
          thumb.select(index, true);
        }
        
      }
    }                                        
                                        
    var changeSortOrder = function(b, s){
      this.sortOrderDialog(_self.store);
    }
    
    this.sortOrderDialog = function(_store){
      if (_store.getCount() < 2){
        Ext.Msg.alert('No Files!', 'You must upload at least 2 files to change their Public Sorting Order.');
        return false;
      }
      var curfiles = _store.getRange();
      if (curfiles.length < 2){
        Ext.Msg.alert('Not Enough Files!', 'You must upload at least 2 files to change their Public Sorting Order.');
        return false;
      }
      //alert(newfiles.toSource());
      var newfiles = [];
      curfiles.each(function(c){
        var d = {};
        d.leaf=true;
        d.id = c.data.id;
        d.priority = c.data.priority;
        d.record = c;;
        d.text = c.data.filetitle || c.data.filename;
        newfiles.push(d);
      });
      newfiles = newfiles.sortBy(function(s) {return s.priority;});

      var treePanner = new Ext.tree.TreePanel({
                                                region: 'center',
                                                useArrows: true,
                                                autoScroll: true,
                                                containerScroll: true,
                                                animate: true,
                                                enableDD: true,
                                                rootVisible: false,
                                                root: {
                                                    nodeType: 'async',
                                                    text: 'Files',
                                                    draggable: false,
                                                    children: newfiles
                                                }
                                              });

      var myWin = new Ext.Window({
        title: 'Public Sorting Order',
        constrainHeader: true,
        height: 450,
        width: 350,
        resizable: true,
        border: false,
        layout: 'border',
        modal: true,
        items: [ {region: 'north', padding: 5, margins: '0 0 5 0', html: '<strong>Drag and Drop files to specify the Public Sorting Order.</strong><br /><br />Click \'Update\' below when you are finished.'},
                 treePanner
              ],
        buttons: [
                  {
                    text: 'Update',
                    handler: function(){
                      var nnn=0;
                      treePanner.getRootNode().childNodes.each(function(s){
                          var rec = s.attributes.record;
                          rec.beginEdit();
                          rec.set('priority', nnn++); 
                          rec.endEdit();
                      });
                      myWin.close();
                    }
                  },
                  {
                    text:'Cancel', 
                    handler: function(){ myWin.close();} 
                  }
                ]
      });

      myWin.show(this);
    }

    this.deleteFile = function(restoreMode, permMode){
      var curRecords = [];
      if (_self.settings.currentView == 'list'){
        curRecords = _self.grid.getSelectionModel().getSelections();
      }else{
        curRecords = _self.thumbs.getSelectedRecords();
      }
      var delCount = curRecords.length;
      if (delCount == 1){
        msg = 'Are you sure you want to delete this '+delCount+' item?';
      }else{
        msg = 'Are you sure you want to delete these '+delCount+' items?';
      }
      //alert(msg);

      var fileIDs = [];
      var dataIDs = [];
      for(var i = 0; i < delCount; i++){
        if (curRecords[i].data.xtype == "file"){
          fileIDs.push(curRecords[i].data.fileID);
        }else if(curRecords[i].data.xtype == "data"){
          dataIDs.push(curRecords[i].data.fileID);
        }
      }
      var params = {fileIDs: fileIDs, dataIDs: dataIDs, restore: restoreMode, perm: permMode};
      Ext.Ajax.request({
        url: '/ajax/explorer/actions/deleteFiles.cfm',
        method: 'POST',
        'params': params,
        success: function(response, opts) {
          _self.updateStore();
        },
        failure: function(response, opts) {
          Ext.Msg.alert('Error Deleting File(s)', 'There was a problem communicating with the server. Please check your internet connection and try again.');
        }
      });
    }

    this.setupTrashLayout = function(){
      _self.currentLayout = 'trash';
      _self.gridSwitch.restoreFileBtn.show();
      _self.gridSwitch.trashFileBtn.hide();
      _self.gridSwitch.deleteFileBtn.show();
      _self.centerManager.getLayout().setActiveItem(1);
    }
    this.setupFCKLayout = function(){
      _self.currentLayout = 'fckeditor';
      _self.gridSwitch.restoreFileBtn.hide();
      _self.gridSwitch.trashFileBtn.hide();
      _self.gridSwitch.deleteFileBtn.show();
      _self.centerManager.getLayout().setActiveItem(1);
    }
    this.setupAlbumLayout = function(){
      _self.currentLayout = 'album';
      _self.gridSwitch.sortingBtn.show();
      _self.gridSwitch.sortingBtn.setDisabled(false);
      _self.gridSwitch.uploadBtn.show();
      _self.gridSwitch.getURLBtn.show();
      _self.centerManager.getLayout().setActiveItem(1);      
    }
    this.setupAlbumLockerLayout = function(){
      _self.currentLayout = 'albumlocker';
      this.centerInfoPane.update(this.infoAlbumLockerMessage.apply());
    }
    this.setupMyFilesLayout = function(){
      _self.currentLayout = 'myfiles';
      this.centerInfoPane.update(this.infoMyFilesMessage.apply());
    }
    this.setupModulePickLayout = function(){
      _self.currentLayout = 'module';
      this.centerInfoPane.update(this.infoModulePickMessage.apply());
    }
    this.setupModuleLayout = function(){
      _self.currentLayout = 'module';
      this.centerInfoPane.update(this.infoModuleMessage.apply({module: ucfirst(_self.settings.currentActionType)}));
    }
    this.setupModuleYearLayout = function(){
      _self.currentLayout = 'year';
      this.centerInfoPane.update(this.infoModuleYearMessage.apply({module: ucfirst(_self.settings.currentActionType), thing: "Month", year: _self.settings.currentYear}));
    }
    this.setupModuleMonthLayout = function(){
      _self.currentLayout = 'month';
      this.centerInfoPane.update(this.infoModuleMonthMessage.apply({module: ucfirst(_self.settings.currentActionType), thing: "Post", year: _self.settings.currentYear, month: _self.settings.currentMonthStr}));
    }
    this.setupModuleLegacyLayout = function(){
      _self.currentLayout = 'legacy';
      this.centerInfoPane.update(this.infoModuleLegacyMessage.apply({module: ucfirst(_self.settings.currentActionType)}));
    }
    this.setupFilesLayout = function(){
      _self.currentLayout = 'files';
      _self.gridSwitch.getURLBtn.show();
      _self.gridSwitch.uploadBtn.show();
      _self.gridSwitch.uploadBtn.setDisabled(false);
      _self.centerManager.getLayout().setActiveItem(1);
    }
    this.setupNoLayout = function(){
      this.centerInfoPane.update(this.infoPaneMessage.apply());

      _self.centerManager.getLayout().setActiveItem(0);
      _self.currentLayout = '';
      _self.gridSwitch.refreshBtn.setDisabled(false);
      _self.gridSwitch.uploadBtn.hide();
      _self.gridSwitch.uploadBtn.setDisabled(true);
      _self.gridSwitch.sortingBtn.hide();
      _self.gridSwitch.sortingBtn.setDisabled(true);
      _self.gridSwitch.restoreFileBtn.hide();
      _self.gridSwitch.restoreFileBtn.setDisabled(true);
      _self.gridSwitch.trashFileBtn.show();
      _self.gridSwitch.trashFileBtn.setDisabled(true);
      _self.gridSwitch.deleteFileBtn.hide();
      _self.gridSwitch.deleteFileBtn.setDisabled(true);
      _self.gridSwitch.getURLBtn.setDisabled(true);
      _self.gridSwitch.getURLBtn.hide();
      _self.gridSwitch.replaceFileBtn.setDisabled(true);
    }
    this.setupUploadButton = function(){
      _self.gridSwitch.uploadBtn.setDisabled(false);
    }
    
    this.uploadFile = function(){
      switch(_self.settings.currentMode){
        case "gallery":
          uploadType = "image";
          contentType = "image";
          curID = _self.settings.currentAlbumID;
          break;
          
        case "post":
          uploadType = "normal";
          contentType = _self.settings.currentActionType;
          curID = _self.settings.currentDataID;
          break;
          
        default:
          return false;
      }
      new CS2.Upload.File({explorer: _self, uploadType: uploadType, contentType: contentType, editorID: curID});
    }
    
    this.gridSwitch = new Ext.Panel({
      tbar: [
        {text: 'Refresh', disabled: true, iconCls: 'file-refresh-icon', ref: '../refreshBtn', tooltip: 'Refresh the file list', handler: _self.updateStore},
        {text: 'Upload...', disabled: true, hidden: true, iconCls: 'file-upload-icon', ref: '../uploadBtn', tooltip: 'Upload files from your computer', handler: _self.uploadFile},
        {text: 'Sorting...', disabled: true, hidden: true, iconCls: 'iconSort', ref: '../sortingBtn', tooltip: '<b>Public Sorting Order</b><br />Adjust the order the public see\'s the files', handler: changeSortOrder.createDelegate(this, [], true)},
        {text: 'Get Link', disabled: true, hidden: true, ref: '../getURLBtn', iconCls: 'iconGetLink', tooltip: 'Get the URL fror the selected file', handler: _self.showFileURL},
        {text: 'Replace', disabled: true, hidden: true, ref: '../replaceFileBtn', iconCls: 'file-upload-icon', tooltip: 'Replace this file with one on your computer'},
        '-',
        {text: 'Trash', disabled: true, ref: '../trashFileBtn', iconCls: 'file-delete-icon', tooltip: 'Put the selected file(s) in the Rubbish Bin', handler: _self.deleteFile.createDelegate(this, [false, false])},
        {text: 'Delete', disabled: true, hidden: true, ref: '../deleteFileBtn', iconCls: 'file-permdelete-icon', tooltip: 'Delete the selected file(s)', handler: _self.deleteFile.createDelegate(this, [false, true])},
        {text: 'Restore', disabled: true, hidden: true, ref: '../restoreFileBtn', iconCls: 'iconRestoreItem', tooltip: 'Restore the selected file(s)', handler: _self.deleteFile.createDelegate(this, [true, false])}
      ],
      bbar: [
        '->',
        {text: 'List', ref: '../listViewBtn', iconCls: "iconListView", tooltip: 'View files in a list with details', pressed: true, toggleGroup: 'viewType', toggleHandler: changeViewports.createDelegate(this, ['list'], true)},
        {text: 'Thumbnail', ref: '../iconViewBtn', iconCls: "iconIconView", tooltip: 'View files as thumbnails', pressed: false, toggleGroup: 'viewType', toggleHandler: changeViewports.createDelegate(this, ['thumb'], true)}
      ],
      layout:'card',
      activeItem: 0,
      border: true,
      region: 'center',
      items: [
        {
          id: 'gridView',
          layout: 'fit',
          border: false,
          items: this.grid
        },{
          id: 'thumbView',
          layout: 'fit',
          border: false,
          autoScroll: true,
          items: this.thumbs
        }
      ]

    });
    
    this.grid.getSelectionModel().on('selectionchange', function(sm){
      _self.setToolbars(sm.getCount());
    });
    this.thumbs.on('selectionchange', function(dv, sel){
      _self.setToolbars(sel.length);
    });
    this.setToolbars = function(countSel){
        var tpl = new Ext.XTemplate('{count} File<tpl if="count != 1">s</tpl> Selected');
        Ext.fly(_self.selCount.getEl()).update(tpl.apply({count: countSel}));
        
        if (_self.currentLayout == 'files' || _self.currentLayout == 'album' || _self.currentLayout == 'trash'){
          _self.gridSwitch.trashFileBtn.setDisabled(countSel < 1);
        }
        if (_self.currentLayout == 'files' || _self.currentLayout == 'album'){
          _self.gridSwitch.getURLBtn.setDisabled(countSel != 1);
          _self.gridSwitch.replaceFileBtn.setDisabled(countSel != 1);
        }
        if (_self.currentLayout == 'trash' ){
          _self.gridSwitch.deleteFileBtn.setDisabled(countSel < 1);
          _self.gridSwitch.restoreFileBtn.setDisabled(countSel < 1);
        }
        if (_self.currentLayout == 'fckeditor'){
          _self.gridSwitch.deleteFileBtn.setDisabled(countSel < 1);
        }    
    };
    this.searchHolder = new Ext.Panel({
      title: 'Search',
      region: 'north',
      split: true,
      cmargins: '0 0 5 0',
      collapsible: true,
      collapsed: true,
      height: 140,
      html: 'test'
    });
    this.gridInfo = new Ext.Panel({
      region: 'south',
      hidden: true,
      split: true,
      height: 100,
      html: 'test'
    });
    this.treeHolder = new Ext.Panel({
      region: 'west',
      collapsible: true,
      split: true,
      width: 160,
      layout: 'fit',
      items: this.tree
    });
    this.gridHolder = new Ext.Panel({
      layout: 'border',
      border: false,
      items: [this.gridSwitch, this.gridInfo]
    });
    
    
    
    this.infoPaneMessage = new Ext.XTemplate(
      '<h3 style="font-size: 14px">Welcome to the File Manager!</h3>',
      '<span>',
        '<p style="margin-bottom: 5px;">Here you can manage files for the following:</p>',
        '<ul style="list-style: disc; padding: 0 0 0 20px">',
          '<li>My Files',
            '<ul style="list-style: disc; padding: 0 0 0 20px">',
              '<li>By Content',
                '<ul style="list-style: disc; padding: 0 0 0 20px">',
                  '<li>Blog Posts</li>',
                  '<li>News Posts</li>',
                  '<li>Calendar Events</li>',
                  '<li>Pages</li>',
                '</ul>',
              '</li>',
              '<li>FCKEditor Uploads</li>',
            '</ul>',
          '</li>',
          '<li>Image Galleries</li>',
          '<li>Rubbish Bin</li>',
        '</ul>',
        '<br />',
        '<div class="sectionArrow" style="font-size: 13px; position: relative; left: 500px; top: 0; opacity: 0">&lArr; Select a section from the left to get started</div>',
      '</span>'
    );
    this.infoMyFilesMessage = new Ext.XTemplate(
      '<h3 style="font-size: 14px">My Files</h3>',
      '<span>',
        '<p style="margin-bottom: 5px;">Here you can manage files for the following:</p>',
            '<ul style="list-style: disc; padding: 0 0 0 20px">',
              '<li><strong>By Content</strong><br />Contains all Resource Files uploaded via the Resource Tab',
                '<ul style="list-style: disc; padding: 0 0 0 20px">',
                  '<li>Blog Posts</li>',
                  '<li>News Posts</li>',
                  '<li>Calendar Events</li>',
                  '<li>Pages</li>',
                '</ul>',
              '</li>',
              '<li><strong>FCKEditor Uploads</strong><br />Files that were embeded directly into posts uploaded via FCK Editor</li>',
            '</ul>',
      '</span>'
    );
    this.infoAlbumLockerMessage = new Ext.XTemplate(
      '<h3 style="font-size: 14px">My Galleries</h3>',
      '<span>',
        '<p style="margin-bottom: 5px;">Select a Gallery from the list</p>',
      '</span>'
    );
    this.infoModulePickMessage = new Ext.XTemplate(
      '<h3 style="font-size: 14px">My Files &raquo; By Content</h3>',
      '<span>',
        '<p style="margin-bottom: 5px;">Select a Module from the list</p>',
      '</span>'
    );
    this.infoModuleMessage = new Ext.XTemplate(
      '<h3 style="font-size: 14px">My Files &raquo; By Content &raquo; {module}</h3>',
      '<span>',
        '<p style="margin-bottom: 5px;">Select a Year from the list or (Legacy) to view items that have missing or invalid dates</p>',
      '</span>'
    );
    this.infoModuleYearMessage = new Ext.XTemplate(
      '<h3 style="font-size: 14px">My Files &raquo; By Content &raquo; {module} &raquo; {year}</h3>',
      '<span>',
        '<p style="margin-bottom: 5px;">Select a Month from the list</p>',
      '</span>'
    );
    this.infoModuleMonthMessage = new Ext.XTemplate(
      '<h3 style="font-size: 14px">My Files &raquo; By Content &raquo; {module} &raquo; {year} &raquo; {month}</h3>',
      '<span>',
        '<p style="margin-bottom: 5px;">Select a Post from the list</p>',
      '</span>'
    );
    this.infoModuleLegacyMessage = new Ext.XTemplate(
      '<h3 style="font-size: 14px">My Files &raquo; By Content &raquo; {module} &raquo; Legacy</h3>',
      '<span>',
        '<p style="margin-bottom: 5px;">Select a Post from the list</p>',
      '</span>'
    );
    this.centerInfoPane = new Ext.Panel({
      padding: 10,
      plain: true,
      html: this.infoPaneMessage.apply(),
      listeners: {
        'afterrender' : function(p){
          var arrowEl = p.body.select('div.sectionArrow').elements[0];
          new Effect.Parallel([
            new Effect.Opacity(arrowEl, { sync: true, from: 0, to: 1 }),
            new Effect.Move(arrowEl, { sync: true, x: -500, y: 0, mode: 'relative' })
          ], { 
            duration: 2,
            delay: .5,
            transition: Effect.Transitions.spring 
          });
        }
      }
    });
    
    this.centerManager = new Ext.Panel({
      region: 'center',
      border: false,
      layout:'card',
      activeItem: 0,
      items: [this.centerInfoPane, this.gridHolder]
    });
                                        
    this.mainHolder = new Ext.Panel({
      layout: 'border',
      border: false,
      items: [this.treeHolder, this.centerManager] //, this.searchHolder]
    });
    
    this.selCount = new Ext.Toolbar.TextItem('0 Files Selected');
    this.clock = new Ext.Toolbar.TextItem('');

    this.win = new Ext.Window({
        title: 'My Explorer',
        iconCls: 'iconMyExplorer',
        constrainHeader: true,
        width:800,
        height:400,
        modal: true,
        maximizable: true,
        layout: 'fit',
        padding: 5,
        items: [this.mainHolder],/*
        tbar: new Ext.ux.StatusBar({
          ref: '../LocationBar',
          defaultText: '',
          text: 'Welcome to the File Manager!',
          iconCls: 'x-status-valid'
	}),*/
        bbar: new Ext.ux.StatusBar({
          ref: '../statusBar',
          defaultText: 'Ready',
          text: 'Ready',
          iconCls: 'x-status-valid',
          items: [
            this.selCount,
            '-',
            this.clock
          ],
        listeners: {
          render: {
            fn: function(){
              Ext.TaskMgr.start({
                run: function(){
                  Ext.fly(_self.clock.getEl()).update(new Date().format('g:i:s A'));
                },
                interval: 1000
              });
            },
            delay: 100
          }
        }
      })
    });
    this.win.show(this);
};

reportingIn('fileManager');
