home *** CD-ROM | disk | FTP | other *** search
/ Organic Chemistry (8th Edition) / Image.iso / pc / edugen / media / js / windows.js < prev   
Text File  |  2002-12-05  |  2KB  |  100 lines

  1. // Edugen JavaScripts Library V1.0 =========================================
  2. //
  3. //     File windows.js
  4. //     
  5. //     This file is part of the Edugen JavaScripts Library.
  6. //     Copyright (c) 2002 WWL Corp. - A Subsidiary of John Wiley & Sons, Inc.
  7. // =========================================================================
  8.  
  9. // Create an array to hold references to the child windows.
  10. // Each member of this array will be a window object created using the createWindow function below.
  11. var m_Windows = new Array();
  12.  
  13. // Constructor for the window.
  14. // This function should be called only by the createWindow function below.
  15. function newWindow(in_URL, in_windowName)
  16. {
  17.     var features = "";
  18.     if (null != arguments[2])
  19.     {
  20.         features = arguments[2];
  21.     }
  22.     
  23.     return window.open(in_URL, in_windowName, features);
  24. }
  25.  
  26. // Add a window to the m_Windows collection.
  27. // If a window was already opened and yet not close - focus the window.
  28. function createWindow(in_URL, in_windowName)
  29. {
  30.     var features = "";
  31.     if (null != arguments[2])
  32.     {
  33.         features = arguments[2];
  34.     }
  35.  
  36.     if (m_Windows[in_windowName])
  37.     {
  38.         if (!m_Windows[in_windowName].closed)
  39.         {
  40.             m_Windows[in_windowName].focus();
  41.             m_Windows[in_windowName] = new newWindow(in_URL, in_windowName, features);
  42.         }
  43.         else
  44.         {
  45.             m_Windows[in_windowName] = new newWindow(in_URL, in_windowName, features);
  46.         }
  47.     }
  48.     else
  49.     {
  50.         m_Windows[in_windowName] = new newWindow(in_URL, in_windowName, features);
  51.     }
  52. }
  53.  
  54. // Close all the opened windows.
  55. // To close an individual window, its close method is called.
  56. // This function should be called during the onUnload event to automatically close all open windows.
  57. function closeWindows()
  58. {
  59.     for (w in m_Windows)
  60.     {
  61.         if (m_Windows[w]!=null)
  62.         {
  63.             if (!m_Windows[w].closed)
  64.             {
  65.                 m_Windows[w].close();
  66.                 m_Windows[w]=null;
  67.             }
  68.             else
  69.             {
  70.                 m_Windows[w]=null;
  71.             }
  72.         }
  73.         else
  74.         {
  75.             m_Windows[w]=null;
  76.         }
  77.     }
  78. }
  79.  
  80. // Close an individual opened window.
  81. function closeWindow(in_window)
  82. {
  83.     if (m_Windows[in_window]!=null)
  84.     {
  85.         if (!m_Windows[in_window].closed)
  86.         {
  87.             m_Windows[in_window].close();
  88.             m_Windows[in_window]=null;
  89.         }
  90.         else
  91.         {
  92.             m_Windows[in_window]=null;
  93.         }
  94.     }
  95.     else
  96.     {
  97.         m_Windows[in_window]=null;
  98.     }
  99. }
  100.