See the sticky post at the top of this forum about setInterval() - that's what you're looking for.

code:

millisecondsToDelay = 4*1000; // 4 seconds

myFutureFunction = function()
{
clearInterval(ih);
// do future stuff here...
}

ih = setInterval(myFutureFunction, millisecondsToDelay);