Ext.override(Ext.data.Store, {

        // private

        // Keeps track of the load status of the store. Set to true after a successful load event

        loaded: false,

        /**

         * Returns true if the store has previously performed a successful load function.

         * @return {Boolean} Whether the store is loaded.

         */

        isLoaded: function(){

            return this.loaded;

        },

        // private

    // Called as a callback by the Reader during a load operation.

    loadRecords : function(o, options, success){

        if(!o || success === false){

            if(success !== false){

                this.fireEvent("load", this, [], options);

            }

            if(options.callback){

                options.callback.call(options.scope || this, [], options, false);

            }

            return;

        }

        var r = o.records, t = o.totalRecords || r.length;

        if(!options || options.add !== true){

            if(this.pruneModifiedRecords){

                this.modified = [];

            }

            for(var i = 0, len = r.length; i < len; i++){

                r[i].join(this);

            }

            if(this.snapshot){

                this.data = this.snapshot;

                delete this.snapshot;

            }

            this.data.clear();

            this.data.addAll(r);

            this.totalLength = t;

            this.applySort();

            this.fireEvent("datachanged", this);

        }else{

            this.totalLength = Math.max(t, this.data.length+r.length);

            this.add(r);

        }

                this.loaded = true;

        this.fireEvent("load", this, r, options);

        if(options.callback){

            options.callback.call(options.scope || this, r, options, true);

        }

    }

});

Ext.override(Ext.form.ComboBox,{

    /**

     * Sets the specified value into the field.  If the value finds a match, the corresponding record text

     * will be displayed in the field.  If the value does not match the data value of an existing item,

     * and the valueNotFoundText config option is defined, it will be displayed as the default field text.

     * Otherwise the field will be blank (although the value will still be set).

     * @param {String} value The value to match

     */

    setValue : function(v){

        var text = v;

                if (v && this.mode == 'remote' && !this.store.isLoaded()) {

                    this.lastQuery = '';

                    this.store.load({

                        scope: this,

                        params: this.getParams(),

                        callback: function(){

                            this.setValue(v);

                        }

                    });

                }

        if(this.valueField){

            var r = this.findRecord(this.valueField, v);

            if(r){

                text = r.data[this.displayField];

            }else if(this.valueNotFoundText !== undefined){

                text = this.valueNotFoundText;

            }

        }

        this.lastSelectionText = text;

        if(this.hiddenField){

            this.hiddenField.value = v;

        }

        Ext.form.ComboBox.superclass.setValue.call(this, text);

        this.value = v;

    }

}); 

  
/*
  function enableEditing(userToken){
    var uFullName = userToken.userFullName;
    var uID = userToken.userID;
    var uSchoolAlias = userToken.schoolAlias;
    var uWebmail = userToken.schoolWebmail;
    var loginTemp = new Ext.Template(
                                  '<ul>',
                                    '<li><a href="/{school_alias}/profile&amp;id={user_id}">Hello <strong>{user_name}</strong></a></li>',
                                    '<li><a href="#" onclick="windowSiteConfig(); return false;">Site Config</a></li>',
                                    '<li><a href="/{school_alias}/sc&amp;mode=edit" onclick="siteConfig(this,1); return false;">Manage Galleries</a></li>',
                                    '<li><a href="/go.cfm?url={webmail_url}" target="_blank" class="" onclick="">WebMail</a></li>',
                                    '<li><a href="/{school_alias}/profile&amp;id={user_id}">My Account</a></li>',
                                    '<li><a href="/{school_alias}/staff&amp;level=login" class="userAuthBoxLogout" style="border: 0pt none ;" onclick="return userLogout();">Logout</a></li>',
                                  '</ul>'
                                  );

    $$('.userAuthBox')[0].update(loginTemp.apply({user_id: uID, user_name: uFullName, webmail_url: uWebmail, school_alias: uSchoolAlias}));
    $$('.csEditHolder').each(function(e){e.addClassName('hidden');});
    $$('.csEditHolder_' + uID).each(function(e){e.removeClassName('hidden');});
    canEdit=true;
  }
*/
  
  var win;
  var googWin;
  var finishOpenID = false;
  var currentlyAlerting = false;
  function loggedOutAlert(){
    if (currentlyAlerting){
      return false;
    }        
    logoutAlert = new Ext.Window({
          title: 'Session Timeout',
          id: 'loggedOutAlert',
          modal: true,
          cls: 'x-window-dlg',
          border: true,
          resizable: false,
          buttonAlign: 'center',
          closable: false,
          layout: 'border',
          height: 180,
          width: 360,
          items: [
                    {
                      bodyStyle: 'font-size: 13px; padding: 10px;',
                      region: 'north',
                      border: false,
                      height: 80,
                      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>Session for ' + currentUser.displayname + ' has timed out.</strong>',
                              '<br /><br />',
                              'Logging in as the above user will re-enable all open tabs allow you to continue editing.',
                            '</span>',
                          '</div>',
                          '<div class="x-clear"></div>',
                        '</div>'
                      ).apply()
                    },{
                      region: 'center',                    
                      border: false,
                      layout: {
                                type:'vbox',
                                padding:'5',
                                align:'stretch'
                              },
                      items:[{
                                layout:'column',
                                border: false,
                                height: 40,
                                items:[{
                                        columnWidth:.5,
                                        xtype:'button',
                                        cls: 'bigPrint1',
                                        text: 'Log Back In',
                                        handler: function(){
                                          userLogin(true, true);
                                        }
                                      },{
                                        columnWidth:.5,
                                        xtype:'button',
                                        cls: 'bigPrint1',
                                        text: 'New Window',
                                        handler: function(){
                                          var newWindow = window.open(currentURLBaseSchool, '_blank');
                                        }
                                      }]
                              },{
                                xtype:'button',
                                cls: 'bigPrint2',
                                text: 'Log Out / Lose Unsaved Changes',
                                handler: function(){
                                  restartREQUIRED=true;
                                  userLogout(true);
                                  logoutAlert.close();
                                  currentlyAlerting = true;
                                }
                              }]
                    }
                ]
        
        });
        logoutAlert.show(this);
        currentlyAlerting = true;
  
  }
  
  var pollFreq = 30000;
  var pollTimer;
  var remainingSeconds = -10;
  function updateCountdown(){
    var nodes = Ext.get('timeoutCountdown');
    if (!nodes)
      return false;
    //nodes.update(currentlyAlerting + ' / ' + remainingSeconds);
    if (!currentlyAlerting){
      if (remainingSeconds == -10){
        if (loggedIn){
          nodes.removeClass('hidden');
          nodes.update('Gathering time...');
        }else{
          nodes.update('Logged out!');
          //nodes.addClass('hidden');
        }
      }else if(remainingSeconds > 0){
        nodes.update('Auto Logout in: '+(remainingSeconds--)+'sec');
      }else if(remainingSeconds === 0){
        pollLoginCheck();
        nodes.update('Session Timeout!');
      }
    }
    setTimeout( function(){ updateCountdown(); }, 1000);    
  }
  
  function pollLoginCheck(){    
    
    Ext.Ajax.request({
       url: '/ajax/login/checkLoggedIn.cfm',
       method: 'GET',
       reader : new Ext.data.JsonReader({
        success : '@success'
       }),
       success: function(response, opts) {
          var obj = Ext.decode(response.responseText);
          var lastDelay = obj.currentTime - obj.lastHit;
          currentUser.lastHit = obj.lastHit;
          
          remainingSeconds = obj.timeout - obj.lastTimeRange;
          //var nodes = Ext.get('timeoutCountdown');
          //nodes.update(obj.toSource());
          
          if (!obj.loggedIN || obj.user_id != currentUser.id){
            clearTimeout(pollTimer);
            pollTimer = setTimeout( function(){ pollLoginCheck(); }, pollFreq);
            loggedOutAlert();
          }else{
            clearTimeout(pollTimer);
            pollTimer = setTimeout( function(){ pollLoginCheck(); }, pollFreq);
            if (currentlyAlerting && obj.user_id == currentUser.id){
              reloginOK();
            }
          }
       },
       failure: function(response, opts) {
        clearTimeout(pollTimer);
        pollTimer = setTimeout( function(){ pollLoginCheck(); }, pollFreq);
        //Ext.Msg.alert('Error Deleting User', 'There was a problem communicating with the server. Please check your internet connection and try again.');
       }
    });   
  }
  
  var isReady = false;
  Ext.onReady(function () {
    isReady = true;
    if (loggedIn){
      clearTimeout(pollTimer);
      pollTimer = setTimeout( function(){ pollLoginCheck(); }, 45000);
    }
    updateCountdown();
  });
  
  function reloginOK(){
    currentlyAlerting = false;
    clearTimeout(pollTimer);
    pollLoginCheck();
    setTimeout(function(){ Ext.getCmp('LoginwinIES').close(); }, 10);
    setTimeout(function(){ Ext.getCmp('Loginwin').close(); }, 10);
    setTimeout(function(){ Ext.getCmp('loggedOutAlert').close(); }, 10);
  }
  var globalNoReload = false;
  var restartREQUIRED = false;
  function successGoogle(loggedID){
    currentlyAlerting = false;
    reloginOK();
    if (globalNoReload && loggedID == currentUser.id){
      if (journeyHelper.isRunning){
        journeyHelper.showText('Welcome Back!', true, null);
      }
      Ext.Msg.wait('You have been logged back in!', 'Logged In!');
      googWin.close();
      setTimeout(function(){
        Ext.Msg.hide();
      }, 750);
    }else{
      restartREQUIRED=true;
      Ext.Msg.wait('You are being logged in, please wait...', 'Google Account');
      googWin.close();
      
      if (finishOpenID)
        window.location="/"+currentSchool.Alias+"/";
      else
        window.location.reload(false);
    }
  }
  function setupGoogle(){
    googWin.close();
    Ext.Msg.alert('Almost there!', 'Please login to continue linking your account with Google.');
  }
  function failGoogle(){
    googWin.close();
    Ext.Msg.alert('Whoops!', 'There was an error linking up with your Google Account. Try back later if you feel this was in error.');
  }
  
  function launchGoogleLogin(){
    googWin = window.open("/authsub/openID.cfm?p=1","cyberschoolGoogle","menubar=no,width=450,height=500,toolbar=no");
  }
  
  function userLogout(forced){
    if (forced){
      canEdit=false;
      if (journeyHelper.isRunning)
        journeyHelper.showText('Your session is being logged out, please wait...', true, null);
      Ext.Msg.wait('Your session is being logged out, please wait...', 'Logging Out');
      window.location="/action/logout.cfm";
      return false;
    }
    var loginTemp = new Ext.Template(
                                  '<ul>',
                                    '<li><a href="/#request.cyberschool.school.alias#/staff&amp;level=login" onclick="userLogin(); return false;" style="border: 0pt none ;">Login</a></li>',
                                  '</ul>'
                                  );
    $$('.userAuthBox')[0].update(loginTemp.apply());
    $$('.csEditHolder').each(function(e){e.addClassName('hidden');});
    canEdit=false;
    if (journeyHelper.isRunning)
      journeyHelper.showText('Your session is being logged out, please wait...', true, null);
    Ext.Msg.wait('Your session is being logged out, please wait...', 'Logging Out');
    return true;
  }
  var userStore = {};
  var userGroupStore = new Ext.data.Store({
        autoLoad: true,
        url: '/ajax/login/getUserGroups.cfm',
        reader : new Ext.data.JsonReader({
            root : 'users'
          },[
            {name: 'id', mapping: 'id'},
            {name: 'groupname', mapping: 'groupname'}
          ]
        )
    });
  function userLoginIES(noReload, forceLastUser){
    
    launchModule('userLoginIES', [noReload, forceLastUser, true]);
    return false;
    
    globalNoReload = noReload;
    if (!isSpecial)
      return false;
    var infoBox = {region: 'north', baseCls: '', cls: 'dialogHelpTitle', border:false, height: 48, html: '<strong style="font-size: 13px; font-weight: bold">IES Global Login</strong>'};

    var loginBox = new Ext.form.FieldSet({
                                            labelAlign: 'top',
                                            border: false,
                                            defaults: {
                                                anchor: '100%'
                                            },
                                            items:[
                                                    new Ext.form.Hidden({
                                                      name: forceLastUser ? 'login_special' : 'login_special_unused_atm',
                                                      value: lastLoggedInUserID
                                                    }),
                                                    forceLastUser ? new Ext.Panel({
                                                      border: false,
                                                      bodyStyle: 'font-size: 12px; text-align: center; margin-bottom: 10px;',
                                                      html: 'Session Locked by:<br /><strong>'+lastLoggedInDisplayName+'</strong><br /><span style="font-size: 10px">IES: No Password Required</span>'
                                                    }) : 
                                                    new Ext.form.ComboBox({
                                                          store: new Ext.data.Store({
                                                              autoLoad: true,
                                                              url: '/ajax/login/getUsers.cfm',
                                                              reader : new Ext.data.JsonReader({
                                                                  root : 'users'
                                                                },[
                                                                  {name: 'id', mapping: 'id'},
                                                                  {name: 'username', mapping: 'username'},
                                                                  {name: 'fullname', mapping: 'fullname'},
                                                                  {name: 'email', mapping: 'email'},
                                                                  {name: 'image', mapping: 'image'}
                                                                ]
                                                              )
                                                          }),
                                                          mode: 'remote',
                                                          triggerAction: 'all',
                                                          allowBlank:false, 
                                                          forceSelection: true,
                                                          anchor: '0',
                                                          itemSelector: 'div.search-item',
                                                          tpl:new Ext.XTemplate(
                                                            '<tpl for="."><div class="search-item">',
                                                              '<h3><span>{fullname}</span></h3><strong>{username}</strong> &bull; {email}',
                                                            '</div></tpl>'
                                                          ),
                                                          fieldLabel: 'Username',
                                                          hiddenName: 'login_special',
                                                          hiddenId: 'login_special_ies_hid',
                                                          id: 'login_special_ies',
                                                          valueField: 'id',
                                                          displayField: 'fullname',
                                                          value: forceLastUser ? currentUser.id : lastLoggedInUserID,
                                                          readOnly: forceLastUser
                                                        }),
                                                    new Ext.Panel({
                                                      border: false,
                                                      bodyStyle: 'font-size: 12px; text-align: center; margin-bottom: 10px;' + (finishOpenID ? '' : 'font-weight: bold;'),
                                                      html: finishOpenID ? 'To finish linking your Google Account please login as normal.' : '-- or --'
                                                    }),
                                                    new Ext.Panel({
                                                      border: false,
                                                      bodyStyle: 'font-size: 10px; text-align: center',
                                                      html: finishOpenID ? '' : '<a style="text-decoration: none; color: black;" onclick="launchGoogleLogin(); return false;" href="/authsub/openID.cfm">Sign in with your<br /><img src="/common/images/google_transparent.gif" /> <span style="color: black; font-size: 14px; position: relative; top: -8px; font-weight: bold;">Account</span></a>'
                                                      //html: '<a style="text-decoration: none; color: black;" onclick="launchGoogleLogin(); return false;" href="https://www.google.com/accounts/AuthSubRequest?scope=http%3A%2F%2Fwww.google.com%2Fm8%2Ffeeds%2F%20http%3A%2F%2Fwww.google.com%2Fcalendar%2Ffeeds%2F%20http%3A%2F%2Fdocs.google.com%2Ffeeds%2F&session=1&secure=0&next=http%3A%2F%2Fdev1.cyberschool.com%2Fauthsub&hd=default">Sign in with your<br /><img src="/common/images/google_transparent.gif" /> <span style="color: black; font-size: 14px; position: relative; top: -8px; font-weight: bold;">Account</span></a>'
                                                    })
                                                  ]
                                        });
    var formPanel = new Ext.FormPanel({
                                        region: 'center', 
                                        id: 'login_form_ies', 
                                        border:true, 
                                        monitorValid:true, 
                                        plain: true, 
                                        items: loginBox,
                                        keys: [{key : [10,13],fn: function(){
                                                  var bt = Ext.getCmp('login_submit'); 
                                                  bt.focus();
                                                  bt.fireEvent("click", bt);
                                             }
                                        }]
                                        });

    var loginWinIES = new Ext.Window({
        title: "Login",
        id: "LoginwinIES",
        width: 270, 
        height: finishOpenID ? 235 : 260,
        layout: 'fit',
        border:true,
        padding: 5,
        modal: true,
        resizable:false,
        closeAction: 'close',
        items: new Ext.Panel({layout: 'border', border: false, items: [infoBox, formPanel]}),
        keys: [
                {
                  key: 27, // Esc key
                  handler: function(){ loginWin.close(); },
                  scope: this
                }
              ],
        buttons: [
                  {
                    text: 'Login',
                    id: 'login_submit_ies', 
                    formBind: true,
                    handler: function(){
                      Ext.getCmp('login_form_ies').getForm().submit({
                        clientValidation: true,            
                        url:'/ajax/login/doLogin.cfm', 
                        waitMsg:'Checking Credentials...',
                        errorReader : new Ext.data.JsonReader({
                            root:"errors",
                            successProperty:"success"
                          }, ['id', 'msg']),
                        success: function(form, action) {
                          if (noReload && action.result.userID == currentUser.id){
                            if (journeyHelper.isRunning)
                              journeyHelper.showText('Welcome Back!', true, null);
                            Ext.Msg.wait('You have been logged back in!', 'Logged In!');
                            reloginOK();
                            setTimeout(function(){
                              Ext.Msg.hide();
                            }, 750);
                          }else{
                            restartREQUIRED=true;
                            if (journeyHelper.isRunning)
                              journeyHelper.showText('You are being logged in, please wait...', true, null);

                            Ext.Msg.wait('You are being logged in, please wait...', 'Logging In');
                            //enableEditing(action.result)
                            loginWinIES.close();
                            if (finishOpenID)
                              window.location="/"+currentSchool.Alias+"/";
                            else
                              window.location.reload(false);
                          }
                        },
                        failure: function(form, action) {
                          switch (action.failureType) {
                              case Ext.form.Action.CLIENT_INVALID:
                                  Ext.Msg.alert('Failure', 'Please verify all form 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);
                          }
                          }
                      });
                    }
                  },{
                    text: 'Cancel',
                    handler: function(){
                      loginWinIES.close();
                    }
                  }
                ]
      });
    loginWinIES.show();
    if (journeyHelper.isRunning)
      journeyHelper.showText('Who would you like to be today?', true, 5000);

  }
  var loginWin;
  function userLogin(noReload, forceLastUser){
  globalNoReload = noReload;
    if (isSpecial){
      userLoginIES(noReload, forceLastUser);
      return false;
    }
    var curMsg = forceLastUser ? 'Unlock your account' : 'Login to your account';
    var infoBox = {region: 'north', baseCls: '', cls: 'dialogHelpTitle', border:false, height: 48, html: '<strong style="font-size: 13px; font-weight: bold">'+curMsg+'</strong>'};
    var loginBox = new Ext.form.FieldSet({
                                            labelAlign: 'top',
                                            border: false,
                                            defaults: {
                                                anchor: '-20',
                                                msgTarget: 'side'
                                            },
                                            items: [new Ext.form.Hidden({
                                                      name: forceLastUser ? 'username' : 'username_unused_atm',
                                                      value: currentUser.username
                                                    }),
                                                    forceLastUser ? new Ext.Panel({
                                                      border: false,
                                                      bodyStyle: 'font-size: 12px; text-align: center; margin-bottom: 10px;',
                                                      html: 'Session Locked by:<br /><strong>'+lastLoggedInDisplayName+'</strong>'
                                                    }) : {
                                                      xtype: 'textfield',
                                                      name:'username',
                                                      id: 'login_user',
                                                      maskRe:/^([ _a-zA-Z0-9\^\$\.\+\?\=\:\|\\\/\(\)\[\]\&\-])+$/,
                                                      selectOnFocus: true,
                                                      blankText: 'Username is Required',
                                                      allowBlank: false,
                                                      fieldLabel: 'Username',
                                                      value: lastLoggedInUserName
                                                    },{
                                                      xtype: 'textfield',
                                                      name:'password',
                                                      id: 'login_password',
                                                      inputType:'password',
                                                      selectOnFocus: true,
                                                      blankText: 'Password is Required',
                                                      allowBlank: false,
                                                      fieldLabel: 'Password'
                                                    },
                                                    new Ext.Panel({
                                                      border: false,
                                                      anchor: '0',
                                                      bodyStyle: 'font-size: 12px; text-align: center; margin-bottom: 10px;' + (finishOpenID ? '' : 'font-weight: bold;'),
                                                      html: finishOpenID ? 'To finish linking your Google Account please login as normal.' : '-- or --'
                                                    }),
                                                    new Ext.Panel({
                                                      border: false,
                                                      anchor: '0',
                                                      bodyStyle: 'font-size: 10px; text-align: center',
                                                      html: finishOpenID ? '' : '<a style="text-decoration: none; color: black;" onclick="launchGoogleLogin(); return false;" href="/authsub/openID.cfm">Sign in with your<br /><img src="/common/images/google_transparent.gif" /> <span style="color: black; font-size: 14px; position: relative; top: -8px; font-weight: bold;">Account</span></a>'
                                                      //html: '<a style="text-decoration: none; color: black;" onclick="launchGoogleLogin(); return false;" href="https://www.google.com/accounts/AuthSubRequest?scope=http%3A%2F%2Fwww.google.com%2Fm8%2Ffeeds%2F%20http%3A%2F%2Fwww.google.com%2Fcalendar%2Ffeeds%2F%20http%3A%2F%2Fdocs.google.com%2Ffeeds%2F&session=1&secure=0&next=http%3A%2F%2Fdev1.cyberschool.com%2Fauthsub&hd=default">Sign in with your<br /><img src="/common/images/google_transparent.gif" /> <span style="color: black; font-size: 14px; position: relative; top: -8px; font-weight: bold;">Account</span></a>'
                                                    })]
                                          });
    var formPanel = new Ext.FormPanel({
                                        region: 'center', 
                                        id: 'login_form', 
                                        border:true, 
                                        monitorValid:true, 
                                        plain: true, 
                                        items: loginBox,
                                        keys: [{key : [10,13],fn: function(){
                                                  var bt = Ext.getCmp('login_submit'); 
                                                  bt.focus();
                                                  bt.fireEvent("click", bt);
                                             }
                                        }]
                                        });

    loginWin = new Ext.Window({
        title: "Login",
        id: "Loginwin",
        width: 270, 
        height: finishOpenID ? 280 : 310,
        layout: 'fit',
        border:true,
        padding: 5,
        modal: true,
        resizable:false,
        closeAction: 'close',
        items: new Ext.Panel({layout: 'border', border: false, items: [infoBox, formPanel]}),
        keys: [
                {
                  key: 27, // Esc key
                  handler: function(){ loginWin.close(); },
                  scope: this
                }
              ],
        buttons: [
            {
              text: 'Login',
              id: 'login_submit', 
              formBind: true,
              handler: function(){
                Ext.getCmp('login_form').getForm().submit({
                  clientValidation: true,            
                  url:'/ajax/login/doLogin.cfm', 
                  waitMsg:'Checking Credentials...',
                  errorReader : new Ext.data.JsonReader({
                      root:"errors",
                      successProperty:"success"
                    }, ['id', 'msg']),
                  success: function(form, action) {
                    if (action.result.SpecialIES){
                      isSpecial=true;
                      userLoginIES(noReload, forceLastUser);
                      loginWin.close();
                    }else{
                      if (noReload && action.result.userID == currentUser.id){
                        if (journeyHelper.isRunning)
                          journeyHelper.showText('Welcome Back!', true, null);
                        Ext.Msg.wait('You have been logged back in!', 'Logged In!');
                        reloginOK();
                        setTimeout(function(){
                          Ext.Msg.hide();
                        }, 750);
                      }else{
                        restartREQUIRED=true;
                        if (journeyHelper.isRunning)
                          journeyHelper.showText('You are being logged in, please wait...', true, null);
                        Ext.Msg.wait('You are being logged in, please wait...', 'Logging In');
                        loginWin.close();
                        if (finishOpenID)
                          window.location="/"+currentSchool.Alias+"/";
                        else
                          window.location.reload(false);
                      }
                    }

                  },
                  failure: function(form, action) {
                    switch (action.failureType) {
                        case Ext.form.Action.CLIENT_INVALID:
                            Ext.Msg.alert('Failure', 'Please verify all form 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);
                    }
                    }
                });
              }
            },{
              text: 'Cancel',
              handler: function(){
                loginWin.close();
              }
            }
          ]
      });
    loginWin.show();
    if (journeyHelper.isRunning)
      journeyHelper.showText('Enter your username and password to access your files and account information!', true, 5000);

  }


  function resetPass(id){
    
	var infoBox = {region: 'north', baseCls: '', cls: 'dialogHelpTitle', height: 48, border: 0, html: '<strong style="font-size: 13px; font-weight: bold">Type the new password in the text area</strong>'};
	
	var loginBox = {region: 'center', baseCls: '', cls: '', height: 48, border: 0, autoLoad: '/ajax.cfm?frame=true&a=staff&mode=edit&tab=resetPass&id=' + id + '&s=' + currentSchoolAlias };

	win = new Ext.Window({
      title: "Login",
      minWidth: 320,
      width: 250,
	  layout:'fit',
      height: 250,
      layout: 'border',
      modal: true,
      maximizable: false,
      closeAction: 'hide',
      buttons: [],
      items: [infoBox,loginBox],
      keys: {
        key: 27, // Esc key
        handler: function(){ win.hide(); },
        scope: this
      }
    });
    win.show();
  }
  
  

  function checkCommentForm(cName){
    if (cName.trim() == ''){
      alert('You must specify a Name to post a comment');
      return false;
    }
    if (cName.trim() == ''){
      alert('You must specify an Email to post a comment');
      return false;
    }
    if (cName.trim() == ''){
      alert('You must specify a Comment to post!');
      return false;
    }
  }
  
  
reportingIn('userLogin');
reportingIn('userLogout');