You can just parse the number right out of the location like this:
setTimeout(function() {
var matches = window.location.hash.match(/^#page(\d+)$/);
if (matches) {
scroll(+matches[1] - 1);
}
}, 500);
OK, now that you've changed to random strings, you could use a table lookup like this:
setTimeout(function() {
var values = {
"#somename": 1,
"#somethingelse": 2,
"#someotherword": 3,
"#sometext": 4
};
var val = values[window.location.hash];
if (val) {
scroll(val - 1);
}
}, 500 );
P.S. Note, there is no reason to return anything from the setTimeout() callback as the return value is not processed by anything which is why I removed the return statement.