/* ********************************************************************
* HTML Block Scroller & Marquee JavaScript - v2.0 
*  - From http://www.greywyvern.com/javascript
*  - Copyright 2008 - Licenced for free distribution under the BSDL
*  -     http://www.opensource.org/licenses/bsd-license.php
*
* Have one or more scrolling blocks of HTML anywhere on your webpages.
* The scroller will even pause on mouseover and resume on mouseout.
*
* Version 2.0
*   - Uses DOM-only methods (compatible with application/xhtml+xml)
*   - Blocks are created in the HTML page, rather than as JS variables
*   - Automatic startup on page load

***********************************************************************/
var Page_MarqueeVer= "2";

function scrollObject(main, width, height, direct, pause, speed, tdclass) {
  var self = this;
  this.main = main;
  this.width = width;
  this.height = height;
  this.direct = direct;
  this.pause = pause;
  this.speed = Math.max(1.001, Math.min((direct == "up" || direct == "down") ? height : width, speed));
  this.slope = (direct == "up" || direct == "left") ? 1 : -1;
  this.prev = this.offset = 0;
  this.curr = 1;
  this.mouse = false;
  this.scroll = function() {
    this.main = document.getElementById(this.main);
    this.main.style.overflow = "hidden";
    this.main.style.position = "relative";
    this.main.style.width = this.width + "px";
    this.main.style.height = this.height + "px";
    if (this.main.childNodes.length > 1) {
      this.main.onmouseover = function() { self.mouse = true; };
      this.main.onmouseout = function() { self.mouse = false; };
      setInterval(function() {
        if (!self.offset && self.scrollLoop() ) self.main.childNodes[self.curr].style.visibility = "visible";
      }, this.pause);
    } this.main.childNodes[this.prev].style.visibility = "visible";
  };
  this.scrollLoop = function()
   {
         if(this.mouse)
         {
            setTimeout(function() { self.scrollLoop(); }, 30);
            return false;
         }
        if (!this.offset) 
        {
            this.offset = (this.direct == "up" || this.direct == "down") ? this.height : this.width;
        } 
        else 
        {
               this.offset = Math.floor(this.offset / this.speed);
             // this.offset -= 2;
        }
       
        if (this.direct == "up" || this.direct == "down") 
        {
            this.main.childNodes[this.curr].style.top = (this.offset * this.slope) + "px";
            this.main.childNodes[this.prev].style.top = ((this.offset - this.height) * this.slope) + "px";
        } 
        else 
        {
           
            this.main.childNodes[this.curr].style.left = (this.offset * this.slope) + "px";
           
            this.main.childNodes[this.prev].style.left = ((this.offset - this.width) * this.slope) + "px";
           
        }
         if (!this.offset) 
        {
            this.main.childNodes[this.prev].style.visibility = "hidden";
            this.prev = this.curr;
            if (++this.curr >= this.main.childNodes.length) this.curr = 0;
           
        } 
        else 
            setTimeout(function() { self.scrollLoop(); }, 30);
        return true;
    };
  if (window.addEventListener) {
    window.addEventListener('load', function() { self.scroll(); }, false); 
  } else if (window.attachEvent)
    window.attachEvent('onload', function() { self.scroll(); });
}
