function submitWithDelay(millis) {
    delay(millis);
    document.theForm.submit();
}

function delay(delayInMillis) {
    var then,now;
    then = new Date().getTime();
    now = then;
    while ((now - then) < delayInMillis)
    {
        now = new Date().getTime();
    }
}