  var staffWin;
  var currentAction;
  var currentItemID;
 
  var isReady = false;
  Ext.onReady(function () {
    isReady = true;
  });

  var staffDetails;
  var staffAccess;
  
  var dialogHeight;

  function add2EditStaff(ID, currentAction){
    if (ID > 0){
      staffWin.setTitle('Updated Staff #' + ID + '...');
      currentID = ID;

      evtThumb = Ext.getCmp('User_Access');
      evtThumb.enable();
      evtThumb.html = '<iframe src="/ajax.cfm?frame=true&a=staff&mode=edit&tab=access&uid=' + ID + '&s=' + currentSchoolAlias + '" style="width: 100%; border: 0; height: 100%"></iframe>';
		
      helpPane = Ext.getCmp('help_pane');
      helpPane.body.update(getTitle(ID, currentAction));
    }
  }
  
    function setEditStaffTitle(titleStr){
    if (currentID > 0)
      staffWin.setTitle(titleStr);
  }
  
  
  
  function staffEdit(el, userID){
    if (!isReady){
      setTimeout("staffEdit(" + userID + ")", 1000);
      return false;
    }
    
    dialogHeight = 500;
    
    //Set our highlight ID for when we refresh.
    currentID = userID;
		
    var staffDetails = {
		title: "User Info",
		id: "User_Info", 
		height: dialogHeight, 
		html: '<iframe src="/ajax.cfm?frame=true&a=staff&mode=edit&tab=detail&uid=' + userID + '&s=' + currentSchoolAlias + '" style="width: 100%; border: 0; height: 100%"></iframe>'
		};
			
	var staffAccess = {
			title: "User Access",
			id: "User_Access",  
			height: dialogHeight, 
			html: '<iframe src="/ajax.cfm?frame=true&a=staff&mode=edit&tab=access&uid=' + userID + '&s=' + currentSchoolAlias + '" style="width: 100%; border: 0; height: 100%"></iframe>'
			};
    
    
   if (userID == 0){
      staffAccess.disabled = true;
    }
    var tabHolder = new Ext.TabPanel({
                                        activeTab: 0,                                   
                                        region: 'center',
                                        height: dialogHeight,
                                        items:[
                                         staffDetails,
										 staffAccess
                                        ]
                                    });

		var modTitle = "Edit an Existing User";		
		if (userID == 0)
			modTitle = "Create a New User";			

		var infoBox = {region: 'north', baseCls: '', cls: 'dialogHelpTitle', height: 48, border: 0, html: '<strong style="font-size: 13px; font-weight: bold">' + modTitle + '</strong><br /><a href="#">Click here to learn more about staff administration</a>'};

		var helpText = "<strong>Username</strong> is how the user will login to the site.<br /><br /><strong>First Name</strong> of the user logging in<br /><br /><strong>Last Name</strong> of the user logging in<br /><br/><br />...";
		var helpBox = {region: 'east', title: 'Help', split: true, width: 200, minSize: 150, layout:'fit', collapsible: true,  cls: 'dialogHelp', items: [{bodyStyle: 'padding: 10px; font-size: 1.4em', html: helpText}]};
    
    
    var windowTitle = 'Staff Editor';
    if (userID > 0)
    var windowTitle = 'Staff #' + userID + '...';
    
    
    staffWin = new Ext.Window({
      title: windowTitle,
      minWidth: 320,
      width: 600,
			layout:'fit',
      height: dialogHeight + 48,
      layout: 'border',
      modal: true,
      maximizable: true,
      closeAction: 'hide',
      buttons: [{
				text: 'Finish',
				handler: function(){
					staffWin.hide();}
				}],
      items: [infoBox, tabHolder, helpBox],
      keys: {
        key: 27, // Esc key
        handler: function(){ staffWin.hide(); },
        scope: this
      }
    });
    staffWin.show();
  }

  function processUpdate(el, w){
    var tmpCurrentRow = $(el);
    
    tmpCurrentRow.childElements()[0].update('test');
    
    new Effect.Highlight(tmpCurrentRow);
    w.staffWin.hide();  
  }
  
    	function deleteUser(el, id){
		
		Ext.Msg.confirm('Delete User','Are you sure you would like to delete this User?', 
						function(btn){
								if(btn == 'yes') {
									deleteItem(el, id);
									new Ajax.Request('/ajax/delete_user.cfm?uid=' +id , { method: 'get'});
								}
							}
						);
	
	}
