/**
 * Blank constructor to define the namespace
 */
function DWRHelper()
{
}

/**
 * Defines debug mode.  If in debug mode, a stack trace is displayed for the displayed error,
 */
DWRHelper.debugMode = false;

/**
 * The timeout for ajax calls
 */
DWRHelper.ajaxTimeout = 30000;

/**
 * Displays a detailed error message for erroneous DWR calls
 * @param method the method that the error is from
 * @param message the error messgae,
 * @param info details about the error
 */
DWRHelper.displayDWRError = function(method, message, info)
{
    // if the message is timeout and not in debug mode, return
    if (message == "Timeout" && !DWRHelper.debugMode)
    {
        return;
    }

    var errorMessage = message;
    var i;

    if (DWRHelper.debugMode)
    {
        errorMessage = message;

        if (typeof info.javaClassName != "undefined")
        {
            errorMessage += "\nException:  " + info.javaClassName;
            errorMessage += "\n\nStackTrace:";
            for (i = 0; i < info.stackTrace.length; ++i)
            {
                errorMessage += "\n\t" + info.stackTrace[i].className + "." + info.stackTrace[i].methodName +
                        " in " + info.stackTrace[i].fileName + ", line " + info.stackTrace[i].lineNumber;
            }
        }
    }

    MessageBox.error("Error calling " + method, errorMessage);
};

