function moveLayer(layer, dragEle)
{

	/// ·¹ÀÌ¾î ///
	this.layer = $(layer);


	/// ¸®»çÀÌÁî ÀÌº¥Æ® DIV ///
	this.N = null;

	this.E = null;

	this.W = null;

	this.S = null;

	this.NW = null;

	this.SW = null;

	this.NE = null;

	this.SE = null;


	/// ¸®»çÀÌÁî °¡´É À¯¹« ///
	this.resizeObjN = null;

	this.resizeObjE = null;

	this.resizeObjW = null;

	this.resizeObjS = null;

	this.resizeObjNW = null;

	this.resizeObjSW = null;

	this.resizeObjNE = null;

	this.resizeObjSE = null;


	/// µå·¡±× ÀÌº¥Æ® DIV ///
	this.dragEle = $(dragEle);

	
	/// µå·¡±× °¡´É À¯¹« ///
	this.dragObj = null;

	
	/// ¸¶¿ì½º¸¦ Å¬¸¯ÇßÀ» ¶§ À§Ä¡ ///
	this.mouseDownPos = null;

	
	/// ¸¶¿ì½º°¡ ÀÌµ¿ÇÑ À§Ä¡ ///
	this.mouseMovePos = null;

	
	/// ¸¶¿ì½º Å¬¸¯ÇßÀ» ¶§ ¿¤·¹¸ÕÆ®ÀÇ À§Ä¡ ///
	this.moveEleOffset = null;

	
	
	/// z-index °ªÀ» ±¸ÇÑ´Ù. ///
	///IE7 Â¯³ª.¤Ð¤Ð ///
	this.zindex = 0;

	this.getZindex();


	/// ÃÊ±âÈ­ ÇÔ¼ö ½ÇÇà ///
	this.init();
}



moveLayer.prototype.getZindex = function()
{
	var child = this.layer.childNodes;

	for(var i=0; i < child.length; i++)
	{
		if(child[i].style)
		{
			if(child[i].style.zIndex)
			{
				this.zindex = (parseInt(child[i].style.zIndex) > this.zindex) ? parseInt(child[i].style.zIndex) : this.zindex;

			} else {
				child[i].style.zIndex = 1;
			}
		}
	}
}



///  ÃÊ±âÈ­ ÇÔ¼ö  ///
moveLayer.prototype.init = function ()
{
	this.layer.style.position = "absolute";

	this.layer.style.overflow = "hidden";


	/// ¸®»çÀÌÁî ÀÌº¥Æ®°¡ ³ªÅ¸³ª´Â DIV »ý¼º ///
	/// ½±°Ô µ¿ÂÊÀº e ¼­ÂÊÀº w ÀÌ·±½ÄÀ» ÀÛ¸í ///
	this.createN();

	this.createE();

	this.createW();

	this.createS();

	this.createNW();

	this.createSW();

	this.createNE();

	this.createSE();

	
	/// µå·¡±× ÀÌº¥Æ® ÇÔ¼ö ///
	this.dragEvent();

	
	/// ¸®»çÀÌÁî ÀÌº¥Æ® ÇÔ¼ö ///
	this.resizeEvent();


	var oThis = this;

	/// µå·¡±× Á¾·á ///
	
	document.observe("mouseup", function(evt)
	{
		oThis.dragObj = null;

		oThis.resizeObjN = null;

		oThis.resizeObjE = null;

		oThis.resizeObjW = null;

		oThis.resizeObjS = null;

		oThis.resizeObjNW = null;

		oThis.resizeObjSW = null;

		oThis.resizeObjNE = null;

		oThis.resizeObjSE = null;
	});
	

	/// µå·¡±× ///
	document.observe("mousemove", function(evt) {
		if(!oThis.dragObj && !oThis.resizeObjN && !oThis.resizeObjE && !oThis.resizeObjW && !oThis.resizeObjS && !oThis.resizeObjNW && !oThis.resizeObjSW && !oThis.resizeObjNE && !oThis.resizeObjSE) return false;
		

		if(oThis.dragObj)
		{
			oThis.mouseMovePos = oThis.mousePositon(evt);

			/// ¸¶¿ì½º°¡ ¿òÁ÷ÀÎ °Å¸®¸¸Å­ ¿¤·¹¸ÕÆ®À§Ä¡µµ ¼öÁ¤ ///
			var left = oThis.moveEleOffset.x + (oThis.mouseMovePos.x - oThis.mouseDownPos.x);
			var top = oThis.moveEleOffset.y + (oThis.mouseMovePos.y - oThis.mouseDownPos.y);

			/// ÀÌµ¿ Á¦ÇÑ ¼³Á¤ ///
			left = (left < 0) ? 0 : left;
			top = (top < 0) ? 0 : top;

			/// ¸¶¿ì½º°¡ ÀÌµ¿ÇÑ °Å¸®¸¸Å­ ÀÌµ¿ ///
			oThis.layer.style.left = left + "px";
			oThis.layer.style.top = top + "px";

			setCookie('posleft',left,1);
			setCookie('postop',top,1);

			return false;

		} else if(oThis.resizeObjN) {

			// ºÏÂÊ ¸®»çÀÌÁî
			oThis.rN(evt);

		} else if(oThis.resizeObjE) {

			// µ¿ÂÊ ¸®»çÀÌÁî
			oThis.rE(evt);
		
		} else if(oThis.resizeObjW) {

			// ¼­ÂÊ ¸®»çÀÌÁî
			oThis.rW(evt);

		} else if(oThis.resizeObjS) {
			
			// ³²ÂÊ ¸®»çÀÌÁî
			oThis.rS(evt);

		} else if(oThis.resizeObjNE) {
			
			// ºÏµ¿ÂÊ ¸®»çÀÌÁî
			oThis.rN(evt);
			
			oThis.rE(evt);

		} else if(oThis.resizeObjSE) {
			
			// ³²µ¿ÂÊ ¸®»çÀÌÁî
			oThis.rS(evt);

			oThis.rE(evt);

		} else if(oThis.resizeObjNW) {

			// ºÏ¼­ÂÊ ¸®»çÀÌÁî
			oThis.rN(evt);

			oThis.rW(evt);

		} else if(oThis.resizeObjSW) {

			// ³²¼­ÂÊ ¸®»çÀÌÁî
			oThis.rS(evt);

			oThis.rW(evt);

		}
	}); 

}


moveLayer.prototype.rN = function(evt)
{
	oThis = this;

	oThis.mouseMovePos = oThis.mousePositon(evt);

	/// ¸¶¿ì½º°¡ ¿òÁ÷ÀÎ °Å¸®¸¸Å­ ¸®»çÀÌÁî ///
	var height = oThis.moveEleOffset.h + (oThis.mouseDownPos.y - oThis.mouseMovePos.y);
			
	/// ¸¶¿ì½º°¡ ¿òÁ÷ÀÎ °Å¸®¸¸Å­ ¿¤·¹¸ÕÆ®À§Ä¡µµ ¼öÁ¤ ///
	var top = oThis.moveEleOffset.y + (oThis.mouseMovePos.y - oThis.mouseDownPos.y)
			
	/// ¸®»çÀÌÁî Á¦ÇÑ ¼³Á¤ ///
	if(height < 50) return false;

	if(top < 0) return false;

	oThis.layer.style.height = height + "px";
		
	oThis.layer.style.top = top + "px";


	oThis.W.style.height = height - 6 + "px";

	oThis.E.style.height = height - 6 + "px";

	return false;
}



moveLayer.prototype.rE = function(evt)
{
	oThis = this;
	
	oThis.mouseMovePos = oThis.mousePositon(evt);

	/// ¸¶¿ì½º°¡ ¿òÁ÷ÀÎ °Å¸®¸¸Å­ ¸®»çÀÌÁî ///
	var width = oThis.moveEleOffset.w + (oThis.mouseMovePos.x - oThis.mouseDownPos.x);
			
	/// ¸®»çÀÌÁî Á¦ÇÑ ¼³Á¤ ///
	if(width < 50) return false;

		
	oThis.layer.style.width = width + "px";

	
	oThis.S.style.width = width - 6 + "px";

	oThis.N.style.width = width - 6 + "px";

	return false;
}



moveLayer.prototype.rW = function(evt)
{
	oThis = this;
	
	oThis.mouseMovePos = oThis.mousePositon(evt);

	/// ¸¶¿ì½º°¡ ¿òÁ÷ÀÎ °Å¸®¸¸Å­ ¸®»çÀÌÁî ///
	var width = oThis.moveEleOffset.w + (oThis.mouseDownPos.x - oThis.mouseMovePos.x);

	/// ¸¶¿ì½º°¡ ¿òÁ÷ÀÎ °Å¸®¸¸Å­ ¿¤·¹¸ÕÆ®À§Ä¡µµ ¼öÁ¤ ///
	var left = oThis.moveEleOffset.x + (oThis.mouseMovePos.x - oThis.mouseDownPos.x);
			
	/// ¸®»çÀÌÁî Á¦ÇÑ ¼³Á¤ ///
	if(width < 50) return false;

	if(left < 0) return false;

			
	oThis.layer.style.width = width + "px";

	oThis.layer.style.left = left + "px";

	
	oThis.S.style.width = width - 6 + "px";

	oThis.N.style.width = width - 6 + "px";

	return false;
}



moveLayer.prototype.rS = function(evt)
{
	oThis = this;
	
	oThis.mouseMovePos = oThis.mousePositon(evt);

	/// ¸¶¿ì½º°¡ ¿òÁ÷ÀÎ °Å¸®¸¸Å­ ¸®»çÀÌÁî ///
	var height = oThis.moveEleOffset.h + (oThis.mouseMovePos.y - oThis.mouseDownPos.y);
						
	/// ¸®»çÀÌÁî Á¦ÇÑ ¼³Á¤ ///
	if(height < 50) return false;

	oThis.layer.style.height = height + "px";

	
	oThis.W.style.height = height - 6 + "px";

	oThis.E.style.height = height - 6 + "px";
			
	return false;
}



moveLayer.prototype.createEle = function()
{
	var nd = new Element("div");

	this.layer.appendChild(nd);

	nd.style.position = "absolute";

	nd.style.backgroundColor = "#333";

	nd.setOpacity(0)

	nd.style.zIndex = parseInt(this.zindex) + 1;

	return nd;
}



moveLayer.prototype.createN = function()
{
	this.N = this.createEle();

	this.N.style.top = "-17px";

	this.N.style.left = "3px";

	this.N.style.width = this.layer.offsetWidth - 6 + "px";

	this.N.style.height = "20px";
}



moveLayer.prototype.createS = function()
{
	this.S = this.createEle(); 

	this.S.style.bottom = "-17px";

	this.S.style.left = "3px";

	this.S.style.width = this.layer.offsetWidth - 6 + "px";

	this.S.style.height = "20px";
}



moveLayer.prototype.createW = function()
{
	this.W = this.createEle();

	this.W.style.top = "3px";

	this.W.style.left = "0px";

	this.W.style.height = this.layer.offsetHeight - 6 + "px";

	this.W.style.width = "3px";
}



moveLayer.prototype.createE = function()
{
	this.E = this.createEle();

	this.E.style.top = "3px";

	this.E.style.right = "0px";

	this.E.style.height = this.layer.offsetHeight - 6 + "px";

	this.E.style.width = "3px";
}



moveLayer.prototype.createNW = function()
{
	this.NW = this.createEle();

	this.NW.style.top = "-17px";

	this.NW.style.left = "0px";

	this.NW.style.width = "3px";

	this.NW.style.height = "20px";
}



moveLayer.prototype.createSW = function()
{
	this.SW = this.createEle();

	this.SW.style.bottom = "-17px";

	this.SW.style.left = "0px";

	this.SW.style.width = "3px";

	this.SW.style.height = "20px";
}


moveLayer.prototype.createNE = function()
{
	this.NE = this.createEle();

	this.NE.style.top = "-17px";

	this.NE.style.right = "0px";

	this.NE.style.width = "3px";

	this.NE.style.height = "20px";
}



moveLayer.prototype.createSE = function()
{
	this.SE = this.createEle();

	this.SE.style.bottom = "-17px";

	this.SE.style.right = "0px";

	this.SE.style.width = "3px";

	this.SE.style.height = "20px";
}



/// µå·¡±× ÀÌº¥Æ® ÇÔ¼ö ///
moveLayer.prototype.dragEvent = function()
{
	/// ÀÌº¥Æ® ¸Þ¼­µå ¾È¿¡¼­ this¸¦ »ç¿ëÇÏ¸é ÀÌº¥Æ®°¡ ¹ß»ýÇÏ´Â °´Ã¼¸¦ °¡¸£Å°¹Ç·Î. ///
	var oThis = this;

	this.dragEle.observe("mouseover", function(evt) 
	{
		oThis.dragEle.style.cursor = "move";
	});

	this.dragEle.observe("mousedown", function(evt) 
	{
		oThis.dragObj = evt.element();
		oThis.mouseDownPos = oThis.mousePositon(evt);
			
		oThis.moveEleOffset = {
			x : oThis.layer.offsetLeft,
			y : oThis.layer.offsetTop			
		}
		
		return false;
	});
}



/// ¸¶¿ì½ºÀÇ À§Ä¡ °Ë»ö ///
moveLayer.prototype.mousePositon = function(evt)
{	
	var Pos = {
		x : evt.pointerX(),
		y : evt.pointerY()
	}

	return Pos;
}



/// ¸®»çÀÌÁî ÀÌº¥Æ® ÇÔ¼ö ///
moveLayer.prototype.resizeEvent = function()
{
	this.resizeN();

	this.resizeE();

	this.resizeW();

	this.resizeS();

	this.resizeNE();

	this.resizeSE();

	this.resizeNW();

	this.resizeSW();
}



moveLayer.prototype.resizeN = function()
{
	var oThis = this;


	this.N.observe("mouseover", function(evt) 
	{
		oThis.N.style.cursor = "row-resize";
	});



	this.N.observe("mousedown", function(evt) 
	{
		oThis.resizeObjN = evt.element();
		oThis.mouseDownPos = oThis.mousePositon(evt);

		oThis.moveEleOffset = {
			x : oThis.layer.offsetLeft,
			y : oThis.layer.offsetTop,	
			w : oThis.layer.offsetWidth,
			h : oThis.layer.offsetHeight			
		}
			
		return false;
	});
}



moveLayer.prototype.resizeE = function()
{
	var oThis = this;


	this.E.observe("mouseover", function(evt) 
	{
		oThis.E.style.cursor = "col-resize";
	});


	this.E.observe("mousedown", function(evt) 
	{
		oThis.resizeObjE = evt.element();
		oThis.mouseDownPos = oThis.mousePositon(evt);

		oThis.moveEleOffset = {
			x : oThis.layer.offsetLeft,
			y : oThis.layer.offsetTop,	
			w : oThis.layer.offsetWidth,
			h : oThis.layer.offsetHeight			
		}
			
		return false;
	});
}



moveLayer.prototype.resizeW = function()
{
	var oThis = this;


	this.W.observe("mouseover", function(evt) 
	{
		oThis.W.style.cursor = "col-resize";
	});


	this.W.observe("mousedown", function(evt) 
	{
		oThis.resizeObjW = evt.element();
		oThis.mouseDownPos = oThis.mousePositon(evt);

		oThis.moveEleOffset = {
			x : oThis.layer.offsetLeft,
			y : oThis.layer.offsetTop,	
			w : oThis.layer.offsetWidth,
			h : oThis.layer.offsetHeight			
		}
			
		return false;
	});
}


moveLayer.prototype.resizeS = function()
{
	var oThis = this;


	this.S.observe("mouseover", function(evt) 
	{
		oThis.S.style.cursor = "row-resize";
	});


	this.S.observe("mousedown", function(evt)
	{
		oThis.resizeObjS = evt.element();
		oThis.mouseDownPos = oThis.mousePositon(evt);

		oThis.moveEleOffset = {
			x : oThis.layer.offsetLeft,
			y : oThis.layer.offsetTop,	
			w : oThis.layer.offsetWidth,
			h : oThis.layer.offsetHeight			
		}
			
		return false;
	});
}


moveLayer.prototype.resizeNE = function()
{
	var oThis = this;


	this.NE.observe("mouseover", function(evt) 
	{
		oThis.NE.style.cursor = "ne-resize";
	});


	this.NE.observe("mousedown", function(evt)
	{
		oThis.resizeObjNE = evt.element();
		oThis.mouseDownPos = oThis.mousePositon(evt);

		oThis.moveEleOffset = {
			x : oThis.layer.offsetLeft,
			y : oThis.layer.offsetTop,	
			w : oThis.layer.offsetWidth,
			h : oThis.layer.offsetHeight			
		}
			
		return false;
	});
}


moveLayer.prototype.resizeSE = function()
{
	var oThis = this;


	this.SE.observe("mouseover", function(evt) 
	{
		oThis.SE.style.cursor = "nw-resize";
	});


	this.SE.observe("mousedown", function(evt)
	{
		oThis.resizeObjSE = evt.element();
		oThis.mouseDownPos = oThis.mousePositon(evt);

		oThis.moveEleOffset = {
			x : oThis.layer.offsetLeft,
			y : oThis.layer.offsetTop,	
			w : oThis.layer.offsetWidth,
			h : oThis.layer.offsetHeight			
		}
			
		return false;
	});
}



moveLayer.prototype.resizeNW = function()
{
	var oThis = this;


	this.NW.observe("mouseover", function(evt) 
	{
		oThis.NW.style.cursor = "nw-resize";
	});


	this.NW.observe("mousedown", function(evt)
	{
		oThis.resizeObjNW = evt.element();
		oThis.mouseDownPos = oThis.mousePositon(evt);

		oThis.moveEleOffset = {
			x : oThis.layer.offsetLeft,
			y : oThis.layer.offsetTop,	
			w : oThis.layer.offsetWidth,
			h : oThis.layer.offsetHeight			
		}
			
		return false;
	});
}



moveLayer.prototype.resizeSW = function()
{
	var oThis = this;


	this.SW.observe("mouseover", function(evt) 
	{
		oThis.SW.style.cursor = "ne-resize";
	});


	this.SW.observe("mousedown", function(evt)
	{
		oThis.resizeObjSW = evt.element();
		oThis.mouseDownPos = oThis.mousePositon(evt);

		oThis.moveEleOffset = {
			x : oThis.layer.offsetLeft,
			y : oThis.layer.offsetTop,	
			w : oThis.layer.offsetWidth,
			h : oThis.layer.offsetHeight			
		}
			
		return false;
	});
}