function scrollAll()
{
	tableScroller.scrollAll();
//bu timer'ı objenin içine almayı beceremedim bir türlü... o yüzden böyle komik 
//bir dışarıdan içeriyi çağırma muhabbeti var...
}

function createTableScroller(pageCount)
{
	this.pageCount=pageCount;
  this.currentPage=0;
  
 	this.init=function()
  {
  	var i1;
  	this.left=$("#TableScroll1").offset().left;
    this.top=$("#TableScroll1").offset().top;
  	this.width=$("#TableScroll1").width();
    this.height=$("#TableScroll1").height();
    this.posArr= new Array(this.pageCount);
    for (i1=0;i1<this.pageCount;i1++)
    {
    	this.posArr[i1]=new TDivPos();
      if (i1 == 0) this.posArr[i1].visible=true;
      this.posArr[i1].x=$("#TableScroll"+(i1+1)).offset().left;
      this.posArr[i1].y=$("#TableScroll"+(i1+1)).offset().top;
      this.posArr[i1].width=$("#TableScroll"+(i1+1)).width();
      this.posArr[i1].height=$("#TableScroll"+(i1+1)).height();
      this.posArr[i1].xToGo=this.posArr[i1].x;
      this.posArr[i1].yToGo=this.posArr[i1].y;
    }//for i1
  }//this.init.
  
  this.goToNextPage = function()
  {
  	if (this.currentPage+1 < this.pageCount)
    	this.goToPage(1+this.currentPage+1);
    
  }
  
  this.goToPrevPage = function()
  {
  	if (this.currentPage-1 >= 0)
    	this.goToPage(1+this.currentPage-1);
  }
  
  this.goToPage = function(n)
  {
  	if (((n-1) >= 0) && ((n-1) < this.pageCount))
    {
    	if ((n-1) > this.currentPage)
      {
  	  	this.posArr[this.currentPage].xToGo=this.left-this.width;
        this.posArr[this.currentPage].yToGo=this.top;
        this.posArr[n-1].xToGo=this.left;
        this.posArr[n-1].yToGo=this.top;
        this.posArr[n-1].x=this.posArr[this.currentPage].x+this.width;
        this.posArr[n-1].y=this.top;
        this.timerId=setTimeout("scrollAll()",50);
      }
      if ((n-1) < this.currentPage)
      {
  	  	this.posArr[this.currentPage].xToGo=this.left+this.width;
        this.posArr[this.currentPage].yToGo=this.top;
        this.posArr[n-1].xToGo=this.left;
        this.posArr[n-1].yToGo=this.top;
        this.posArr[n-1].x=this.posArr[this.currentPage].x-this.width;
        this.posArr[n-1].y=this.top;
        this.timerId=setTimeout("scrollAll()",50);
      }
      this.currentPage=n-1;
    }//if (((n-1) >= 0) && ((n-1) < this.pageCount))*/
  }//this.goToPage
  
  this.scrollAll = function()
  {
  	var i1;
    var changed=false;
  	for (i1=0;i1<this.pageCount;i1++)
    {
    	if (this.posArr[i1].x != this.posArr[i1].xToGo)
      {
      	if (Math.abs(this.posArr[i1].x-this.posArr[i1].xToGo) < 2)
       	{
        	this.posArr[i1].x=this.posArr[i1].xToGo;
        } else
        {
        	this.posArr[i1].x=(this.posArr[i1].x+this.posArr[i1].xToGo)/2;
        }
        if (this.InRect(i1) == true)
        {
        	if (this.posArr[i1].visible == false)
          {
          	$("#TableScroll"+(i1+1)).css("display","block");
            this.posArr[i1].visible=true;
          }
        } else//if (this.InRect(i1) == true)
        {
        	if (this.posArr[i1].visible == true)
          {
          	$("#TableScroll"+(i1+1)).css("display","none");
            this.posArr[i1].visible=false;
          }
        }//if (this.InRect(i1) == true),else
        $("#TableScroll"+(i1+1)).css("left",this.posArr[i1].x+"px");
        this.setClipRect(i1);
        changed=true;
      }//if (this.posArr[i1].x <> this.posArr[i1].xToGo)
    }//for i1
    if (changed == true)
    {
			this.timerId=setTimeout("scrollAll()",50);    	
    }
    else
    {
    	for (i1=0;i1<this.pageCount;i1++)
      {
      	if (i1 == this.currentPage)
        {
		    	$("#TableScroll"+(i1+1)).css("display","block");
          this.posArr[i1].visible=true;
        }else
        {
         	$("#TableScroll"+(i1+1)).css("display","none");
          this.posArr[i1].visible=false;
        }
      }//for i1
    }
  }//this.scrollAll.
  
  this.InRect = function(ind)
  {
  	var b=false;
		if ((this.posArr[ind].x >= this.left) && (this.posArr[ind].x <= this.left+this.width))
    	b=true;  	
		if ((this.posArr[ind].x+this.posArr[ind].width >= this.left) && (this.posArr[ind].x+this.posArr[ind].width <= this.left+this.width))
    	b=true;
    return b;  	
  }//this.InRect.
  
  this.setClipRect = function(ind)
  {
  	var str;
  	if (this.posArr[ind].x < this.left)
    {
			str="rect(0px,"+this.posArr[ind].width+"px,"+this.posArr[ind].height+"px,"+(this.left-this.posArr[ind].x)+"px)";
    }
    else
    {
    	str="rect(0px,"+(this.posArr[ind].width-(this.posArr[ind].x-this.left))+"px,"+this.posArr[ind].height+"px,0px)";
    }  	
    $("#TableScroll"+(ind+1)).css("clip",str);
  }
  
}

function TDivPos()
{
	this.x=0;
  this.y=0;
  this.xToGo=0;
  this.yToGo=0;
  this.width=0;
  this.height=0;
  this.visible=false;
}