Alexander Belov,
var names = ["Kurt", "Dave", "Kris", "Pat", "Steve"]
function nextPerson(a) {
if (a != +a) return a = names.indexOf(a) + 1, [a *= 2, --a].reverse();
a % 2 && ++a;
for (var d = names.length, b = -1, c = 0; c < a; c += 2) b = ++b % d;
return names[b]
};
alert ( nextPerson ( 17 ) );
alert ( nextPerson ( "Pat" ) );
names.push( "Richard" );
alert ( nextPerson ( "Richard" ) );