libraries/ManiaLib/Gui/Tools.php
final public static function getAlignedPosY($posY, $sizeY, $valign, $newAlign)
    {
        switch ($valign) {
            case 'top':
            case null:
                $valign = 'right';
                break;

            case 'bottom':
                $valign = 'left';
                break;
        }
        switch ($newAlign) {
            case 'top':
                $newAlign = 'right';
                break;

            case 'bottom':
                $newAlign = 'left';
                break;
        }
        return self::getAlignedPosX($posY, $sizeY, $valign, $newAlign);
    }
final public static function getAlignedPosY($posY, $sizeY, $valign, $newAlign)
    {
        switch ($valign) {
            case 'top':
            case null:
                $valign = 'right';
                break;

            case 'bottom':
                $valign = 'left';
                break;
        }
        switch ($newAlign) {
            case 'top':
                $newAlign = 'right';
                break;

            case 'bottom':
                $newAlign = 'left';
                break;
        }
        return self::getAlignedPosX($posY, $sizeY, $valign, $newAlign);
    }
Returns the Y position of an element in relation to another element and
according to their respective alignments

@param int Y position of the parent element
@param int Height of the parent element
@param string Vertical alignement of the parent element
@param string Vertical alignement of the element you want to place
@return int Calculated Y position of the element you want to place