var lastResult;
function handleAjaxResponse(result) 
{
    
    // routine to handle ajax responses
    var params = result.extraParamsResponse || {};
    if (params.script) 
    {
        eval(params.script);
    }
}

function handleBeforeWorkflowEvent(parent, eventType) 
{
    // routine to handle any preprocessing before a workflow event takes place
    if (eventType == 0)
        return true;
    if (eventType == 1 && parent.onWorkflowAccept != null)
        return parent.onWorkflowAccept();
    if (eventType == 2 && parent.onWorkflowReject != null)
        return parent.onWorkflowReject();
    return true;
}

var evalLastResult = function () 
{
// routine to evaluate last minute scripts from window closures
    if (lastResult != null) {
        eval(lastResult);
        lastResult = null;
    }
}

var loadTab = function (id, title, href) {
    // routine to make the tab which will house the screen 
    var tab = App.tabPanel.getComponent(id);
    if (tab) {
        App.tabPanel.setActiveTab(tab);
    }
    else {
        // add the tab
        makeTab(id, title, href);
    }
};
var makeTab = function (id, title, href) {
    // routine to make the tab which will house the screen 
    var mac = href;
    // add the tab
    tab = App.tabPanel.add(new Ext.Panel({ id: id, title: title, hideMode: "offsets",
        loader:
        {
            scripts: true,
            url: href,
            renderer: "frame",
            loadMask: true
        },
        closable: true
    }));
    // make it the active tab
    setTimeout(function () { App.tabPanel.setActiveTab(tab); }, 250);
};

var resetFieldTrigger = function (el) {
    el.getTrigger(0).hide();
    el.reset();
}
var showFieldTrigger = function (el) {
    if (el.value == null)
        return true;
    el.getTrigger(0).show();
    el.updateLayout();
}
