function C_Layer()
{
	var className;
	this.className = "C_Layer";
	var l_obj;
	var layerID;
	this.Show = Show;
	this.Hide = Hide;
	this.GetLeft = GetLeft;
	this.GetTop = GetTop;
	this.GetHeight = GetHeight;
	this.GetWidth = GetWidth;
	this.SetHeight = SetHeight;
	this.SetWidth = SetWidth;
	this.SetLeft = SetLeft;
	this.SetTop = SetTop;
	this.CreateByObj = CreateByObj;
	this.CreateByID = CreateByID;
	this.MoveToPos = MoveToPos;
	this.MoveWithDelta = MoveWithDelta;
	
	function CreateByObj(layerObj)
	{
		this.l_obj = layerObj;
		if(layerObj)
		{
			this.layerID = layerObj.id;
		}
		//dm(this.l_obj);
	}
	
	function CreateByID(layerID)
	{
		var layerObj;
		layerObj = GetObjByID(layerID);
		//dm(layerObj);
		this.CreateByObj(layerObj);
	}
	
	function GetLeft()
	{
		if(this.l_obj)
		{
			var obj = this.l_obj;
			var left = "0px";
			if(obj.style)
			{
				if(obj.style.left)
				{
					left = obj.style.left;
				}
			}
			var mv = new C_MeasuredValue(mu_px);
			mv.CreateByString(left);
			return(new Number(mv.GetValue()));
		}
		return(null);
	}
	
	function GetTop()
	{
		if(this.l_obj)
		{
			var obj = this.l_obj;
			var top = "0px";
			if(obj.style)
			{
				if(obj.style.top)
				{
					top = obj.style.top;
				}
			}
			var mv = new C_MeasuredValue(mu_px);
			mv.CreateByString(top);
			return(new Number(mv.GetValue()));
		}
		return(null);
	}
	
	function GetHeight()
	{
		if(this.l_obj)
		{
			var obj = this.l_obj;
			var height = "0px";
			dm(obj.style.left);
			if(obj.style.height)
			{
				height = obj.style.height;
			}
			else
			{
				if(obj.style.pixelHeight)
				{
					height = obj.style.pixelHeight;
				}
				else
				{
					if(obj.style.posHeight)
					{
						height = obj.style.posHeight;
					}
				}
			}
			dm(height);
			var mv = new C_MeasuredValue(mu_px);
			mv.CreateByString(height);
			return(new Number(mv.GetValue()));
		}
		return(null);
	}
	
	function GetWidth()
	{
		if(this.l_obj)
		{
			var obj = this.l_obj;
			var width = "0px";
			if(obj.style.width)
			{
				width = obj.style.width;
			}
			var mv = new C_MeasuredValue(mu_px);
			mv.CreateByString(width);
			return(new Number(mv.GetValue()));
		}
		return(null);
	}
	
	function SetWidth(width)
	{
		if(this.l_obj)
		{
			var obj = this.l_obj;
			var mv = new C_MeasuredValue(mu_px);
			mv.CreateByString(width);
			var widthNew = mv.GetMeasuredValue();
			obj.style.width = widthNew;
			return(0);
		}
		return(-1);
	}
	
	function SetHeight(height)
	{
		if(this.l_obj)
		{
			var obj = this.l_obj;
			var mv = new C_MeasuredValue(mu_px);
			mv.CreateByString(height);
			var heightNew = mv.GetMeasuredValue();
			obj.style.height = heightNew;
			return(0);
		}
		return(-1);
	}
	
	function SetLeft(left)
	{
		if(this.l_obj)
		{
			var obj = this.l_obj;
			//if(obj.style)
			//{
				//if(obj.style.left)
				//{
					//var str = "left elötte : " + left.toString();
					//str+= " obj.style.left elötte : " + obj.style.left.toString();
					
					var mv = new C_MeasuredValue(mu_px);
					mv.CreateByString(left);
					var leftNew = mv.GetMeasuredValue();
				
					//str+= " left utána: " + leftNew.toString();

					obj.style.left = leftNew;
					
					//str+= " obj.style.left utána: " + obj.style.left.toString();
					//window.status = str;
					return(0);
				//}
			//}
		}
		return(-1);
	}
	
	function SetTop(top)
	{
		if(this.l_obj)
		{
			var obj = this.l_obj;
			/*if(obj.style)
			{
				if(obj.style.top)
				{*/
					var mv = new C_MeasuredValue(mu_px);
					mv.CreateByString(top);
					var topNew = mv.GetMeasuredValue();
					obj.style.top = topNew;
					return(0);
				/*}
			}*/
		}
		return(-1);
	}
	
	function MoveToPos(x, y)
	{
		x = new Number(x);
		y = new Number(y);
		if(this.SetLeft(x) == 0)
		{
			return(this.SetTop(y));
		}
		return(-1);
	}
	
	function MoveWithDelta(dx, dy)
	{
		var dx = new Number(dx);
		var dy = new Number(dy);
		var x = this.GetLeft();
		var y = this.GetTop();
		if(!x)
		{
			x = 0;
		}
		if(!y)
		{
			y = 0;
		}
		x = new Number(x);
		y = new Number(y);
		if(dx == 0 || this.SetLeft(x + dx) == 0)
		{
			if(dy == 0 || this.SetTop(y + dy) == 0)
			{
				return(0);
			}
		}
		return(-1);
	}
	
	function Show()
	{
		if(this.l_obj)
		{
			var obj = this.l_obj;
			if(obj)
			{
				obj.style.display = "block";
				return(0);
			}
		}
		return(-1);
	}
	
	function Hide()
	{
		if(this.l_obj)
		{
			var obj = this.l_obj;
			if(obj)
			{
				obj.style.display = "none";
				return(0);
			}
		}
		return(-1);
	}
}

