	var contentHeight = 0; 	// The total height of the content
	var visibleContentHeight = 0;	
	var scrollActive = false;
	
	var scrollHandleObj = false; // reference to the scroll handle
	var scrollHandleHeight = false;
	var scrollbarTop = false;
	var eventYPos = false;

	var scrollbuttonActive = false;
	var scrollbuttonDirection = false;
	var scrollbuttonSpeed = 2; // How fast the content scrolls when you click the scroll buttons(Up and down arrows)
	var scrollTimer = 10;	// Also how fast the content scrolls. By decreasing this value, the content will move faster	
	
	var scrollMoveToActive = false;
	var scrollMoveToYPosition = false;
	
	var operaBrowser = false;
	if(navigator.userAgent.indexOf('Opera')>=0)operaBrowser=1;
		
	function scrollDivstartScroll(e)
	{
		if(document.all && !operaBrowser)e = event;
		scrollbarTop = document.getElementById('scrolldivtheScroll').offsetTop;
		eventYPos = e.clientY;
		scrollActive = true;
	}
	
	function scrollDivstopScroll()
	{
		scrollActive = false;
		scrollbuttonActive = false;
		scrollMoveToActive = false;
	}
	function scrollDivscroll(e)
	{
		if(!scrollActive)return;
		if(document.all && !operaBrowser)e = event;
		if(e.button!=1 && document.all)return;
		var topPos = scrollbarTop + e.clientY - eventYPos; 
		if(topPos<0)topPos=0;
		if(topPos/1>visibleContentHeight-(scrollHandleHeight+4)/1)topPos = visibleContentHeight-(scrollHandleHeight+4);
		document.getElementById('scrolldivtheScroll').style.top = topPos + 'px';
		document.getElementById('scrolldivcontent').style.top = 0 - Math.floor((contentHeight) * ((topPos)/(visibleContentHeight-scrollHandleHeight)))+'px' 
	}
	
	/*
	Click on the slider
	Move the content to the this point
	*/
	function scrolldivscrollMoveToInit(e)
	{		
		if(document.all && !operaBrowser)e = event;
		scrollMoveToActive = true;
		scrollMoveToYPosition = e.clientY - document.getElementById('scrolldivscrollbar').offsetTop;
		if(document.getElementById('scrolldivtheScroll').offsetTop/1 > scrollMoveToYPosition) scrollbuttonDirection = scrollbuttonSpeed*-2; else  scrollbuttonDirection = scrollbuttonSpeed*2;
		scrolldivscrollMoveTo();	
	}
	
	function scrolldivscrollMoveTo()
	{
		if(!scrollMoveToActive || scrollActive)return;
		var topPos = document.getElementById('scrolldivtheScroll').style.top.replace('px','');
		topPos = topPos/1 + scrollbuttonDirection;
		if(topPos<0){
			topPos=0;
			scrollMoveToActive=false;
		}
		if(topPos/1>visibleContentHeight-(scrollHandleHeight+4)/1){
			topPos = visibleContentHeight-(scrollHandleHeight+4);	
			scrollMoveToActive=false;
		}
		if(scrollbuttonDirection<0 && topPos<scrollMoveToYPosition-scrollHandleHeight/2)return;	
		if(scrollbuttonDirection>0 && topPos>scrollMoveToYPosition-scrollHandleHeight/2)return;			
		document.getElementById('scrolldivtheScroll').style.top = topPos + 'px';
		document.getElementById('scrolldivcontent').style.top = 0 - Math.floor((contentHeight) * ((topPos)/(visibleContentHeight-scrollHandleHeight)))+'px' 		
		setTimeout('scrolldivscrollMoveTo()',scrollTimer);		
	}
	
	function cancelEvent()
	{
		return false;			
	}

	function scrolldivscrollButton()
	{
		if(this.id=='scrolldivscrollDown')scrollbuttonDirection = scrollbuttonSpeed; else scrollbuttonDirection = scrollbuttonSpeed*-1;
		scrollbuttonActive=true;
		scrolldivscrollButtonScroll();
	}
	function scrolldivscrollButtonScroll()
	{
		if(!scrollbuttonActive)return;
		var topPos = document.getElementById('scrolldivtheScroll').style.top.replace('px','');
		topPos = topPos/1 + scrollbuttonDirection;
		if(topPos<0){
			topPos=0;
			scrollbuttonActive=false;
		}
		// alert (topPos + " " + visibleContentHeight + " " + scrollHandleHeight);
		
		if(topPos/1>visibleContentHeight-(scrollHandleHeight+4)/1){
			topPos = visibleContentHeight-(scrollHandleHeight+4);	
			scrollbuttonActive=false;}	

		document.getElementById('scrolldivtheScroll').style.top = topPos + 'px';
		document.getElementById('scrolldivcontent').style.top = 0 - Math.floor((contentHeight) * ((topPos)/(visibleContentHeight-scrollHandleHeight)))+'px' 			
		setTimeout('scrolldivscrollButtonScroll()',scrollTimer); 
	}
	function scrolldivscrollButtonStop()
	{
		scrollbuttonActive = false;
	}
	
	
	function scrolldivinitScroll()
	{
		visibleContentHeight = document.getElementById('scrolldivscrollbar').offsetHeight ;
		if (visibleContentHeight<=0) visibleContentHeight=520;
		contentHeight = document.getElementById('scrolldivcontent').offsetHeight - visibleContentHeight;
		if (contentHeight<=0) contentHeight=7000;
		scrollHandleObj = document.getElementById('scrolldivtheScroll');
		scrollHandleHeight = scrollHandleObj.offsetHeight;
		if (scrollHandleHeight<=0) scrollHandleHeight=13;
		scrollbarTop = document.getElementById('scrolldivscrollbar').offsetTop;		
		document.getElementById('scrolldivtheScroll').onmousedown = scrollDivstartScroll;
		document.body.onmousemove = scrollDivscroll;
		document.getElementById('scrolldivscrollbar').onselectstart = cancelEvent;
		document.getElementById('scrolldivtheScroll').onmouseup = scrollDivstopScroll;
		if(document.all)document.body.onmouseup = scrollDivstopScroll; else document.documentElement.onmouseup = scrollDivstopScroll;
		document.getElementById('scrolldivscrollDown').onmousedown = scrolldivscrollButton;
		document.getElementById('scrolldivscrollUp').onmousedown = scrolldivscrollButton;
		document.getElementById('scrolldivscrollDown').onmouseup = scrolldivscrollButtonStop;
		document.getElementById('scrolldivscrollUp').onmouseup = scrolldivscrollButtonStop;
		document.getElementById('scrolldivscrollUp').onselectstart = cancelEvent;
		document.getElementById('scrolldivscrollDown').onselectstart = cancelEvent;
		document.getElementById('scrolldivscrollbar').onmousedown = scrolldivscrollMoveToInit;
	}
	/*
	Change from the default color
	*/	
	function scrolldivsetColor(rgbColor)
	{
		document.getElementById('scrolldivscrollbar').style.borderColor = rgbColor;
		document.getElementById('scrolldivtheScroll').style.backgroundColor = rgbColor;
		document.getElementById('scrolldivscrollUp').style.borderColor = rgbColor;
		document.getElementById('scrolldivscrollDown').style.borderColor = rgbColor;
		document.getElementById('scrolldivscrollUp').style.color = rgbColor;
		document.getElementById('scrolldivscrollDown').style.color = rgbColor;
		document.getElementById('scrolldivparentContainer').style.borderColor = rgbColor;
	}
	/*
	Setting total width of scrolling div
	*/
	function scrolldivsetWidth(newWidth)
	{
		document.getElementById('dhtmlgoodiesscrolldiv').style.width = newWidth + 'px';
		document.getElementById('scrolldivparentContainer').style.width = newWidth-30 + 'px';		
	}
	
	/*
	Setting total height of scrolling div
	*/
	function scrolldivsetHeight(newHeight)
	{
		document.getElementById('dhtmlgoodiesscrolldiv').style.height = newHeight + 'px';
		document.getElementById('scrolldivparentContainer').style.height = newHeight + 'px';
		document.getElementById('scrolldivslider').style.height = newHeight + 'px';
		document.getElementById('scrolldivscrollbar').style.height = newHeight-40 + 'px';		
	}
	/*
	Setting new background color to the slider 
	*/
	function setSliderBgColor(rgbColor)
	{
		document.getElementById('scrolldivscrollbar').style.backgroundColor = rgbColor;
		document.getElementById('scrolldivscrollUp').style.backgroundColor = rgbColor;
		document.getElementById('scrolldivscrollDown').style.backgroundColor = rgbColor;
	}
	/*
	Setting new content background color
	*/
	function setContentBgColor(rgbColor)
	{
		if (rgbColor!="none") document.getElementById('scrolldivparentContainer').style.backgroundColor = rgbColor;
	}
	
	/*
	Setting scroll button speed
	*/
	function setScrollButtonSpeed(newScrollButtonSpeed)
	{
		scrollbuttonSpeed = newScrollButtonSpeed;
	}
	/*
	Setting interval of the scroll
	*/
	function setScrollTimer(newInterval)
	{
		scrollTimer = newInterval;
	}