function showLayerXY(id, x, y)
{
	var element = getObject(id);

	if(element)
	{
		setObjectX(element, x);
		setObjectY(element, y);
	}
}

/*
 * direction = "top" | "left" | "right" | "bottom"
 * align     = "top" | "left" | "right" | "bottom | "center"
 */
function showLayerObjectAligned(id, obj, direction, align)
{
	var element = getObject(id);
	var source = getObject(obj);
	
	var x, y;
	
	if(element && source)
	{
		var sx = getObjectX(source);
		var sy = getObjectY(source);
		var sw = getObjectWidth(source);
		var sh = getObjectHeight(source);

		var dw = getObjectWidth(element);
		var dh = getObjectHeight(element);
		
		//if(sx && sy && sw && sh && dw && dh)
		{
	
			if(direction == "top")
			{
				if(align == "left")
				{
					x = sx;
					y = sy - dh;
				}
				
				if(align == "center")
				{
					x = sw / 2 + sx - dw / 2;
					y = sy - dh;
				}
				
				if(align == "right")
				{
					x = sx + sw - dw;
					y = sy - dh;
				}
			}
			
			if(direction == "left")
			{
				if(align == "top")
				{
					x = sx - dw;
					y = sy;
				}
				
				if(align == "bottom")
				{
					x = sx - dw;
					y = sy + sh - dh;
				}
				
				if(align == "center")
				{
					x = sx - dw;
					y = sh / 2 + sy - dh / 2;
				}
			}
			
			if(direction == "right")
			{
				if(align == "top")
				{
					x = sx + sw;
					y = sy;
				}
				
				if(align == "bottom")
				{
					x = sx + sw;
					y = sy + sh - dh;
				}
				
				if(align == "center")
				{
					x = sx + sw;
					y = sh / 2 + sy - dh / 2;
				}
			}
			
			if(direction == "bottom")
			{
				if(align == "left")
				{
					x = sx;
					y = sy + sh;
				}
				
				if(align == "center")
				{
					x = sw / 2 + sx - dw / 2;
					y = sy + sh;
				}
				
				if(align == "right")
				{
					x = sx + sw - dw;
					y = sy + sh;
				}
			}
			
			showLayerXY(id, x, y);
		}
	}
}

function hideLayer(id)
{
	var element = getObject(id);

	if(element)
	{
		setObjectX(element, -999);
		setObjectY(element, -9999);
	}
}