Index: cprs/branches/tmg-cprs/CPRS-Chart/fImages.pas
===================================================================
--- cprs/branches/tmg-cprs/CPRS-Chart/fImages.pas	(revision 738)
+++ cprs/branches/tmg-cprs/CPRS-Chart/fImages.pas	(revision 793)
@@ -126,4 +126,5 @@
     function CreateBarcode(MsgStr: AnsiString; ImageType: AnsiString): AnsiString;
     function DecodeBarcode(LocalFNamePath,ImageType: AnsiString): AnsiString;
+    procedure EnsureImagesDownloaded(ImagesList : TStringList);
   published
   end;
@@ -152,4 +153,6 @@
 
 procedure TfrmImages.timLoadImagesTimer(Sender: TObject);
+//This function's goal is to download images in the background,
+// with one image to be downloaded each time the timer fires
 begin
   inherited;
@@ -185,4 +188,36 @@
 
 
+procedure TfrmImages.EnsureImagesDownloaded(ImagesList : TStringList);
+//This function's goal is to download images in the FOREground,
+// But only images matching those passed in ImagesList will be downloaded;
+// The intent is to only download images that have links to them in HTML source
+//Thus, if note has a large amount of images attached to it, but not referenced
+//  in HTML code, then they will not be downloaded here. (But will be downloaded
+//  later via timLoadImagesTimer
+var i : integer;
+    Rec : TImageInfo;
+
+begin
+  if ImagesList.Count = 0 then exit;
+  GetImageList();
+  if ImageInfoList.Count = 0 then exit;
+  if ImageInfoList.Count > 1 then begin
+    ImageTransferForm.ProgressMsg.Caption := 'Downloading Images';
+    ImageTransferForm.ProgressBar.Min := 0;
+    ImageTransferForm.ProgressBar.Position := 0;
+    ImageTransferForm.ProgressBar.Max := ImageInfoList.Count-1;
+    ImageTransferForm.Show;
+  end;
+  for i := 0 to ImageInfoList.Count-1 do begin
+    ImageTransferForm.ProgressBar.Position := i;
+    Rec := TImageInfo(ImageInfoList[i]);
+    if ImagesList.IndexOf(Rec.ServerFName)>-1 then begin
+      DownloadToCache(i);
+    end;
+  end;
+  ImageTransferForm.Hide;
+end;
+
+
 { TPage common methods --------------------------------------------------------------------- }
 procedure TfrmImages.mnuChartTabClick(Sender: TObject);
@@ -211,5 +246,6 @@
   CurImageToLoad := 0;
   CacheDir := ExtractFilePath(ParamStr(0))+ 'Cache';
-  NullImageName := ExtractFilePath(ParamStr(0)) + 'images\blank.htm';
+  //NullImageName := ExtractFilePath(ParamStr(0)) + 'images\blank.htm';
+  NullImageName := 'about:blank';
   if not DirectoryExists(CacheDir) then ForceDirectories(CacheDir);
 
@@ -563,6 +599,9 @@
   RPCBrokerV.Param[2].Value := '1'; //see comments in UploadFile re '1' hardcoding
 
-  RPCBrokerV.Call;  //Move file into dropbox.
-  Result := (Piece(RPCBrokerV.Results[0],'^',1)='1');  //1=success, 0=failure
+  //RPCBrokerV.Call;  //Move file into dropbox.
+  CallBroker;
+  if RPCBrokerV.Results.Count>0 then begin
+    Result := (Piece(RPCBrokerV.Results[0],'^',1)='1');  //1=success, 0=failure
+  end else Result := false;
 end;
 
@@ -692,5 +731,6 @@
   RPCBrokerV.Param[2].Value := '1'; //see comments in UploadFile re '1' hardcoding
 
-  RPCBrokerV.Call;  //Move file into dropbox.
+  //RPCBrokerV.Call;  //Move file into dropbox.
+  CallBroker;
   if RPCBrokerV.Results.Count > 0 then begin
     Result := (Piece(RPCBrokerV.Results[0],'^',1)='1');  //1=success, 0=failure
@@ -702,4 +742,9 @@
 
   if Result=true then begin
+    if DirectoryExists(DropboxDir) = False then begin     //elh   added to ensure a dropbox directory is valid
+      MessageDlg('Invalid Dropbox Directory. Please check your settings and try again.',mtError,[mbOK],0);
+      ImageTransferForm.hide;
+      exit;
+    end;
     CurrentFileSize := strtoint(Piece(RPCBrokerV.Results[0],'^',3));  //Piece 3 = file size
     DropboxFile := ExcludeTrailingBackslash(DropboxDir) + '\' + FName;
@@ -1080,5 +1125,6 @@
   RPCBrokerV.Param[1].PType := list;
   RPCBrokerV.Param[1].Mult['"IMAGE TYPE"'] := ImageType;
-  RPCBrokerV.Call;
+  //RPCBrokerV.Call;
+  CallBroker;
 
   Application.ProcessMessages;
