<?php if (!is_null($information['bracket']) and ((!is_null($information['bracket']->bracket->published_at) and strtotime($information['bracket']->bracket->published_at) < time()) or Auth::check() and Auth::user()->isOsaaUser())): ?>

	<?php /*  Bracket Container  */ ?>
	<div class="bracket" style="width: 1020px; min-height: 600px; padding: 0 5px; position: relative;">

		<?php /*  Bracket Title (event->name)  */ ?>
		<div class="bracket_title" style="text-align: center; font-weight: bold; font-size: 17pt; margin: 1em 0 0.5em 0; padding-bottom: 1em; border-bottom: 2px solid #e1c146;">
			<?php echo $information['bracket']->event->name; ?>
		</div>	

		<div class="bracket_actions" style="height: 32px; margin-bottom: 0.5em; border-bottom: 1px solid #ffefb0;">						
			
			<div style="float: left; margin-right: 1.5em;">
				<a href="<?php echo url('/brackets/' . $information['bracket']->bracket->id . '/print'); ?>" class="float_right" target="_blank">
					<img src="<?php echo asset('/images/icons/print_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />
					Print
				</a>			
			</div>

			<div style="float: left; margin-right: 1.5em;">
				<a href="<?php echo url('/media'); ?>" target="_blank">
					<img src="<?php echo asset('/images/icons/microphone_blue_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />
					Broadcast
				</a>
			</div>

			<div style="float: left; margin-right: 1.5em;">
				<a href="<?php echo url('/programs'); ?>" target="_blank">
					<img src="<?php echo asset('/images/icons/digital_program_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />
					Program
				</a>
			</div>			

			<div style="float: left; margin-right: 1.5em;">			

				<?php
					$site = null;
					if (!is_null($information['bracket']->event->location))
					{
						$location = location::find($information['bracket']->event->location);

						if (!is_null($location))
						{
							$site = '&amp;site=' . strtolower(substr($location->name, 0, stripos($location->name, ' ')));
						}
					}
				?>

				
				<?php /*  Hide for football semis played at different locations 

				<?php if (BracketsController::bracketHasLiveCoverageContests($information['bracket']) and 
				     !(Helpers::strEqual($information['bracket']->bracket->activity, 'FBL') and
				       Helpers::strEqual($information['bracket']->bracket->division, array('6A', '4A')))): ?>
				  */ ?>
 
				<?php /*   <?php if (BracketsController::bracketHasLiveCoverageContests($information['bracket'])): ?>  */ ?>

				<?php if (false and time() >= strtotime('2017-11-04 16:00:00')): ?>

					<a href="<?php echo url('activities/' . strtolower($information['bracket']->bracket->activity) . '/brackets/live?div=' . Session::get('division') . $site); ?>">
						<img src="<?php echo asset('/images/icons/live_coverage_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />
						Live Coverage
					</a>
					
				<?php endif; ?>
			</div>

			<?php if (Helpers::strEqual($information['bracket']->bracket->activity, array('FBL')) and time() < strtotime("2013-11-30 21:00:00")): ?>
				<?php if ($information['bracket']->bracket->division == '6A'): ?>				
					<div style="float: left; margin-right: 1.5em;">						
						<img src="<?php echo asset('/images/icons/information_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />Semifinal Spectator Information:
						<a href="<?php echo asset('/docs/fbl/6AJELDWENSemispecinfo.pdf'); ?>" target="_blank">JELD-WEN Field</a>
					</div>
				<?php elseif ($information['bracket']->bracket->division == '5A'): ?>				
					<div style="float: left; margin-right: 1.5em;">						
						<img src="<?php echo asset('/images/icons/information_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />Spectator Information:						
						<a href="<?php echo asset('/docs/fbl/HSFinalsspecinfo.pdf'); ?>" target="_blank">Hillsboro Stadium</a>
					</div>
				<?php elseif ($information['bracket']->bracket->division == '4A'): ?>
					<div style="float: left; margin-right: 1.5em;">						
						<img src="<?php echo asset('/images/icons/information_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />Spectator Information:						
						<a href="<?php echo asset('/docs/fbl/HSFinalsspecinfo.pdf'); ?>" target="_blank">Hillsboro Stadium</a>
					</div>
				<?php elseif ($information['bracket']->bracket->division == '3A'): ?>
					<div style="float: left; margin-right: 1.5em;">						
						<img src="<?php echo asset('/images/icons/information_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />Spectator Information:
						<a href="<?php echo asset('/docs/fbl/SMTFinalsspecinfo.pdf'); ?>" target="_blank">Summit High School</a>
					</div>
				<?php elseif ($information['bracket']->bracket->division == '2A'): ?>
					<div style="float: left; margin-right: 1.5em;">						
						<img src="<?php echo asset('/images/icons/information_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />Spectator Information:
						<a href="<?php echo asset('/docs/fbl/SMTFinalsspecinfo.pdf'); ?>" target="_blank">Summit High School</a>
					</div>
				<?php elseif ($information['bracket']->bracket->division == '1A'): ?>
					<div style="float: left; margin-right: 1.5em;">						
						<img src="<?php echo asset('/images/icons/information_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />Spectator Information:						
						<a href="<?php echo asset('/docs/fbl/HSFinalsspecinfo.pdf'); ?>" target="_blank">Hillsboro Stadium</a>
					</div>
				<?php endif; ?>

			<?php endif; ?>	
			
			<?php if (Helpers::strEqual($information['bracket']->bracket->activity, array('VBL', 'BBX', 'GBX'))): ?>
				<?php if (!is_null($information['bracket']->bracket->overview_file) and file_exists(public_path() . '/stats/' . strtolower($information['bracket']->bracket->activity) . '/' . $information['bracket']->bracket->overview_file)): ?>

					<div style="float: left; margin-right: 1.5em;">
						<a href="<?php echo asset('/stats/' . strtolower($information['bracket']->bracket->activity) . '/' . $information['bracket']->bracket->overview_file); ?>" target="_blank">
							<img src="<?php echo asset('/images/icons/overview_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />
							All-Tournament Team<?php /*  and Attendance  */ ?>
						</a>
					</div>

				<?php else: ?>
					<div style="float: left; margin-right: 1.5em;">
						<img src="<?php echo asset('/images/icons/overview_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />
						All-Tournament Team<?php /*  and Attendance  */ ?>
					</div>
				<?php endif; ?>
			<?php endif; ?>			

			<?php if (Helpers::strEqual($information['bracket']->bracket->activity, array('BBX', 'GBX'))): ?>
				<?php if (file_exists(public_path() . '/stats/' . strtolower($information['bracket']->bracket->activity) . '/' . $information['bracket']->bracket->school_year . '-' . (intval(substr($information['bracket']->bracket->school_year, 2, 2)) + 1) . '/' . strtoupper($information['bracket']->bracket->division) . '/' . strtolower($information['bracket']->bracket->division) . strtolower(substr($information['bracket']->bracket->activity, 0, 1)) . 'stats.htm')): ?>

					<div style="float: left; margin-right: 1.5em;">
						<a href="<?php echo asset('/stats/' . strtolower($information['bracket']->bracket->activity) . '/' . $information['bracket']->bracket->school_year . '-' . (intval(substr($information['bracket']->bracket->school_year, 2, 2)) + 1) . '/' . strtoupper($information['bracket']->bracket->division) . '/' . strtolower($information['bracket']->bracket->division) . strtolower(substr($information['bracket']->bracket->activity, 0, 1)) . 'stats.htm'); ?>" target="_blank">
							<img src="<?php echo asset('/images/icons/cumulative_stats_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />
							 Tournament Stats
						</a>
					</div>

				<?php else: ?>
					<div style="float: left; margin-right: 1.5em;">
						<img src="<?php echo asset('/images/icons/cumulative_stats_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />
						Tournament Stats 			
					</div>
				<?php endif; ?>			
			<?php endif; ?>	

			<div style="float: left; margin-right: 1.5em;">
				<a href="http://www.osaastore.com" target="_blank">
					<img src="<?php echo asset('/images/icons/shopping_cart_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />
					Shop
				</a>
			</div>

			<?php if (Helpers::strEqual($information['bracket']->bracket->activity, array('FBL', 'VBL', 'BSC', 'GSC', 'BBX', 'GBX', 'BBL', 'SBL'))): ?>

				<div style="float: left; margin-right: 1.5em;">
					<a href="<?php echo url('/shop/tickets'); ?>" target="_blank">
					<?php /*  <a href="<?php echo url('/activities/' . strtolower($information['bracket']->bracket->activity) . '/tickets'); ?>" target="_blank">  */ ?>
						<img src="<?php echo asset('/images/icons/ticket_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />
						Tickets
					</a>
				</div>

			<?php endif; ?>
			

			<?php if (is_null($information['bracket']->bracket->published_at) and Auth::check() and Auth::user()->isOsaaUser()): ?>
				<div style="float: left; margin-right: 1.5em;">
					<b>Unpublished</b> - OSAA Staff Preview
				</div>

				<div class="button publish_this_bracket float_left" style="font-size: 8pt;">Publish Bracket</div>
			<?php endif; ?>

			<?php if (Auth::check() and Auth::user()->isOsaaUser()): ?>
				<div style="float: right;">
					<a href="#" class="bracket_info_button"><img src="<?php echo asset('/images/icons/database_info_2_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" /></a>

					<a href="<?php echo url('/activities/' . strtolower($information['bracket']->bracket->activity) . '/brackets?div=' . $information['bracket']->bracket->division . '&amp;show-ticket-reports=1' ); ?>" target="_blank" style=""><img src="<?php echo asset('/images/icons/view_ticket_reports_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" /></a>
				</div>
			<?php endif; ?>

		</div>

		<?php /*  Bracket Footer  */ ?>
		<div style="width: 1020px; position: absolute; bottom: 0.5em;">

			<div style="text-align: center; line-height: 10em; font-size: 9pt; color: #7d7b7d; z-index: 1;">
				<?php /*  The better ranked team shall be the designated home team (bottom team in the matchup).  */ ?>
				The team with the better Adjusted Playoff Ranking (APR) shall be the designated home team (bottom team in the matchup).
			</div>			

		</div>

		<?php echo $__env->make ('brackets.' . $information['bracket']->template_directory . '.' . str_replace('-', '_', $information['bracket']->template), array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
		
		<br class="clear" /><br /><br /><br />
				

	</div>

<?php else: ?>

	<h2>Coming Soon</h2>
	<p>Brackets will be posted later in the season as playoffs get closer.</p>

	<h2>OSAA Sample Brackets</h2>

	&raquo; <a href="<?php echo asset ('docs/osaainfo/SampleBracket32TeamSingle.pdf'); ?>" target="_blank">32-Team Single Elimination</a> | 
	&raquo; <a href="<?php echo asset ('docs/osaainfo/SampleBracket16TeamSingle.pdf'); ?>" target="_blank">16-Team Single Elimination</a> |
	&raquo; <a href="<?php echo asset ('docs/osaainfo/SampleBracket12TeamSingle.pdf'); ?>" target="_blank">12-Team Single Elimination</a> <br>	

	&raquo; <a href="<?php echo asset ('docs/osaainfo/SampleBracket32Team8TeamFinals.pdf'); ?>" target="_blank">32-Team, 8 Team Final Site</a> | 
	&raquo; <a href="<?php echo asset ('docs/osaainfo/SampleBracket24Team8TeamFinals.pdf'); ?>" target="_blank">24-Team, 8 Team Final Site</a> |
	&raquo; <a href="<?php echo asset ('docs/osaainfo/SampleBracket16Team8TeamFinals.pdf'); ?>" target="_blank">16-Team, 8 Team Final Site</a> 		

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

	<?php if (Auth::check() and Auth::user()->isOsaaUser()): ?>

		<?php			
			$autofill = new stdClass();
			
			$autofill->school_year = Session::get('year');
			$autofill->division = strtoupper(Session::get('division'));
			$autofill->activity = strtoupper($activity_slug);
			$autofill->start_at = null;
			$autofill->end_at = null;
			$autofill->location = null;
			$autofill->location_name = null;
			$autofill->bracket_type = null;
			$autofill->layout = null;
			$autofill->number_rounds = null;

			if (!is_null($information['old_bracket']))
			{
				$autofill->start_at = date('Y-m-d', strtotime($information['old_bracket']->event->start_at . " +1 year"));
				$autofill->end_at = date('Y-m-d', strtotime($information['old_bracket']->event->end_at . " +1 year"));
				$autofill->location = $information['old_bracket']->event->location;
				if (!is_null($autofill->location))
				{
					$autofill->location_name = location::findOrFail($autofill->location)->name;
				}
				$autofill->bracket_type = $information['old_bracket']->bracket_type;
				$autofill->layout = $information['old_bracket']->layout;
				$autofill->number_rounds = $information['old_bracket']->number_rounds;
			}

			// Available bracket layouts for team sports (SELECT DISTINCT(layout) FROM brackets WHERE 1)
			$bracket_layouts = array('STACKED'     => 'Stacked',
									 '24-STACKED'  => 'Stacked (24 teams)',
									 'STRAIGHT'    => 'Straight',
									 '12-STRAIGHT' => 'Straight (12 teams)');
		?>

		<div class="horizontal_divider" style="width: 100%;"></div>

		<br />

		<h2 style="margin-bottom: 1em;"><img src="<?php echo asset('/images/icons/shield_32px.png'); ?>" alt="" title="" style="width: 24px; float: left; position: relative; top: -5px; margin-right: 5px;" /> Create This Bracket</h2>

		<?php echo Form::open(array('url' => url('/brackets/create-bracket'))); ?>

			<p>
				Use this form to create a new bracket for this school year/activity/division.  Last year's bracket information is auto-filled and adjusted for this current school year.  Fields with a lock icon, <img src="<?php echo asset('/images/icons/locked_24px.png'); ?>" alt="" title="" style="width: 16px; vertical-align: middle;" />, cannot be changed.
			</p>
			<p>
				Note, the <b>Number of Rounds</b> field counts all rounds from the first to the final round and includes any consolation or special placement rounds counted separately.  The <b>Bracket Type</b> field lists the maximum number of teams that this bracket design can hold.  This number must be a power of 2.  Even if fewer teams are allowed, round up to the nearest power of two.  (E.g. a 24 team bracket should have a type of 32.)
			</p>
			<p>	
				<b>Layout</b> has two main styles: Stacked and Straight.  Stacked layouts have a final event site with consolation rounds and are listed bottom to top, then center to right/left for final rounds.  Straight layouts do not have consolation rounds and are listed straight across the page, left to right.  The layout can also be selected to modify the number of total teams allowed.  If using a Stacked layout, set the <b>Start Date</b> as the first date of contests at the finals event site.  If using a Straight layout, set the <b>Start Date</b> as the date of the first round of competition.
			</p>

			<h3 style="color: #990000;">Bracket Parameters</h3>

			<div class="columns">

				<div class="fourth">
					<?php echo Form::label('school_year', 'School Year:', array('style' => 'font-weight: bold;')); ?>
					<?php echo Form::text('school_year', $autofill->school_year, array('readonly' => 'readonly', 'style' => 'width: 50px;')); ?>
					<img src="<?php echo asset('/images/icons/locked_24px.png'); ?>" alt="" title="" style="vertical-align: middle;" />
					<br />
					<span class="small gray note"><?php echo $autofill->school_year; ?>-<?php echo (intval(substr($autofill->school_year, 2, 2)) + 1); ?> school year</span>
				</div>

				<div class="fourth">
					<?php echo Form::label('activity', 'Activity:', array('style' => 'font-weight: bold;')); ?>
					<?php echo Form::text('activity', $autofill->activity, array('readonly' => 'readonly', 'style' => 'width: 50px;')); ?>
					<img src="<?php echo asset('/images/icons/locked_24px.png'); ?>" alt="" title="" style="vertical-align: middle;" />
					<br />
					<span class="small gray note"><?php echo Helpers::getActivityName($autofill->activity); ?></span>
				</div>

				<div class="fourth">
					<?php echo Form::label('division', 'Division:', array('style' => 'font-weight: bold;')); ?>
					<?php echo Form::text('division', $autofill->division, array('readonly' => 'readonly', 'style' => 'width: 50px;')); ?>
					<img src="<?php echo asset('/images/icons/locked_24px.png'); ?>" alt="" title="" style="vertical-align: middle;" />
				</div>

				<div class="fourth">
					<?php echo Form::label('number_rounds', 'Number of Rounds:', array('style' => 'font-weight: bold;')); ?>
					<?php echo Form::text('number_rounds', $autofill->number_rounds, array('style' => 'width: 50px;')); ?>					
					<br />
					<span class="small gray note">Number of rounds in this bracket</span>
				</div>

			</div>

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

			<div class="columns">

				<div class="fourth">
					<?php echo Form::label('bracket_type', 'Bracket Type:', array('style' => 'font-weight: bold;')); ?>
					<?php echo Form::select('bracket_type', array(8 => 8, 16 => 16, 32 => 32, 64 => 64), $autofill->bracket_type, array('style' => 'width: 50px;')); ?>					
					<br />
					<span class="small gray note">Max. number of teams in this bracket</span>
				</div>

				<div class="fourth">
					<?php echo Form::label('layout', 'Layout:', array('style' => 'font-weight: bold;')); ?>
					<?php echo Form::select('layout', $bracket_layouts, $autofill->layout, array('style' => '')); ?>					
					<br />
					<span class="small gray note">Bracket design/modify number of teams</span>
				</div>

				<div class="fourth">
					<?php echo Form::label('start_at', 'Start Date:', array('style' => 'font-weight: bold;')); ?>
					<?php echo Form::text('start_at', $autofill->start_at, array('data-datepicker' => 'yy-mm-dd', 'style' => 'width: 100px;')); ?>					
					<br />
					<span class="small gray note">Date of round 1 or first date at finals site</span>
				</div>

				<div class="fourth">
					<?php echo Form::label('end_at', 'End Date:', array('style' => 'font-weight: bold;')); ?>
					<?php echo Form::text('end_at', $autofill->end_at, array('data-datepicker' => 'yy-mm-dd', 'style' => 'width: 100px;')); ?>					
					<br />
					<span class="small gray note">Last date in this bracket</span>
				</div>

			</div>

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

			<div class="columns">
				
				<div class="fourth">
					<?php echo Form::label('location', 'Location:', array('style' => 'font-weight: bold;')); ?>
					<?php echo Form::text('location', (!is_null($autofill->location)) ? $autofill->location : null, array('style' => 'width: 75px;')); ?>
					<br />
					<span class="small gray note">Location ID of the final site</span>
				</div>

				<div class="half">

					<?php if (!is_null($autofill->location)): ?>
						(<?php echo $autofill->location; ?>) "<?php echo $autofill->location_name; ?>"
					<?php else: ?>
						No Location Selected
					<?php endif; ?>
					<br />
					<a href="#" id="bracket_location_lookup">
						<img src="<?php echo asset('images/icons/search_32px.png'); ?>" alt="" title="" style="width: 16px; vertical-align: middle;" />
						Lookup a Different Location
					</a>

				</div>

				<div class="fourth">					
					<br />
					<?php echo Form::submit('Create Bracket', array('style' => 'font-size: 10pt;', 'class' => 'button')); ?>					
				</div>

			</div>



		<?php echo Form::close(); ?>

	<?php endif; ?>

<?php endif; ?>