<?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())): ?>

	<style type="text/css">	
		.match_hover {
				background: #fceabb; /* Old browsers */
				background: -moz-linear-gradient(top,  #fceabb 0%, #fccd4d 50%, #f8b500 51%, #fbdf93 100%); /* FF3.6+ */
				background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fceabb), color-stop(50%,#fccd4d), color-stop(51%,#f8b500), color-stop(100%,#fbdf93)); /* Chrome,Safari4+ */
				background: -webkit-linear-gradient(top,  #fceabb 0%,#fccd4d 50%,#f8b500 51%,#fbdf93 100%); /* Chrome10+,Safari5.1+ */
				background: -o-linear-gradient(top,  #fceabb 0%,#fccd4d 50%,#f8b500 51%,#fbdf93 100%); /* Opera 11.10+ */
				background: -ms-linear-gradient(top,  #fceabb 0%,#fccd4d 50%,#f8b500 51%,#fbdf93 100%); /* IE10+ */
				background: linear-gradient(to bottom,  #fceabb 0%,#fccd4d 50%,#f8b500 51%,#fbdf93 100%); /* W3C */
				filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fceabb', endColorstr='#fbdf93',GradientType=0 ); /* IE6-9 */
			}

		.ui-tooltip {
			max-width: 800px !important;
		}

	</style>

	<?php /*  OSAA User Seeding Utilities  */ ?>
	<?php if (Helpers::strEqual($activity_slug, array('WRE', 'BTN', 'GTN')) and Auth::check() and Auth::user()->isOsaaUser()): ?>

		<style type="text/css">			
			#seed_tools {
				position: fixed;
				
				
				z-index: 500;
			}			

			#seed_list {
				position: fixed;
				top: 40px;
				
				right: -302px;
				/*right: 0;*/

				width: 283px;
				/*height: 548px;*/

				padding: 0.5em;

				background-color: #ffefb0;
				border: 1px solid #e1c146;				
			}

			#seed_list h1 {
				font-weight: bold !important;
				font-size: 12pt  !important;
				padding: 0 0 2px 0  !important;
				border-bottom: 4px solid #990000;
				margin: 0 0 0.5em 0  !important;
				color: #000000 !important;
			}

			#seed_list .participant {
				font-family: Arial, Helvetica, sans-serif !important;
				border: 1px solid #7d7b7d;
				background-color: #fefefe;
				margin-bottom: 0.25em;
				padding: 0.25em 0.25em 0.25em 1.25em;				
				font-size: 8pt;
				line-height: 110%;
				height: 2em;
			}

			#seed_list .grabber {
				position: absolute;
				left: 2px;
				top: 6px;
				width: 8px;				
				height: 16px;
				padding-right: 4px;
				background-image: url('<?php echo asset('/images/icons/grab_affordance_16px.png'); ?>');
				background-repeat: no-repeat;
			}			

			#seed_list .participant .seed {
				font-weight: bold;
				width: 15px;
				text-align: center;
				
				display: inline-block;
			}

			#seed_list .participant .name {
				width: 245px;
				display: inline-block;
				font-weight: bold;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;

			}

			#seed_list .participant .id {
				width: 30px;
				float: left;
				font-size: 6pt;
				font-family: monospace;
				color: #7d7b7d;
				padding-top: 1px;	
				font-weight: normal;			
			}

			#seed_list .participant .notes {				
				display: inline-block;
				font-size: 7pt;
				font-weight: normal;
			}

			#seed_list .participant .team {
				margin-left: 2px;
				display: inline-block;
				font-size: 7pt;
				font-weight: normal;
				max-width: 125px;
				white-space: nowrap;
				overflow: hidden;
				position: absolute;
			}			

			#seed_list p {
				font-size: 9pt;
				line-height: 105%;				
				margin: 0 0 0.5em 0;
				text-align: justify;
			}
			
			.participant_hover {
				background: #add9e4; /* Old browsers */
				background: -moz-linear-gradient(left,  #add9e4 0%, #d9edf2 25%, #f7fbfc 100%); /* FF3.6+ */
				background: -webkit-gradient(linear, left top, right top, color-stop(0%,#add9e4), color-stop(25%,#d9edf2), color-stop(100%,#f7fbfc)); /* Chrome,Safari4+ */
				background: -webkit-linear-gradient(left,  #add9e4 0%,#d9edf2 25%,#f7fbfc 100%); /* Chrome10+,Safari5.1+ */
				background: -o-linear-gradient(left,  #add9e4 0%,#d9edf2 25%,#f7fbfc 100%); /* Opera 11.10+ */
				background: -ms-linear-gradient(left,  #add9e4 0%,#d9edf2 25%,#f7fbfc 100%); /* IE10+ */
				background: linear-gradient(to right,  #add9e4 0%,#d9edf2 25%,#f7fbfc 100%); /* W3C */
				filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#add9e4', endColorstr='#f7fbfc',GradientType=1 ); /* IE6-9 */

			}
			
		</style>


		<div id="seed_tools">		

			<div id="seed_list" class="ui-corner-left">
				
				<img class="toggle" src="<?php echo asset('images/icons/gear_48px.png'); ?>" alt="" title="" style="position: absolute; left: -54px;"/>

				<?php if (Helpers::strEqual($activity_slug, 'WRE')): ?>
					<h1><?php echo Session::get('division'); ?> - <?php echo $information['subdivision']; ?> lbs Wrestlers</h1>
				<?php elseif (Helpers::strEqual($activity_slug, array('BTN', 'GTN'))): ?>
					<h1><?php echo Session::get('division'); ?> - <?php echo (Helpers::strEqual($activity_slug, 'BTN')) ? 'Boys' : 'Girls'; ?> - <?php echo (Helpers::strEqual($information['subdivision'], 'S')) ? 'Singles' : 'Doubles'; ?> Qualifiers</h1>
				<?php endif; ?>

				<p>
					<span class="ui-icon ui-icon-info float_left" style="position: relative; top: -4px; height: 16px; margin-bottom: -6px;"></span>
					To <b>place</b> a participant in the first round of the bracket, click the handle and drag the participant into the desired position.  You can <b>swap</b> a placed participant with another position in the same round by clicking a participant on the bracket.
				</p>


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

					<?php foreach ($information['mps'] as $mp): ?>

						<?php if (!$mp->placed): ?>
							
							<?php
								
								if (Helpers::strEqual($information['bracket']->bracket->activity, 'WRE'))
								{
									$data_line = $mp->getWrestlingLine();
								}
								elseif (Helpers::strEqual($information['bracket']->bracket->activity, array('BTN', 'GTN')))
								{
									$data_line = $mp->getTennisLine();
								}
							?>

							<div class="participant ui-corner-all draggable" data-participant="<?php echo $mp->id; ?>" data-line="<?php echo $data_line; ?>">												
								
								<div class="grabber"></div>

								<div class="seed"><?php echo $mp->seed; ?></div>
								<div class="name"><?php echo $mp->display_name; ?></div>
								<div class="id"><?php echo $mp->id; ?></div>
								<div class="notes">
									<?php
										$notes = json_decode($mp->notes);									
									?>
									<?php if (!is_null($notes)): ?>
										<?php if (!Helpers::strIsEmpty($notes->league)): ?>
											<?php echo preg_replace('/( \(.*\))/', '', $notes->league); ?>
										<?php endif; ?>
										<?php if (!Helpers::strIsEmpty($notes->place)): ?>
											#<?php echo $notes->place; ?>
										<?php endif; ?>
										<?php if (!Helpers::strIsEmpty($notes->seeded)): ?>
											(<?php echo $notes->seeded; ?>)
										<?php endif; ?>
									<?php endif; ?>

								</div>
								<div class="team"><?php echo $mp->team_name; ?></div>
							</div>
						<?php endif; ?>

					<?php endforeach; ?>

				<?php endif; ?>				

				<div class="edit_special_match">Edit Inset Match</div>
				<div class="reset_bracket_button">Reset/Clear</div>				

			</div>

		</div>

	<?php endif; ?>


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

		<?php /*  Bracket Title (event->name)  */ ?>
		<?php
			$font_size = 17;

			if (Helpers::strEqual($activity_slug, array('BTN', 'GTN')) and
				Helpers::strEqual(Session::get('division'), '4A/3A/2A/1A'))
			{
				$font_size = 16;
			}
		?>		
		<div style="text-align: center; font-weight: bold; font-size: <?php echo $font_size; ?>pt; margin: 1em 0 0.5em 0; padding-bottom: 1em; border-bottom: 2px solid #e1c146; line-height: 1em;">
			<?php echo $information['bracket']->event->name; ?>
		</div>	

		<div style="height: 32px; margin-bottom: 0.5em; border-bottom: 1px solid #ffefb0;">						
			
			<?php /*  Print Button  */ ?>
			<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>

			<?php /*  Tennis Schedules  */ ?>
			<?php if (Helpers::strEqual($information['bracket']->bracket->activity, array('BTN', 'GTN'))): ?>
			
				<?php
					if (!is_null($information['bracket']->bracket->data))
					{
						if (!is_object($information['bracket']->bracket->data) or
							!property_exists($information['bracket']->bracket->data, 'schedule'))
						{
							throw new Exception("The tennis bracket's data object is corrupt.  Expected a JSON object with a 'schedule' property on bracket (ID = " . $information['bracket']->bracket->id . ").");						
						}

						if (!$information['bracket']->bracket->data->schedule->is_inclement)
						{
							$tennis_schedule_title = $information['bracket']->bracket->data->schedule->normal->title;
							$tennis_schedule_file = $information['bracket']->bracket->data->schedule->normal->file;
							$tennis_schedule_icon = '/images/icons/schedule_24px.png';
						}
						else
						{
							$tennis_schedule_title = $information['bracket']->bracket->data->schedule->inclement->title;
							$tennis_schedule_file = $information['bracket']->bracket->data->schedule->inclement->file;
							$tennis_schedule_icon = '/images/icons/inclement_weather_24px.png';
						}					
					}
					else
					{
						$tennis_schedule_file = null;
					}
				?>
				<?php if (!is_null($tennis_schedule_file)): ?>

					<div style="float: left; margin-right: 1.5em;">
						
						<a href="<?php echo url($tennis_schedule_file); ?>" target="_blank">					

							<img src="<?php echo asset($tennis_schedule_icon); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />
							<?php echo $tennis_schedule_title; ?>
						</a>

						<?php if (Auth::check() and Auth::user()->isOsaaUser() and !is_null($information['bracket']->bracket->data->schedule->inclement->file)): ?>

							[<?php /*  Button to turn on inclement weather schedule  */ ?>
							<?php if (!$information['bracket']->bracket->data->schedule->is_inclement): ?>
								<img src="<?php echo asset('/images/icons/cloud_16px.png'); ?>" alt="" title="" class="toggle_inclement" style="vertical-align: middle;" data-inclement="true" />								
							<?php else: ?>
							<?php /*  Button to turn off inclement weather schedule  */ ?>
								<img src="<?php echo asset('/images/icons/sun_16px.png'); ?>" alt="" title="" class="toggle_inclement" style="vertical-align: middle;" data-inclement="false" />
							<?php endif; ?>]

						<?php endif; ?>


					</div>				

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

			<?php
				$file_year = Session::get('year') . '-' . substr(intval(Session::get('year')) + 1, 2, 2);

				$tennis_score_file = null;

				if (Helpers::strEqual($information['bracket']->bracket->division, array('6A')))
				{
					$tennis_score_file = array('/stats/tn/' . $file_year . '/6ateamthursday.pdf' => 'Thursday',
											   '/stats/tn/' . $file_year . '/6ateamfriday.pdf' => 'Friday',
											   '/stats/tn/' . $file_year . '/6ateamfinal.pdf' => 'Final');
				}
				elseif (Helpers::strEqual($information['bracket']->bracket->division, array('5A')))
				{
					$tennis_score_file = array('/stats/tn/' . $file_year . '/5ateamthursday.pdf' => 'Thursday',
											   '/stats/tn/' . $file_year . '/5ateamfriday.pdf' => 'Friday',
											   '/stats/tn/' . $file_year . '/5ateamfinal.pdf' => 'Final');
				}
				elseif (Helpers::strEqual($information['bracket']->bracket->division, array('4A/3A/2A/1A')))
				{
					$tennis_score_file = array('/stats/tn/' . $file_year . '/4ateamfriday.pdf' => 'Friday',
											   '/stats/tn/' . $file_year . '/4ateamfinal.pdf' => 'Final');
				}				

			?>
			<?php if (!is_null($tennis_score_file)): ?>

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

					<?php $count = 0; ?>
					
					<?php foreach ($tennis_score_file as $file_name => $title): ?>

						<?php $count++; ?>

						<?php if (file_exists(public_path() . $file_name)): ?>
							<a href="<?php echo url($file_name); ?>" target="_blank"><?php echo $title; ?></a>
						<?php else: ?>
							<?php echo $title; ?>
						<?php endif; ?>

						<?php if($count < count($tennis_score_file)): ?>
							|
						<?php endif; ?>

					<?php endforeach; ?>
					
				</div>			

			<?php endif; ?>


			<?php if (!Helpers::strEqual($activity_slug, array('BTN', 'GTN'))): ?>
				<div style="float: left; margin-right: 1.5em;">
					<a href="<?php echo url('/media'); ?>">
						<img src="<?php echo asset('/images/icons/microphone_blue_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />
						Broadcast Schedule
					</a>
				</div>
			<?php endif; ?>

			<?php if (Helpers::strEqual($activity_slug, 'WRE')): ?>

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

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

					<div style="float: left; margin-right: 1.5em;">
						<a href="<?php echo url('/brackets/wre-bracket-collection/' . str_replace('/', '-', $information['bracket']->bracket->division)); ?>">
							<img src="<?php echo asset('/images/icons/pdf_2_24px.png'); ?>" alt="" title="" style="position: relative; top: -3px; float: left; margin-right: 5px;" />
							Zip <?php echo $information['bracket']->bracket->division; ?> Brackets
						</a>
					</div>

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

				<?php endif; ?>

			<?php endif; ?>

			<?php if (Helpers::strEqual($activity_slug, array('BTN', 'GTN')) and (Auth::check() and Auth::user()->isOsaaUser())): ?>					

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

			<?php endif; ?>

			<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 if (BracketsController::bracketHasLiveCoverageContests($information['bracket'])): ?>			

					<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('VBL', 'BBX', 'GBX'))): ?>
				<?php if (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 Teams 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 Teams and Attendance			
					</div>
				<?php endif; ?>
			<?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>
				</div>

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

			<?php if (Auth::check() and Auth::user()->isOsaaUser()): ?>
				<div style="float: right;">
					<?php /*  <a href="<?php echo url('/brackets/' . $information['bracket']->bracket->id . '/info'); ?>" target="_blank">  */ ?>
					<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>
				</div>
			<?php endif; ?>

		</div>


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

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

		<img src="http://www.osaa.org/images/icons/ajax_loader3.gif" style="display: none;" />

	</div>

<?php else: ?>

	<div style="text-align: center; padding-top: 4em;">
		
		<h2>Coming Soon</h2>
		<img src="<?php echo asset('images/icons/shadow.png'); ?>" alt="" title="" style="margin: 1.5em 0 1em 0;" /><br />
		<div style="font-size: 9pt; color: #7d7b7d;">
			Brackets will be posted later in the season as the championship gets closer.
		</div>
		<img src="<?php echo asset('images/icons/shadow.png'); ?>" alt="" title="" style="margin: 1em 0 2em 0;" /><br />
	</div>

<?php endif; ?>