 var dragobject	= {
	z:	0,
	// x,y are the mouse pixel coords when the mouse is clicked (before dragging)
	x:	0,
	y:	0,
	// offsetx, offsety are the targobj's pixel coords when the mouse is clikced (before dragging)
	offsetx	: null,
	offsety	: null,
	maxleft: null,
	maxtop: null,
	maxbott: null,
	maxright: null,
	targetobj	: null,
	contobj	: null,
	dragapproved	: 0,
	initialize	: function() {
		document.onmousedown=this.drag;
		document.onmouseup	= function() { 
			this.dragapproved=0;
/*
alert(this.maxleft);
alert(this.contobj.style.left);
alert(this.targetobj.style.left);
*/
		}
	},
	drag	: function(e) {
		var evtobj	= (window.event) ? window.event : e;
		var clickedObj	= (window.event) ? event.srcElement : e.target;
		var tObj	= document.getElementById(clickedObj.id.replace("Handle",""));
		this.targetobj	= (tObj) ? tObj : clickedObj;
		if (this.targetobj.className.match("drag")){
			this.dragapproved	= 1;
			setStylePos(this.targetobj);
			this.offsetx	= parseInt(this.targetobj.style.left);
			this.offsety	= parseInt(this.targetobj.style.top);
			this.x	= evtobj.clientX;
			this.y	= evtobj.clientY;
			if (evtobj.preventDefault) {
				evtobj.preventDefault();
			}
			this.contobj	= document.getElementById("container");
			if (this.contobj) {
				setStylePos(this.contobj);
				this.maxleft	= parseInt(this.contobj.style.left);
				this.maxtop	= parseInt(this.contobj.style.top);
				this.maxright	= this.maxleft + this.contobj.clientWidth;
				this.maxbott	= this.maxtop + this.contobj.clientHeight;
			}
			document.onmousemove=dragobject.moveit;
		}
	},
	moveit:function(e){
		var evtobj=window.event? window.event : e;
		if (this.dragapproved==1) {
			var newleft	= this.offsetx + evtobj.clientX - this.x;
			var newtop	= this.offsety + evtobj.clientY - this.y;
			if (this.maxleft) {
				if (newleft < this.maxleft) {
					newleft	= this.maxleft;
				}
				if (newleft + evtobj.clientWidth > this.maxright) {
					newleft	= this.maxleft;
				}
			}
			if (this.maxtop) {
				if (newtop < this.maxtop) {
					newtop	= this.maxtop;
				}
				if (newtop + evtobj.clientHeight > this.maxbott) {
					newtop	= this.maxtop;
				}
			}
//DEBUGPANE.innerHTML	+= newleft + " =? " + this.maxleft  + "<BR>\n";
			this.targetobj.style.left	= newleft + "px";
			this.targetobj.style.top	= newtop + "px";
			return false;
		}
	}
 }

 function setStylePos(obj) {
	if (!isNaN(parseInt(obj.style.top))) { return; }
	var objLeft	= 0;
	var objTop	= 0;
	if (obj.style.position	!= "relative") {
		var tmp	= obj;
//DEBUGPANE.innerHTML	+= "ID: " + obj.id + ", POS: " + obj.style.position + ", parent: " + tmp.offsetParent + "<BR>\n";
		objLeft	= tmp.offsetLeft;
		objTop	= tmp.offsetTop;
		while ((tmp = tmp.offsetParent) != null) {
			objLeft	+= tmp.offsetLeft;
			objTop	+= tmp.offsetTop;
		}
	}
//DEBUGPANE.innerHTML	+=  obj.className + ":" + objLeft + "<BR>\n";
	obj.style.left	= objLeft + "px";
	obj.style.top	= objTop + "px";
 }
