<?php
	$round_names = array('1'  => 'Round 1',
						 '2'  => 'Round 2',
						 'QF' => 'Quarterfinals',
						 'SF' => 'Semifinals',
						 'F'  => 'Final',
						 'S'  => '3rd/5th Place',
						 'SC' => 'Consolation',
						 'C' => '4th/6th Place');

?>

<!-- Sub Title -->
<div style="text-align: center; color: #000000; font-size: 13pt; line-height: 2em; font-weight: bold;">
	<?php
		if (is_null($information['bracket']->location))
		{
			$sub_title = date('F j', strtotime($information['bracket']->event->start_at)) . '-' . date('j', strtotime($information['bracket']->event->end_at));
		}	
		else
		{
			$sub_title = date('F j', strtotime($information['bracket']->event->start_at)) . '-' . date('j', strtotime($information['bracket']->event->end_at)) . ', ' . $information['bracket']->location->name;
		}
	?>

	<?php echo $sub_title; ?>

</div>


<div style="width: 200px; height: 50px; position: absolute; top: 525px; left: 50px; background-image: url(<?php echo asset('images/logos/USBank_200x50px.png'); ?>); background-repeat: no-repeat;"></div>

<div style="width: 200px; height: 50px; position: absolute; top: 525px; right: 50px; background-image: url(<?php echo asset('images/logos/LesSchwab_200x50px.png'); ?>); background-repeat: no-repeat;">
</div>

<div style="width: 250px; height: 130px; position: absolute; top:555px; left: 390px; background-image: url(<?php echo asset('images/logos/OSAAStateChampionship_250x130px.png'); ?>); background-repeat: no-repeat;">
</div>



<!-- Top Half -->
<div style="height: 500px; margin-bottom: 125px;">

	<!-- Round 7, C -->
	<div class="round left" style="height: 500px; padding: 0 8px; margin-left: 20px;">
		
		<!-- Round Info -->
		<div class="info" style="margin-top: 16px;">
			<div class="title">
				<?php echo $round_names[$information['bracket']->rounds[7]->round->round_type]; ?>
			</div>
			<div class="date">
				<?php echo date('M. j', strtotime($information['bracket']->rounds[7]->event->start_at)); ?>
			</div>
		</div>

		<div class="spacer" style="height: 150px;"></div>

		<div class="connector right bottom" style="margin-top: 41px;"></div>			

		<!-- Matchups -->
		<?php for ($i = 26; $i < 27; $i++): ?>

			<?php echo BracketsController::getMatchup('left', $information['bracket']->matchups[$i]); ?>			

		<?php endfor; ?>
		

	</div>
	
	<!-- Round 6, SC -->
	<div class="round left" style="height: 500px; padding: 0 8px;">
		
		<!-- Round Info -->
		<div class="info" style="margin-top: 16px;">
			<div class="title">
				<?php echo $round_names[$information['bracket']->rounds[6]->round->round_type]; ?>
			</div>
			<div class="date">
				<?php echo date('M. j', strtotime($information['bracket']->rounds[6]->event->start_at)); ?>
			</div>
		</div>

		<div class="spacer" style="height: 48px;"></div>			


		<div class="connector left top" style="height: 101px; margin-top: 41px;"></div>			
		<div class="connector left bottom" style="height: 108px; margin-top: 144px;"></div>


		<!-- Matchups -->
		<?php for ($i = 24; $i < 26; $i++): ?>

			<div class="connector right bottom" style="margin-top: 41px;"></div>
			
			<?php echo BracketsController::getMatchup('left', $information['bracket']->matchups[$i]); ?>		
			
			<div class="spacer" style="height: 127px; position: relative;">
				<?php if ($i == 24 and
				     !is_null($information['bracket']->bracket->data) and
				     property_exists($information['bracket']->bracket->data, 'flag') and
				     property_exists($information['bracket']->bracket->data, 'show_flag') and
				     $information['bracket']->bracket->data->show_flag and
				     !Helpers::strIsEmpty($information['bracket']->bracket->data->flag)): ?>
					<div style="position: absolute; top: 49px; width: 293px; height: 25px; font-size: 7pt; line-height: 1.15em; left: 7px; color: #000000; overflow: hidden; ">

						<img src="<?php echo asset('/images/icons/alert_2_16px.png'); ?>" alt="" title="" style="vertical-align: middle; width: 0.9em; height: 0.9em; margin: 0 2px 0 4px; top: -1px; position: relative;" />

						<?php echo $information['bracket']->bracket->data->flag; ?>

					</div>
				<?php endif; ?>
			</div>						

		<?php endfor; ?>

	</div>

	<!-- Round 2, QF -->
	<div class="round left" style="height: 500px; padding: 0 8px;">

		<!-- Round Info -->
		<div class="info" style="margin-top: 16px;">
			<div class="title">
				<?php echo $round_names[$information['bracket']->rounds[2]->round->round_type]; ?>
			</div>
			<div class="date">
				<?php echo date('M. j', strtotime($information['bracket']->rounds[2]->event->start_at)); ?>
			</div>
		</div>

		<!-- Matchups -->
		<?php for ($i = 16; $i < 20; $i++): ?>
			
			<?php if ($i == 16 or $i == 18): ?>
				<div class="connector right top" style="height: 47px; margin-top: 41px;"></div>			
				<div class="connector right bottom" style="height: 47px; margin-top: 90px;"></div>		

				<div class="connector left top" style="height: 47px; margin-top: 41px;"></div>			
				<div class="connector left bottom" style="height: 47px; margin-top: 90px;"></div>		
			<?php endif; ?>

			<?php echo BracketsController::getMatchup('right', $information['bracket']->matchups[$i]); ?>
			
			<?php if ($i == 17): ?>
				<div class="spacer" style="height: 32px;"></div>
			<?php else: ?>
				<div class="spacer" style="height: 12px;"></div>
			<?php endif; ?>

		<?php endfor; ?>

	</div>

	<?php if (!BracketsController::matchupHasTeams($information['bracket']->matchups[16]->matchup->id) or
	     !BracketsController::matchupHasTeams($information['bracket']->matchups[17]->matchup->id) or
	     !BracketsController::matchupHasTeams($information['bracket']->matchups[18]->matchup->id) or
	     !BracketsController::matchupHasTeams($information['bracket']->matchups[19]->matchup->id)): ?>		

		<!-- Group Letters -->
		<div style="position: absolute; height: 500px; left: 504px; width: 24px; text-align: center;">

			<div class="group_letter" style="margin-top: 67px;">
	    	    <?php if (!BracketsController::matchupHasTeams($information['bracket']->matchups[16]->matchup->id)): ?>
	    			A
	    		<?php else: ?>
	    			&nbsp;
	    		<?php endif; ?>
			</div>
			<div class="group_letter" style="margin-top: 60px;">
				<?php if (!BracketsController::matchupHasTeams($information['bracket']->matchups[17]->matchup->id)): ?>
	    			B
	    		<?php else: ?>
	    			&nbsp;
	    		<?php endif; ?>
			</div>
			<div class="group_letter" style="margin-top: 78px;">
				<?php if (!BracketsController::matchupHasTeams($information['bracket']->matchups[18]->matchup->id)): ?>
	    			C
	    		<?php else: ?>
	    			&nbsp;
	    		<?php endif; ?>
			</div>
			<div class="group_letter" style="margin-top: 58px;">
				<?php if (!BracketsController::matchupHasTeams($information['bracket']->matchups[19]->matchup->id)): ?>
	    			D
	    		<?php else: ?>
	    			&nbsp;
	    		<?php endif; ?>
			</div>

		</div>
	<?php endif; ?>
	
	<!-- Round 3, SF -->
	<div class="round left" style="height: 500px; padding: 0 8px;">
		
		<!-- Round Info -->
		<div class="info" style="margin-top: 16px;">
			<div class="title">
				<?php echo $round_names[$information['bracket']->rounds[3]->round->round_type]; ?>
			</div>
			<div class="date">
				<?php echo date('M. j', strtotime($information['bracket']->rounds[3]->event->start_at)); ?>
			</div>
		</div>

		<div class="spacer" style="height: 48px;"></div>	

		<div class="connector right top" style="height: 101px; margin-top: 41px;"></div>			
		<div class="connector right bottom" style="height: 108px; margin-top: 144px;"></div>		

		<!-- Matchups -->
		<?php for ($i = 20; $i < 22; $i++): ?>

			<div class="connector left bottom" style="margin-top: 41px;"></div>

			<?php echo BracketsController::getMatchup('right', $information['bracket']->matchups[$i]); ?>
						
			<div class="spacer" style="height: 127px;"></div>						

		<?php endfor; ?>

	</div>
	
	<!-- Round 4, F -->
	<div class="round left" style="height: 500px; padding: 0 8px;">

		<!-- Round Info -->
		<div class="info" style="margin-top: 16px;">
			<div class="title">
				<?php echo $round_names[$information['bracket']->rounds[4]->round->round_type]; ?>
			</div>
			<div class="date">
				<?php echo date('M. j', strtotime($information['bracket']->rounds[4]->event->start_at)); ?>
			</div>
		</div>

		<div class="spacer" style="height: 150px;"></div>

		<div class="connector left bottom" style="margin-top: 41px;"></div>			

		<!-- Matchups -->
		<?php for ($i = 22; $i < 23; $i++): ?>

			<?php echo BracketsController::getMatchup('right', $information['bracket']->matchups[$i]); ?>
			
		<?php endfor; ?>

	</div>

	<!-- Round 5, S -->	
	<div class="round left" style="padding: 0 8px; position: absolute; left: 596px; top: 249px;">

		<!-- Round Info -->
		<div class="info" style="margin-bottom: -10px;">
			<div class="title" style="text-align: right;">
				<?php echo $round_names[$information['bracket']->rounds[5]->round->round_type]; ?>
			</div>
			<div class="date" style="text-align: right;">
				<?php echo date('M. j', strtotime($information['bracket']->rounds[5]->event->start_at)); ?>
			</div>
		</div>		

		<div class="connector right dashed" style="margin-top: -31px; height: 130px;"></div>			
		<div class="connector right bottom" style="margin-top: 41px;"></div>			

		<!-- Matchups -->
		<?php for ($i = 23; $i < 24; $i++): ?>

			<?php echo BracketsController::getMatchup('right', $information['bracket']->matchups[$i]); ?>
			
		<?php endfor; ?>

	</div>

</div>

<!-- Bottom Half -->
<div style="height: 500px;">


	<!-- Round 0 (1), Left Side -->
	<div class="round left" style="height: 500px; padding: 0 8px;">
		
		<!-- Round Info -->
		<div class="info" style="margin-top: 16px;">
			<div class="title">
				<?php echo $round_names[$information['bracket']->rounds[0]->round->round_type]; ?>
			</div>
			<div class="date">
				<?php echo date('M. j', strtotime($information['bracket']->rounds[0]->event->start_at)); ?>
			</div>
		</div>

		<!-- Matchups -->
		<?php for ($i = 0; $i < 4; $i++): ?>

			<?php /* <div class="connector right top" style="margin-top: 41px; height: 48px;"></div> */ ?>

			<?php echo BracketsController::getMatchup('right', $information['bracket']->matchups[$i]); ?>
			
			<div class="spacer" style="height: 24px;"></div>

		<?php endfor; ?>

	</div>

	<!-- Round 1 (2), Left Side -->
	<div class="round left" style="height: 500px; padding: 0 8px;">
		
		<!-- Round Info -->
		<div class="info" style="margin-top: 16px; margin-bottom: 58px;">
			<div class="title">
				<?php echo $round_names[$information['bracket']->rounds[1]->round->round_type]; ?>
			</div>
			<div class="date">
				<?php echo date('M. j', strtotime($information['bracket']->rounds[1]->event->start_at)); ?>
			</div>
		</div>

		<!-- Matchups -->
		<?php for ($i = 8; $i < 12; $i++): ?>

			<?php /* <?php if ($i != 8): ?>
				<div class="connector left bottom" style="margin-top: 41px;"></div>
			<?php else: ?>
				<div class="connector left bottom" style="margin-top: 31px;"></div>
			<?php endif; ?> */ ?>

			<?php if ($i == 8): ?>
				<div class="connector right top" style="margin-top: 89px; height: 48px;"></div>
				<div class="connector right bottom" style="margin-top: 149px; height: 48px;"></div>								
				<div class="connector right bottom" style="margin-top: 139px; right:-6px;"></div>
				<div class="connector right bottom" style="margin-top: 149px; right:-6px;"></div>
			<?php endif; ?>

			<?php if ($i == 10): ?>
				<div class="connector right top" style="margin-top: 41px; height: 48px;"></div>				
				<div class="connector right bottom" style="margin-top: 101px; height: 48px;"></div>
				<div class="connector right bottom" style="margin-top: 91px; right:-6px;"></div>
				<div class="connector right bottom" style="margin-top: 101px; right:-6px;"></div>

			<?php endif; ?>

			<?php echo BracketsController::getMatchup('right', $information['bracket']->matchups[$i]); ?>
			
			<div class="spacer" style="height: 24px;"></div>

		<?php endfor; ?>

	</div>


	<!-- Group Letters -->
	<div style="float: left; margin-left: 12px; height: 500px;">	

		<div class="group_letter" style="margin-top: 170px;">
			<?php if (!BracketsController::matchupHasTeams($information['bracket']->matchups[16]->matchup->id)): ?>
    			A
    		<?php else: ?>
    			&nbsp;
    		<?php endif; ?>
		</div>
		<div class="group_letter" style="margin-top: 175px;">
			<?php if (!BracketsController::matchupHasTeams($information['bracket']->matchups[17]->matchup->id)): ?>
    			B
    		<?php else: ?>
    			&nbsp;
    		<?php endif; ?>
		</div>

	</div>
	
	
	<!-- League Champions -->
	<?php
		$margin_left = '10px';
		if (BracketsController::matchupHasTeams($information['bracket']->matchups[16]->matchup->id) and
			BracketsController::matchupHasTeams($information['bracket']->matchups[17]->matchup->id))
		{
			$margin_left = '20px';
		}

	?>	
	<div style="float: left; width:150px; height: 500px; margin-left: <?php echo $margin_left; ?>; text-align: center;">
		<div style="margin-top: 140px; font-size: 10pt; font-weight: bold; color: #000000; margin-bottom: 1em;">			
			League Champions
		</div>
		
		<?php foreach ($information['leagues'] as $league): ?>
			<div style="font-size: 8pt; color: #7d7b7d; line-height: 100%; ">
				<?php echo preg_replace('/\(.*\)/', '', $league->slug); ?> <?php echo $league->name; ?>
			</div>

			<div style="font-size: 10pt; line-height: 100%; margin-bottom: 0.75em; font-weight: bold;">
				<?php if (count($information['league_champions']) > 0): ?>
					
					<?php $find = false; ?>

					<?php foreach ($information['league_champions'] as $lc): ?>
						<?php if (Helpers::strEqual($lc->league, $league->slug)): ?>
							<?php $find = true; ?>

							<?php echo $lc->name; ?>

							<?php break; ?>

						<?php endif; ?>

					<?php endforeach; ?>

					<?php if (!$find): ?>
						TBD
					<?php endif; ?>

				<?php else: ?>					
					TBD
				<?php endif; ?>

			</div>

		<?php endforeach; ?>

	</div>	


	<!-- Round 0 (1), Right Side -->
	<div class="round right" style="height: 500px; padding: 0 8px;">		
		
		<!-- Round Info -->
		<div class="info" style="margin-top: 16px;">
			<div class="title">
				<?php echo $round_names[$information['bracket']->rounds[0]->round->round_type]; ?>
			</div>
			<div class="date">
				<?php echo date('M. j', strtotime($information['bracket']->rounds[0]->event->start_at)); ?>
			</div>
		</div>

		<!-- Matchups -->
		<?php for ($i = 4; $i < 8; $i++): ?>

			<?php /* <div class="connector left top" style="margin-top: 41px; height: 48px;"></div> */ ?>

			<?php echo BracketsController::getMatchup('left', $information['bracket']->matchups[$i]); ?>
			
			<div class="spacer" style="height: 24px;"></div>

		<?php endfor; ?>
	</div>

	<!-- Round 1 (2), Right Side -->
	<div class="round right" style="height: 500px; padding: 0 8px;">		
		
		<!-- Round Info -->
		<div class="info" style="margin-top: 16px; margin-bottom: 58px;">
			<div class="title">
				<?php echo $round_names[$information['bracket']->rounds[1]->round->round_type]; ?>
			</div>
			<div class="date">
				<?php echo date('M. j', strtotime($information['bracket']->rounds[1]->event->start_at)); ?>
			</div>
		</div>

		<!-- Matchups -->
		<?php for ($i = 12; $i < 16; $i++): ?>			

			<?php if ($i == 12): ?>
				<div class="connector left top" style="margin-top: 89px; height: 48px;"></div>
				<div class="connector left bottom" style="margin-top: 149px; height: 48px;"></div>
				<div class="connector left bottom" style="margin-top: 139px; left:-6px;"></div>
				<div class="connector left bottom" style="margin-top: 149px; left:-6px;"></div>
			<?php endif; ?>

			<?php if ($i == 14): ?>
				<div class="connector left top" style="margin-top: 41px; height: 48px;"></div>
				<div class="connector left bottom" style="margin-top: 101px; height: 48px;"></div>
				<div class="connector left bottom" style="margin-top: 91px; left:-6px;"></div>
				<div class="connector left bottom" style="margin-top: 101px; left:-6px;"></div>
			<?php endif; ?>

			<?php echo BracketsController::getMatchup('left', $information['bracket']->matchups[$i]); ?>
			
			<div class="spacer" style="height: 24px;"></div>

		<?php endfor; ?>
	</div>
	
	<!-- Group Letters -->
	<div style="float: right; margin-right: 12px; height: 500px;">
		<div class="group_letter" style="margin-top: 170px;">
			<?php if (!BracketsController::matchupHasTeams($information['bracket']->matchups[18]->matchup->id)): ?>
    			C
    		<?php else: ?>
    			&nbsp;
    		<?php endif; ?>
		</div>
		<div class="group_letter" style="margin-top: 175px;">
			<?php if (!BracketsController::matchupHasTeams($information['bracket']->matchups[19]->matchup->id)): ?>
    			D
    		<?php else: ?>
    			&nbsp;
    		<?php endif; ?>
		</div>
	</div>

</div>


