/***********************************************
 * ThreadMap javascript - portion that should be in the head
 ***********************************************/
function isUndefined(obj) {
    if (typeof(obj) != "undefined") {
        return false;
    } else {
        return true;
    }
}
function isDefined(obj) {
    return !isUndefined(obj);
}
/**
 * Checks if response code is indeed 200. For long-running ajax calls, if you
 * leave a page the original request will get immediate callback with onSuccess but you
 * it will have status of 0 and no data.
 * @param result
 */
function isResponseCodeSuccess(result) {
    if (result.status == 200) {
        return true;
    } else {
        return false;
    }
}

/**
 * Checks if we got anything back from ajax at all.
 * @param result
 */
function isNullJSON(result) {
    if ('' == result.responseText || '{}' == result.responseText) {
        return true;
    } else {
        return false;
    }
}

/**
 * Returns array consisting of command (string) and the url (string)
 * @param state
 */
function parseHistoryState(state) {
    //    alert('given: '+state);
    var i = state.indexOf(":");
    var command = state.substring(0, i);
    var url = state.substring(i + 1);
    //    alert("command: "+command+", url: "+url);
    var result = new Array();
    result[0] = command;
    result[1] = url;
    return result;
}

// return name of "class" (actually,
// JavaScript object prototype of
// which object is a copy)
function getClassName(obj) {
    // get classname abstracted from
    // constructor property
    var c = obj.constructor.toString();
    var start = c.indexOf('function ') + 9;
    var stop = c.indexOf('(');
    c = c.substring(start, stop);
    return c;
}


