//*****************************************************************************/
//*   CONFIDENTIAL AND PROPRIETARY PROPERTY OF GENEALOGY.COM (510) 794-6850   */
//*                        PO Box 7865, FREMONT, CA 94537                     */
//* THIS PROGRAM IS AN UNPUBLISHED WORK FULLY PROTECTED BY THE UNITED STATES  */
//* COPYRIGHT LAWS AND IS CONSIDERED A TRADE SECRET BELONGING TO THE COPY-    */
//* RIGHT HOLDER.                                                             */
//*****************************************************************************/

//==================================================================
// Open OFT in an appropriately sized and propertied window, passing
// your query string.
//==================================================================
function LaunchApp(sQuery)
{
   window.top.name = "OFT_Opener";

   var sProps = getWindowSize() + ",resizable=1";
   var	sWindowName = "OFT_Top";
   var sURL = "/genealogy/cgi-bin/tree_gen.cgi?" + sQuery;

   var wOFT = window.open(sURL,sWindowName,sProps);
   if (wOFT != null)
   {
      wOFT.focus();
      return 0;
   }
   else
   {
      return 1;
   }
}

//==================================================================
// Open OFT to the named tree
//==================================================================
function OpenTree(sfile)
{
   LaunchApp("file=" + sfile);
}

//==================================================================
// Launch /cgi-bin/LinkToTrees.cgi in a sized OFT window.  This 
// take the following actions, depending on the # of saved trees the
// user has:
//
// 0   - Start FTM-WE at Intro page
// 1   - Start FTM-WE with tree loaded
// >1  - Close FTM-WE window and load searches.html into opener
//==================================================================
function LinkToTrees()
{
  window.top.name = "OFT_Opener";

  var sSize = getWindowSize();
  var sProps = "resizable," + sSize;
  window.open("/genealogy/cgi-bin/LinkToTrees.cgi","OFT_Top",sProps);
}

//==================================================================
// Return the window size portion of a property string.  The window
// should be 50 pixels less in width and height than the screen on
// which it is displayed (with a maximum size of 750x550)
//==================================================================
function getWindowSize()
{
  var maxwidth = 750
  var maxheight = 550;
  var window_width = screen.width - 50;
  var window_height = screen.height - 50;

  if ((maxwidth < screen.width - 50) && (maxheight < screen.height - 50))
  {
    window_width = maxwidth
    window_height = maxheight
  }

  var sSize = "WIDTH=" + window_width + ",HEIGHT=" + window_height;

  return sSize;
}
