﻿$.ajaxSetup({ cache: false });

function MinuteRandomString() {
    var date = new Date();
    var time = date.getHours() * 60 + date.getMinutes();
    return "" + time;
}

function RemoveQueryStringParam(url, parameter) {
    var queryStart = url.indexOf("?");
    if (queryStart == -1)
        return url;
    var startIndex = url.indexOf(parameter);
    if (startIndex == -1)
        return url;
    var stopIndex = url.indexOf("&", startIndex);
    if (stopIndex == -1)
        stopIndex = url.length;
    return url.substring(0, startIndex) + url.substring(stopIndex);

}

String.prototype.endsWith = function (suffix) {
    return this.indexOf(suffix, this.length - suffix.length) !== -1;
};


function getShortDateFormat(date) {
    var pattern = 'M/d/yyyy';
    try {
        pattern = $('#ShortDateFormat').text();
    }
    catch (e) { }

    var m;
    var d;
    var y;
    return pattern.replace('yyyy', y = '' + date.getFullYear()).replace('yy', y.substring(2)).replace('MM', zeroPad(m = date.getMonth() + 1)).replace('M', m).replace('dd', zeroPad(d = date.getDate())).replace('d', d);
}

function zeroPad(n) {
    return (+n < 10 ? '0' : '') + n;
}

function LocalizeDate(container, time) {
    try {

        var dt = new Date(time);
        var dtFormated = getShortDateFormat(dt);
        $(container).html(dtFormated);
    }
    catch (e) { }
}

