/* Marquee JavaScript */
/* DO NOT EDIT THIS FILE!!!!!! */
/* OR ELSE !!!!!! */

/* These values should be defined in the calling page, or in another js file
  var marqueeStartDelay       = 2000;     // Delay before marquee starts to scroll (in Ms)
  var marqueeScrollSpeed      = 2;        // Marquee scroll speed (larger is faster)
  var marqueeMouseoverPause   = true;     // Pause marquee on Mousever events
  var marqueeScrollDirection  = 'left';   // or 'up'
*/
  var marqueeSpeed;
  var marqueeStep;
  var marqueeInterval;
  var marqueeScrollHeight;
  var marqueeScrollWidth;

  function marqueeScroll() {
    var marqueeTimeoutValue = marqueeInterval;
    if (marqueeScrollDirection == 'left') {
      if (parseInt(marqueeObj.sty.left)>(marqueeScrollWidth+marqueeStep)*-1) {
        var newPosition = parseInt(marqueeObj.sty.left)-marqueeStep;
        marqueeObj.sty.left = newPosition+"px";
        if (marqueePageMode) {
          if (newPosition < marqueeWidth) {
            var mod = Math.abs(newPosition) % marqueeWidth;
            if (mod < marqueeStep) {
              marqueeTimeoutValue = marqueeStartDelay;
            }
          }
        }
      } else {
        marqueeObj.sty.left=parseInt(marqueeWidth)+marqueeStep+"px";
      }
    } else if (marqueeScrollDirection == 'up') {
      if (parseInt(marqueeObj.sty.top)>(marqueeScrollHeight*(-1)+marqueeStep)) {
        marqueeObj.sty.top=parseInt(marqueeObj.sty.top)-marqueeSpeed+"px";
      } else {
        marqueeObj.sty.top=parseInt(marqueeHeight)+marqueeStep+"px";
      }
    }
    setTimeout('marqueeScroll()', marqueeTimeoutValue);
  }

  function marqueeInit(){
    marqueeObj = getLyr("marqueeInner");
    marqueeScrollHeight = marqueeObj.h();
    marqueeScrollWidth = marqueeObj.w();
    marqueeParent = getLyr("marqueeOuter");
    marqueeHeight = marqueeParent.h();
    marqueeWidth = marqueeParent.w();
    marqueeObj.sty.top = (marqueeScrollDirection=='left' ? 0 : marqueeHeight);
    marqueeObj.sty.left = (marqueeScrollDirection=='top' ? 0 : marqueeWidth);

    marqueeStep = marqueeStepSize;
    marqueeInterval = marqueeScrollSpeed;

    if (marqueeMouseoverPause) {
      mo = document.getElementById("marqueeOuter");
      mo.onmouseover = function() { marqueeStep = 0; }
      mo.onmouseout  = function() { marqueeStep = marqueeStepSize; }
    }

    //if Opera or Netscape 7x, add scrollbars to scroll and exit
    if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){
      marqueeObj.style.height = marqueeHeight+"px";
      marqueeObj.style.overflow = "scroll";
      return;
    }

    if (marqueePageMode) {
     // for page mode, set all inner dives to the same width
      var divs = marqueeObj.ref.children;
      var marqueeWidthValue = marqueeWidth - (marqueeItemPadding*2);
      for (i=0; i<divs.length; i++) {
        divs[i].style.width = marqueeWidthValue+'px';
      }
      marqueeScrollWidth = marqueeWidth * divs.length;
      marqueeObj.w(marqueeScrollWidth);
    }

    // Start the scrolling.  We use setTimeout instead of setInterval to reduce
    // the jerkiness of the scroll.  To reduce it further, play with the speeds.
    setTimeout('marqueeScroll()', marqueeStartDelay);
  }

  function openMarqueePopup(p,h,w) {
    w = open(p, 'mp',
          'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,'+
          'resizable=0,width='+w+',height='+h+',dependent=1');
    w.focus();
  }

  addEvent(window,'load',marqueeInit);
