function DivScroller(outerDiv, innerDiv, scrollX, scrollY)
{
	this.outerDiv = document.getElementById(outerDiv);
	this.innerDiv = document.getElementById(innerDiv);
	
	this.scrollX = scrollX;
	this.scrollY = scrollY;
	
	this.innerCursor = {x:0, y:0};
	this.outerCursor = {x:0, y:0};
	
	this.setCursor = function(obj, e)
	{
		if ( obj == this.outerDiv )
		{
			this.outerCursor = this.getObjectCursorPosition(obj, e);
			this.adjustInnerPosition();
		}
		else 
			this.innerCursor = this.getObjectCursorPosition(obj, e);
	}
	
	
	this.adjustInnerPosition = function()
	{
		var innerWidth, innerHeight, outerWidth, outerHeight;

		if ( this.scrollX ) 
		{
			innerWidth = this.innerDiv.offsetWidth;
			outerWidth = this.outerDiv.offsetWidth;
			relativeOuterX = this.outerCursor.x / outerWidth;
		
			innerXpos = relativeOuterX * innerWidth;
			innerXoffset = innerXpos - this.outerCursor.x;
		
			this.innerDiv.style.left = '-' + innerXoffset + 'px';
		}
		
		if ( this.scrollY )
		{
			innerHeight = this.innerDiv.offsetHeight;
			outerHeight = this.outerDiv.offsetHeight;
			relativeOuterY = this.outerCursor.y / outerHeight;
		
			innerYpos = relativeOuterY * innerHeight;
			innerYoffset = innerYpos - this.outerCursor.y;
		
			this.innerDiv.style.top = '-' + innerYoffset + 'px';
		}
	}

	this.getObjectCursorPosition = function(obj, e)
	{
		var objectCursorPosition = {x:0, y:0};
		var cursor = this.getCursorPosition(e);
		var objectPostion = this.getObjectPosition(obj);
		
		objectCursorPosition.x = cursor.x - objectPostion.x;
		objectCursorPosition.y = cursor.y - objectPostion.y;
		
		return objectCursorPosition;
	}
	
	this.getObjectPosition = function(obj)
	{
    	var cursor = {x:0, y:0};
		if (obj.offsetParent) {
			do {
				cursor.x += obj.offsetLeft;
				cursor.y += obj.offsetTop;
			} while (obj = obj.offsetParent);
		}
		return cursor;
	}
	
	this.getCursorPosition = function(e)
	{
    	e = e || window.event;
    	var cursor = {x:0, y:0};
    	if (e.pageX || e.pageY) {
      		cursor.x = e.pageX;
        	cursor.y = e.pageY;
    	} 
    	else {
        	var de = document.documentElement;
        	var b = document.body;
        	cursor.x = e.clientX + 
            	(de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        	cursor.y = e.clientY + 
            	(de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    	}
    	return cursor;
	}
	
	return true;
}

