﻿/* execute ajax command */
function ajaxError(XMLHttpRequest, textStatus, errorThrown) {
    if (XMLHttpRequest != null) {
        switch (XMLHttpRequest.status) {
            case 401:
                window.document.location = loginURL;
                break;
        }
    }
}

function formatJSONDate(jsonDate, format) {
    if (jsonDate == '/Date(-62135571600000)/')
        return "";
    if (format == null)
        format = "shortDate";
    jsonDate = eval('new' + jsonDate.replace(/\//g, ' '));
    var newDate = dateFormat(jsonDate, format);
    if (newDate == "1/1/1")
        newDate = "";
    return newDate;
}

function escapeQuotes(string) {
    if (escapeable.test(string))
    {
        return '"' + string.replace(escapeable, function (a) 
        {
            var c = meta[a];
            if (typeof c === 'string') {
                return c;
            }
            c = a.charCodeAt();
            return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
        }) + '"';
    }
    return '"' + string + '"';
}
