// Title: Tigra Scroller PRO
// URL: http://www.softcomplex.com/products/tigra_scroller_pro/
// Version: 1.1
// Date: 10-14-2002 (mm-dd-yyyy)
// Technical Support: support@softcomplex.com (specify product title and order ID)
// Notes: Registration needed to use this script legally.
//	Visit official site for details.

// set correct path to Tigra Scroller files
var TScroll_path_to_files = '/js/tsp_files/', TScroll = [];

// please, don't change anything below this line
document.write('<script language="JavaScript" src="' + TScroll_path_to_files + 'scroll.dflt.js"></script>');
document.write('<script language="JavaScript" src="' + TScroll_path_to_files + 'scroll.' 
  + (document.layers ? 'nn4' : 'dom') + '.js"></script>');

function TScroll_init (LOOK, BEHAVE, ITEMS) {
  this.id = TScroll.length;
  TScroll[this.id] = this;
  
  this.step = BEHAVE.speed != 0 ? BEHAVE.speed : 1;
  this.interval = this.prior = 0;
  this.pseq = this.step < 0 ? [1, 0] : [0, 1];
  this.astep = Math.abs(this.step);
  
  var i, 
  ctrl = {
    "up" : LOOK.up && typeof(LOOK.up) == "object" ? LOOK.up : TScr_DEFAULT.up,
    "dn" : LOOK.dn && typeof(LOOK.dn) == "object" ? LOOK.dn : TScr_DEFAULT.dn,
    "pa" : LOOK.pa && typeof(LOOK.pa) == "object" ? LOOK.pa : TScr_DEFAULT.pa,
    "re" : LOOK.re && typeof(LOOK.re) == "object" ? LOOK.re : TScr_DEFAULT.re,
    "nx" : LOOK.nx && typeof(LOOK.nx) == "object" ? LOOK.nx : TScr_DEFAULT.nx,
    "pr" : LOOK.pr && typeof(LOOK.pr) == "object" ? LOOK.pr : TScr_DEFAULT.pr
  },
  vertical = BEHAVE.vertical,
  hide_buttons = BEHAVE.hide_buttons,
  w = LOOK.size[0] ? LOOK.size[0] : TScr_DEFAULT.size[0],
  h = LOOK.size[1] ? LOOK.size[1] : TScr_DEFAULT.size[1];
  
	this.height = vertical ? h : w;
  this.distance = LOOK.distance ? LOOK.distance : this.height;
  this.pos = - this.distance;
  
  this.items = [];
	this.auto = BEHAVE.auto;
  
  this.build = TScr_build;
  this.run = TScr_run;
  this.ctrl = [];
  this.img = [];

  this.move = function (p) { 
    if (this.prior <= p && this.interval == 0) {  
      this.prior = 0
      this.interval = setInterval('TScroll[' + this.id + '].roll()', 50) 
    }
  } 

  this.stop = function (p) { 
    if (this.prior < p) this.prior = p
    if (this.interval != 0) {
      clearInterval(this.interval)
      this.interval = 0
    }
  }

  this.sleep = function (delay) { 
    this.stop(0); 
    setTimeout('TScroll[' + this.id + '].wake()', delay * 1000);
  }
  
  this.wake = function () {
    this.ajust(); 
    this.pos -= this.step;
    this.move(0);
  }

  this.roll = function () { 
    var i, j, t;
    if (this.step > 0 && this.pos + this.img_last < this.astep) this.pos = this.step;
    else if (this.step < 0 && - this.pos < this.astep) this.pos = - this.img_last;

    for (i in this.items)
      for (j in this.pseq)
        if (Math.abs(this.pos + this.items[i].delta[this.pseq[j]]) < this.astep) {
          if (document.body && document.body.filters) { 
            x = this.pos + this.items[i].delta[this.pseq[1 - j]]
            this.t = ((x > 0) ^ (this.step > 0) || (x == 0)) ?
              (this.step > 0 ? 
                (i == this.items.length - 1 ? [this.img[0], 0] : [this.img[i * 1 + 1], i * 1 + 1]) : 
                (i == 0 ? [this.img[this.items.length], this.items.length - 1] : [this.img[i], i - 1])
              ) : 0
          }
          if (this.items[i].pause[this.pseq[j]] > 0) {
            this.pos = - this.items[i].delta[this.pseq[j]];
            this.ajust(1)
            return this.sleep (this.items[i].pause[this.pseq[j]])
          }
        }
    this.pos -= this.step
    this.ajust() 
  }
// event handlers
  if (this.auto) {
    this.mout = hide_buttons ? 
      function () { 
        this.ctrl.nxt.visibility = 
        this.ctrl.prv.visibility = 
        this.ctrl.pau.visibility = 
        this.ctrl.res.visibility = this.lay_hide;
        this.move(1) 
      } : function () { this.move(1) }

    this.mover  = hide_buttons ? 
      function () { 
        this.ctrl.nxt.visibility = 
        this.ctrl.prv.visibility = this.lay_show; 
        if (this.prior < 2) {
          this.ctrl.pau.visibility = this.lay_show; 
          this.ctrl.res.visibility = this.lay_hide;
        }
        else  {
          this.ctrl.pau.visibility = this.lay_hide; 
          this.ctrl.res.visibility = this.lay_show;
        }
        this.stop(1) 
      } : function () { this.stop(1) }  
    
    this.click_pau = function () {
      this.ctrl.pau.visibility = this.lay_hide  
      this.ctrl.res.visibility = this.lay_show  
      this.stop(2); 
    }

    this.click_res = function () {
      this.ctrl.pau.visibility = this.lay_show  
      this.ctrl.res.visibility = this.lay_hide  
      this.prior = 1
    }

    this.click_pass = function (dir) {
      if (this.step * dir > 0) {
        var i = 0;
        while (i < this.img.length && this.distance + this.img[i] <= - this.pos) i ++;
        if (i == this.img.length - 1) i = 0;
        this.pos = - this.img[i] - this.distance;
      }
      else {  
        var i = this.img.length - 1;
        while (i >= 0 && this.img[i] >= - this.pos + this.distance) i --;
        if (i == 0) i = this.img.length - 1;
        this.pos = - this.img[i] + this.distance;
      }
      this.ajust();
    }
  }
  else {
    if (hide_buttons) { 
      this.mover = function () { this.ctrl.up.visibility = this.ctrl.dn.visibility = this.lay_show }
      this.mout  = function () { this.ctrl.up.visibility = this.ctrl.dn.visibility = this.lay_hide }
	    this.mout_dn = this.mout_up = function () { this.mout(); this.stop(1); }
    }
		else this.mout_dn = this.mout_up = function () { this.stop(1) }		
    this.mover_up = function () {
      if (hide_buttons) this.mover()
      this.step = - this.astep;
      this.pseq = [0, 1];
      this.move(1) 
    }
    this.mover_dn = function () { 
      if (hide_buttons) this.mover()
      this.step = this.astep; 
      this.pseq = [1, 0];
      this.move(1) 
    }
  }

// building HTML
  this.build (w, h, vertical, hide_buttons, ctrl, ITEMS);
}

function TScr_run () {  
// size estimations

  this.main = this.getLayrStyle("main");
  for (var i in this.items) {
    this.img[i] = this.getImgOffset(i);
    this.items[i].delta = [this.img[i] + this.distance, this.getImgOffset(i*1 + 1) - this.height];
  }
  this.img_last = this.img[this.img.length] = this.getImgOffset(this.items.length); 

  if (this.auto) {
    this.ctrl.pau = this.getLayrStyle("pau");
    this.ctrl.res = this.getLayrStyle("res");
    this.ctrl.nxt = this.getLayrStyle("nxt");
    this.ctrl.prv = this.getLayrStyle("prv");
    
    this.move(0);
  }
  else {
    this.ctrl.up = this.getLayrStyle("aup"); 
    this.ctrl.dn = this.getLayrStyle("adn");
  }
}