////
// err.js : logs client side errors.
////
window.onerror         = handleError;
var gaGlobalErrorMsgs  = new Array();

AddOnLoadScript("processErrorMsg()",200);

function GetFunctionName(sNm)
{
var sR="";
    if(sNm != null)
    {
        sR = sNm;
        sR = sR.slice(0,sR.indexOf(")")+1);
        sR = sR.replace(/function /g,"");
    }
    else
    {
        sR = "no caller";
    }
    return sR;
}

function handleError(err, url, line)
{
    try
    {
        var fxn;

        if(handleError.caller != null){fxn = GetFunctionName(handleError.caller.toString())}
        else{fxn = "no caller";}

        gaGlobalErrorMsgs = [err,url,fxn,line];

    }
    catch(e)
    {
        //nothing further to do.
    }
}

function processErrorMsg()
{
    if(gaGlobalErrorMsgs.length > 0)
    {
        try
        {
            sSrc    = "/e.gif?ERROR=msg:" + gaGlobalErrorMsgs[0] + ";page:" + gaGlobalErrorMsgs[1] + ";fxn:" + gaGlobalErrorMsgs[2] +";line:" + gaGlobalErrorMsgs[3] + ";";
            sSrc    = sSrc.replace(/ /g,"_");
            oEB     = GE("imgErrBeacon");
            oEB.src = sSrc;
        }
        catch(e)
        {
            //nothing further to do.
        }
    }
}

