<?php $__env->startSection('page_title'); ?>
    OSAA - School Classifications and Districts
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page_sub_title'); ?>    
   OSAA School Classifications and Districts
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
    @parent

<?php $__env->stopSection(); ?>

<?php $__env->startSection('jquery_init'); ?>
	$('.button').button({icons : { primary : 'ui-icon-document'}});	
	$('.page_functions').css('width', 'auto');
	
	$('#adm_menu').menu();
	$('#adm_drop_down_button').button({icons : { secondary : 'ui-icon-triangle-1-s'}})
						      .click(function ()
						             {
							            if ($('#adm_menu').is(':visible'))
							            {
							            	$('#adm_menu').slideUp(400);
							            	$(this).button({icons : { secondary : 'ui-icon-triangle-1-s'}});
							        	}
							        	else
							        	{
							                $('#adm_menu').slideDown(400);
							                $(this).button({icons : { secondary : 'ui-icon-triangle-1-n'}});
							            }
								     });

	$('#district_menu').menu();
	$('#district_drop_down_button').button({icons : { secondary : 'ui-icon-triangle-1-s'}})
							       .click(function ()
							              {
								             if ($('#district_menu').is(':visible'))
								             {
								             	 $('#district_menu').slideUp(400);
								             	 $(this).button({icons : { secondary : 'ui-icon-triangle-1-s'}});
								        	 }
								        	 else
								        	 {
								                 $('#district_menu').slideDown(400);
								                 $(this).button({icons : { secondary : 'ui-icon-triangle-1-n'}});
								             }
									      });							
	

<?php $__env->stopSection(); ?>

<?php $__env->startSection('page_functions'); ?>
    
	<a href="<?php echo asset('docs/osaainfo/18-22RegularDistricts.pdf'); ?>" class="button" target="_blank" style="font-size: 9pt;">18-22 Adopted Regular Districts</a>
	
<?php $__env->stopSection(); ?>


<?php $__env->startSection('main_content'); ?>    	

	<div style="float: right; position: relative; margin-right: -10px;">
	
		<?php if (Auth::check() and Auth::user()->isOsaaUser()): ?>

			<a href="<?php echo url('/schools/classification-history-download'); ?>" class="button" target="_blank" style="font-size: 9pt; margin-right: 10px;">Download History</a>

		<?php endif; ?>


		<?php if (count($information['adm_files']) > 0): ?>
			<div id="adm_drop_down_button" style="font-size: 9pt;">
				ADM History
			</div>

			<ul id="adm_menu" style="display: none; padding-left: 0; position: absolute; overflow-y: auto; height: 300px; width: 118px;">
				<?php foreach ($information['adm_files'] as $file): ?>
					<li><a href="<?php echo $file->link; ?>" target="_blank"><?php echo $file->name; ?></a></li>
				<?php endforeach; ?>
			</ul>
		<?php endif; ?>

		<?php if (count($information['district_files']) > 0): ?>
			<div id="district_drop_down_button" style="font-size: 9pt; margin-left: 10px;">
				District History
			</div>

			<ul id="district_menu" style="display: none; padding-left: 0; position: absolute; overflow-y: auto; height: 300px; width: 138px; left: 133px;">
				<?php foreach ($information['district_files'] as $file): ?>
					<li><a href="<?php echo $file->link; ?>" target="_blank"><?php echo $file->name; ?></a></li>
				<?php endforeach; ?>
			</ul>
		<?php endif; ?>
	</div>

	
	<?php  
	    $current_classification = null;
	    $league_i = 0;
	    echo '<div style="display:none;">';


		// Go through each league
		foreach ($leagues as $league)
		{
			$league_i++;

			$classification = substr ($league->slug, 0, 2);						
			
			// Is this a new classification
			if (!Helpers::strEqual($classification, $current_classification))
			{						

				echo '</div><br class="clear" />';

				$league_i = 1;

				$current_classification = $classification;
				
				$school_count = $school_information[$current_classification . '_count']['schools'];

				$league_count = $school_information[$current_classification . '_count']['leagues'];

				if (!Helpers::strEqual($current_classification, '6A'))
				{
					echo '<div class="horizontal_divider" style="width:100%;"> </div>';
				}

				echo '<h1>' . $current_classification . ' Classification <span style="margin-left:50px; color:#000000; font-size:11pt;">(' . $school_count . ' schools in ' . $league_count . ' leagues)</span></h1>';
			}

			if ($league_i == 1)
			{				
				echo '<div class="columns">';				
			}
			if ($league_i == 5)
			{
				echo '<br class="clear" />';
			}

			echo '<div class="fourth">';
			echo '<h2 style="font-size:12pt;">' . preg_replace('/\(.*\)/', null, $league->slug) . ' ' . $league->name . '</h2>';
			
			foreach ($school_information as $school)
			{
				if (isset ($school['league'][0]))
				{
					if (Helpers::strEqual ($school['league'][0]->league, $league->slug))
					{
						//if ($school['classification'][0]->is_irregular) echo '*';
						
						echo '<span style="font-size:10pt;">';
						
						// Replace 'Adventist' with 'Adv.'
						if (Helpers::strContains('adventist', $school['school'][0]->short_name))
						{
							$school['school'][0]->short_name = str_replace('Adventist', 'Adv.', $school['school'][0]->short_name);
						}

						// Replace 'Rougue Valley' with 'Rogue Val.'
						if (Helpers::strContains('Rogue Valley', $school['school'][0]->short_name))
						{
							$school['school'][0]->short_name = str_replace('Valley', 'Val.', $school['school'][0]->short_name);
						}


						if (Helpers::strContains('-', $school['school'][0]->short_name) or Helpers::strContains(',', $school['school'][0]->short_name))
						{							
							echo '<small>' . $school['school'][0]->short_name . '</small>';
						}
						else
						{
							echo $school['school'][0]->short_name;
						}

						if (!Helpers::strEqual ($school['classification'][0]->classification, $current_classification))
						{
							echo ' (' . $school['classification'][0]->classification . ')';
						}

						echo '</span>';

						echo '<span class="small gray note" style="font-size:7pt;"> - ';

						if (isset ($school['mascot'][0]))
						{
							echo $school['mascot'][0]->name;
						}

						echo '</span>';

						if ($school['demographic'][0]->enrollment == 0) 
						{
							$school['demographic'][0]->enrollment = 'n/a';
						}
						echo '<span style="float:right; margin-right:15px; font-size:9pt;">' . $school['demographic'][0]->enrollment . '</span><br />';
					}
				}
				
			}

			echo '</div>';
		}
		echo '</div>';


	?>



<?php $__env->stopSection(); ?>