function pullLinks()
{
    global $area;
    $permissions = getAllUserPermissions();
    $admin = isAdmin();
    $su = isSuperuser();
    $content = "<ul>";
    $topLevel = linkPullTopLinksIndexCurrentArea();
    foreach ($topLevel as $curTopLevel) {
        if (!linkIsVisible($curTopLevel, $permissions, $admin, $su)) {
            continue;
        }
        $content .= "<li><a ";
        if (isNewTab($curTopLevel)) {
            $content .= "target='_blank' ";
        }
        $content .= "href=\"" . linkReturnFullUrl($curTopLevel) . "\">" . linkReturnName($curTopLevel) . "</a>";
        if (linkHasChild($curTopLevel)) {
            $content .= "<div class='sub'><div class='links'>";
            $secondLevel = linkPullChildrenIndex($curTopLevel);
            foreach ($secondLevel as $curSecondLevel) {
                if (!linkIsVisible($curSecondLevel, $permissions, $admin, $su)) {
                    continue;
                }
                $content .= "<a ";
                if (isNewTab($curSecondLevel)) {
                    $content .= "target='_blank' ";
                }
                $content .= "href=\"" . linkReturnFullUrl($curSecondLevel) . "\">" . linkReturnName($curSecondLevel) . "</a>";
                if (linkHasChild($curSecondLevel)) {
                    $content .= "<div class='sublinks'>";
                    $thirdLevel = linkPullChildrenIndex($curSecondLevel);
                    foreach ($thirdLevel as $curThirdLevel) {
                        if (!linkIsVisible($curThirdLevel, $permissions, $admin, $su)) {
                            continue;
                        }
                        $content .= "<a ";
                        if (isNewTab($curThirdLevel)) {
                            $content .= "target='_blank' ";
                        }
                        $content .= "href=\"" . linkReturnFullUrl($curThirdLevel) . "\">" . linkReturnName($curThirdLevel) . "</a>";
                    }
                    $content .= "</div>";
                }
            }
            $content .= "</div></div>";
        }
        $content .= "</li>";
    }
    $content .= "</ul>";
    echo $content;
}
function recursiveCall($parentIndex)
{
    echo "<ul class='sortList'>";
    foreach ($parentIndex as $index) {
        if (linkHasChild($index['index']) && linkIsVisible($index['index'])) {
            //print link header with appropriate edit options
            echo "<li style='list-style-type: none;'>";
            echo "<input type='text' style='width:20px; display:none;' id='" . $index['index'] . "' name='order[" . $index['index'] . "]' value='" . $index['sortOrder'] . "' />";
            echo '<div style="display: inline;" ' . (isSuperuser() ? 'class="trigger"' : 'class="trigger"') . ' index="' . $index['index'] . '" id="title' . $index['index'] . '" internal="' . $index['internal'] . '" onclick="togglediv(\'children' . $index['index'] . '\')"><b>' . $index['name'] . '</b>';
            echo '</div>';
            $content = "<span class='popup' id='span" . $index['index'] . "' style='display:none;margin-left:10px; '>";
            $content .= '<input type="button" value="Edit" onclick="javascript:newwindow(\'./editLink.php?id=' . $index['index'] . '&internal=' . $index['internal'] . '\')">';
            $content2 = '<input type="button" value="Delete" onclick="deleteLink(' . $index['index'] . ')">';
            $content2 .= "</span>";
            if (isSuperuser()) {
                echo $content . $content2;
            } else {
                $content .= "</span>";
                echo $content;
            }
            echo '<br/><br/>';
            echo '<div id="children' . $index['index'] . '" style="display:none;">';
            $nextLevel = linkPullChildren($index['index']);
            recursiveCall($nextLevel);
            echo '</div>';
            echo "</li>";
        } else {
            if (linkIsVisible($index['index'])) {
                echo '<li style="list-style-type: none;">';
                echo "<input type='text' style='width:20px;display:none;' id='" . $index['index'] . "' name='order[" . $index['index'] . "]' value='" . $index['sortOrder'] . "' />";
                echo "<span " . (isSuperuser() ? 'class="trigger"' : 'class="trigger"') . " id='" . $index['index'] . "span' index='" . $index['index'] . "'>" . $index['name'];
                echo "</span>";
                $content = "<span class='popup' id='span" . $index['index'] . "' style='display:none;margin-left:10px;'>";
                $content .= '<input type="button" value="Edit" onclick="javascript:newwindow(\'./editLink.php?id=' . $index['index'] . '\')">';
                $content2 = '<input type="button" value="Delete" onclick="deleteLink(' . $index['index'] . ')">';
                $content2 .= "</span>";
                if (isSuperuser()) {
                    echo $content . $content2;
                } else {
                    $content .= "</span>";
                    echo $content;
                }
                echo '<br/><br/>';
                echo '</li>';
            }
        }
    }
    echo "<ul>";
}