



function RSPDragger( e, f, min, max )
{
	this.dragging = false;
	this.f        = f;
	this.max      = max == null ? 800 : max;
	this.min      = min == null ? 300 : min;



	RSPDragger.prototype.getMousePosition = function( e, f )
	{
		if ( e.pageX || e.pageY )
		{
			return {
				x: e.pageX,
				y: e.pageY
			};
		}
		else if ( e.clientX || e.clientY )
		{
			return {
				x: e.clientX + f.body.scrollLeft + f.documentElement.scrollLeft,
				y: e.clientY + f.body.scrollTop  + f.documentElement.scrollTop
			};
		}

		return null;
	};



	RSPDragger.prototype.assignMouseEvents = function( f )
	{
		f.onmousemove = function( event )
		{
			if ( !_this.dragging )
			{
				return false;
			}

			if ( !event )
			{
				event = window.event;
			}

			var mouse    = _this.getMousePosition(event,f);

			if ( mouse.x < _this.min )
			{
				mouse.x    = _this.min;
			}
			else if ( mouse.x > _this.max )
			{
				mouse.x    = _this.max;
			}

			var dx       = mouse.x - _this.mouse.x;
			_this.mouse  = mouse;

			var ex       = parseInt(e.offsetLeft);
			e.style.left = ( ex + dx ) + 'px';

			_this.f(dx);

			/**
			if ( _this.dmm )
			{
				_this.dmm(v);
			}
			/**/

			return false;
		};

		f.onmouseup   = function( event )
		{
			_this.dragging = false;
			document.getElementById('d_cover').style.zIndex = -1;

			f.onmousemove = _this.dmm;
			f.onmouseup   = _this.dmu;

			parent.window.gmap.checkResize();
		};
	};



	var _this = this;
	e.onmousedown = function( event )
	{
		if ( !event )
		{
			event = window.event;
		}

		document.getElementById('d_cover').style.zIndex = 4;

		_this.dmm      = document.onmousemove;
		_this.dmu      = document.onmouseup;
		_this.dragging = true;
		_this.mouse    = _this.getMousePosition(event,document);

		_this.assignMouseEvents(document);

		return false;
	}
}





