Glider.holder = [];
function Glider(id,x,y,w,h,d,ac,ob_y) {
      var temp = document.getElementById("gDiv") 
	this.glideDur = d || 1000; 
      this.origX = x; 
      this.origY = y ; 
      this.ob_y = ob_y;
      this.sp_y = temp.clientHeight;
      this.sp_yst = this.sp_y;
      this.tr_y = 409; // distance to top 
      this.ofset = 2*this.origY + 155 + 134; // objects in the cell plus position on load in the cell   
      this.center = (screen.availHeight - this.ob_y)/2;
      this.ac = -ac || 0;
	this.baseObj = dynObj;
	this.baseObj(id,x,y,w,h);
  Glider.holder[Glider.holder.length] = this;
  if (!Glider.winHt) Glider.winHt = getWinHeight();
}

Glider.prototype = new dynObj;
Glider.prototype.onGlideInit = function () {}

Glider.prototype.checkGlider = function() {
      var bida = getScrollY(); 
      var temp = document.getElementById("gDiv") 
      
      var tempi = temp.clientHeight;
      if (tempi != this.sp_yst) this.sp_y = tempi; 
      else this.sp_y = this.sp_yst;

      var bidi = this.sp_y - this.ob_y;      
      var temp = this.tr_y;

      if (this.ob_y > this.tr_y) temp = this.ob_y; 
      if (bida < temp)  bid = 0; 
      else  bid = bida - this.tr_y + this.center/2;               
      if (bid > bidi - this.ofset) bid = bidi - this.ofset;
      this.bida_old = bida;
	var destY = bid + this.origY;
	if (destY != this.y) {
		if (destY != this.dy) {
			this.dy = destY;
			this.glideInit();
                  this.onGlideInit();
		   } 
		this.glide();
	}
}

Glider.prototype.glideInit = function() {
	this.gt = new Date().getTime();
	var distY = this.dy - this.y;    
	if ( Math.abs(distY) > Glider.winHt ) {	// distance greater than window height?
		this.gsy = (distY > 0)? this.dy - Glider.winHt: this.dy + Glider.winHt;
	} else this.gsy = this.y;
  this.g_yc1 = this.gsy + ( (1+this.ac) * (this.dy - this.gsy)/3 );
	this.g_yc2 = this.gsy + ( (2+this.ac) * (this.dy - this.gsy)/3 );
}

Glider.prototype.glide = function() {
	var elapsed = new Date().getTime() - this.gt;
  if (elapsed < this.glideDur) {
    var y = dw_Bezier.getValue( elapsed/this.glideDur, this.gsy, this.dy, this.g_yc1, this.g_yc2 );
    this.shiftTo(null,y);
  } else this.shiftTo(null,this.dy);
}

Glider.control = function() {
  for (var i=0; Glider.holder[i]; i++) {
    var curObj = Glider.holder[i];
    if (curObj) curObj.checkGlider();
  }
}
//Glider.timer = setInterval("Glider.control()",20);
dw_Animation.add(Glider.control);

// returns amount of vertical scroll
function getScrollY() {
	var sy = 0;
	if (document.documentElement && document.documentElement.scrollTop)
		sy = document.documentElement.scrollTop;
	else if (document.body && document.body.scrollTop) 
		sy = document.body.scrollTop; 
	else if (window.pageYOffset)
		sy = window.pageYOffset;
	else if (window.scrollY)
		sy = window.scrollY;
	return sy;
}

// onresize, get window height
if (window.addEventListener)
  window.addEventListener("resize", function(){ Glider.winHt = getWinHeight(); }, "false");
else if (window.attachEvent)
  window.attachEvent("onresize", function(){ Glider.winHt = getWinHeight(); } );