<?php

include($BIB."bib_mailing.php3");

$i = 0;
$totalAds = count($arr_tags);
echo "<style type='text/css'>
      div#banniere img {
        cursor:pointer;
      }
      </style>";
echo "<div id='banniere'>";
echo "<img src='Images/boutons/cliquez-ici.png' top='2' style='cursor:default;'/><br />";

while ($i < min($NB_ADS,$totalAds)){
    
	$totalPonderation = array_sum($arr_ponderation);
	$randval = rand(1, $totalPonderation);

	$avancement = 1;
    $ok = false;

	foreach($arr_tags as $key=>$value){
        if (!$ok){
            if( $totalAds >= $NB_ADS ){
                if ($randval >= $avancement &&  $randval < $avancement+$arr_ponderation[$key] && !in_array($key, $arr_display)){
                    $value = replaceTag("__EMAIL__", $member["Email"], $value);
                    echo $value."<br /><br />";
                    $i++;
                    $arr_display[$i] = $key;
                    $ok = true;
                    unset($arr_tags[$key]);
                    unset($arr_ponderation[$key]);
                }
            }
            else {
                if (!in_array($key, $arr_display)){
                    $value = replaceTag("__EMAIL__", $member["Email"], $value);
                    echo $value."\n";
                    $i++;
                    $arr_display[$i] = $key;
                    unset($arr_tags[$key]);
                    unset($arr_ponderation[$key]);
                }
            }
            
            $avancement +=$arr_ponderation[$key];
        }

        
    }

    
}

?>
<table width="100%">
    <tr>
        <td align="center">
            <a style="margin:0 10px;color:rgba(0,0,0,.9)" href="<?php echo $sess->link3($CHOOSE_BET_PAGE,""); ?>" ><img border=0 src='<?php echo $IMAGES_DIR."boutons/bouton_GrandRetour.gif" ?>'></a>
        </td>
    </tr>

</table>
</div>
