HELP!

I am stuck trying to traverse through function in the below script.... I am trying to essentially end up with the newsID in the title of the filename that I am writing but for some reason I cannot get it to pass through the functions? newsID is always undefined but the first alert is fine.

Can anyone help here please

Thanks in advance!


function downloadFileNews(newsID){



alert ('downloading '+newsID);




window.requestFileSystem(
LocalFileSystem.PERSISTENT, 0,
function onFileSystemSuccess(fileSystem,newsID) {
fileSystem.root.getFile(
"dummy.html", {create: true, exclusive: false},
function gotFileEntry(fileEntry){
var sPath = fileEntry.fullPath.replace("dummy.html","");
var fileTransfer = new FileTransfer();
fileEntry.remove();

fileTransfer.download(
"http://gwc.dreamshock.com/newsImages/thumbs/"+newsID+"_1.jpg",
sPath + "22257_1.jpg",
function(theFile) {
console.log("download complete: " + theFile.toURI());
showLink(theFile.toURI());
},
function(error) {
console.log("download error source " + error.source);
console.log("download error target " + error.target);
console.log("upload error code: " + error.code);
}
);
},
fail);
},
fail);



}