var uploadId; //stores the id of the EworxUpload control
var uploadFirstTime = 1;
var uploadMessage = "";

function Upload(id) {
    Toggle("div" + id + "_Upload", "div" + id + "_Progress");
    uploadId = id;
    UploadStatus();
}


function UploadStatus() {
    UploadWebService.GetUploadStatus(GetQuerystring("uploadId"), UploadStatusCallback, Timeout, Error);
    if (!IsIE() && uploadFirstTime == 1) { //we need this bullshit, because otherwise Firefox throws an exception (I have no idea why, damn thing).
        uploadFirstTime = 0;
        alert(uploadMessage);
    }
}


function UploadStatusCallback(result) {
    if (result == -1) {
        GetElement("div" + uploadId + "_ProgressDone").style.width = "0%";
        GetElement("div" + uploadId + "_ProgressTodo").style.width = "0%";      
    }
    else {
        GetElement("div" + uploadId + "_ProgressDone").style.width = result + "%";
        GetElement("div" + uploadId + "_ProgressTodo").style.width = (100 - result) + "%";
    }
    setTimeout("UploadStatus();", 1000);
}
