<?
function array_average($array)
{
 return array_sum($array) / count($array);
}

function graph($aData){
    
	if(!count($aData)) return;
	
	$aData = array_slice($aData,0,6);

    echo '<table>';
    foreach($aData as $sKey => $sValue){
        echo '  <tr style="font-size:10px;color:#555555">
                    <td style="padding-right:10px"><span style="cursor:help" title="'.addslashes($sKey).'">' . character_limiter($sKey,100) . '</span></td>
                    <td style="color:#252525">' . $sValue . '</td>
                </tr>';
    }
    echo '</table>';
}

?>


<div class="dashboard_box dashboard_focus">
<div style="height:17px"></div>
<p style=""><span style="font-size:18px; font-weight:bold"><?= array_sum(array_values($visitors)); ?></span> Liczba wizyt</p>
<p style=""><span style="font-size:18px; font-weight:bold"><?= array_sum(array_values($pageviews)); ?></span> Liczba odsłon</p>
<p style=""><span style="font-size:18px; font-weight:bold"><?= round(array_average(array_values($visitsperhour)),2); ?></span> Czas spędzony na stronie</p>
</div>



<div class="dashboard_box ">
<p style="font-weight:bold">Odnośniki:</p>
<?php graph($referrers); ?>
</div>

<div class="dashboard_box">
<p style="font-weight:bold">Wyszukiwane słowa:</p>
<?php graph($searchwords); ?>
</div>

<div class="dashboard_box dashboard_box_large">
<p style="font-weight:bold">Pzeglądarki internetowe:</p>
<?php graph($browsers); ?>
</div>

<div class="dashboard_box dashboard_box_small">
<p style="font-weight:bold">System operacyjny:</p>
<?php graph($os); ?>
</div>

<div class="dashboard_box">
<p style="font-weight:bold">Rozdzielczość ekranu:</p>
<?php graph($screenresolutions); ?>
</div>


<div class="clear"></div>