//var pendingMask;
var pendingitems = {};
pendingitems.pendingMask = "";

pendingitems.showPendingItems = function(pendingItemsID)
{
    // Update the form field
    document.getElementById('pendingItemsSelected').value = pendingItemsID;
    // Clear everything
    document.getElementById('pendingitems').innerHTML='';
    pendingitems.PluginPendingItems();
}

pendingitems.PluginPendingItems =  function()
{
    // Clean the DIV used for showing the data
    document.getElementById('pendingitems').innerHTML = '';
    pendingitems.showMask();
    
    var pendingItemsID = document.getElementById('pendingItemsSelected').value;
    
    switch(pendingItemsID){
		case 'autoclose':
			ce.lazyLoad(
                '../plugins/dashboard/pendingitems/ViewTicketsAutoClosing.js',
                function(){
                    pendingitems.hideMask();
                    ticketsclosing.ViewTickets();
                }
            );
			break;
			
		case 'pendingusers':
			ce.lazyLoad(
                '../plugins/dashboard/pendingitems/ViewDeletePendingUsers.js',
                function(){
                    pendingitems.hideMask();
                    pendingusers.ViewPendingUsers();
                }
            );
		
			break;
			
		case 'invoicegenerator':
			ce.lazyLoad(
                '../plugins/dashboard/pendingitems/ViewInvoiceGenerator.js',
                function(){
                    pendingitems.hideMask();
                    invoices.ViewInvoices();
                }
            );
		
			break;
			
		case 'mailer':
			ce.lazyLoad(
                '../plugins/dashboard/pendingitems/ViewQueuedEmails.js',
                function(){
                    pendingitems.hideMask();
                    mailer.ViewQueuedEmails();
                }
            );
		
			break;
			
		case 'rebiller':
			ce.lazyLoad(
                '../plugins/dashboard/pendingitems/Rebiller.js',
                function(){
                    pendingitems.hideMask();
                    rebiller.ViewInvoiceReminders();
                }
            );
		
			break;
			
		case 'autosuspend':
			ce.lazyLoad(
                '../plugins/dashboard/pendingitems/AutoSuspend.js',
                function(){
                    pendingitems.hideMask();
                    suspender.ViewSuspender();
                }
            );
		
			break;
			
		case 'batchnotifier':
			ce.lazyLoad(
                '../plugins/dashboard/pendingitems/BatchNotifier.js',
                function(){
                    pendingitems.hideMask();
                    batchnotifier.ViewEntries();
                }
            );

			break;

		default:
            pendingitems.hideMask();
            document.getElementById('pendingitems').innerHTML = '&nbsp;&nbsp;<font color=red>These items are not available yet.</font>';
            break;
    }
}

pendingitems.showMask = function()
{
    if(!pendingitems.pendingMask){
        pendingitems.pendingMask = new Ext.LoadMask('pendingmask', {msg:"Please wait..."});
    }
    
    document.getElementById('pendingmask').style.display = '';
    pendingitems.pendingMask.show();
}

pendingitems.hideMask = function()
{
    pendingitems.pendingMask.hide();
    document.getElementById('pendingmask').style.display = 'none';
}
