function getParams(querystr) {
    var r = {}, params = querystr.replace(/^[#?]/, '').split('&');
    for (var i = params.length-1;  i >= 0;  i--) {
        var p = params[i].split('='), key = p[0];
        if (key) r[key] = p[1];
    }
    return r;
}