
// http: //www.west-wind.com/weblog/posts/884279.aspx
getUrlEncodedKey = function (key, query) {
    
    if (!query)
        query = window.location.search;
    var re = new RegExp("[?|&]" + key + "=(.*?)&");
    var matches = re.exec(query + "&");
    return (!matches || matches.length < 2 ? ""
        : decodeURIComponent(matches[1].replace("+", " ")));
};
setUrlEncodedKey = function (key, value, query) {

    query = query || window.location.search;
    var q = query + "&";
    var re = new RegExp("[?|&]" + key + "=.*?&");
    q = (!re.test(q) ? q + key + "=" + encodeURI(value)
        : q.replace(re, "&" + key + "=" + encodeURIComponent(value) + "&"));
    q = q.trimStart("&").trimEnd("&");
    return q[0] == "?" ? q : q = "?" + q;
};

changePlatform = function (val) {
    window.location.href = 'http://model-xtractor.com/web/'
        + (window.location.href.indexOf('Metadata.aspx') > 0 ? 'Metadata' : 'Diagrams') + '.aspx?p=' + val;
};

String.prototype.trimEnd = function (c) { return (c ? this.replace(new RegExp(c.escapeRegExp() + "*$"), '') : this.replace(/\s+$/, '')); };
String.prototype.trimStart = function (c) { return (c ? this.replace(new RegExp("^" + c.escapeRegExp() + "*"), '') : this.replace(/^\s+/, '')); };
String.prototype.escapeRegExp = function () { return this.replace(/[.*+?^${}()|[\]\/\\]/g, "\\$0"); };
