var jSONCheckURL = "/chiprepo/upload/progressbar"

function beginUpload(progressBarId, formToFadeId) {
        jQuery("#"+progressBarId).fadeIn(500);
        jQuery("#"+formToFadeId).animate ({opacity:0.5})

        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);

  }
