  
  var winGCD;
  var currentAction;
  var currentItemID;
 
  var isReady = false;
  Ext.onReady(function () {
    isReady = true;
  });

  var eventDetails;
  var dialogHeight;
  var dialogWidth;
  
  
  
  function gcdItem(mainContainer, itemContainer, itemID, catID, newDataAction){
	
  
    //Set our highlight ID for when we refresh.
    currentPageHighlight = itemContainer;
    currentID = itemID;
    
  if (catID == '')
      var catID = 0;
    
    var windowTitle = 'Loading Item #' + itemID + '...';
    if (itemID == 0)
      var windowTitle = 'Add New';

      
    dialogHeight = 550;
    dialogWidth = 680;
    
    eventDetails = {
        title: 'Details',
        id: 'tab_detail',
        height: dialogHeight,
        html: '<iframe src="/ajax.cfm?frame=true&a=edit&mode=editGCD&id=' + itemID + '&catID=' + catID + '&s=' + currentSchoolAlias + '&new=' + newDataAction + '" style="width: 100%; border: 0; height: 100%"></iframe>'
      };


                   
                      
    var tabHolder = new Ext.TabPanel({
                                        activeTab: 0,                      
                                        region: 'center',
                                        height: dialogHeight,
                                        items: [eventDetails]
                                    });

  
    var helpBox = {region: 'north', id: 'help_pane', baseCls: '', cls: 'calendarHelpTitle', height: 48, border: 0, html:getTitle(itemID, newDataAction)};

    winGCD = new Ext.Window({
        title: windowTitle,
        minWidth: dialogWidth,
        width: dialogWidth,
        minHeight: dialogHeight - 48,
        height: dialogHeight - 48,
        layout: 'border',
        modal: true,
        closeAction: 'hide',
        maximizable: false,
        closable: false,
        items: [helpBox, tabHolder],
        buttons: [{
                    text: 'Close',
                    handler: function(){
                      processWindowUpdate();
                      winGCD.hide();
                    }
                  }]
      });
    winGCD.show();
  }


  
  
  	function gcdDel(id,backlink){
		
		Ext.Msg.confirm('Item Deletion','Are you sure you would like to delete this item? Doing so will delete all items associated with it.', 
						function(btn){if(btn == 'yes') {
							new Ajax.Request('/ajax/delete_gcd.cfm', { method: 'post', parameters: {data: id}});
              if(!backlink)
                window.location.reload(true);
              else
                window.location = backlink;
							}});
}	

	
