Here you can find the source of sleep(delay)
function sleep(delay){ var start = new Date().getTime(); while (new Date().getTime() < start + delay); }
Function.prototype.repeat = function(interval){ return setInterval(this, interval); };