/**
 * Support functions for browsers which do support try/catch
 *
 * @author     Herman Kuiper
 * @copyright  Frontier Information Technologies
 * @version    v1
 *
 * @package    fritz
 **/

/**
 * Check if the current form is in a separate window
 * from the the main window.
 */
function checkSeparateWindow()
{
   var sep = false;

   try
   {
      // Need a try/catch to prevent an Access denied error when opening from another application
      var d = window.opener.document;
      sep = (d && d.getElementById && d.getElementById('epaForm'));
   }
   catch(e)
   {
      sep = false;
   }
   finally
   {
      // If there is an opener, and it contains our form, assume it is our parent
      if(sep && document.forms['epaForm'] && document.forms['epaForm'].refer)
         document.forms['epaForm'].refer.value = 0;
   }
   return sep;
}

/**
 * Event handler coupled with onkeypress for the body of a template.
 * Checks to see if we are in an IFRAME without scrollbars, in which
 * case we transfer focus to our parent frame, so keyboard scrolling
 * works sort of.
 */
function transferFocus()
{
   var noParent = true;
   try
   {
      noParent = (!parent || parent == self || !parent.document.getElementById("epaForm"));
   }
   catch(e)
   {
      noParent = true;
   }
   finally
   {
      if(!noParent)
      {
         if(document.activeElement.nodeName == "BODY" || document.activeElement.nodeName == "TD")
         {
            getSizes();
            if(bWidth <= wWidth && bHeight <= wHeight)
               parent.window.focus();
         }
      }
   }
}



