 		vp = vp_pl[placement]
 
 		# console.debug "Layer.position: Placement:", placement, "Wanted:", wanted_placement, "Allowed:", allowed_placements, "Viewports:", vp_pl, @
+
+		# console.info "PLACEMENT --- ", placement, "---"
+		# console.debug "Layer POS", vp.layer_pos, "align:", vp.align_horizontal, "/", vp.align_vertical, "overlap:", vp.overlap_align, vp.push_left, vp.push_right
+		# console.debug "Pointer POS", vp.pointer_pos, "align:", vp.pointer_align_horizontal, "/", vp.pointer_align_vertical
 
 		# set layer
 		CUI.DOM.setStyle @__layer.DOM,

							vp.overlap_height = Math.min(vp.window_right - layer_pos.right, overlap_width)
							layer_pos.width = layer_pos.width + vp.overlap_width

			if vp.dim_pointer
				# now align the pointer within the available viewport
				switch vp.pointer_align_horizontal
					when "left"
						pointer_pos.left = dim_element.viewportRight + vp.dim_pointer.marginLeft
					when "right"
						pointer_pos.left = dim_element.viewportLeft - vp.dim_pointer.borderBoxWidth - vp.dim_pointer.marginLeft
					when "center"
						pointer_pos.left = dim_element.viewportCenterHorizontal - vp.dim_pointer.borderBoxWidth / 2

				switch vp.pointer_align_vertical
					when "top"
						pointer_pos.top = dim_element.viewportBottom + vp.dim_pointer.marginTop
					when "bottom"
						pointer_pos.top = dim_element.viewportTop - vp.dim_pointer.marginBoxHeight + vp.dim_pointer.marginTop
					when "center"
						pointer_pos.top = dim_element.viewportCenterVertical - vp.dim_pointer.borderBoxHeight / 2

				pointer_pos.width = vp.dim_pointer.borderBoxWidth
				pointer_pos.height = vp.dim_pointer.borderBoxHeight
				pointer_pos.direction = vp.dim_pointer.direction

			if @_onPosition
				# link dimensions, so the callback can

				when "center"
					layer_pos.top = dim_element.viewportCenterVertical - layer_pos.height / 2


			if vp.dim_pointer
				# now align the pointer within the available viewport
				switch vp.pointer_align_horizontal
					when "left"
						pointer_pos.left = dim_element.viewportRight + vp.dim_pointer.marginLeft
					when "right"
						pointer_pos.left = dim_element.viewportLeft - vp.dim_pointer.borderBoxWidth - vp.dim_pointer.marginLeft
					when "center"
						pointer_pos.left = dim_element.viewportCenterHorizontal - vp.dim_pointer.borderBoxWidth / 2

				switch vp.pointer_align_vertical
					when "top"
						pointer_pos.top = dim_element.viewportBottom + vp.dim_pointer.marginTop
					when "bottom"
						pointer_pos.top = dim_element.viewportTop - vp.dim_pointer.marginBoxHeight + vp.dim_pointer.marginTop
					when "center"
						pointer_pos.top = dim_element.viewportCenterVertical - vp.dim_pointer.borderBoxHeight / 2

				pointer_pos.width = vp.dim_pointer.borderBoxWidth
				pointer_pos.height = vp.dim_pointer.borderBoxHeight
				pointer_pos.direction = vp.dim_pointer.direction


			# move layer into viewport in case we overlap
			if layer_pos.top < vp.top
				layer_pos.top = vp.top
