
String.prototype.format = function()
{
    var pattern = /\{\d+\}/g;
    var args = arguments;
    return this.replace(pattern, function(capture){ return args[capture.match(/\d+/)]; });
};

String.prototype.startsWith = function(str)
{
    return (this.indexOf(str) === 0);
}

function urlparam(param)
{
    var regex = '[?&]' + param + '=([^&#]*)';
    var results = (new RegExp(regex)).exec(window.location.href);

    if(results)
    {
        return results[1];
    }

    return '';
};

function dir(ob)
{
    out = [];

    for (attr in ob)
    {
        out.push('{0}: {1}'.format(attr, ob[attr]));
    }

    out.sort();

    return out;
}


