<?php if (Helpers::strEqual($activity_slug, array('CHO', 'BND', 'SPE'))): ?>
	<div class="tabs" style="width:100%;">
		<ul style="padding-left:5px; font-size:10pt;">
		    <?php foreach ($information['leagues'] as $division => $info): ?>
		        <li><a href="#tabs-<?php echo $division; ?>"><?php echo $division; ?></a></li>
		    <?php endforeach; ?> 
	   	</ul>

	    <?php foreach ($information['leagues'] as $division => $info): ?>
	            
	    	<div id="tabs-<?php echo $division; ?>" style="padding-left:.25em; padding-right:.25em;">            
	            
	            <div class="columns">
				    <div class="half">
		        
				        <?php $j = 0; ?>

				        <?php foreach ($info as $data): ?>

				        	<?php	                    
					        	$j++;
					        	$league = $data->league;
					            $teams = $data->teams;
					        ?>

					        <?php if ($j == floor(count($info) / 2) + 1): ?>
					       		</div>
					       		<div class="half">
					        <?php endif; ?>

					        <table class="teams_leagues" style="width:100%;">
		                    	<thead class="head">
		                    		<tr>
		                    			<th class="league" style="width: 350px;"><?php echo $league->display_slug; ?> <?php echo $league->name; ?></th>		
		                    		</tr>
		                    	</thead>

			                	<tbody>
									<?php foreach ($teams as $i => $team): ?>
					                    <tr <?php if ($i++ % 2 == 1): ?> class="odd" <?php endif; ?>>
					                       	
											<td class="team" style="width: auto;">					                       	
					                       			
			                       				<?php                                                                                
		                                            $image_url = ImagesController::getImageURLFromTeamID($team->team_id, 'logo', '32x32');
		                                        ?>
		                                        <?php if (!is_null($image_url)): ?>
		                                            <img src="<?php echo $image_url; ?>" alt="" title="" style="width: 24px; height: 24px; vertical-align: middle;" />
		                                        <?php else: ?>       
		                                            <img src="<?php echo asset('images/no_logo.png'); ?>" alt="" title="" style="width: 24px; height: 24px; vertical-align: middle;" />
		                                        <?php endif; ?>
				                       			<a href="<?php echo $team->link; ?>">
				                       				<?php echo $team->name; ?>
				                       			</a>
				                       		</td>
										</tr>
					                <?php endforeach; ?>	                    	
			                    </tbody>
			                </table>
			            <?php endforeach; ?>
			        </div>
			    </div> 

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

	    <?php endforeach; ?>
	</div>	

<?php else: ?>



	<?php if (count($information['leagues']) > 0): ?>

		<div class="tabs" style="width:100%;">
	        
	        <ul style="padding-left:5px; font-size:10pt;">
		        <?php foreach ($information['leagues'] as $division => $info): ?>
		        	<li><a href="#tabs-<?php echo $division; ?>"><?php echo str_replace('6A/5A/4A/3A/2A/1A', 'Combined Classifications', $division); ?></a></li>
		        <?php endforeach; ?> 
	    	</ul>

	        <?php foreach ($information['leagues'] as $division => $info): ?>
	            
	        	<div id="tabs-<?php echo $division; ?>" style="padding-left:.25em; padding-right:.25em;">            

		            <?php if (count($info) > 0): ?>
		            	
		            	<?php $j = 0; ?>

		            	<?php if (!Helpers::strEqual($activity_type, 'TS')): ?>
			                <div class="columns">
				            <div class="half">   
				        <?php endif; ?>

		            	<?php foreach ($info as $data): ?>

		            		<?php $j++; ?>
							
		            		<?php if (Helpers::strEqual($activity_type, 'TS')): ?>

								<?php	                    
			                    	$league = $data->league;
			                    	$teams = $data->teams;

			                    	$points_scored = '';
			                    	$points_allowed = '';
			                    	if (Helpers::strEqual($activity_slug, array('FBL', 'BBX', 'GBX')))
			                    	{
			                    		$points_scored = 'Points Scored';
			                    		$points_allowed = 'Allowed';		                    		
			                    	}
			                    	elseif (Helpers::strEqual($activity_slug, array('VBL')))
			                    	{
			                    		$points_scored = 'Sets Won';
			                    		$points_allowed = 'Sets Lost';		                    			
			                    	}
			                    	elseif (Helpers::strEqual($activity_slug, array('BSC', 'GSC')))
			                    	{
			                    		$points_scored = 'Goals Scored';
			                    		$points_allowed = 'Goals Allowed';		                    		
			                    	}
			                    	if (Helpers::strEqual($activity_slug, array('BBL', 'SBL')))
			                    	{
			                    		$points_scored = 'Runs Scored';
			                    		$points_allowed = 'Runs Allowed';		                    		
			                    	}
			                   	?>	                    

			                    <table class="teams_leagues">
			                    	<thead class="head">
			                    		<tr>
				                    		<th class="league text_left">
				                    			<a name="<?php echo $league->display_slug; ?>"></a>
				                    			<?php if (Auth::check() and Auth::user()->isOsaaUser()): ?>
				                    				<div class="edit_league_finish" data-league="<?php echo $league->slug; ?>" data-activity="<?php echo $activity_slug; ?>"></div>
				                    			<?php endif; ?>

				                    			<?php echo $league->display_slug; ?> <?php echo $league->name; ?>
				                    		</th>
				                    		<th class="league_record">League</th>
				                    		<th class="overall_record">Overall</th>
				                    		<th class="points_earned"><?php echo $points_scored; ?></th>
				                    		<th class="points_allowed"><?php echo $points_allowed; ?></th>
				                    		<th class="ranking">OSAA Ranking</th>			                    		
				                    	</tr>
			                    	</thead>

			                    	<tbody>
				                    	<?php if (count($teams) > 0): ?>
				                    		<?php $i = 0; ?>

						                    <?php foreach ($teams as $team): ?>
						                        <tr <?php if ($i++ % 2 == 1): ?> class="odd" <?php endif; ?>>
						                       		<td class="team">
						                       			<?php if (!is_null($team->finish)): ?>									
						                       				<img src="<?php echo asset('images/icons/ribbons/ribbon_' . $team->finish . '_24px.png'); ?>" class="tooltip" alt="| <?php echo $team->finish; ?> |" style="float: left;" title="<?php echo Helpers::ordinalNumber($team->finish, false); ?> Place in League" />
					                       				<?php endif; ?>
					                       				<?php                                                                                
				                                            $image_url = ImagesController::getImageURLFromTeamID($team->team_id, 'logo', '32x32');
				                                        ?>
				                                        <?php if (!is_null($image_url)): ?>
				                                            <img src="<?php echo $image_url; ?>" alt="" title="" style="width: 24px; height: 24px; vertical-align: middle;" />
				                                        <?php else: ?>       
				                                            <img src="<?php echo asset('images/no_logo.png'); ?>" alt="" title="" style="width: 24px; height: 24px; vertical-align: middle;" />
				                                        <?php endif; ?>
						                       			<a href="<?php echo $team->link; ?>">
						                       				<?php echo $team->name; ?>
						                       			</a>
						                       		</td>
													<td class="league_record">
														<?php echo $team->lr; ?>
													</td>
													<td class="overall_record">
													    <?php echo $team->oar; ?>
													</td>
						                        	<td class="points_scored">
						                        	    <?php echo $team->points_scored; ?>
						                        	</td>
						                        	<td class="points_allowed">
						                        	    <?php echo $team->points_allowed; ?>
						                        	</td>
						                        	<td class="ranking">
						                        	    <a href="<?php echo url('/teams/' . $team->ap_id . '?view=1'); ?>">
						                        	    	<?php echo $team->rank; ?>
						                        	    </a>
						                        	</td>
						                        </tr>
						                    <?php endforeach; ?>
						                    
				                    	<?php endif; ?>
				                    </tbody>
			                    </table>
			                <?php elseif (Helpers::strEqual($activity_type, 'IS') or Helpers::strEqual($activity_slug, 'SOL')): ?>

			                	<?php /*  Individual Sports and Activities  */ ?>

								<?php	                    
			                    	$league = $data->league;
			                    	$teams = $data->teams;		                    	
			                   	?>	           	                   	
			                   

				                <?php if ($j == ceil((count($info) + 1) / 2)): ?>
				                	</div>
				                	<div class="half">
				                <?php endif; ?>

			                    <table class="teams_leagues" style="width:100%;">
			                    	<thead class="head">
			                    		<tr>
			                    			<th class="league" style="width: 350px;"><?php echo $league->display_slug; ?> <?php echo $league->name; ?></th>		
			                    		</tr>
			                    	</thead>

			                    	<tbody>
				                    	<?php if (count($teams) > 0): ?>
				                    		<?php $i = 0; ?>

						                    <?php foreach ($teams as $team): ?>
						                        <tr <?php if ($i++ % 2 == 1): ?> class="odd" <?php endif; ?>>
						                       		<td class="team" style="width: auto;">
						                       			<a href="<?php echo $team->link; ?>">
						                       				<?php echo $team->name; ?>
						                       			</a>
						                       		</td>												
						                        </tr>
						                    <?php endforeach; ?>
						                    
				                    	<?php endif; ?>
				                    </tbody>
			                    </table>

			               	<?php endif; ?>	
		                <?php endforeach; ?> 

		                <?php if (!Helpers::strEqual($activity_type, 'TS')): ?>
		                	</div>
		                	</div>
		                	<br class="clear" />
		                <?php endif; ?>

		            <?php endif; ?>                   

		            <?php if (count($information['independents'][$division]) > 0): ?>
		            
		                <div style="font-size: 13pt; color: #990000; font-weight: bold; border-bottom: 2px solid #e1c146; padding-bottom: 2px;">Independent / No League Assigned</div>

		                <?php foreach ($information['independents'][$division] as $ap): ?>                    
		                    <a href="<?php echo url('/teams/' . $ap->id); ?>" style="display: block; color: #005fa9;"><?php echo $ap->name; ?></a>
		                <?php endforeach; ?> 
		            <?php endif; ?>                
	            
		        </div>

	        <?php endforeach; ?> 

		</div>

	<?php elseif (count($information['independents']) > 0): ?>
			
		
		<div class="tabs" style="width:100%; min-height: 660px;">
	        
	        <ul style="padding-left:5px; font-size:10pt;">
		        <?php foreach ($information['independents'] as $division => $teams): ?>
		        	<li><a href="#tabs-<?php echo $division; ?>"><?php echo str_replace('6A/5A/4A/3A/2A/1A', 'Combined Classifications', $division); ?></a></li>
		        <?php endforeach; ?> 
	    	</ul>    	

	        <?php foreach ($information['independents'] as $division => $teams): ?>
	            
	        	<div id="tabs-<?php echo $division; ?>" style="padding-left:.25em; padding-right:.25em;">            

					<?php if (count($teams) > 0): ?>

						<?php
							$j = 0;

							$teams = $teams->sort(function($a, $b)
							{
								return strcmp($a->name, $b->name);
							});

						?>

		            	<div class="columns">
				        	<div class="third">   

								<?php foreach ($teams as $team): ?>                   

					                <?php if ($j++ == intval(ceil((count($teams) + 1) / 3))): ?>
					                	</div>
					                	<div class="third">

					                	<?php $j = 0; ?>				                	
					                <?php endif; ?>				                    	
						                    
	                       			<?php /* <a href="<?php echo url('/teams/' . $team->id); ?>" style="color: #005FA9;"><?php echo $team->name; ?></a><br /> */ ?>
	                       			<a href="<?php echo url('/schools/' . $team->host_school); ?>" style="color: #005FA9;"><?php echo $team->name; ?></a><br />

	                       		<?php endforeach; ?>
	                       	</div>
	                    </div>	

	                    <br class="clear" />		                    

					<?php endif; ?>

				</div>

			<?php endforeach; ?>

		</div>


	<?php endif; ?>

<?php endif; ?>
