// Copyright © 2000 Topiary Communications LLC
// All Rights Reserved

function openWindow(WindowURL, MmoWidth, MmoHeight) {
   var WindowType = null
   var WindowWidth = 0
   var WindowHeight = 0
   var WidthMargins = 30     // setup as small margins, anticipating wide Image or Video

   WindowType = WindowURL.substring(0,3)

   // Use width of TEXTAREA (350), Image, or Video whichever is greater
   {
   if (WindowType == "Img" || WindowType == "Vid")
      {
      if (MmoWidth < 350)
         {MmoWidth = 350;
          WidthMargins = 100;}   // Overlay with large margins for narrow Image or Video
      }
   }
   
   {
   if (WindowType == "Txt" && MmoWidth == 0 && MmoHeight == 0)
         // constant window size
         {WindowWidth = 450;
          WindowHeight = 330;} 
      else
      if (WindowType == "Snd" && MmoWidth == 0 && MmoHeight == 0)
         // constant window size
         {WindowWidth = 450;
          WindowHeight = 350;} 
      else
      if (WindowType == "Vid")
         {WindowWidth = MmoWidth + WidthMargins;
          WindowHeight = 200 + MmoHeight;}
      else
      if (WindowType == "Img")
         {WindowWidth = MmoWidth + WidthMargins;
          WindowHeight = 233 + MmoHeight;}
      else
         // For any other case, actual width and height should be supplied
         {WindowWidth = MmoWidth;
          WindowHeight = MmoHeight;
          WidthMargins = 0;}   
   }   

   // Allow for size of IE's Media Player controller or Navigator's explanatory line 
   {
   if (WindowType == "Vid")
      WindowHeight = WindowHeight + 46;
   }

   // Finally, adjust for the actually available monitor size
   {   
   if (window.screen)
      {
      if (WindowWidth > window.screen.availWidth - 34)
          WindowWidth = (window.screen.availWidth - 34);

      if (WindowHeight > window.screen.availHeight - 120)
          WindowHeight = (window.screen.availHeight - 120);
      }
   }

   {
   if (WindowType == "Txt" || WindowType == "Snd" || WindowType == "Vid" || WindowType == "Img")
         {window.open(WindowURL, '', 'width='  + WindowWidth  + ',' + 
                                     'height=' + WindowHeight + ',' +
         'top=20,left=20,status=yes,resizable=yes,scrollbars=yes,menubar=yes,alwaysRaised=yes');}
      else
         // For any other case, mainly Document Link
         {window.open(WindowURL, '', 'width='  + WindowWidth  + ',' + 
                                     'height=' + WindowHeight + ',' +
         'top=20,left=20,status=yes,resizable=yes,scrollbars=yes,menubar=yes,alwaysRaised=yes,toolbar=yes,location=yes');}
   }   
}
