The problem with this script is that it's nothing like an actual alert box. It will not block the script while waiting for the user to say ok.
For example, if you write
alert('I will now redirect you to Google. Press ok to continue.');
location = 'http://www.google.com';
the code will in fact not wait for the user to rpess ok, because the script is non-blocking.
bals28mjk is right about which line is causing the problem, however, removing it will do no good. Either the script will cause an error, or you'll get all the boxes on top of each other, with the one you created last, at the top.