if (getFileFunction()==0) {
//if it returns true, that means they got the first file, so do the next one
if (getFileFunction()==0) {
FYI.... In JavaScript, 1 is true and 0 is false. Replace the 0's with 1 (or true)!

As for the download requests, you could just do a window.location and, depending on the mime type of the file, set the content disposition in the HTTP header.