// Function to display upload progress
// Does not attempt to give accurate estimate of progress or time left
var nX = 0;

function showActivity() {
   var oUploadBar = document.getElementById("uploadBar");
   var sBar = '--------------------';
   var nMaxX = sBar.length;
   var sNew;

   sNew = sBar.substring(0, nX) + '|' + sBar.substring(0, (nMaxX - nX - 1));
   nX++;
   if (nX == nMaxX) nX = 0;
   oUploadBar.innerHTML = sNew;
   window.setTimeout("showActivity()", 300);
} 
 
function postWithActivity(sFormId, sFileId) {
   // Show upload activity box
   var sBackSlash = String.fromCharCode(92);
   var oForm = document.getElementById(sFormId);
   var oFile = document.getElementById(sFileId);
   var sFileName = oFile.value;
   if (sFileName != '') {
      // This assumes the contents of this is the full path which it should be if 
      // they used the 'Browse' box to choose the file
      sFileName = sFileName.slice(sFileName.lastIndexOf(sBackSlash));
      sFileName = sFileName.substring(1); // Strip off leading slash
      
      var oUploadBox = document.getElementById("uploadActivity");
      var oMsg = oUploadBox.getElementsByTagName("strong");
      oMsg[0].innerHTML = oMsg[0].innerHTML + sFileName; // Ad file name to message box

      // Bring Upload box into visible area and center it
      oUploadBox.style.top = "200px";
      oUploadBox.style.left = ((document.body.offsetWidth - oUploadBox.offsetWidth)/2) + "px";
      showActivity(); // Show the progress bar
   }
   else {
      // No file to upload
      oForm.uploadFile.value = 'false';
   }
   // Post form data
   oForm.submit();
}

