docs: public static int positionElementInside(Element element, Element parent, int currentIndex, int x, int y) {
  
          if ((x == -1) && (y == -1)) {
              // this is wrong usage, do nothing
              CmsDebugLog.getInstance().printLine("this is wrong usage, doing nothing");
              return currentIndex;
          }
          int indexCorrection = 0;
          int previousTop = 0;
          for (int index = 0; index < parent.getChildCount(); index++) {
              Node node = parent.getChild(index);
              if (node.getNodeType() != Node.ELEMENT_NODE) {
                  continue;
              }
              Element child = (Element)node;
              if (child == element) {
                  indexCorrection = 1;
              }
              String positioning = CmsDomUtil.getCurrentStyle(child, Style.position);
              if (Position.ABSOLUTE.getCssName().equals(positioning) || Position.FIXED.getCssName().equals(positioning)) {
                  // only not 'position:absolute' elements into account,
                  // not visible children will be excluded in the next condition
                  continue;
              }
              int left = 0;
              int width = 0;
              int top = 0;
              int height = 0;
              if (y != -1) {
                  // check if the mouse pointer is within the height of the element
                  top = CmsDomUtil.getRelativeY(y, child);
                  height = child.getOffsetHeight();
                  if ((top <= 0) || (top >= height)) {
                      previousTop = top;
                      continue;
                  }
              }
              if (x != -1) {
                  // check if the mouse pointer is within the width of the element
                  left = CmsDomUtil.getRelativeX(x, child);
                  width = child.getOffsetWidth();
                  if ((left <= 0) || (left >= width)) {
                      previousTop = top;
                      continue;
                  }
              }
  
              boolean floatSort = false;
              String floating = "";
              if ((top != 0) && (top == previousTop)) {
                  floating = getCurrentStyle(child, Style.floatCss);
                  if ("left".equals(floating) || "right".equals(floating)) {
                      floatSort = true;
                  }
              }
              previousTop = top;
              if (child == element) {
                  return currentIndex;
              }
              if ((y == -1) || floatSort) {
                  boolean insertBefore = false;
                  if (left < (width / 2)) {
                      if (!(floatSort && "right".equals(floating))) {
                          insertBefore = true;
                      }
                  } else if (floatSort && "right".equals(floating)) {
                      insertBefore = true;
                  }
                  if (insertBefore) {
                      parent.insertBefore(element, child);
                      currentIndex = index - indexCorrection;
                      return currentIndex;
                  } else {
                      parent.insertAfter(element, child);
                      currentIndex = (index + 1) - indexCorrection;
                      return currentIndex;
                  }
              }
              if (top < (height / 2)) {
                  parent.insertBefore(element, child);
                  currentIndex = index - indexCorrection;
                  return currentIndex;
              } else {
                  parent.insertAfter(element, child);
                  currentIndex = (index + 1) - indexCorrection;
                  return currentIndex;
              }
  
          }
          // not over any child position
          if ((currentIndex >= 0) && (element.getParentElement() == parent)) {
              // element is already attached to this parent and no new position available
              // don't do anything
              return currentIndex;
          }
          int top = CmsDomUtil.getRelativeY(y, parent);
          int offsetHeight = parent.getOffsetHeight();
          if ((top >= (offsetHeight / 2))) {
              // over top half, insert as first child
              parent.insertFirst(element);
              currentIndex = 0;
              return currentIndex;
          }
          // over bottom half, insert as last child
          parent.appendChild(element);
          currentIndex = parent.getChildCount() - 1;
          return currentIndex;
      }