function delegate(obj, func) {
    return function () { return func.call(obj); };
}

// javascript unescape function will not convert the plus sign to spaces
function URLDecode(psEncodeString) {
    var lsRegExp = /\+/g;
    return unescape(String(psEncodeString).replace(lsRegExp, " "));
}

function setstatus(text) {
    window.status = text;
}

function wait(millis) {
    setstatus("wait");
    var date = new Date();
    var curDate = null;

    do { curDate = new Date(); }
    while (curDate - date < millis);
}

// PARSE URL FOR PARAMS
function gup(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return results[1];
}


function whereami() {
    setstaus("where am i?");
    document.getElementById("cord").innerHTML = map.getCenter() + ' - ' + map.getZoom();
}

(function ($) {
    $.QueryString = (function (a) {
        if (a == "") return {};
        var b = {};
        for (var i = 0; i < a.length; ++i) {
            var p = a[i].split('=');
            if (p.length != 2) continue;
            b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
        }
        return b;
    })(window.location.search.substr(1).split('&'))
})(jQuery);
