var uploadCount = 0;

function uploadImages() {
   /// Starts uploads of images selected in IFRAMEs.

   var iframes = document.getElementsByTagName('iframe');

   for (var i = 0; i < iframes.length; i++) {
      var iframe = iframes[i];
      if (iframe.contentWindow.uploadFile)
         uploadCount += iframe.contentWindow.uploadFile();
   }

   if (uploadCount == 10)
      document.getElementById('addControls').innerHTML =
         '<a href="javascript:window.location.reload()">Add more images</a>';
}


function uploadFile() {
   /// Starts upload of file selected in the IFRAMEs.

   if (document.getElementById('input').value) {
      var form = document.getElementById('form');
      form.submit();
      form.innerHTML = '<p class="marginless">Uploading...';
      return 1;
   }

   return 0;
}