function Dragger(dragdrops)
{		
	this.draggables = dragdrops;	
	this.mouseOffset = null;		
	var that = this;
	this.width = 730;
	
	document.onmousemove = function(e){that.mouseMove(e)};
    document.onmouseup   = function(e){that.mouseUp(e)};

	this.init();
}

Dragger.prototype.init = function()
{	
	var that = this;
	for(var i=0; i<this.draggables.length; i++)
	{		
		for(var j=0; j<this.draggables[i].length; j++)
		{			
			this.makeDraggable($(that.draggables[i][j]));			
		}
	}
}

Dragger.prototype.mouseCoords = function(e)
{
	if(e.pageX || e.pageY)
	{
		return {x:e.pageX, y:e.pageY};
	}
	return {
				x:e.clientX + document.body.scrollLeft - document.body.clientLeft,
				y:e.clientY + document.body.scrollTop  - document.body.clientTop
		   };
}

Dragger.prototype.getMouseOffset = function(target, e)
{
	e = e || window.event;
	var docPos    = this.getPosition(target);
	var mousePos  = this.mouseCoords(e);
	return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
}

Dragger.prototype.getPosition = function(e)
{
	var left = 0;
	var top  = 0;

	while (e.offsetParent)
	{
		left += e.offsetLeft;
		top  += e.offsetTop;
		e = e.offsetParent;
	}

	left += e.offsetLeft;
	top  += e.offsetTop;
	return {x:left, y:top};
}

Dragger.prototype.makeDraggable = function(item)
{		
	var that = this;	
	item.onmousedown = function(e)
	{					
		that.dragObject  = this;		
		that.dragObject.style.position = 'absolute';			
		that.dragObject.style.cursor = 'move';
		that.mouseOffset = that.getMouseOffset(that.dragObject, e);		
		return false; 
	};	
}

Dragger.prototype.mouseMove = function(e)
{			
	e = e || window.event;
	var that = this;
	var mousePos = that.mouseCoords(e);		
	if(that.dragObject)
	{				
		if( ((mousePos.x - that.mouseOffset.x) + that.width) < screen.availWidth && (mousePos.x - that.mouseOffset.x) > 10)
		{
			that.dragObject.style.left = ((mousePos.x - that.mouseOffset.x) ) + 'px';
			that.dragObject.style.top = ((mousePos.y - that.mouseOffset.y) ) + 'px';
			that.moveEnd();
		}
		return false;				
	}
}

Dragger.prototype.mouseUp = function(e)
{	
	e = e || window.event;
	if(this.dragObject)
	{
		this.dragObject.style.cursor = 'default';
	}
	this.dragEnd(e);
}

Dragger.prototype.dragEnd = function(e)
{	
	try
    {			
		if(!this.dragObject) return;		
		this.dragObject = null;		
		return;				  						
	}
	catch(err)
	{
		alert(err.message + ' dragEnd');
	}
}

Dragger.prototype.moveEnd = function()
{	
	try
    {	
		if(!this.dragObject) return;		
		
		var offset = (parseInt(this.dragObject.style.left.replace('px','')));											
	}
	catch(err)
	{
		alert(err.message + ' Moveend');
	}
}