//Scroller
Scroller = function(id,classId,clipTop,clipLeft,clipRight,clipBottom,topper,lefter,addDim)
{
	var thelayer,lyrheight,lyrwidth,time,amountV,theTime,amountH,dirV,dirH,theHeight,DHTML, posH, posV;
	var origClipTop = 0;
	var origClipBottom = 0;
	var origClipLeft = 0;
	var origClipRight = 0;
	var skipV = false;
	var SkipH = false;
	DHTML = (document.getElementById || document.all || document.layers)
	if (!DHTML) return;
	thelayer = new getObj(id);
	if (!thelayer) return;
	this.GetDimension = function()
	{
		if (document.layers)
		{
			origClipTop = thelayer.style.clip.top;
			origClipBottom = thelayer.style.clip.bottom;
			origClipLeft = thelayer.style.clip.left;
			origClipRight = thelayer.style.clip.right;
			
			lyrheight = thelayer.style.clip.bottom;
			lyrwidth = thelayer.style.clip.right;
			lyrwidth += 20;
			lyrheight += 20;
			thelayer.style.clip.top = clipTop;
			thelayer.style.clip.left = clipLeft;
			thelayer.style.clip.right = clipRight;
			thelayer.style.clip.bottom = clipBottom;
		}
		else if (document.getElementById || document.all)
		{		
			origClipTop = 0;
			origClipBottom = thelayer.obj.clientHeight;
			origClipLeft = 0;
			origClipRight = thelayer.obj.clientWidth;
			
			lyrheight = thelayer.obj.clientHeight;
			lyrwidth = thelayer.obj.clientWidth;
			lyrwidth += addDim;
			lyrheight += addDim;
			thelayer.style.clip = 'rect('+clipTop+'px,'+clipRight+'px,'+clipBottom+'px,'+clipLeft+'px)';
		}
		
		// code for IE, etc.
		if (window.ActiveXObject)
		{
			lyrwidth += 1;
			lyrheight += 1;
		}
		
		//alert('my id: ' + id + ' width: ' + lyrwidth)
	}
	this.RemClip = function()
	{
		if (document.layers)
		{
			thelayer.style.clip.top = origClipTop;
			thelayer.style.clip.left = origClipBottom;
			thelayer.style.clip.right = origClipLeft;
			thelayer.style.clip.bottom = origClipRight;
		}
		else if (document.getElementById || document.all)
		{		
			thelayer.style.clip = 'rect('+origClipTop+'px,'+origClipRight+'px,'+origClipBottom+'px,'+origClipLeft+'px)';
		}
	}
	this.RemClip();
	this.GetDimension();
	this.align = function(posV, posH, clTp, clBt)
	{
		if (posV != 0)
		{
			topper = posV;
		}
		if (posH != 0)
		{
			lefter = posH;
		}
		
		if (document.getElementById || document.all)
		{
			if (clTp != -1 && clBt != -1)
			{
				
				clipTop = clTp;
				clipBottom = clBt;
				clipstring = 'rect('+clipTop+'px,'+clipRight+'px,'+clipBottom+'px,'+clipLeft+'px)';
				thelayer.style.clip = clipstring;
			}
			thelayer.style.top = topper + 'px';
			thelayer.style.left = lefter + 'px';
		}
		else if (document.layers)
		{
			
			if (clTp != -1 && clBt != -1)
			{				
				clipTop = clTp;
				clipBottom = clBt;
				thelayer.style.clip.top = clipTop;
				thelayer.style.clip.bottom = clipBottom;
			}
			thelayer.style.top = topper;
			thelayer.style.left = lefter;
		}
	}
	this.myPosV = function()
	{
		return topper;
	}
	this.myClipTop = function()
	{
		return clipTop;
	}
	this.myClipBottom = function()
	{
		return clipBottom;
	}
	this.myPosH = function()
	{
		return lefter;
	}
	this.myHeight = function()
	{
		return lyrheight;
	}
	this.myWidth = function()
	{
		return lyrwidth;
	}
	this.Scrollayer = function(amtV,timV,amtH,timH,dir)
	{
		if (!DHTML) return;
		if (!thelayer) return;
		
		amountV = amtV;
		amountH = amtH;
		
		if (lyrheight == 0 || lyrwidth == 0)
		{
			this.GetDimension();
		}
		
		if (dir == 0)
		{
			
			dirV = 1;
			theTime = timV;
		}
		else if (dir == 1)
		{
			
			dirH = 1;
			theTime = timH;
		}
		else if (dir == 2)
		{
			dirV = 1;
			dirH = 1;
			theTime = parseInt((timV+timH)/2);
		}
		this.RealScroll();
		//alert(id + ' - ' + dir + ' - ' + lyrwidth + ' x ' + lyrheight);
	}
	this.RealScroll = function()
	{
		
		if (!DHTML) return;
		skipV = false;
		skipH = false;
		if (dirV == 1)
		{
			clipTop += amountV;
			clipBottom += amountV;
			topper -= amountV;
			
			if (clipTop < 0 || clipBottom > lyrheight)
			{
				clipTop -= amountV;
				clipBottom -= amountV;
				topper += amountV;
				skipV = true;
			}
			else
			{
				skipV = false;
			}
			if ( (document.getElementById || document.all) && (!skipV) )
			{
				clipstring = 'rect('+clipTop+'px,'+clipRight+'px,'+clipBottom+'px,'+clipLeft+'px)';
				thelayer.style.clip = clipstring;
				thelayer.style.top = topper + 'px';
			}
			else if ( (document.layers) && (!skipV) )
			{
				thelayer.style.clip.top = clipTop;
				thelayer.style.clip.bottom = clipBottom;
				thelayer.style.top = topper;
			}
		}
		if (dirH == 1)
		{
			clipLeft += amountH;
			clipRight += amountH;
			lefter -= amountH;
			
			if (clipLeft < 0 || clipRight > lyrwidth)
			{
				clipLeft -= amountH;
				clipRight -= amountH;
				lefter += amountH;
				skipH = true;
			}
			else
			{
				skipH = false;
			}
			if ( (document.getElementById || document.all) && (!skipH) )
			{
				clipstring = 'rect('+clipTop+'px,'+clipRight+'px,'+clipBottom+'px,'+clipLeft+'px)';
				thelayer.style.clip = clipstring;
				thelayer.style.left = lefter + 'px';
			}
			else if ( (document.layers) && (!skipH) )
			{
				thelayer.style.clip.left = clipLeft;
				thelayer.style.clip.right = clipRight;
				thelayer.style.left = lefter;
			}
		}
		if (skipV && skipH)
		{
			if (time) clearTimeout(time);
			return;
		}
		else
		{
			time = setTimeout(classId+'.RealScroll()',theTime);
		}
	}
	this.StopScroll = function()
	{
		if (time) clearTimeout(time);
	}
}
//ENDScroller
