function phpAds_displayStatsRow($data_arr, $total_arr, $expand_arr, $omit_arr, $level = 0)
{
    global $campaignid, $clientid, $cnt, $phpAds_TextDirection, $phpAds_TextAlignRight;
    $show_children = false;
    echo "\t\t\t\t<tr height='25' " . ($cnt % 2 == 0 ? "bgcolor='#F6F6F6'" : "") . ">\n";
    if ($level == 0) {
        echo "\t\t\t\t\t<td colspan='2'>";
    } else {
        $checked = in_array($data_arr['path'], $omit_arr) ? '' : ' checked';
        echo "\t\t\t\t\t<td><input type='checkbox' name='keep[]' value='" . $data_arr['path'] . "'" . $checked . "><input type='hidden' name='omit[]' value='" . $path . "'></td>\n";
        echo "\t\t\t\t\t<td>";
        if ($level > 1) {
            echo "<img src='images/spacer.gif' width='" . $level * 15 . "' height='1' border='0'>";
        }
    }
    if (isset($data_arr['children']) && is_array($data_arr['children']) && sizeof($data_arr['children']) > 0) {
        if (in_array($data_arr['name'], $expand_arr)) {
            echo "<a href='stats-campaign-optimise.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&collapse=" . $data_arr['name'] . "'><img src='images/triangle-d.gif' align='absmiddle' border='0'></a>";
            $show_children = true;
        } else {
            echo "<a href='stats-campaign-optimise.php?clientid=" . $clientid . "&campaignid=" . $campaignid . "&expand=" . $data_arr['name'] . "'><img src='images/" . $phpAds_TextDirection . "/triangle-l.gif' align='absmiddle' border='0'></a>";
        }
    }
    if ($level == 0) {
        echo "&nbsp;<b>" . $data_arr['name'] . "</b></td>\n";
    } else {
        echo "&nbsp;" . $data_arr['name'] . "</td>\n";
    }
    echo "\t\t\t\t\t<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($data_arr['views']) . "</td>\n";
    echo "\t\t\t\t\t<td align='center'>(" . phpAds_formatPercentage(phpAds_buildRatio($data_arr['views'], $total_arr['views']), 0) . ")</td>\n";
    echo "\t\t\t\t\t<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($data_arr['clicks']) . "</td>\n";
    echo "\t\t\t\t\t<td align='center'>(" . phpAds_formatPercentage(phpAds_buildRatio($data_arr['clicks'], $total_arr['clicks']), 0) . ")</td>\n";
    echo "\t\t\t\t\t<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatPercentage($data_arr['ctr']) . "</td>\n";
    echo "\t\t\t\t\t<td align='center'>(" . phpAds_formatPercentage(phpAds_buildRatio($data_arr['ctr'], $total_arr['ctr']), 0) . ")</td>\n";
    echo "\t\t\t\t\t<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatNumber($data_arr['conversions']) . "</td>\n";
    echo "\t\t\t\t\t<td align='center'>(" . phpAds_formatPercentage(phpAds_buildRatio($data_arr['conversions'], $total_arr['conversions']), 0) . ")</td>\n";
    echo "\t\t\t\t\t<td align='" . $phpAds_TextAlignRight . "'>" . phpAds_formatPercentage($data_arr['cnvr']) . "&nbsp;&nbsp;</td>\n";
    echo "\t\t\t\t\t<td align='center'>(" . phpAds_formatPercentage(phpAds_buildRatio($data_arr['cnvr'], $total_arr['cnvr']), 0) . ")</td>\n";
    echo "\t\t\t\t</tr>\n";
    if ($show_children) {
        for ($i = 0; $i < sizeof($data_arr['children']); $i++) {
            phpAds_displayStatsRow($data_arr['children'][$i], $total_arr, $expand_arr, $omit_arr, $level + 1);
        }
    }
    if ($level == 0) {
        $cnt++;
    }
}
function phpAds_displayDataRow($data_arr, $level = 0)
{
    global $cnt, $page_ID, $phpAds_TextDirection;
    $show_children = false;
    echo "<tr class='data_row" . ($cnt % 2 == 0 ? "_alt" : "") . ">\n";
    // Change this to a SPAN??
    if ($level > 1) {
        echo "<img src='images/spacer.gif' width='" . $level * 15 . "' height='1' border='0'>";
    }
    if (isset($data_arr['children']) && is_array($data_arr['children']) && sizeof($data_arr['children']) > 0) {
        if (in_array($data_arr['name'], $expand_arr)) {
            echo "<a href='" . $page_ID . "?collapse=" . $data_arr['name'] . "'><img src='images/triangle-d.gif' align='absmiddle' border='0'></a>";
            $show_children = true;
        } else {
            echo "<a href='" . $page_ID . "?expand=" . $data_arr['name'] . "'><img src='images/" . $phpAds_TextDirection . "/triangle-l.gif' align='absmiddle' border='0'></a>";
        }
    }
    if ($level == 0) {
        echo "<span class='data_row_top'>" . $data_arr['name'] . "</span></td>\n";
    } else {
        echo $data_arr['name'] . "</td>\n";
    }
    echo "</tr>\n";
    if ($show_children) {
        for ($i = 0; $i < sizeof($data_arr['children']); $i++) {
            phpAds_displayStatsRow($data_arr['children'][$i], $expand_arr, $level + 1);
        }
    }
    if ($level == 0) {
        $cnt++;
    }
}