function removeElmentInArray(array, arrayElement) {
    for (var i = 0; i < array.length; i++) {
        if (array[i] == arrayElement)
            array.splice(i, 1);
    }
}

//Show Error message in ajax request
function checkAndShowErrorMessage (ajaxResponse, redirectUrl) {
    if (ajaxResponse.indexOf("errorMsg") != -1) {
        //Convert to json if find error key in text
        var messageObj = $.parseJSON(ajaxResponse);
        //Find error if chache
        $.showError(unescape(messageObj.errorMsg),
                        unescape(messageObj.errorTitle), null, redirectUrl || messageObj.redirectUrl || "/");
        return true;
    } else {
        return false;
    }
}

//Parse JSOn date
function parseJSONDate(value) {
    var res = /\/Date\((-?\d+)\)/.exec(value);
    return (res) ? new Date(parseInt(res[1])) : null;
}
