function animate(id, delay) {
var elem = document.getElementById(id);
var x = 0;
while (true) {
elem.style.left = x++;
x %= 400;
hold(delay);
}
}
spawn(function() { animate('red_box', 10); });
spawn(function() { animate('blue_box', 30); });