// Windowドラック制御クラス.
function DragLayer()
{
	var offsetX = 0;
	var offsetY = 0;
	var mouseX = 0;
	var mouseY = 0;
	this.LayerObj = null;
	
	// ShowConsole.
	// id			対象のオブジェクトのid.
	this.ShowConsole = function(id)
	{
		var obj = null;
		
		obj = common.GetChildNode(document.getElementById(id), "console");
		if (obj != null)
		{
			obj.style.visibility = "inherit";
		}
		
		obj = common.GetChildNode(document.getElementById(id), "drag");
		if (obj != null)
		{
			obj = common.GetChildNode(obj, "max");
			if (obj != null)
			{
				obj.style.visibility = "hidden";
			}
		}
		
		obj = common.GetChildNode(document.getElementById(id), "drag");
		if (obj != null)
		{
			obj = common.GetChildNode(obj, "min");
			if (obj != null)
			{
				obj.style.visibility = "inherit";
			}
		}
	}
	
	// HiddenConsole.
	// id			対象のオブジェクトのid.
	this.HiddenConsole = function(id)
	{
		var obj = null;
		obj = common.GetChildNode(document.getElementById(id), "console");
		if (obj != null)
		{
			obj.style.visibility = "hidden";
		}
		
		obj = common.GetChildNode(document.getElementById(id), "drag");
		if (obj != null)
		{
			obj = common.GetChildNode(obj, "max");
			if (obj != null)
			{
				obj.style.visibility = "inherit";
			}
		}
		
		obj = common.GetChildNode(document.getElementById(id), "drag");
		if (obj != null)
		{
			obj = common.GetChildNode(obj, "min");
			if (obj != null)
			{
				obj.style.visibility = "hidden";
			}
		}
	}
	
	// Show.
	// id			対象のオブジェクトのid.
	this.Show = function(id)
	{
		this.LayerObj = document.getElementById(id);
		this.LayerObj.style.visibility = "visible";
	}
	
	// Close.
	// id			対象のオブジェクトのid.
	this.Close = function(id)
	{
		this.LayerObj = document.getElementById(id);
		this.LayerObj.style.visibility = "hidden";
		this.LayerObj = null;
	}
	
	
	// ドラッグ開始処理.
	// id			対象のオブジェクトのid.
	this.DragStart = function(id)
	{
		this.LayerObj = document.getElementById(id);
		offsetX = mouseX - parseInt(this.LayerObj.style.left);
		offsetY = mouseY - parseInt(this.LayerObj.style.top);
	}
	
	// ドラッグ終了処理.
	// id			対象のオブジェクトのid.
	this.DragEnd = function()
	{
		this.LayerObj = null;
	}
	
	// ドラッグ中の処理.
	this.Drag = function()
	{
		mouseX = currentDocument.ActiveMouseX;
		mouseY = currentDocument.ActiveMouseY;
		
		if (this.LayerObj)
		{
			this.LayerObj.style.left = mouseX - offsetX;
			this.LayerObj.style.top = mouseY - offsetY;
		}
		
		return false;
	}
}

