// This javascript works great if you want to globally show an
// indicator or animated gif on an any ajax call.  Otherwise
// to have precise controll use AjaxBehaviorEffects to call
// doAjaxPreCall() and doAjaxPostCall()

function registerCallHandlers() {

    var indicator = document.getElementById("ajax_indicator1");
    var panelToHide = document.getElementById("hide_on_ajax_call1");
    var errorIndicator = document.getElementById("ajax_error_indicator1");

    try {
        Wicket.Ajax.registerPreCallHandler(function() {
            doAjaxPreCall2(indicator, panelToHide, errorIndicator)
        });
        Wicket.Ajax.registerPostCallHandler(function() {
            doAjaxPostCall2(indicator, panelToHide)
        });
        Wicket.Ajax.registerFailureHandler(function() {
            doAjaxFailureCall2(indicator, panelToHide, errorIndicator)
        });
    } catch(ex) {}
}

function doAjaxPreCall(indicatorId, panelId, errorIndicatorId) {
    doAjaxPreCall2(document.getElementById(indicatorId),
        document.getElementById(panelId), document.getElementById(errorIndicatorId));
}

function doAjaxPostCall(indicatorId, panelId) {
    doAjaxPostCall2(document.getElementById(indicatorId), document.getElementById(panelId));
}

function doAjaxFailureCall(indicatorId, panelId, errorIndicatorId) {
    doAjaxFailureCall2(document.getElementById(indicatorId),
        document.getElementById(panelId), document.getElementById(errorIndicatorId));    
}

function doAjaxPreCall2(indicator, panelToHide, errorIndicator) {
    
    if(indicator != undefined && indicator != null)
        indicator.style.display = "";
    if(panelToHide != undefined && panelToHide != null)
        panelToHide.style.display = "none";
    if(errorIndicator != undefined && errorIndicator != null)
        errorIndicator.style.display = "none";
}

function doAjaxPostCall2(indicator, panelToHide) {

    if(indicator != undefined && indicator != null)
        indicator.style.display = "none";
    if(panelToHide != undefined && panelToHide != null)
        panelToHide.style.display = "";
}

function doAjaxFailureCall2(indicator, panelToHide, errorIndicator) {

    if(indicator != undefined && indicator != null)
        indicator.style.display = "none";
    if(panelToHide != undefined && panelToHide != null)
        panelToHide.style.display = "";
    if(errorIndicator != undefined && errorIndicator != null)
        errorIndicator.style.display = "";
}