i can see that a lot of lines in your code do not end with a semi-colon. here are just a few. you may want to go through and clean that up, maybe it will help.
HTML Code:
var dir = "images/"
HTML Code:
window.status='Done'
var text = ''; // this one is ok
text +='<table border="0">'