var jSONCheckURL = "/upload/progressbar"


function beginUpload(progressBarId) {
        jQuery("#"+progressBarId).fadeIn();

        var i = setInterval(function(){

          jQuery.getJSON(jSONCheckURL, function(data) {
                  if (data == null || data.status=="DONE") {
                          clearInterval(i);
                          return true;
                  }

                  var percentage = Math.floor(100 * parseInt(data.bytesRead) / parseInt(data.totalSize));
                  jQuery("#"+progressBarId).progressBar(percentage);
          });

        }, 1500);

  }
