////////////////////////////////////////////////////////////////////////////////
// BEGIN
//
	
	var multiplier = 1;
	var scrollPosInit = 0;
	var scrollActive = false;
	var textHeight = 0;
	var contentHeight = 324;
	var scrollBarHeight = 50;
	
	var startX = 0;
	var startY = 0;

	var scrollBarJS;

	// Capture mouse movements
	var IE = document.all?true:false
	if(!IE) { document.captureEvents(Event.MOUSEMOVE); }
	document.onmousemove = getMouseXY;
		var tempX = 0;
		var tempY = 0;

	function initScrollbar()
	{
		// Determine content height and set scroll multiplier
		var D=document
		var EL = D[D.getElementById?"getElementById":"all"]("content");
		
		// Init Scrollbar Position
		scrollBarJS = document.getElementById( "scrollBar" );
		scrollPosInit = findPosY( scrollBarJS );
		textHeight = EL.offsetHeight;
		
		var sRatio = 1 / (EL.offsetHeight / contentHeight);
		if( sRatio > 1 ) { sRatio = 1; }
			scrollBarHeight = sRatio * contentHeight;
			scrollBarJS.style.height = scrollBarHeight + "px";
			
		// Multiplier
		multiplier = ((EL.offsetHeight - contentHeight + 20) / (contentHeight - scrollBarHeight));
	}
	
	function updateScrollActive( value )
	{
		scrollActive = value;
		startY = tempY - findPosY( scrollBarJS );
	}
	
	function myScroll()
	{
		if( scrollActive )
		{
			var outputJS = document.getElementById( "output" );
			
			// Current scroll position
			var curY = findPosY( scrollBarJS );
			var	newPos = tempY - startY;
			
			var scrollBottom =  newPos + scrollBarHeight;
			var trackBottom = scrollPosInit + contentHeight;
			

			if( newPos >= scrollPosInit && scrollBottom < trackBottom )
			{
				// Scrollbar Position
				scrollBarJS.style.position = "absolute";
				scrollBarJS.style.top = newPos + "px";
				
				// Scroll content
				var contentJS = document.getElementById( "content" );
				var myScrollTo = ((newPos - scrollPosInit) * multiplier) * (-1);
				//var myScrollTo = (scrollPosInit - newPos);
				contentJS.style.top = myScrollTo + "px";
				//outputJS.innerHTML = "newPos: " + newPos + "  scrollBarHeight: " + scrollBarHeight + "  scrollPosInit: " + scrollPosInit + "  scrollBottom: " + scrollBottom + "  trackBottom: " + trackBottom + "  myScrollTo: " + myScrollTo + "  multiplier: " + multiplier + "  textHeight: " + textHeight;
			}
		}
	}

	function getMouseXY(e)
	{
		if( IE )
		{
			tempX = event.clientX + document.body.scrollLeft;
			tempY = event.clientY + document.body.scrollTop;
		}
		else
		{
			tempX = e.pageX;
			tempY = e.pageY;
		}
		
		if (tempX < 0){tempX = 0;}
		if (tempY < 0){tempY = 0;} 
	}

	function findPosX(obj)
	{
		var curleft = 0;
		if(obj.offsetParent)
			while(1) 
			{
			  curleft += obj.offsetLeft;
			  if(!obj.offsetParent)
				break;
			  obj = obj.offsetParent;
			}
		else if(obj.x)
			curleft += obj.x;
		return curleft;
	}
	
	function findPosY(obj)
	{
		var curtop = 0;
		if(obj.offsetParent)
			while(1)
			{
			  curtop += obj.offsetTop;
			  if(!obj.offsetParent)
				break;
			  obj = obj.offsetParent;
			}
		else if(obj.y)
			curtop += obj.y;
		return curtop;
	}
//
// END
////////////////////////////////////////////////////////////////////////////////