/**
 ******************************************************************************
 *
 * Confidential Property of Documentum, Inc.
 * (c) Copyright Documentum, Inc. 2001.
 * All Rights reserved.
 * May not be used without prior written agreement
 * signed by a Documentum corporate officer.
 *
 ******************************************************************************
 *
 * Project        WDK Forms
 * File           scroll.js
 * Description    WDK Forms Visibility / Scroll Position Maintenance Mechanism
 * Created on     04 Jun 2001
 * Tab width      3
 *
 ******************************************************************************
 *
 * PVCS Maintained Data
 *
 * Revision       $Revision: 4$ 
 * Modified on    $Date: 8/21/02 4:18:17 AM$
 *
 * Log at EOF
 * 
 ******************************************************************************
 */

/**
 * Scroll the page to the given position. Not that this will not work from
 * within a table.
 * @param Xoffset The Horizontal offset
 * @param Yoffset The Vertical offset
 */
function setScrollPosition(nXoffset, nYoffset)
{
   if (isDispatchableWindow(window) == true)
   {
      if ( window.navigator.appName == "Netscape" )
      {
         window.scrollTo(nXoffset, nYoffset);
      }
      else
      {
         window.scroll(nXoffset, nYoffset);
      }
   }
}

/**
 * Stores the scroll position in the form's x and y hidden fields
 */
function storeScrollPosition(formId, propertyXId, propertyYId)
{
   if ((formId == null) || (typeof formId == "undefined"))
   {
      throwError("storeScrollPosition: formId is mandatory.");
      return;
   }
   if ((propertyXId == null) || (typeof propertyXId == "undefined"))
   {
      return;
   }
   if ((propertyYId == null) || (typeof propertyYId == "undefined"))
   {
      return;
   }
   
   //Retrieve scroll position
   var nXOffset = 0;
   var nYOffset = 0;
   if ( window.navigator.appName == "Netscape" )
   {
      nXOffset = window.pageXOffset;
      nYOffset = window.pageYOffset;
   }
   else
   {
      nXOffset = document.body.scrollLeft;
      nYOffset = document.body.scrollTop;
   }
   
   //Now store the scroll position in the x and y hidden fields
   document.forms[formId].elements[propertyXId].value=nXOffset;
   document.forms[formId].elements[propertyYId].value=nYOffset;
}
