//variable for iframe timer
var iFrameTimer=null;

/*
 * Name:
 *     stopIframeScroll
 * Description:
 *     Stops the iframe scroller
 * Preconditions:
 *     None
 * Postconditions:
 *     Stops the iframe scroller
*/
function stopIframeScroll()
{
   clearTimeout(iFrameTimer)
}

/*
 * Name:
 *     startIframeScroll
 * Description:
 *     Has to be passed the following variables
 *     -- iFrameName         the name of the iframe to scroll
 *     -- scrollingSpeed     usually 1, can be changed to increase the
 *                           speed of scrolling
 *     -- direction          { 'up' | 'down' | 'left' | 'right }
 * Preconditions:
 *
 * Postconditions:
 *
*/
function startIframeScroll(iFrameName, scrollingSpeed, direction)
{

  //get html reference
  var referenceIFrame ="frames['"+iFrameName+"']";

  //determine whether the browser bieng used is IE
  //isIE is true iff browser is Ie
  var isIE=document.all;


  //get direction for scrolling
  var pageOffsetDirection , directionScroll , absolutePosition;
  if(direction=='down' || direction == 'up')
    {
      absolutePosition = '0,currentPosition';
      directionScroll = 'scrollTop';
      pageOffsetDirection='pageYOffset';
    }
  else
    {
      absolutePosition = 'currentPosition,0';
      directionScroll = 'scrollLeft';
      pageOffsetDirection='pageXOffset';
    }



  //get the offset for the amount scrolled
  //if direction is down
  //    if isIE    set amountScrolled to scrollingSpeed
  //    else       set amountScrolled to scrollingSpeed+0.9
  //else if direction is up
  //    if isIE    set amountScrolled to -scrollingSpeed
  //    else       set amountScrolled to -(scrollingSpeed-0.9)
  var amountScrolled=(direction=='down' || direction=='right')?(isIE)?scrollingSpeed:scrollingSpeed+.9:(isIE)?-scrollingSpeed:-(scrollingSpeed-.9);

  //if isIE
  //    then evaluate
  //        parent.<referenceIFrame>.document.body.scrollTop.amountScrolled  to  scroll iframe
  //else evaluate
  //        parent.<referenceIFrame>.document.body.pageYOffset.amountScrolled
  var currentPosition =
       (document.all)?eval("parent."+referenceIFrame+".document.body."+directionScroll)+amountScrolled:eval("parent."+referenceIFrame+"."+pageOffsetDirection)+amountScrolled;




  //in case browser resets position
  var absolutePositionResult  =eval("parent."+referenceIFrame+".window.scrollTo("+absolutePosition+")");

  //timeout for 1 second and then scroll
  iFrameTimer=setTimeout("startIframeScroll('"+iFrameName+"',"+scrollingSpeed+",'"+direction+"')",1)

}

