function moveDiv(divElement, autoClose)
{
	var mainObject = divElement;
	var movableObject = mainObject;
	var xRelative, yRelative;
	var moveFlag = false;
	var persistent = true;

	this.object = movableObject;

	var cpos = unescape(getCookie("DIV_POS_"+movableObject.id)).split("/");
	cpos = cpos[0].split(":");

	if(autoClose){
		persistent = false;
	}

	this.setMovableObject = function(divElement){
		movableObject = divElement;
		if(!is_ie || is_opera){
			this.object = movableObject;
			var top = document.documentElement.scrollTop;
		}
		else{
			object = movableObject;
			var top = window.scrollY;
		}
	}

	this.showMovable = function(innerObject, htmlText){
		if(innerObject && htmlText){
			innerObject.innerHTML = htmlText;
		}
		if (is_ie || is_opera){
			var top = document.documentElement.scrollTop;
		}
		else{
			var top = window.scrollY;
		}
		movableObject.style.top = (top+100) + 'px';
		movableObject.style.display = 'block';
	}

	this.addBeforeHTML = function(innerObject, htmlText){
		innerObject.innerHTML = htmlText + innerObject.innerHTML;
	}

	this.isOpen = function(){
		if(movableObject.style.display == 'none'){
			return false;
		}
		else{
			return true;
		}
	}

	this.hideMovable = function(divElement){
		movableObject.style.display = 'none';
	}

	var topLimit = function(clientY, yRelative){
		if (is_ie || is_opera){
			return (clientY - yRelative) > document.body.scrollTop;
		}
		else{
			return (clientY - yRelative) > window.scrollY;
		}
	}

	var bottomLimit = function(clientY, yRelative, height){
		if (is_ie || is_opera){
			return (clientY - yRelative + height) < document.body.clientHeight + document.body.scrollTop;
		}
		else{
			return (clientY - yRelative + height) < window.innerHeight + window.scrollY;
		}
	}

	var leftLimit = function(clientX, xRelative){
		if (is_ie || is_opera){
			return (clientX - xRelative) > document.body.scrollLeft;
		}
		else{
			return (clientX - xRelative) > window.scrollX;
		}
	}

	var rightLimit = function(clientX, xRelative, width){
		if (is_ie || is_opera){
			return (clientX - xRelative + width) < document.body.clientWidth + document.body.scrollLeft;
		}
		else{
			return (clientX - xRelative + width) < window.innerWidth + window.scrollX;
		}
	}

	var handleMouseDown = function(e){
		//var xRelative = e.clientX - parseInt(movableObject.style.left);
		//var yRelative = e.clientY - parseInt(movableObject.style.top);
		xRelative = e.clientX - parseInt(movableObject.offsetLeft);
		yRelative = e.clientY - parseInt(movableObject.offsetTop);
		moveFlag = true;
		if (!is_ie || is_opera){
			e.preventDefault();
		}
		else{
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
	}

	var handleMouseUp = function(e){
		moveFlag = false;
	}

	var handleMouseMove = function(e){
		if (moveFlag == true){
			if(leftLimit(e.clientX, xRelative) && rightLimit(e.clientX, xRelative, parseInt(movableObject.offsetWidth+20))){
				movableObject.style.left = e.clientX - xRelative + 'px';
			}
			if(topLimit(e.clientY, yRelative) && bottomLimit(e.clientY, yRelative, parseInt(movableObject.offsetHeight+30))){
				movableObject.style.top = e.clientY - yRelative + 'px';
			}

			if (!is_ie || is_opera){
				e.preventDefault();
			}
			else{
				window.event.cancelBubble = true;
				window.event.returnValue = false;
			}
		}
	}

	if(is_gecko){
		mainObject.addEventListener("mousedown", handleMouseDown, true);
		document.addEventListener("mouseup", handleMouseUp, true);
		document.addEventListener("mousemove", handleMouseMove, true);
	}
	else{
		mainObject.attachEvent("onmousedown", handleMouseDown);
		document.attachEvent("onmouseup", handleMouseUp);
		document.attachEvent("onmousemove", handleMouseMove);
	}
}