/**
 * Support function for forcing a page to load in an outer frame
 *
 * @author     Herman Kuiper
 * @copyright  Frontier Information Technologies
 * @version    v1
 *
 * @package    fritz
 **/

/**
 * Check if we are in a specifically named frame, or if the user opened
 * a link by hand in a new window.
 *
 * @param string frame  Name of target frame
 * @return bool TRUE if we need to load our parent frame too
 */
function forceFramed(frame)
{
   // If the user opened one of our windows in a separate window by hand, let him
   if(checkSeparateWindow())
      return false;

   // If already in the correct frame, also no problem
   if(parent.document.getElementById(frame) && parent.document.getElementById(frame).document == document)
      return false;

   if(parent.frames[frame] && parent.frames[frame].document == document)
      return false;

   return true;
}


/**
 * Load a specific URL into a named frame.
 */
function referToFrame(url, frame)
{
   if(frame == "_top")
      top.window.location = url;
   else if(frame == "_parent")
      parent.window.location = url;
   else
      // The remainder needs testing - not used until now
      for(var w = window; w; w = window.parent)
      {
         for(var i = 0; i < w.frames.length; i++)
            if(w.frames[i].name == frame)
            {
               w.location.href = url;
               return;
            }
      }
}

