<?php   defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
<div id="ccm-randomizerBlock<?php   echo intval($bID) ?>" class="ccm-randomizerBlock">
<?php    
$blocksDisplayed=0; 

//make sure all blocks are good
$safeBlocks=array();
foreach($blockPoolBlocks as $block){
	//make sure user doesn't try to display this block, otherwise it's an infinate loop.
	if( intval($bID)==intval($block->getBlockID()) ) continue;
	$safeBlocks[]=$block;
}
$blockPoolBlocks=$safeBlocks;

//limit number of blocks to display, depending on mode
//if animation is off, just go by the displayCount
if( !$animate && intval($displayCount)>0 ){
	$blockPoolBlocks=array_slice($blockPoolBlocks, 0, $displayCount );
}elseif($animate && intval($animateDisplayLimit)>0 ){
	$blockPoolBlocks=array_slice($blockPoolBlocks, 0,$animateDisplayLimit );
}
?>
<div class="ccm-randomizerSubBlock" style="position:inherit;"  >
<?php  
foreach($blockPoolBlocks as $block){ 
	if( ( ($blocksDisplayed)%$displayCount==0 && $blocksDisplayed>0) || (!intval($displayCount) && $blocksDisplayed>0) ) {
		echo '</div>';	
		echo '<div class="ccm-randomizerSubBlock" style="display:none;">'; 
	}	
	
	echo '<div class="ccm-randomizerBlockWrap">';	
		$bv = new BlockView();
		$bv->render($block); 
	echo '</div>';
	
	$blocksDisplayed++;
}

if( $animate ){ 
	//echo '$blocksDisplayed: '.$blocksDisplayed.' $displayCount'.$displayCount.' '.($blocksDisplayed % $displayCount).'<br>';
	$numberToPrint = $displayCount - $blocksDisplayed % $displayCount;
	if(($blocksDisplayed % $displayCount)!=0) for($i=0;$i<$numberToPrint;$i++){
		if(!$blockPoolBlocks[$i] instanceof Block) { continue; }
		echo '<div class="ccm-randomizerBlockWrap">';
			$bv = new BlockView();
			$bv->render($blockPoolBlocks[$i]); 		
		echo '</div>';
	}
}
?>
</div>
</div>