<?
if (!defined('webid')) {
    exit();
}
?>
<script type="text/javascript">
$('#statlink').tipTip();
$('.cep_add').tipTip();
</script>
<table style='width: 968px; margin: 0 auto; margin-top: -5px; margin-left: 23px;'>
    <tr>
        <?
            $sql = mysql_query("SELECT * FROM cep_links WHERE balance >= price and modered = 1 and paused = 0 ORDER BY RAND() LIMIT 4") or die(mysql_error());
            $irs = 1;
            while ($row = mysql_fetch_assoc($sql)) { 
	            if($row['balance'] < $row['price']) {
		            mysql_query("UPDATE cep_links SET paused = 1, balance = 0 WHERE id = '" . $row['id'] . "'") or die(mysql_error());
	            }
	            if($irs == 1) { $buttom_add = "<a href='/addcep' class='cep_add' id='cep_add' title='Добавить свою ссылку в цепочку' ></a>"; $cep_class = "cep_b"; } else { $buttom_add = ""; $cep_class = "cep_a"; }
	            ?>
	                <td style='width: 200px; height: 45px;'>
		                <?=$buttom_add?>    
	                    <div class='<?=$cep_class?>'> <a title='Кликов: <?=$row['views'] ?>' href='/cp_url.php?link=<?=$row['id'] ?>' id="statlink" target='_blank'><div class='cep_hover'><?=substr($row['description'], 0, 55) ?> </div></a></div>
	                </td>
                <? 
                $irs++;
            }
        ?>
	</tr>
</table>