<?php $__env->startSection('page_title'); ?>
    OSAA - Contest Editor
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page_sub_title'); ?>    
    Edit <?php echo $information['event']->name; ?>
<?php $__env->stopSection(); ?>

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

	<script src="<?php echo asset('scripts/jquery.timepicker.min.js'); ?>" type="text/javascript"></script> 	

	<style type="text/css">
		.ui-autocomplete {
			max-height: 200px;
			overflow-y: auto;
			/* prevent horizontal scrollbar */
			overflow-x: hidden;
		}
		/* IE 6 doesn't support max-height
		* we use height instead, but this forces the menu to always be this tall
		*/
			* html .ui-autocomplete {
			height: 200px;
		}
	</style>

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

<?php $__env->startSection('jquery_init'); ?>
	$('.tooltip').tooltip();

	$('.button').button();

	$('#cancel_button').button({ icons : { primary : 'ui-icon-circle-close'}}).css('font-size', '10pt').tooltip().attr('title', 'Cancel editing and do not save changes.');

	$('#event_date').datepicker({'dateFormat' : 'mm/dd/yy', 'minDate' : '<?php echo $information['first_event_at']; ?>', 'maxDate' : '<?php echo $information['last_event_at']; ?>'});
	
	$('#event_time').timepicker({ 'timeFormat': 'h:i A' , 'step' : 15});


    $('#contest_type').buttonset();

    function updateOOSState ()
    {
		if ($('#is_home_oos:checked').length > 0)
    	{
    		$('#home_state').removeAttr('disabled');   		
    	}
    	else
    	{
    		$('#home_state').attr('disabled', 'disabled');
    	}  

    	if ($('#is_away_oos:checked').length > 0)
    	{
    		$('#away_state').removeAttr('disabled');   		
    	}
    	else
    	{
    		$('#away_state').attr('disabled', 'disabled');
    	} 
	}

	updateOOSState ();

    $('#is_home_oos, #is_away_oos').change(function ()
    {
    	updateOOSState ();
    });

    var original_status = '<?php echo $information['event']->event_status; ?>';
    var original_endowment = <?php echo $information['contest']->is_endowment; ?>;
    
    function updateEndowmentNotes ()
    {
    	/* Endowment: Checked */
    	if ($('#is_endowment:checked').size() > 0)
    	{   		
    		/* Original: SCHD */
    		if (original_status == 'SCHD')    		
    		{
				/* Original: SCHD , Yes Endowment = Approved */
				if (original_endowment == 1)
				{
					$("input[name='event_status']").attr('value', 'SCHD');
    				$('#event_status_value').html('Scheduled');    			
    				$('#new_endowment_note').css('display', 'none');
    				$('#remove_endowment_note').css('display', 'none');
    				$('#pending_endowment_note').css('display', 'none');
    			}
    			/* Original: SCHD , No Endowment = New Request */
    			else
    			{    				
    				$("input[name='event_status']").attr('value', 'PND');
    				$('#event_status_value').html('Pending');
    				$('#new_endowment_note').css('display', 'block');
    				$('#remove_endowment_note').css('display', 'none');
    				$('#pending_endowment_note').css('display', 'none');
    			}
    		}
    		/* Original: PND */
    		else if (original_status == 'PND')
    		{    			
    			/* Original: PND , Yes Endowment = Currently Waiting */
    			if (original_endowment == 1)
    			{
    				$("input[name='event_status']").attr('value', 'PND');
    				$('#event_status_value').html('Pending');
    				$('#new_endowment_note').css('display', 'none');
    				$('#remove_endowment_note').css('display', 'none');
    				$('#pending_endowment_note').css('display', 'block');
    			}    			
    			/* Original: PND , No Endowment = New Request */
    			else
    			{
					$("input[name='event_status']").attr('value', 'PND');
    				$('#event_status_value').html('Pending');
    				$('#new_endowment_note').css('display', 'block');
    				$('#remove_endowment_note').css('display', 'none');
    				$('#pending_endowment_note').css('display', 'none');
    			}
    		} 
    	}    	
    	/* Endowment Unchecked */
    	else
    	{
    		/* Original: SCHD */
    		if (original_status == 'SCHD')    		
    		{
				/* Original: SCHD , Yes Endowment = Remove Approved */
				if (original_endowment == 1)
				{
					$("input[name='event_status']").attr('value', 'SCHD');
    				$('#event_status_value').html('Scheduled');    			
    				$('#new_endowment_note').css('display', 'none');
    				$('#remove_endowment_note').css('display', 'block');
    				$('#pending_endowment_note').css('display', 'none');
    			}
    			/* Original: SCHD , No Endowment = Nothing new */
    			else
    			{    				
    				$("input[name='event_status']").attr('value', 'SCHD');
    				$('#event_status_value').html('Scheduled');
    				$('#new_endowment_note').css('display', 'none');
    				$('#remove_endowment_note').css('display', 'none');
    				$('#pending_endowment_note').css('display', 'none');
    			}
    		}
    		/* Original: PND */
    		else if (original_status == 'PND')
    		{    			
    			/* Original: PND , Yes Endowment = Remove Currently Waiting */
    			if (original_endowment == 1)
    			{
    				$("input[name='event_status']").attr('value', 'SCHD');
    				$('#event_status_value').html('Scheduled');
    				$('#new_endowment_note').css('display', 'none');
    				$('#remove_endowment_note').css('display', 'block');
    				$('#pending_endowment_note').css('display', 'none');
    			}    			
    			/* Original: PND , No Endowment = Nothing new */
    			else
    			{
					$("input[name='event_status']").attr('value', 'PND');
    				$('#event_status_value').html('Pending');
    				$('#new_endowment_note').css('display', 'none');
    				$('#remove_endowment_note').css('display', 'none');
    				$('#pending_endowment_note').css('display', 'none');
    			}
    		}     		
    	}   	

	}

    $('#is_endowment').change (function ()
    {
    	updateEndowmentNotes();
	});

	updateEndowmentNotes();
 
 	$('#swap_home_away')
 		.button({text : false, icons : { primary : 'ui-icon-shuffle'}})
 		.click(function ()
		{
			var home_team = $("input[name='home_team_name']").val();
	    	var away_team = $("input[name='away_team_name']").val();

			home_team = home_team.replace(/(<([^>]+)>)/ig,"");
	    	away_team = away_team.replace(/(<([^>]+)>)/ig,"");

	    	var home_level = $("select[name='home_team_level'] option:selected").val();
	    	var away_level = $("select[name='away_team_level'] option:selected").val();

	    	var home_state = $("select[name='home_state'] option:selected").val();
	    	var away_state = $("select[name='away_state'] option:selected").val();

	    	var home_oos = $("#is_home_oos:checked").size() > 0;
	    	var away_oos = $("#is_away_oos:checked").size() > 0;	    	
	    	
			$("input[name='home_team_name']").val(away_team);
			$("input[name='away_team_name']").val(home_team);		

			$("select[name='home_team_level']").val(away_level);
			$("select[name='away_team_level']").val(home_level);

			$("select[name='home_state']").val(away_state);
			$("select[name='away_state']").val(home_state);

			
			if (home_oos && !away_oos)
			{
				$('#is_away_oos').click();
				$('#is_home_oos').click();
			}
			else if (!home_oos && away_oos)
			{
				$('#is_away_oos').click();
				$('#is_home_oos').click();
			}
			
		});		


 	var availableOpponents = [
      <?php echo $information['available_opponents']; ?>
    ];

    var availableLocations = [
      <?php echo $information['available_locations']; ?>
    ];

    var availableTournaments = [
      <?php echo $information['available_tournaments']; ?>
    ];
    
    $(".team_name" ).autocomplete({source : availableOpponents});

	$('#location').autocomplete({source : availableLocations});
	$('#tournament').autocomplete({source : availableTournaments});
   

	$('#is_tournament').change(function ()
	{
		if ($('#is_tournament:checked').size() > 0 && $('#is_neutral_location:checked').size() < 1)
    	{
    		$('#is_neutral_location').click();
    	}    	
	});	

	$('#confirm_dialog').dialog({
      autoOpen: false,
      resizable: false,
      height:275,
      width: 400,
      modal: true,
      buttons: {
        "Yes": function() {

          $('#editContest').submit();

          $(this).dialog("close");

          return true;
        },
        "No": function() {
          $(this).dialog( "close" );
          return false;
        }
      }
    });  

	$('.button[data-confirm]').click(function ()
	{
		var button_id = $(this).attr('id');
		var action = $(this).attr('data-confirm');

		var input = $('<input>').attr('type', 'hidden').attr('name', 'special_action').val(button_id);
		$('#editContest').append($(input));

		$('#confirm_dialog').html(action).dialog('open');
	});


    $('#is_postpone').click(function ()
    {
        $('<div></div>')
            .appendTo('body')
            .html('Are you sure you want to postpone this contest?<br /><br /><div class="ui-state-highlight" style="padding:5px;"><div class="ui-icon ui-icon-alert float_left margin-right:1em;"></div>A postponed contest will be played at a later date that you can enter below.  If you don\'t know the time, leave it blank.</div><br /><b>Rechedule Contest To:</b><br /><br /><?php echo Form::label('postpone_date', 'Date', array('class' => 'input_label', 'style' => '')); ?> <?php echo Form::text('postpone_date', null, array('style' => 'width:100px;')); ?> <span class="small gray note">MM/DD/YYYY</span><br /><br /><?php echo Form::label('postpone', 'Time', array('class' => 'input_label', 'style' => '')); ?> <?php echo Form::text('postpone_time', null, array('style' => 'width:80px;')); ?>')
            .dialog(
                 {
                 autoOpen: true,
                 draggable: false,
                 resizable: false,
                 height: 360,
                 width: 400,
                 title: 'Confirm Postpone',
                 modal: true,
                 buttons: [
                    {
                        text : "Postpone",
                        'class' : "float_left",
                        icons : { primary : 'ui-icon-check'},
                        click : function()
                              {                                                                   
                                  if ($('input[name="postpone_date"]').val() == '')
                                  {
                                      alert('You must enter in the date this contest will be postponed to.');
                                      return false;
                                  }

                                  var input = $('<input>')
                                                  .attr('type', 'hidden')
                                                  .attr('name', 'special_action')
                                                  .val('is_postpone');

                                  $('#editContest').append($(input));

                                  var input = $('<input>')
                                                  .attr('type', 'hidden')
                                                  .attr('name', 'postpone_date')
                                                  .val($('input[name="postpone_date"]').val());

                                  $('#editContest').append($(input));

                                  var input = $('<input>')
                                                  .attr('type', 'hidden')
                                                  .attr('name', 'postpone_time')
                                                  .val($('input[name="postpone_time"]').val());

                                  $('#editContest').append($(input));

                                  $('#editContest').submit();

                                  $(this).dialog( "close");
                                  $(this).remove();                                  
                               }
                    },
                    {
                        text : "Cancel",
                        'class' : "float_right",
                        'autofocus' : 'true',
                        icons : { primary : 'ui-icon-cancel'},
                        click : function()
                                {
                                    $(this).dialog( "close");;
                                    $(this).remove();
                                }
                    }
                 ],
                 open : function ()
                 {                   
                      $(this).parent().find('[autofocus]').focus();
                      $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '10pt');
                      $('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');
                      //$('.ui-dialog-titlebar').addClass('ui-state-highlight');
                      $('input[name="postpone_date"]').datepicker({'dateFormat' : 'mm/dd/yy', 'minDate' : '<?php echo $information['first_event_at']; ?>', 'maxDate' : '<?php echo $information['last_event_at']; ?>'});    
                      $('input[name="postpone_time"]').timepicker({ 'timeFormat': 'h:i A' , 'step' : 15});
                  }
            });       
    });

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

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

    <?php if ($information['contest']->contest_type == 'PO'): ?>
        <a href="<?php echo url ('/activities/' . strtolower($information['contest']->activity) . '/brackets?div=' . $information['contest']->division); ?>" id="cancel_button">Exit</a>
    <?php else: ?>
        <a href="<?php echo url ('/teams/' . $information['my_team'] . '/edit'); ?>" id="cancel_button">Exit</a>
    <?php endif; ?>

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


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

	<h2>Edit Contest</h2>				 	

	<?php echo Form::open(array('url' => url('/contests/edit'),
                      'class' => 'editContest',
                      'id' => 'editContest')); ?>

		<?php if (Session::has('errors')): ?>                
            <div class="error ui-state-error"><span class="ui-icon ui-icon-alert box_icon"></span><?php foreach ($errors->all() as $error): ?><?php echo $error; ?> <?php endforeach; ?></div>
        <?php endif; ?>

        <?php echo Form::hidden('my_team', $information['my_team']); ?>

        <div class="columns">

        	<div class="fourth">

				      <div class="input_label">Status</div>
              
              <small><span id="event_status_value"><?php echo Helpers::getEventStatusName ($information['event']->event_status); ?></span></small>
				      
              <?php echo Form::hidden('event_status', $information['event']->event_status); ?>
				
			    </div>

			<div class="fourth">

			    <div class="input_label">Contest ID</div><?php echo $information['contest']->id; ?>
				<?php echo Form::hidden('contest', $information['contest']->id); ?>         

			</div>

			<div class="fourth">

				<div class="input_label">Event ID</div><?php echo $information['event']->id; ?>
				<?php echo Form::hidden('event', $information['event']->id); ?>       

			</div>

      <?php if ($information['contest']->is_forfeit): ?>
          <div class="fourth">
              <div class="input_label">Forfeit</div>
          </div>
      <?php endif; ?>

		</div>
	    
	    <br /><br />

        <?php echo Form::label('away_team_name', 'Away Team', array('class' => 'input_label')); ?>
        <?php if ($information['contest']->contest_type == 'PO'): ?>
            
            <?php if (!Auth::user()->isOsaaUser()): ?>

                <?php echo Form::text('away_team_name',
                              $information['contest']->away_team_name,
                              array('class' => 'team_name',
                                    'style' => 'width:225px;',
                                    'readonly' => 'readonly')); ?>

            <?php else: ?>

                <?php echo Form::text('away_team_name',
                              $information['contest']->away_team_name,
                              array('class' => 'team_name',
                                    'style' => 'width:225px;')); ?>

            <?php endif; ?>

        <?php else: ?>
        
            <?php echo Form::text('away_team_name',
                          $information['contest']->away_team_name,
                          array('class' => 'team_name',
                                'style' => 'width:225px;')); ?>

        <?php endif; ?>
        <?php echo Form::hidden('away_team_id', $information['contest']->away_team); ?>

        <div style="display:inline-block; width:25px;"></div>


        <?php if ($information['contest']->contest_type == 'PO'): ?>

            <?php echo Form::select('away_team_level',
                            array('V' => 'V'),
                            $information['away_team_level'],
                            array('style' => 'width:60px;')); ?>

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

                <?php echo Form::label('away_seed', 'Seed', array('class' => 'input_label', 'style' => 'width: 75px;')); ?>
                <?php                
                    $matchup = matchup::where('contest', '=', $information['contest']->id)
                                      ->firstOrFail();
                    $away_seed = $matchup->away_seed;
                ?>

                <?php echo Form::text('away_seed',
                              $away_seed,
                              array('class' => 'team_seed',
                                    'style' => 'width:75px;')); ?>

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

            <?php echo Form::select('away_team_level',
                            array('V' => 'V', 'JV' => 'JV', 'JV2' => 'JV2', 'FR' => 'FR', 'FR2' => 'FR2'),
                            $information['away_team_level'],
                            array('style' => 'width:60px;')); ?>

            <div style="display:inline-block; width:25px;"></div>

            <?php echo Form::checkbox('is_away_oos',
                              true,
                              ($information['away_team_oos']) ? true : false,
                              array('id' => 'is_away_oos',
                                    'class' => 'button')); ?>
            
            <?php echo Form::label('is_away_oos', 'Out-of-State', array('style' => 'font-size:10pt;')); ?>

            <div style="display:inline-block; width:25px;"></div>

            <?php echo Form::label('away_state', 'State/Province/Territory:', array('class' => 'input_label', 'style' => 'width:auto;')); ?>
            <select style="width:60px;" id="away_state" name="away_state" disabled="disabled">
            <?php

                $states = DB::select("SELECT slug, name FROM states WHERE slug != 'OR' ORDER BY FIELD(slug, 'WA') DESC, FIELD(slug, 'ID') DESC, FIELD(slug, 'CA') DESC, slug");

                foreach ($states as $s)
                {
                    $name = $s->name;
                    $slug = $s->slug;                       
                    
                    echo '<option value="' . $slug . '"';

                    if ($slug == $information['away_team_state']) echo ' selected="selected"';

                    echo '>' . $slug . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $name . '</option>';                      
                }

                unset ($states);

                echo '<option value="Other">Other</option>';

            ?>
            </select>
        <?php endif; ?>

	    <br />
		
		<?php if ($information['contest']->contest_type == 'PO'): ?>
            <?php if (Auth::check() and Auth::user()->isOsaaUser()): ?>
                <div id="swap_home_away" class="tooltip" title="Swap the home and away teams."></div>
            <?php endif; ?>
        <?php else: ?>
            <div id="swap_home_away" class="tooltip" title="Swap the home and away teams."></div>
        <?php endif; ?>

	    <br />

        <?php echo Form::label('home_team_name', 'Home Team', array('class' => 'input_label')); ?>
        <?php if ($information['contest']->contest_type == 'PO'): ?> 

            <?php if (!Auth::user()->isOsaaUser()): ?>
                
                <?php echo Form::text('home_team_name',
                              $information['contest']->home_team_name,
                              array('class' => 'team_name',
                                    'style' => 'width:225px;',
                                    'readonly' => 'readonly')); ?>                
            
            <?php else: ?>
                
                <?php echo Form::text('home_team_name',
                              $information['contest']->home_team_name,
                              array('class' => 'team_name',
                                    'style' => 'width:225px;')); ?> 

            <?php endif; ?>

        <?php else: ?>            
            <?php echo Form::text('home_team_name',
                          $information['contest']->home_team_name,
                          array('class' => 'team_name',
                                'style' => 'width:225px;')); ?>            
        <?php endif; ?>

        <?php echo Form::hidden('home_team_id', $information['contest']->home_team); ?>

        <div style="display:inline-block; width:25px;"></div>

        <?php if ($information['contest']->contest_type == 'PO'): ?> 
            <?php echo Form::select('home_team_level',
                            array('V' => 'V'),
                            $information['home_team_level'],
                            array('style' => 'width:60px;')); ?>            

            <?php if (Auth::user()->isOsaaUser()): ?>
                <?php echo Form::label('home_seed', 'Seed', array('class' => 'input_label', 'style' => 'width: 75px;')); ?>
                <?php                   
                    $home_seed = $matchup->home_seed;
                ?>

                <?php echo Form::text('home_seed',
                              $home_seed,
                              array('class' => 'team_seed',
                                    'style' => 'width:75px;')); ?>
            <?php endif; ?>
        <?php else: ?>
            <?php echo Form::select('home_team_level',
                            array('V' => 'V', 'JV' => 'JV', 'JV2' => 'JV2', 'FR' => 'FR', 'FR2' => 'FR2'),
                            $information['home_team_level'],
                            array('style' => 'width:60px;')); ?>        
        
            <div style="display:inline-block; width:25px;"></div>

            <?php echo Form::checkbox('is_home_oos',
                              true,
                              ($information['home_team_oos']) ? true : false,
                              array('id' => 'is_home_oos',
                                    'class' => 'button')); ?>
            <?php echo Form::label('is_home_oos', 'Out-of-State', array('style' => 'font-size:10pt;')); ?>

            <div style="display:inline-block; width:25px;"></div>

            <?php echo Form::label('home_state', 'State/Province/Territory:', array('class' => 'input_label', 'style' => 'width:auto;')); ?>
            <select style="width:60px;" id="home_state" name="home_state" disabled="disabled">
            <?php

                $states = DB::select("SELECT slug, name FROM states WHERE slug != 'OR' ORDER BY FIELD(slug, 'WA') DESC, FIELD(slug, 'ID') DESC, FIELD(slug, 'CA') DESC, slug");

                foreach ($states as $s)
                {
                    $name = $s->name;
                    $slug = $s->slug;
                    
                    echo '<option value="' . $slug . '"';

                    if ($slug == $information['home_team_state']) echo ' selected="selected"';

                    echo '>' . $slug . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $name . '</option>';                      
                }

                unset ($states);

                echo '<option value="Other">Other</option>';

            ?>
            </select>

        <?php endif; ?>        

	    <br /><br />

      <?php
          // Is this contest flagged as not rankable?
          if (!is_null($information['contest']->flags))
          {
              // Decode the flags from the contest, should be a JSON string
              $flags = json_decode($information['contest']->flags);

              // Was the object decoded, and it's a valid object, and it has an 'is_rankable' property
              if (!is_null($flags) and
                  is_object($flags) and
                  property_exists($flags, 'is_rankable'))
              {
                  // If the property is false, then the contest is not rankable
                  if (!$flags->is_rankable)
                  {
                      $flagged = 1;
                  }
              }
          }
          else
          {
              $flagged = 0;
          }

      ?>

      <div style="float: right;">            
          <?php if (Auth::check() and Auth::user()->isOsaaUser()): ?>
              <label class="input_label" style="width: 215px; text-align: left;">
                  Flag as non-rankable?
                  <input type="checkbox" name="flag_not_rankable" id="flag_not_rankable" value="<?php echo $flagged; ?>" <?php if ($flagged): ?> checked="checked" <?php endif; ?> style="vertical-align: middle; margin-right: 8px;" />
              </label>

              <br />
              <span class="small gray note">OSAA Staff Only: This will exclude the contest from the rankings.</span>

          <?php elseif ($flagged): ?>

              <img src="<?php echo asset('/images/icons/red_flag_16px.png'); ?>" alt="" title="" style="vertical-align: middle; margin-right: 5px;" />
              <span class="input_label" style="text-align: left;">Not Rankable</span>
              <br />
              <span class="small gray note">This contest will be excluded from the rankings.</span>

          <?php endif; ?>

      </div>      
	           
		<?php echo Form::label('event_date', 'Date', array('class' => 'input_label', 'style' => '')); ?>
		<?php echo Form::text('event_date',
                      $information['event_date'],
                      array('style' => 'width:100px;')); ?>
		
        <span class="small gray note">MM/DD/YYYY</span>
		
		<br /><br />

    <?php
      if (!Helpers::strEqual($information['event_time'], 'TBD') and !Helpers::strEqual($information['event']->time_zone, 'PT'))
      {
           $information['event_time'] = date('h:i A', strtotime($information['event']->start_at . ' ' . Helpers::getTimeZoneOffset($information['event']->time_zone)));
      }

    ?>

		<?php echo Form::label('event_time', 'Time', array('class' => 'input_label', 'style' => '')); ?>
		<?php echo Form::text('event_time',
                      $information['event_time'],
                      array('style' => 'width:80px;')); ?>
		
        <?php echo Form::select('time_zone',
                        array('PT' => 'Pacific', 'MT' => 'Mountain', 'CT' => 'Central', 'ET' => 'Eastern'),
                        $information['event']->time_zone,
                        array('style' => 'width:80px;')); ?>

		<br /><br />			
			
		<div class="input_label">Contest Type</div>				

		<div id="contest_type" style="font-size:9pt; display:inline;">				
		    <input type="radio"
                   id="radio1"
                   name="contest_type"
                   value="J"                                      
                   <?php if ($information['contest']->contest_type == 'J'): ?>
                        checked="checked"
                   <?php elseif ($information['contest']->contest_type == 'PO'): ?>                       
                       disabled="disabled"                    
                   <?php endif; ?> />
            <label for="radio1" class="tooltip" title="A jamboree is a shortened contest and is not counted towards contest limitations.">Jamboree</label>    
		    
            <input type="radio"
                   id="radio5"
                   name="contest_type"
                   value="NL"
                   <?php if ($information['contest']->contest_type == 'NL'): ?>
                       checked="checked"
                   <?php elseif ($information['contest']->contest_type == 'PO'): ?>                       
                       disabled="disabled"                    
                   <?php endif; ?> />
            <label for="radio5" class="tooltip" title="Contests between opponents that are not in the same league are considered non-league contests.">Non-League</label>
		    
            <input type="radio"
                   id="radio6"
                   name="contest_type"
                   value="L"
                   <?php if ($information['contest']->contest_type == 'L'): ?>                    
                       checked="checked"
                   <?php elseif ($information['contest']->contest_type == 'PO'): ?>                       
                       disabled="disabled"                   
                   <?php endif; ?> />
            <label for="radio6" class="tooltip" title="If both opponents are from the same league or special district, then the contest is considered a league contest.">League</label>
		    
            <input type="radio"
                   id="radio7"
                   name="contest_type"
                   value="LPO"
                   <?php if ($information['contest']->contest_type == 'LPO'): ?>
                       checked="checked"
                   <?php elseif ($information['contest']->contest_type == 'PO'): ?>                       
                       disabled="disabled"                   
                   <?php endif; ?> />
            <label for="radio7" class="tooltip" title="Contests played within a league to determine final league placement are considered league playoff contests.">League Playoff</label>
		    
            <input type="radio"
                   id="radio8"
                   name="contest_type"
                   value="PI"
                   <?php if ($information['contest']->contest_type == 'PI'): ?>
                       checked="checked"
                   <?php elseif ($information['contest']->contest_type == 'PO'): ?>                       
                       disabled="disabled"                   
                   <?php endif; ?> />
            <label for="radio8" class="tooltip" title="Play-In games are determined by the 6A, 5A, and 4A classifications.">Play-In</label>
		    
            <input type="radio"
                   id="radio9"
                   name="contest_type"
                   value="PO"
                   <?php if ($information['contest']->contest_type == 'PO'): ?>
                       checked="checked"
                   <?php else: ?>
                       disabled="disabled"
                   <?php endif; ?> />
            <label for="radio9">Playoff</label>
		</div>	

        <br />
        <div class="input_label"></div>
        <span class="small">You must specify a contest type, even for tournament or endowment games.</span>		

        <?php if ($information['contest']->contest_type != 'PO'): ?>

    		<?php echo Form::checkbox('is_endowment',
    					      true,
    					      $information['contest']->is_endowment,
    					      array('id' => 'is_endowment',
    					      	    'class' => 'button')); ?>
    		<?php echo Form::label('is_endowment',
    					   'Endowment',
    					   array('style' => 'font-size:10pt; float:right;',
    					   	     'class' => 'tooltip', 'title' => 'Is this contest an endowment contest?')); ?>					

    		<br />

    		<div class="ui-state-highlight ui-corner-all" style="padding:5px; margin-top:1em; display:none;" id="new_endowment_note">			
    			<span class="ui-icon ui-icon-info float_left margin-right:0.5em;"></span><b>Note:</b> Endowment contests require OSAA approval.  By checking "Endowment," you are requesting this contest to be approved as an endowment contest and its status will be changed to pending until the OSAA office approves this endowment contest.
    		</div>

    		<div class="ui-state-highlight ui-corner-all" style="padding:5px; margin-top:1em; display:none;" id="remove_endowment_note">			
    			<span class="ui-icon ui-icon-info float_left margin-right:0.5em;"></span><b>Note:</b> Endowment contests require OSAA approval.  By un-checking "Endowment," you are withdrawing your request to have this contest considered an endowment contest.  If you change your mind, and you really want this contest to be an endowment contest after all, you will have to go through the approval process again.
    		</div>

    		<div class="ui-state-highlight ui-corner-all" style="padding:5px; margin-top:1em; display:none;" id="pending_endowment_note">			
    			<span class="ui-icon ui-icon-info float_left margin-right:0.5em;"></span><b>Note:</b> Endowment contests require OSAA approval.  This contest is currently pending approval from the OSAA office.  Once approved, its status will change to scheduled.
    		</div>

            <br />

    		<?php echo Form::label('tournament', 'Tournament Name', array('class' => 'input_label')); ?>	           
    	    <?php echo Form::text('tournament', $information['contest']->tournament, array('style' => 'width:250px;')); ?>
    	    <span class="small gray note">(If in a tournament)</span>

            <div style="display:inline-block; width:25px;"></div>	            

    	    <?php echo Form::checkbox('is_tournament', true, $information['contest']->is_tournament, array('id' => 'is_tournament', 'class' => 'button')); ?>
    	    <?php echo Form::label('is_tournament', 'Tournament', array('style' => 'font-size:10pt;', 'class' => 'tooltip', 'title' => 'If this contest is being played as part of a tournament, please check this button and provide the tournament name.')); ?>	        	          
    	<?php else: ?>
            
            <?php echo Form::hidden('tournament', null); ?>

        <?php endif; ?>

        <br /><br />

		<?php echo Form::label('location', 'Alternate Location ', array('class' => 'input_label')); ?>	           
        <?php echo Form::text('location', $information['location'], array('style' => 'width:200px;')); ?>
	    <span class="small gray note">(Location name if not played at home team's school)</span>
	    
	    <?php /*  Playoff Contests and Baseball/Softball contests cannot select neutral locations  */ ?>
        <?php if ($information['contest']->contest_type != 'PO' and !Helpers::strEqual($information['contest']->activity, array('BBL', 'SBL'))): ?>

            <div style="display:inline-block; width:25px;"></div>	                     
    		       
    		<?php echo Form::checkbox('is_neutral_location', true, $information['contest']->is_neutral_location, array('id' => 'is_neutral_location', 'class' => 'button')); ?>
            <?php echo Form::label('is_neutral_location', 'Neutral Site', array('style' => 'font-size:10pt;', 'class' => 'tooltip', 'title' => 'If this contest is being played at a neutral site, please check this button.')); ?>

        <?php endif; ?>

        <?php if ($information['contest']->contest_type == 'PO' and Auth::user()->isOsaaUser()): ?>

            <br /><br />

            <h2>Edit Playoff Matchup</h2>

            <br />

            <div class="columns">
                
                <div class="half">

                    <?php echo Form::label('live_url', 'Live Coverage URL', array('class' => 'input_label', 'style' => 'text-align: left;')); ?>
                    <?php echo Form::text('live_url', $information['matchup']->live_url, array('style' => 'width: 310px;')); ?><br />
                    <span class="small gray note">(Fully qualified URL link to the live stats page for this matchup if it'll be covered live.)</span>

                    <br /><br />

                    <?php echo Form::label('video_url', 'Video Feed URL', array('class' => 'input_label', 'style' => 'text-align: left;')); ?>
                    <?php echo Form::text('video_url', $information['matchup']->video_url, array('style' => 'width: 310px;')); ?><br />
                    <span class="small gray note">(Fully qualified URL link to the live video feed or archive file, if any.)</span>

                    <br /><br />

                    <?php echo Form::label('audio_url', 'Audio Feed URL', array('class' => 'input_label', 'style' => 'text-align: left;')); ?>
                    <?php echo Form::text('audio_url', $information['matchup']->audio_url, array('style' => 'width: 310px;')); ?><br />
                    <span class="small gray note">(Fully qualified URL link to the live radio feed or archive file, if any.)</span>

                    <br /><br />

                    <?php echo Form::label('stats_url', 'Stats URL', array('class' => 'input_label', 'style' => 'text-align: left;')); ?>
                    <?php echo Form::text('stats_url', $information['matchup']->stats_url, array('style' => 'width: 310px;')); ?><br />
                    <span class="small gray note">(Fully qualified URL link to the final contest stats, if any.)</span>                    
                </div>

                <div class="half">

                    <?php echo Form::label('broadcasters', 'List of Broadcasters &amp; Media Outlets', array('class' => 'input_label', 'style' => 'text-align: left; width: 100%;')); ?>
                    <?php echo Form::textarea('broadcasters', $information['matchup']->broadcasters, array('style' => 'width: 100%; max-width: 100%; height: 6em; max-height: 6em;')); ?>
                    <span class="small gray note">                       
                        Separate broadcasters with ';' (a semicolon.)  Enclose fully qualified URLs in '{' and '}' (curly braces.)  If the station is providing a video feed, include the word %video% (with percent symbols) somewhere in that line.  For example: "KGIB 101.5 FM {http://www.osaa.org}; KVAL TV Channel 4 %video%"
                    </span>

                    <br /><br />

                    <?php echo Form::label('is_auto_advance', 'Is Auto-Advance?', array('class' => 'input_label', 'style' => 'text-align: left;')); ?>
                    <?php echo Form::checkbox('is_auto_advance', true, $information['matchup']->is_auto_advance, array('style' => 'position: relative; top: 2px;')); ?>
                    <div class="small gray note" style="float: left; position: relative; left: 200px; width: 300px; height: 0;">
                        If checked, once this contest has a score, it will attempt to auto-advance the winner or loser, if applicable.
                    </div>

                    <br /><br /><br />

                    <?php echo Form::label('is_alert', 'Show Alert?', array('class' => 'input_label', 'style' => 'text-align: left;')); ?>
                    <?php echo Form::checkbox('is_alert', true, $information['matchup']->is_alert, array('style' => 'position: relative; top: 2px;')); ?>
                    <div class="small gray note" style="float: left; position: relative; left: 200px; width: 300px; height: 0;">
                        If checked, this contest will have an alert icon displayed on the bracket.
                    </div>



                </div>

            </div>

            <br class="clear" />

        <?php endif; ?>

	    <br />

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

	    <br />		

        <?php if ($information['event']->event_status == 'CXL'): ?>
            <?php echo Form::button('Reinstate Contest',
                             array('id' => 'is_undo_cancel',
                                   'class' => 'button tooltip',
                                   'data-confirm' => 'Are you sure you want to reinstate this contest?<br /><br /><div class="ui-state-error" style="padding:5px;"><div class="ui-icon ui-icon-alert float_left margin-right:1em;"></div>This action will change the contest\'s status from canceled to scheduled.</div>',
                                   'title' => 'Click this button to reinstate this contest.  This will change the status from canceled to scheduled.')); ?>
        <?php else: ?>
    		<?php echo Form::button('Cancel Contest',
            				 array('id' => 'is_cancel',
            				 	   'class' => 'button tooltip',
            				   	   'data-confirm' => 'Are you sure you want to cancel this contest?<br /><br /><div class="ui-state-error" style="padding:5px;"><div class="ui-icon ui-icon-alert float_left margin-right:1em;"></div>A canceled contest will still appear on your schedule, but as canceled.</div>',
            				   	   'title' => 'Click this button to cancel this contest.  A canceled contest will still appear on your schedule, but as canceled.')); ?> 
        <?php endif; ?>

		<div style="display:inline-block; width:25px;"></div>

        <?php echo Form::button('Delete Contest',
        				 array('id' => 'is_delete',
        				 	   'class' => 'button tooltip',
        				   	   'data-confirm' => 'Are you sure you want to delete this contest?<br /><br /><div class="ui-state-error" style="padding:5px;"><div class="ui-icon ui-icon-alert float_left margin-right:1em;"></div>A deleted contest will be removed from your schedule.  Once deleted, this contest cannot be recovered easily.</div>',
        				   	   'title' => 'Click this button to delete this contest.  A deleted contest will be removed from your schedule.  Once deleted, this contest cannot be recovered easily.')); ?>  

        <?php if (Helpers::strEqual($information['contest']->activity, array('BBL', 'SBL'))): ?>

            <div style="display:inline-block; width:25px;"></div>

            <?php echo Form::button('Postpone Contest',
            				 array('id' => 'is_postpone',
            				 	   'class' => 'button tooltip',            				   	   
            				   	   'title' => 'Click this button to postpone this contest.  A postponed contest is a contest that has to be rescheduled, but it will be played at another time in the future.')); ?>

        <?php endif; ?>

        <div style="display:inline-block; width:25px;"></div>


        <?php if (Helpers::strEqual ($information['event']->event_status, array('LIVE', 'DONE')) and $information['contest']->level == 'V' and $information['contest']->is_scoreable): ?>
            <a href="<?php echo url('/contests/' . $information['contest']->id . '/submit-scores'); ?>"
               class="button tooltip"
               title="Submit scoring information for this contest.">Submit Scores</a>
        <?php endif; ?>
         
        
	    <?php echo Form::submit('Update', array('class' => 'button float_right')); ?>

        <br /><br />				

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

		<div id="confirm_dialog" title="Confirmation"></div>	

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

