﻿// JScript File
function divScrollX(div,direction){
	life=1;
	this.divToScroll=document.getElementById(div);
	if (this.Splay) clearInterval(this.Splay);
	
	if (direction=='up') direction=(-1);
	if (direction=='down') direction=(1);
	
	X=direction*((divToScroll.clientHeight)-12);
	startTime2=new Date().getTime();
	this.SmaxX=(divToScroll.scrollHeight)-(divToScroll.clientHeight);
	this.SminX=0;
	this.ScurX=divToScroll.scrollTop;
	this.SnewX=(this.ScurX+X);
	if (this.SnewX<=this.SminX) this.SnewX=this.SminX;
	if (this.SnewX>this.SmaxX) this.SnewX=this.SmaxX;
	this.SnewX=this.SnewX-ScurX;
	this.Slife=life*1000;
	this.Splay=setInterval(Sanimate,20);
}

function Sanimate(){
	this.Sdel=(new Date().getTime()-startTime2);
	this.Sdelta=this.Sdel/this.Slife;
	this.Sx=Math.round(Math.easeOutQuad(this.Sdel,this.ScurX,this.SnewX,this.Slife));
	this.divToScroll.scrollTop=this.Sx;
	if (this.Sdelta>1 || this.Sdelta <0) clearInterval(this.Splay);
}
divScrollX.prototype.Sanimate=Sanimate;

Math.easeOutQuad = function (t, b, c, d) { 
return -c * (t/=d)*(t-2) + b; 
};



