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

		$(function ()
		{
			var data = jQuery.parseJSON('<?php echo $information['json_data']; ?>');			
			var classification = '<?php echo $information['school']->classification; ?>';
			var regular_league = '<?php echo $information['school']->league->slug; ?>';

			$('select[name="activity"]').change(function ()
			{
				updateActivity();
			});

			function updateActivity()
			{
				// Get the selected activity
				var act = $('select[name="activity"] :selected').val();	

				// Find the selected activitiy's data
				var act_obj = jQuery.grep(data, function (n, i)
				{
					return (n.activity == act);
				});
				act_obj = act_obj[0];

				// Get the applicable divisions for this activity
				var divisions = act_obj.divisions;

				// Remove all existing division options
				$('select[name="division"]').children().remove();

				// Append available divisions (default selection to this classification)
				for (var i = 0; i < divisions.length; i++)
				{
					var div = act_obj.divisions[i];
					
					if (div.indexOf(classification) !== -1)
					{
						var selected = ' selected="selected"';
					}
					else
					{
						var selected = '';
					}					

					$('select[name="division"]').append('<option value="' + div + '"' + selected + '>' + div + '</option>');
				}


				// Get the activity's season
				var season = act_obj.season;
				$('input[name="season"]').val(season);


				// Get the applicable leagues for this activity
				var leagues = act_obj.leagues;

				// Remove all existing league options
				$('select[name="league"]').children().remove();

				// Append available leagues (default selection to this regular league)
				for (var i = 0; i < leagues.length; i++)
				{
					var league = act_obj.leagues[i];
					
					if (league.slug ==(regular_league))
					{
						var selected = ' selected="selected"';
					}
					else
					{
						var selected = '';
					}					

					$('select[name="league"]').append('<option value="' + league.slug + '"' + selected + '>' + league.slug + ' ' + league.name + '</option>');
				}

				// Add independent option
				$('select[name="league"]').append('<option value="independent">Independent</option>');

			}

			updateActivity();

		});

	</script>


	<style type="text/css">
		.add_ap_label {font-weight: bold; width: 125px; display: inline-block;}
	</style>

	To add a new activity program for <?php echo $information['school']->name; ?>, select the appropriate information.

	<br /><br />

	<div class="online_form_instructions ui-corner-all small">
		Locked fields cannot be modified and may change with your selections.
	</div>

	<br />

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

		<?php echo Form::label('activity', 'Activity', array('class' => 'add_ap_label')); ?>
		<?php echo Form::select('activity', $information['activities']); ?>	

		<br /><br />

		<?php echo Form::label('season', 'Season', array('class' => 'float_left add_ap_label', 'style' => 'width: 130px;')); ?>
		<?php echo Form::text('season', null, array('readonly' => 'true', 'class' => 'float_left', 'style' => 'width: 25px;')); ?>	
		<img src="<?php echo asset('images/icons/locked_24px.png'); ?>" alt="" title="" style="float: left; position: relative; top: 0px;" />	

		<br /><br />
		
		<?php echo Form::label('school_year', 'School Year', array('class' => 'add_ap_label')); ?>
		<?php echo Form::text('school_year', Session::get('year'), array('style' => 'width: 60px;')); ?>

		<br /><br />
			
		<?php echo Form::label('name', 'Name', array('class' => 'float_left add_ap_label', 'style' => 'width: 130px;')); ?>	
		<?php echo Form::text('name', $information['school']->short_name, array('readonly' => 'true', 'class' => 'float_left', 'style' => 'width: 250px;')); ?>
		<img src="<?php echo asset('images/icons/locked_24px.png'); ?>" alt="" title="" style="float: left; position: relative; top: 0px;" />

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

		<?php echo Form::label('division', 'Division', array('class' => 'add_ap_label')); ?>
		<?php echo Form::select('division', array()); ?><br />
		<span class="small gray" style="margin-left: 130px;">(Classified as a <?php echo $information['school']->classification; ?> school)</span>

		<br /><br />

		<?php echo Form::label('league', 'League', array('class' => 'add_ap_label')); ?>
		<?php echo Form::select('league', array(), null, array('style' => 'max-width: 325px;')); ?><br />
		<span class="small gray" style="margin-left: 130px; display: inline-block; width: 325px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">(Regularly in <?php echo $information['school']->league->slug; ?> <?php echo $information['school']->league->name; ?>)</span>

		<?php echo Form::hidden('host_school', $information['school']->id); ?>
		<?php echo Form::hidden('regular_league', $information['school']->league->slug); ?>

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

<?php else: ?>
	There are no activities to add to this school.
<?php endif; ?>