function ScrollingLayer(id, height, width, holdElem) 
{
	//Public
	this.id = id;
	
	var element = document.getElementById(id);
	var holdingElement = null;
	holdingElement = holdElem;
	
	//Private - Local variables
	var clipTop = 0;
	var clipLeft = 0;
	var clipRight = width;
	var clipBottom = height;
	var topper = 70;
	var lyrheight = 0;
	var lyrwidth = 0;
	var scrollTime = 0;
	var scrollHeight = 0;
	var DHTML = false;
	var timer = null;
	var currentDimensions = null;
    var customInitDone = false;
	
	var amount = 0;
	var time = 0;
	
	//Functions
	this.init = init;
	this.scrollLayer = scrollLayer;
	this.realScroll = realScroll;
	this.stopScroll = stopScroll;
	this.findPos = findPos;
    this.positionElement = positionElement;
    this.customInit = customInit;
	
	//Function declarations
	function findPos(obj) {
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}
		return [curleft,curtop];
	}
    
    function customInit() 
    {
       if (!this.customInitDone) {
           init();
           this.customInitDone = true;
       }
    }
	
	function init() 
	{
		DHTML = (document.getElementById || document.all || document.layers)
		if (!DHTML) return;
		if (document.layers)
		{
			lyrheight = element.style.clip.bottom;
			lyrwidth = element.style.clip.right;
			lyrwidth += 20;
			lyrheight += 20;
			element.style.clip.top = clipTop;
			element.style.clip.left = clipLeft;
			element.style.clip.right = clipRight;
			element.style.clip.bottom = clipBottom;
		}
		else if (document.getElementById || document.all)
		{
			lyrheight = element.offsetHeight;
			lyrwidth = element.offsetWidth;
			element.style.clip = 'rect('+clipTop+'px,'+clipRight+'px,'+clipBottom+'px,'+clipLeft+'px)';
		}
				
		currentDimensions = getDimensions();
		positionElement();	
		addEvent(window, 'resize', positionElement);
	}
	
	function positionElement() 
	{
		if (holdingElement != null) {
			holdingElement.innerHTML = '';
            var position = Position.positionedOffset(holdingElement);
			//var position = findPos(holdingElement);
			element.style.top = position[1];
			element.style.left = position[0];
		} else {
			var tempDimensions = getDimensions();
			if (tempDimensions[0] != currentDimensions[0] || tempDimensions[1] != currentDimensions[1]) {
				element.style.left -= currentDimensions[0] - tempDimensions[0];
				element.style.Top -= currentDimensions[1] - tempDimensions[1];
				currentDimensions = tempDimensions;
			}
		}

		topper = element.style.left.substring(0, element.style.left.length-2);
	}
	
	function getDimensions() 
	{
		var x,y;
		var test1 = document.body.scrollHeight;
		var test2 = document.body.offsetHeight
		if (test1 > test2) // all but Explorer Mac
		{
			x = document.body.scrollWidth;
			y = document.body.scrollHeight;
		}
		else // Explorer Mac;
			 //would also work in Explorer 6 Strict, Mozilla and Safari
		{
			x = document.body.offsetWidth;
			y = document.body.offsetHeight;
		}
		return [x,y];
	}
	
	function scrollLayer(amt,tim)
	{
		if (!DHTML) return;
		if (!element) return;
		amount = amt;
		time = tim;
		this.realScroll();
	}
	
	function realScroll()
	{
		if (!DHTML) return;
		clipLeft += amount;
		clipRight += amount;
		topper -= amount;
		if (clipLeft < 0 || clipRight > lyrwidth)
		{
			clipLeft -= amount;
			clipRight -= amount;
			topper += amount;
			return;
		}
		if (document.getElementById || document.all)
		{
			clipstring = 'rect('+clipTop+'px,'+clipRight+'px,'+clipBottom+'px,'+clipLeft+'px)';
			element.style.clip = clipstring;
			element.style.left = topper + 'px';
		}
		else if (document.layers)
		{
			element.style.clip.left = clipLeft;
			element.style.clip.right = clipRight;
			element.style.left = topper;
		}
		timer = window.setTimeout(realScroll,time);
	}
	
	function stopScroll()
	{
		if (timer) clearTimeout(timer);
	}
}