function startScrollUp()
{
	timer = setInterval("moveUp()", 10);
}

function startScrollDown()
{
	timer2 = setInterval("moveDown()", 10);
}

function stopScrollUp()
{
	clearInterval(timer);
}

function stopScrollDown()
{
	clearInterval(timer2);
}

function moveUp()
{
	if((parseInt(document.getElementById("scroller").style.top) - decal) > 0)
		document.getElementById("scroller").style.top = parseInt(document.getElementById("scroller").style.top) - decal+'px'
	else
		document.getElementById("scroller").style.top = '0px'
	var scrollY = parseInt(document.getElementById("scroller").style.top);
	var docY = 0 - (scrollY * (scroller.docH - scroller.contH) / scroller.scrollDist);
	document.getElementById("content").style.top = docY + "px";
}

function moveDown()
{
	if((parseInt(document.getElementById("scroller").style.top) + decal) < scroller.scrollDist)
		document.getElementById("scroller").style.top = parseInt(document.getElementById("scroller").style.top) + decal+'px'
	else
		document.getElementById("scroller").style.top = scroller.scrollDist+'px'
	var scrollY = parseInt(document.getElementById("scroller").style.top);
	var docY = 0 - (scrollY * (scroller.docH - scroller.contH) / scroller.scrollDist);
	document.getElementById("content").style.top = docY + "px";
}



var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= true ;
		o.vmode			= true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if ( isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if ( isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if ( isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if ( isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper =  null;
		o.yMapper =  null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.root.style.top);
		var x = parseInt(o.root.style.left);
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
		if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;

		if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
		if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		
		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.root.style.top);
		var x = parseInt(o.root.style.left);
		var nx, ny;

		if (o.minX != null) ex = Math.max(ex, o.minMouseX);
		if (o.maxX != null) ex = Math.min(ex, o.maxMouseX);
		if (o.minY != null) ey = Math.max(ey, o.minMouseY);
		if (o.maxY != null) ey = Math.min(ey, o.maxMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		Drag.obj.root.style.left = nx + "px";
		Drag.obj.root.style.top = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style.left), 
									parseInt(Drag.obj.root.style.top));
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};