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

<?php $__env->startSection('page_sub_title'); ?>    
    Edit <?php echo $information['team_name_title']; ?>
<?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();
	$('.tooltip.above').tooltip({ position : {my: "left bottom-15", at: "left top", collision: "flipfit"}});
	$('.tooltip.right').tooltip({ position : {my: "left+15 middle", at: "right middle", collision: "flipfit"}});

	$('.button').button();		
	$('.button.notext').button({text:false});
	$('.button.edit').button({ icons : { primary : 'ui-icon-pencil'}});
	$('.button.delete').button({ icons : { primary : 'ui-icon-closethick'}});
	$('.button.drop').button({ icons : { primary : 'ui-icon-circle-close'}});
	$('.button.cancel').button({ icons : { primary : 'ui-icon-circle-minus'}});
	$('.button.trash').button({ icons : { primary : 'ui-icon-trash'}});
	$('.button.clipboard').button({ icons : { primary : 'ui-icon-clipboard'}});
	$('.button.print').button({ icons : { primary : 'ui-icon-print'}});
	$('.button.add').button({ icons : { primary : 'ui-icon-plusthick'}});
	$('.button.next').button({ icons : { secondary : 'ui-icon-triangle-1-e'}});
	$('.button.add_teams').button({ icons : { secondary : 'ui-icon-triangle-1-e'}});	
	$('.button.join').button({ icons : { secondary : 'ui-icon-triangle-1-e'}});
	$('.button.next_add').button({ icons : { secondary : 'ui-icon-plus'}});
	$('.button.add_more_team_spots').button({ icons : { primary : 'ui-icon-plus'}});
	$('.button.create').button({ icons : { secondary : 'ui-icon-triangle-1-e'}});
	$('.button.search').button({ icons : { secondary : 'ui-icon-triangle-1-e'}});
	$('.button.reset').button({ icons : { primary : 'ui-icon-triangle-1-w'}});
	$('.button.submit_scores').button({ icons : { primary : 'ui-icon-circle-arrow-e' }});	
	$('.home_button').button({ icons : { primary : 'ui-icon-home'}, text : false}).css('height', '24px').css('margin-top', '3px');
	$('.team_view_button').button({ icons : { primary : 'ui-icon-bookmark'}}).css('margin-right', '10px').css('margin-top', '3px');
	$('.oos_button').button({ icons : { primary : 'ui-icon-note' }}).css('margin-right', '10px').css('margin-top', '3px');
	
	$('.button_set').buttonset();
	$('.button_set label').addClass('ui-corner-all');

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

	$('#related_teams input').click(function() {
		var link_location = $(this).attr('data-href');
		
		if (!$(this).attr('checked'))
		{
			window.location = link_location;
		}
	});

	$('#add_team').button({icons : {primary : 'ui-icon-plusthick'}, text : false});

	$('.tabs').tabs({
		beforeActivate : function (event, ui)
		{
			if (ui.newTab.is('[data-escape]'))
			{
				event.preventDefault();
				window.location = ui.newTab.attr('data-escape');				
			}	
		}
	});


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

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


	/*
	$('.add_contest .close').click(event, function () {
        
        var panel = $(event.target).parent();

        var state = panel.attr('data-state');


        if (state == 'expand')
        {
            panel.css('height', panel.attr('data-min'));
            panel.attr('data-state', 'collapse'); 

            panel.children('*').css({'visibility' : 'hidden', 'display' : 'none'});
            panel.children('.close').css({'visibility' : 'visible', 'display' : 'block'});

            panel.children('.close').removeClass ('ui-icon-triangle-1-n');
            panel.children('.close').addClass ('ui-icon-triangle-1-s');            

        }
        
        if (state == 'collapse')
        {
            panel.css('height', panel.attr('data-max'));
            panel.attr('data-state', 'expand'); 

            panel.children('*').css({'visibility' : 'visible', 'display' : 'block'});           

            panel.children('.close').removeClass ('ui-icon-triangle-1-s');
            panel.children('.close').addClass ('ui-icon-triangle-1-n');
        }
    });
    */

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

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

	function updateOOSState2 ()
    {
		if ($('input[name="host_is_oos"]:checked').length > 0)
    	{
    		$('#state').removeAttr('disabled');   		
    	}
    	else
    	{
    		$('#state').attr('disabled', 'disabled');
    	}  
	}

	function updateOOSState3 ()
    {
		if ($('input[name="other_team_is_oos"]:checked').length > 0)
    	{
    		$('#state2').removeAttr('disabled');   		
    	}
    	else
    	{
    		$('#state2').attr('disabled', 'disabled');
    	}  
	}

	updateOOSState ();
	updateOOSState2 ();
	updateOOSState3 ();

    $('#is_oos_opponent').change(function ()
    {
    	updateOOSState ();
    });

    $('input[name="host_is_oos"]').change(function ()
    {
    	updateOOSState2 ();
    });

    $('input[name="other_team_is_oos"]').change(function ()
    {
    	updateOOSState3 ();
    });


    $('#is_endowment').change (function ()
    {
    	if ($('#is_endowment:checked').length > 0)
    	{
    		$("input[name='event_status']").attr('value', 'PND');
    		$('.event_status_text').html('<span style="color:#990000;"><b>Pending / Needs Approval</b></span>');
    		$('.event_status_note').html('Once you create this contest, it must be approved by the OSAA office; it will appear on your schedule as pending<br />');

    	}
    	else
    	{
    		$("input[name='event_status']").attr('value', 'SCHD');
    		/*
    		$('.event_status_text').html('<span style="color:#0d581b;"><b>Ready to be scheduled</b></span>');
    		$('.event_status_note').html('Once you create this contest, it will be added to your schedule');
    		*/
    		$('.event_status_text').html('');
    		$('.event_status_note').html('');
    	}   	

	});
 
 	$('#swap_home_away').button({text : false, icons : { primary : 'ui-icon-shuffle'}});

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

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

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


    $("#opponent" ).autocomplete({
        source : availableOpponents,        
        change : function (event, ui)
    	{    	
	    	if ($('#swapped').val() > 0)
	    	{
	    		$("input[name='home_team_name']").attr('value', $(this).val());
	    	}
	    	else
	    	{
				$("input[name='away_team_name']").attr('value', $(this).val());
	    	}

	    	updateTeamDesignations ();

	    	return true;
		}});

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


    function updateTeamDesignations ()
    {
    	var home_team = $("input[name='home_team_name']").attr('value');
    	var away_team = $("input[name='away_team_name']").attr('value');

    	if (home_team != null)
    	{
    		$('#home_team_name').html(home_team.replace(/(<([^>]+)>)/ig,""));
    	}
    	if (away_team != null)
    	{
    		$('#away_team_name').html(away_team.replace(/(<([^>]+)>)/ig,""));   	
    	}
	}	    

	updateTeamDesignations ();

	$('#swap_home_away').click(function ()
	{
		var home_team = $("input[name='home_team_name']").attr('value');
    	var away_team = $("input[name='away_team_name']").attr('value');
		
		$("input[name='home_team_name']").attr('value', away_team);
		$("input[name='away_team_name']").attr('value', home_team);

		updateTeamDesignations ();

		$('#swapped').val($('#swapped').val() * -1);
	});

	
	$('#is_neutral_location, #is_endowment, #is_tournament, #is_oos_opponent').button();

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

	$('#tournament').change(function ()
	{
		if ($(this).val() != "" && $('#is_tournament:checked').length < 1)
		{
			$('#is_tournament').click();
		}
	});

	/* Display any success messages */
    $('.success_message').delay(5000).fadeOut({'duration' : 2500});
    $('.success_message .ui-icon-close').click(function ()
    {
        $('.success_message').hide();
    });

    $('.edit_contest_button').button({ icons : {primary : 'ui-icon-pencil'},
									   text : false}).css('width', '16px').css('position', 'relative').css('top', '-1px').css('margin-left', '4px').tooltip().attr('title', 'Click to edit this contest.');

	/*$('#schedule tbody tr:even').css('background-color', '#f2f2f2');*/
	$("#schedule tbody tr[data-pending]").css('background-color', '#ffefb0');
	$("#schedule tbody tr[data-canceled]").css('background-color', '#ffb0b0');
	$("#schedule tbody tr[data-postponed]").css('background-color', '#aa9ce7');
	$("#schedule tbody tr[data-live]").css('background-color', '#b0ffbe');

	$('#schedule tbody tr:visible:odd').css('background-color', '#f2f2f2');

	$("#add_a_school").button(
		{
			icons : {
						primary : 'ui-icon-circle-plus'
					}
		}
	).click(function ()
	{
		var n = $('input.other_school').size();		

		var label = $('<label>').attr('for', 'other_school_' + (n +1)).attr('class', 'input_label').html('School:&nbsp;');
		var input = $('<input>').attr('style', 'width:325px').attr('class', 'school_autocomplete other_school').attr('name', 'other_school_' + (n +1)).attr('type', 'text');
		input.autocomplete(
	    {
	    	source : availableOpponents
		});		
		
		$('#other_schools').append(label);
		$('#other_schools').append(input);
		$('#other_schools').append('<br /><br />');
	});

	function colorRows ()
	{
		var rows = 0;
		$('table.roster tbody tr').each(function (row)
		{
			if (row % 2 == 0)
			{
				$(this).css('background-color', '#ffffff');
			}
			else
			{
				$(this).css('background-color', '#f2f2f2');
			}

			row = row + 1;
		});
	}	

	colorRows();

	$('.button.delete').click(function ()
	{
		var row_id = $(this).attr('data-player');
		$('#player_' + row_id).remove();
		colorRows();
	});

	$('.button.add.player').click(function ()
	{
		var next_id = $('tbody tr').size() - 2;
		
		var row = $('#new_player_row').clone();

		row.attr('id', 'player_' + next_id)
		   .removeAttr('style');		

		$('input', row).each(function ()
		{
			$(this).attr('name', $(this).attr('name').replace('_X', '_' + (next_id)));
			if ($(this).val() == "X")
			{
				$(this).val(next_id);
			}					
		});
		$('select', row).each(function ()
		{
			$(this).attr('name', $(this).attr('name').replace('_X', '_' + (next_id)));							
		});

		$('.tooltip', row).tooltip();
		$('.tooltip.right', row).tooltip({ position : {my: "left+15 middle", at: "right middle", collision: "flipfit"}});

		$('.button.delete', row).button({ icons : { primary : 'ui-icon-closethick'}, text : false})
						        .attr('data-player', next_id)
						        .tooltip()
						        .click(function ()
										{
											var row_id = $(this).attr('data-player');
											$('#player_' + row_id).remove();
											colorRows();
										});
		
		
		row.appendTo($('#new_player_row').parent());	

		colorRows();	
		
	});





	$('.contest_viewer').dialog({ autoOpen : false,                                  
                                  buttons : [ { text : 'Done', 'class' : 'float_right', click : function () { $(this).dialog('close'); }}
                                              <?php if (Auth::check()): ?>
                                              , { text : 'Edit Contest',  'class' : 'float_left', 'style' : 'margin-left:5px;', icons : { primary : 'ui-icon-pencil' }, click : function () { window.location = ('/contests/' + $(this).attr('data-contest') + '/edit'); }},
                                              { text : 'Submit Scores',  'class' : 'float_left', 'style' : 'margin-left:10px;', icons : { primary : 'ui-icon-circle-arrow-e' }, click : function () { window.location = ('/contests/' + $(this).attr('data-contest') + '/submit-scores'); }}
                                              <?php endif; ?> ],
                                  draggable : false,                                                                   
                                  height: 'auto',                                   
                                  modal : true,
                                  open : function ()
                                  {                                                                          
                                      
                                      var contest = $(this).attr('data-contest');
                                      $('.contest_viewer').html("<div class='ajax_loader' style='width:16px; height:11px; margin:4em auto; background-image: url(http://www.osaa.org/images/icons/ajax_loader2.gif); background-repeat:no-repeat;'></div>");
                                      var jqxhr = $.ajax({ type : 'GET', url : '/contests/' + contest + '?mode=ajax', dataType : 'html' })
                                                   .done(function (data)
                                                   {
                                                        $('.contest_viewer').html(data);
                                                        $('.button').button();
                                                    })
                                                   .fail(function () { $('.contest_viewer').html('There was an error.'); });

                                      $('.ui-dialog-buttonpane').css('padding', '0').css('font-size', '8pt');
                                      $('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');                                      
                                  },
                                  resizable : false,
                                  show : { effect : 'highlight', delay : 0, duration : 400, easing : 'easeInOutSine' },
                                  title : 'OSAA <?php echo Helpers::getActivityName($information['activity_program']->activity); ?>', 
                                  width : 900                                 
                                });

    $('.contest_details').click(function ()
    {        
        $('.contest_viewer').attr('data-contest', $(this).attr('data-contest')).dialog('open');
    }); 

    
    function readURL(input)
    {
        if (input.files && input.files[0])
        {
            var reader = new FileReader();
            
            reader.onload = function (e)
            {
                $('#preview').attr('src', e.target.result);                
            }
            
            reader.readAsDataURL(input.files[0]);
        }
    }
    
    $('#photo').change(function()
    {
        readURL(this);
    });

	$('#image_uploading').hide();

    $('#upload_photo').click(function ()
    {   	
    	$('#image_uploading').show();    	    	
	});	 

	$('#confirm_delete_dialog').dialog(
	{
      autoOpen: false,
      resizable: false,
      height:275,
      width: 400,
      modal: true,
      buttons: {
        "Yes": function() {
          
			var team = $(this).attr('data-team');

			$.ajax(
			{
				type : "POST",
				url  : '<?php echo url('/teams/remove-photo'); ?>',
				data : { 'team' : team },
				success : function()
				{
					/*location.reload();*/ 

					/* Get the team photo container */
					var p = $('#existing_team_photo').parent();

					/* Remove the team photo and the delete button */
					$('#existing_team_photo').remove();
					$('#delete_photo_button').remove();

					/* Add in the no image found template HTML */
					$(p).html("<div style='width: 100%; height: 400px; text-align: center; border: 1px solid #d9e1e0;'><br/><br /><br /><br /><b>No Team Photo Found</b><br /><br /><br />Use the photo upload form to the left<br />to upload a team photo.</div>");

				}
			});

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

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

	$('#delete_photo_button').click(function ()
	{	
		$('#confirm_delete_dialog').dialog('open');
	});

	$('#confirm_delete_dialog_meet').dialog(
	{
      autoOpen: false,
      resizable: false,
      height:260,
      width: 400,
      modal: true,
      buttons: {
        "Yes": function() {
          	
        	var team = $(this).attr('data-team');
        	var meet = $(this).attr('data-meet');

			$.ajax(
			{
				type : "POST",
				url  : '<?php echo url('/meets/delete'); ?>',
				data : { 'team' : team,
						 'meet' : meet },
				success : function()
				{
					location.reload();					
				}
			});

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

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

	$('.button.delete[data-action="delete"]').click(function ()
	{	
		$('#confirm_delete_dialog_meet').attr('data-meet', $(this).attr('data-meet'))
										.dialog('open');
	});

	$('#confirm_drop_dialog_meet').dialog(
	{
      autoOpen: false,
      resizable: false,
      height:225,
      width: 400,
      modal: true,
      buttons: {
        "Yes": function() {
          	
        	var team = $(this).attr('data-team');
        	var meet = $(this).attr('data-meet');

			$.ajax(
			{
				type : "POST",
				url  : '<?php echo url('/meets/drop'); ?>',
				data : { 'team' : team,
						 'meet' : meet },
				success : function()
				{
					location.reload();					
				}
			});

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

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

	$('.button.cancel[data-action="drop"]').click(function ()
	{	
		$('#confirm_drop_dialog_meet').attr('data-meet', $(this).attr('data-meet'))
									  .dialog('open');
	});



	// Click next button during stage 1
	$('.button.next[data-stage="1"]').click(function ()
	{
		// Ensure meet type is selected
		if ($('input[name="meet_type"]:checked').size() != 1)
		{
			alert ('You must select the type of the meet to continue.');
			return false;
		}

		// Ensure host team is selected
		if ($('input[name="host_team"]').val() == "")
		{
			alert ('You must enter in the hosting team\'s name.');
			return false;
		}

		$('.error').effect("drop", { direction : "right"}, "slow");

		// Transition to the next stage
		$('[name="directions"]').effect("drop", { direction : "right"}, "slow", function ()
		{
			// Meet type is DUAL
			if ($('input[name="meet_type"]:checked').val() == 'DUAL')
			{
				// Show the host name (safeified)
				$('[name="hosting_team_name"]').html($('input[name="host_team"]').val().replace(/<\/?[^>]+(>|$)/g, ""));

				// Do not allow the other team to be OOS if the host is OOS
				if ($('input[name="host_is_oos"]:checked').length > 0 || $('input[name="host_team"]').val() != '<?php echo str_replace('\'', '\\\'', $information['activity_program']->name); ?>')
		    	{
		    		$('input[name="other_team_is_oos"]').attr('disabled' , 'disabled');   		
		    		$('input[name="other_team"]').val('<?php echo str_replace('\'', '\\\'', $information['activity_program']->name); ?>').attr('disabled', 'disabled');

		    	}		    	

				// Show the dual meet creator
				$('[name="dual_creator"]').fadeIn();
			}
			else
			{
				// Show the host name (safeified)
				$('[name="hosting_team_name"]').html($('input[name="host_team"]').val().replace(/<\/?[^>]+(>|$)/g, ""));

				if ($('input[name="host_team"]').val() == '<?php echo str_replace('\'', '\\\'', $information['activity_program']->name); ?>' || $('input[name="host_is_oos"]:checked').length > 0)
				{
					// Show the invitational meet creator (since this is the host team or the host is OOS)
					$('[name="inv_creator"]').fadeIn();
				}
				else
				{
					// Show the invitational meet finder
					$('.button.next_add').button('disable');
					$('.button.join').button('disable');
					
					$('select[name="available_meets"]').parent().append("<div class='ajax_loader' style='width:16px; height:11px; background-image: url(http://www.osaa.org/images/icons/ajax_loader2.gif); background-repeat:no-repeat; position: absolute; top: 2em; left: 1em;'></div>");

					$('[name="inv_finder"]').fadeIn();

					// Get a list of meets for this host team
					var name = $('input[name="host_team"]').val().replace('/<\/?[^>]+(>|$)/g', "");

					$('#returned_result_count').html('(Searching...)');
					
					var jqxhr = $.ajax(
					{
						type : 'GET',
						url : '/teams/get-meets?name=' + name + '&activity=<?php echo $information['activity_program']->activity; ?>',
						dataType : 'html'
					});
					
					jqxhr.done(function (data)
					{
                    	var list = $.parseJSON(data);
                    	
                    	for (var i = 0; i < list.length; i++)
                    	{
                    		var id = list[i].id;
                    		var value = list[i].value;
                    		
                    		$('select[name="available_meets"]').append('<option value="' + id + '">' + value + '</option>');
	                    }
						
						var c = list.length;

						$('#returned_result_count').html('(Found ' + c + ' to choose from)');
                    });

                    jqxhr.fail(function ()
                   	{
                   		$('#returned_result_count').html('(Unable to find any)');
                    });

                    jqxhr.always(function ()
                    {
                     	$('.button.next_add').button('enable');
                     	$('.ajax_loader').hide();                     	
                 	});

				}
			}
		});

		// Disable the first form options
		$('[name="meet_type"]').button("disable");
		$('[name="host_team"]').attr('disabled', 'disabled');
		$('[name="host_is_oos"]').attr('disabled', 'disabled');
		$('[name="state"]').attr('disabled', 'disabled');		
	});


	// Create button is clicked from the invitational meet finder
	$('.button.next_add[data-from="INV_F"]').click(function ()
	{
		$('select[name="available_meets"]').children().remove();
		$('#returned_result_count').html('');

		// Show the host name (safeified)
		$('[name="hosting_team_name"]').html($('input[name="host_team"]').val().replace(/<\/?[^>]+(>|$)/g, ""));

		// Do not allow the other team to be OOS if the host is OOS
		if ($('input[name="host_is_oos"]:checked').length > 0 || $('input[name="host_team"]').val() != '<?php echo str_replace('\'', '\\\'', $information['activity_program']->name); ?>')
    	{
    		$('input[name="other_team_is_oos"]').attr('disabled' , 'disabled');   		
    		$('input[name="other_team"]').val('<?php echo str_replace('\'', '\\\'', $information['activity_program']->name); ?>').attr('disabled', 'disabled');
    	}	

		// Transition to the next stage
		$('[name="inv_finder"]').effect("drop", { direction : "right"}, "slow", function ()
		{				
			$('.button.join').button('disable');
			$('.button.next_add').button('disable');	

			// Show the inv meet creator
			$('[name="inv_creator"]').fadeIn();		
		});
	});


	// Add teams button is clicked from the invitational meet creator
	$('.button.add_teams[data-from="INV"]').click(function ()
	{
		// Make sure we have the required information		
		var d = $('#event_date2').val().replace(/<\/?[^>]+(>|$)/g, "");

		if (d.match(/^\d{2}\/\d{2}\/\d{4}$/) == null)
		{
			alert ('You must enter the meet date in MM/DD/YYYY format.');
			return false;
		}
		

		var n = $('#meet_name').val().replace(/<\/?[^>]+(>|$)/g, "");		

		if (n == '')
		{
			alert ('You must enter the meet name.');
			return false;
		}

		// Show the meet name (safeified)
		$('[name="new_inv_meet_name"]').html(n);
		$('[name="new_inv_meet_date"]').html(d);


		// Add the host to the list of participating schools
		var h = $('input[name="host_team"]').val().replace(/<\/?[^>]+(>|$)/g, "");
		
		if ($('input[name="host_is_oos"]:checked').length > 0)
    	{
    		h = h + ' (' + $('input[name="state"]:selected').val() + ')';
    	}

		var e = '<?php echo str_replace('\'', '\\\'', $information['activity_program']->name); ?>';

		$('input[name="add_team[0]"]').val(h);

		if (h != e)
		{
			$('input[name="add_team[1]"]').val(e);
		}


		// Transition to the next stage
		$('[name="inv_creator"]').effect("drop", { direction : "right"}, "slow", function ()
		{				
			// Show the add team view
			$('[name="inv_creator2"]').fadeIn();		
		});
	});


	// Reset button is clicked from the dual meet creator
	$('.button.reset[data-from="DUAL"]').click(function ()
	{		
		$('#meet_adder').trigger('reset');
		$('input[name="other_team_is_oos"]').removeAttr('disabled');
		$('input[name="other_team"]').removeAttr('disabled');

		// Transition to the previous stage
		$('[name="dual_creator"]').effect("drop", { direction : "right"}, "slow", function ()
		{
			// Enable the first form options
			$('[name="meet_type"]').button("enable");
			$('[name="host_team"]').removeAttr('disabled');
			$('[name="host_is_oos"]').removeAttr('disabled');
			$('[name="state"]').attr('disabled', 'disabled');		

			// Show the dual meet creator
			$('[name="directions"]').fadeIn();		
		});
	});

	// Reset button is clicked from the individual meet creator
	$('.button.reset[data-from="INV"]').click(function ()
	{		
		$('#meet_adder').trigger('reset');
		$('input[name="other_team_is_oos"]').removeAttr('disabled');
		$('input[name="other_team"]').removeAttr('disabled');

		// Transition to the previous stage
		$('[name="inv_creator"]').effect("drop", { direction : "right"}, "slow", function ()
		{
			// Enable the first form options
			$('[name="meet_type"]').button("enable");
			$('[name="host_team"]').removeAttr('disabled');
			$('[name="host_is_oos"]').removeAttr('disabled');
			$('[name="state"]').attr('disabled', 'disabled');		

			// Show the dual meet creator
			$('[name="directions"]').fadeIn();		
		});
	});

	// Reset button is clicked from the individual meet creator
	$('.button.reset[data-from="INV2"]').click(function ()
	{		
		$('#meet_adder').trigger('reset');
		$('input[name="other_team_is_oos"]').removeAttr('disabled');
		$('input[name="other_team"]').removeAttr('disabled');

		// Transition to the previous stage
		$('[name="inv_creator2"]').effect("drop", { direction : "right"}, "slow", function ()
		{
			// Enable the first form options
			$('[name="meet_type"]').button("enable");
			$('[name="host_team"]').removeAttr('disabled');
			$('[name="host_is_oos"]').removeAttr('disabled');
			$('[name="state"]').attr('disabled', 'disabled');		

			// Show the dual meet creator
			$('[name="directions"]').fadeIn();		
		});
	});

	// Reset button is clicked from the invitational meet finder
	$('.button.reset[data-from="INV_F"]').click(function ()
	{		
		$('#meet_adder').trigger('reset');
		$('input[name="other_team_is_oos"]').removeAttr('disabled');

		$('select[name="available_meets"]').children().remove();
		$('#returned_result_count').html('');

		// Transition to the previous stage
		$('[name="inv_finder"]').effect("drop", { direction : "right"}, "slow", function ()
		{
			// Enable the first form options
			$('[name="meet_type"]').button('enable');
			$('[name="host_team"]').removeAttr('disabled');
			$('[name="host_is_oos"]').removeAttr('disabled');
			$('[name="state"]').attr('disabled', 'disabled');	
			$('.button.join').button('disable');
			$('.button.next_add').button('disable');	

			// Show the dual meet creator
			$('[name="directions"]').fadeIn();		
		});
	});

	
	$('select[name="available_meets"]').change(function ()
	{
		$('.button.join').button('enable');
	});

	$('.button.add_more_team_spots').click(function ()
	{
		$('[data-holder="teams"]').append('<br /><br />');

		var i = $('input[type="text"]', '[data-holder="teams"]').size();


		var row = $('<input>').attr('style', 'width:215px')
						      .attr('class', 'school_autocomplete')
						      .attr('name', 'add_team[' + i + ']')
						      .attr('type', 'text');
		
		row.autocomplete(
	    {
	    	source : availableOpponents
		});	
		

		$('[data-holder="teams"]').append(row);

		$('[name="add_team[' + i + ']"').focus();
	});

	
	// Join an invitational
	$('.button.join[data-from="INV_F"]').click(function ()
	{
		$('#meet_adder').append('<input type="hidden" name="action" value="join_inv" />');		
		$('#meet_adder').trigger('submit');
	});


	// Create a dual
	$('.button.create[data-from="DUAL"]').click(function ()
	{
		// Make sure we have the required information		
		var d = $('#event_date').val().replace(/<\/?[^>]+(>|$)/g, "");

		if (d.match(/^\d{2}\/\d{2}\/\d{4}$/) == null)
		{
			alert ('You must enter the meet date in MM/DD/YYYY format.');
			return false;
		}		

		var n = $('#other_team').val().replace(/<\/?[^>]+(>|$)/g, "");		

		if (n == '')
		{
			alert ('You must enter the name of the other team participating in this meet.');
			return false;
		}

		$('[name="meet_type"]').button('enable');
		$('[name="host_team"]').removeAttr('disabled');
		$('[name="other_team"]').removeAttr('disabled');
		$('[name="host_is_oos"]').removeAttr('disabled');
		$('#state').removeAttr('disabled');

		$('#meet_adder').append('<input type="hidden" name="action" value="create_dual" />');		
		$('#meet_adder').trigger('submit');
	});

	// Create an invitational
	$('.button.create[data-from="INV"]').click(function ()
	{
		$('[name="meet_type"]').button('enable');
		$('[name="host_team"]').removeAttr('disabled');
		$('[name="host_is_oos"]').removeAttr('disabled');
		$('#state').removeAttr('disabled');

		$('#meet_adder').append('<input type="hidden" name="action" value="create_inv" />');		
		$('#meet_adder').trigger('submit');
	});

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

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

    
	<div class="ui-icon ui-icon-arrowreturnthick-1-e" style="display:inline-block; position:relative; top:3px;"></div>

	<div id="related_teams" style="font-size:8pt; margin-right:4px; display:inline-block;">
		<?php
		    foreach ($information['related_teams'] as $team)
		    {
		    	echo '<input type="radio" id="radio' . $team->level . '" name="team_select" data-href="' . url('/teams/' . $team->id . '/edit') . '"';
		    	
		    	if ($information['team']->id == $team->id)
		    	{
		    		echo 'checked="checked"';
		    	}		    	
		    	echo ' /><label for="radio' . $team->level . '" class="tooltip" title="Jump to the ' . strtolower (Helpers::getLevelName ($team->level)) . ' team">' . $team->level . '</label>';
	    	}	    
	    ?>	    	    
  	</div>

	<?php if (Auth::user()->canAccessTeamTask($information['activity_program']->id, 'ADMIN', true) and $information['activity_program']->countTeams() < 5 and $information['activity_program']->getActivityType() == 'TS'): ?>                                    
  		<a id="add_team" class="tooltip" title="Add another team" style="height:23px; margin:0 0 0 1px;" href="<?php echo url('teams/add/' . $information['activity_program']->id); ?>"></a>
  	<?php endif; ?>

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


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

	<?php if (Session::get('success')): ?>
        <div class="success_message"><span class="ui-icon ui-icon-close box_icon"></span><span class="ui-icon ui-icon-check" style="display:inline-block;"></span><?php echo Session::get('success'); ?></div>
    <?php endif; ?> 		

	<div class="tabs edit_team">
		<ul style="padding-left:5px;">
			<li><a href="#tabs-1">Schedule</a></li>
			<li><a href="#tabs-2">Roster</a></li>
			<li><a href="#tabs-3">Team Photo</a></li>
			<?php if (Helpers::strEqual($information['activity_program']->activity, 'BBL')): ?>
				<li data-escape="<?php echo url('/teams/' . $information['activity_program']->id); ?>#tabs-pitch-counts"><a href="#">Pitch Counts</a></li>
			<?php endif; ?>

			<a href="/account#tabs-0" class="home_button float_right tooltip" title="Return to my school page."></a>

			<?php if ($information['team']->level == 'V'): ?>

				<a href="<?php echo url('/teams/' . $information['team']->id . '/edit/out-of-state'); ?>" class="oos_button float_right tooltip" title="Manage your out-of-state opponents' records (if applicable.)" style="font-size:9pt;">Out-of-State Management</a>

			<?php endif; ?>

			<a href="<?php echo url('/teams/' . $information['activity_program']->id); ?>" class="team_view_button float_right tooltip" title="View this team as the general public would see it." style="font-size:9pt;">Public View</a>

			

		</ul>
		
		<div id="tabs-1">
			
			<?php
				$contest_or_meet = (Helpers::strEqual (Helpers::getActivityType($information['activity_program']->activity), 'ts')) ? 'contest' : 'meet';		
			?>

			<h2><?php echo ucfirst($contest_or_meet); ?> Schedule</h2>
			
			<h4>Add a <?php echo ucfirst($contest_or_meet); ?></h4>
			<?php if ($contest_or_meet == 'contest'): ?>

				<?php if (Auth::user()->canAccessTeamTask($information['activity_program']->id, 'ADMIN', true) or true): ?>

					<?php /*  Add a contest  */ ?>				    
					<div class="section add_contest">				

						<?php echo Form::open(array('url' => url('/contests/create'), 'class' => 'addContest')); ?>

						<?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('team', $information['team']->id); ?>
			          	<?php echo Form::hidden('activity_program', $information['activity_program']->id); ?>	          		          	

			            <?php echo Form::hidden('event_type', 'CNTST'); ?>
			            <?php echo Form::hidden('event_status', 'SCHD'); ?>	           
			           
			            <?php echo Form::hidden('home_team_name', $information['home_team_name']); ?>
			            <?php echo Form::hidden('away_team_name', ' '); ?>

			            <?php echo Form::hidden('swapped', Input::old('swapped', -1), array('id' => 'swapped')); ?>

			            
			            <div style="float:right; width:500px; height:42px; line-height:21px;">
			            	
			            	<b>Home: </b><span id="home_team_name"></span><br />
			            	<b>Away: </b><span id="away_team_name"></span>         	
			            	
			            </div>


						<?php echo Form::label('event_date', 'Date:', array('class' => 'input_label', 'style' => '')); ?>
						<?php echo Form::text('event_date', null, array('style' => 'width:100px;')); ?>
						<img src="<?php echo asset('images/icons/help_24px.png'); ?>" alt="?" class="tooltip" title="Select the date when this contest starts using the date picker." style="position:relative; top:3px; width:16px; height:16px;" />

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

						<?php echo Form::label('event_time', 'Time:', array('class' => 'input_label', 'style' => '')); ?>
						<?php echo Form::text('event_time', '7:00 PM', array('class' => 'tooltip', 'style' => 'width:80px;', 'title' => 'Select from the drop-down list what time the contest starts.  Or, leave the time black if the start time is unknown.')); ?>

						<?php echo Form::select('time_zone',
				                        array('PT' => 'Pacific', 'MT' => 'Mountain', 'CT' => 'Central', 'ET' => 'Eastern'),
				                        'PT',
				                        array('style' => 'width: 75px; font-size: 8pt;')); ?>
										
						<div id="swap_home_away" class="tooltip" title="Swap the home and away team designations"></div>

						<br />
						<div class="small gray note">Date format: MM/DD/YYYY</div>

						<br />
						
						<?php echo Form::label('opponent', 'Opponent: ', array('class' => 'input_label')); ?>	           
			            <?php echo Form::text('opponent', null, array('style' => 'width:325px;')); ?>	            

			            <img src="<?php echo asset('images/icons/help_24px.png'); ?>" alt="?" class="tooltip" title="Enter in your opponent school's name.  A drop-down list will appear with suggestions.  Tab or click out of the box to confirm selection.  Leave blank for TBD opponents." style="position:relative; top:3px; width:16px; height:16px;" />

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

			            <?php echo Form::select('opponent_level', array('V' => 'V', 'JV' => 'JV', 'JV2' => 'JV2', 'FR' => 'FR', 'FR2' => 'FR2'), $information['team']->level, array('style' => 'width:60px;', 'class' => '', 'title' => 'Select your opponent\'s level.')); ?>

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

			            <?php echo Form::checkbox('is_oos_opponent', true, null, array('id' => 'is_oos_opponent')); ?>
			            <?php echo Form::label('is_oos_opponent', 'Out-of-State', array('style' => 'font-size:10pt;', 'class' => 'tooltip', 'title' => 'If the opponent if an out-of-state opponent, please check this button and specify the opposing team\'s state, province, or territory.')); ?>

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

			            <?php echo Form::label('state', 'State/Province/Territory:', array('class' => 'input_label')); ?>
			            <select style="width:60px;" id="state" name="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 == Input::old('state')) echo ' selected="selected"';

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

			                unset ($states);

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

			            ?>
			        	</select>

						<br /><br />


						<b>Contest Type:</b>
						<div class="small gray note" style="display:inline; margin-left:10px;">
			            	Select the category that best describes this contest
			            </div>

						

						<div style="float:right; padding-top:3px;">					
							<br />
							<?php echo Form::checkbox('is_endowment', true, null, array('id' => 'is_endowment')); ?>
							<?php echo Form::label('is_endowment', 'Endowment', array('style' => 'font-size:10pt;', 'class' => 'tooltip', 'title' => 'Is this contest an endowment contest?')); ?>					
						</div>	

						<div id="contest_type" style="font-size:10pt; padding-top:3px;">				
						    <input type="radio" id="radio1" name="contest_type" value="J" <?php if (Input::old('contest_type') == 'J'): ?> checked="checked" <?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 (Input::old('contest_type') == 'NL'): ?> checked="checked" <?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 (Input::old('contest_type') == 'L'): ?> checked="checked" <?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 (Input::old('contest_type') == 'LPO'): ?> checked="checked" <?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 (Input::old('contest_type') == 'PI'): ?> checked="checked" <?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" disabled="disabled" /><label for="radio9">Playoff</label>
						</div>			
						
			            <div class="event_status_text" style="display:inline-block; margin-top:5px;"></div>

			            <div class="small gray note event_status_note" style="display:inline; margin-left:10px;"></div>

			            <br />

						<?php echo Form::label('tournament', 'Tournament Name: ', array('class' => 'input_label')); ?>	           
			            <?php echo Form::text('tournament', null, array('style' => 'width:200px;')); ?>

			            <img src="<?php echo asset('images/icons/help_24px.png'); ?>" alt="?" class="tooltip" title="If this contest is part of a tournament, please enter in the tournament name, and be sure to click the 'Tournament' button." style="position:relative; top:3px; width:16px; height:16px;" />
			            <div class="small gray note" style="display:inline-block;">(If in a tournament)</div>



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

			           	<?php echo Form::checkbox('is_tournament', true, null, array('id' => 'is_tournament')); ?>
			            <?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.')); ?>	        	          
						

			            <br /><br />

						<?php echo Form::label('location', 'Alternate Location: ', array('class' => 'input_label')); ?>	           
			            <?php echo Form::text('location', null, array('style' => 'width:200px;')); ?>

			            <img src="<?php echo asset('images/icons/help_24px.png'); ?>" alt="?" class="tooltip" title="If this contest is not being played at the home team's school, please enter in an alternate contest location here.  You can also check the 'Neutral Site' button if the contest is being played at a neutral site." style="position:relative; top:3px; width:16px; height:16px;" />
			            <div class="small gray note" style="display:inline-block;">(Optional)</div>
			           
						<?php /*  Baseball/Softball contests cannot be neutral locations  */ ?>
						<?php if (!Helpers::strEqual ($information['activity_program']->activity, array('BBL', 'SBL'))): ?>

							<div style="display:inline-block; width:50px;"></div>	                     
					       
			 				<?php echo Form::checkbox('is_neutral_location', true, null, array('id' => 'is_neutral_location')); ?>
				            <?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; ?>

			            <br /><br />

			            <?php echo Form::submit('Create Contest', array('class' => 'submit submit_button', 'style' => '')); ?>

			            <p style="float:right; margin-right:20px; position:relative; top:5px;">
			            	Be sure to double check your entries before creating this contest.
			            </p>

			            <br /><br />

						

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

					</div>
				<?php else: ?>
					<p>
						You do not have the permissions to add a contest to this schedule.
					</p>
				<?php endif; ?>

				<br />

				<h4><?php echo Helpers::getLevelName ($information['team']->level); ?> Schedule</h4>

				
				<table id="schedule" style="width:100%;">
					<thead class="head ui-tabs-nav ui-widget-header ui-corner-all" >
						<tr>			
							<th style="width:70px;">Status</th>
							<th style="width:78px;">Type</th>
							<th style="width:105px;">Date</th>
							<th style="width:50px;">Day</th>
							<th style="width:110px;">Time</th>
							<th>Opponent</th>
							<th style="width:120px;">Results</th>							
						</tr>
					</thead>

					<tbody>
						<?php foreach ($information['schedule'] as $item): ?>

							<?php if (Helpers::strEqual ($item['status'], array('PND', 'SCHD', 'CXL', 'PPD', 'LIVE', 'DONE'))): ?>						

								<tr style="height:2em;"
									<?php if ($item['status'] == 'PND'): ?> data-pending="true" <?php endif; ?>
									<?php if ($item['status'] == 'CXL'): ?> data-canceled="true" <?php endif; ?>
									<?php if ($item['status'] == 'PPD'): ?> data-postponed="true" <?php endif; ?>
									<?php if ($item['status'] == 'LIVE'): ?> data-live="true" <?php endif; ?>
								>
									<td><a href="<?php echo url('contests/' . $item['contest']->id . '/edit'); ?>" class="edit_contest_button"></a> <?php echo $item['status']; ?></td>
									<td><?php echo $item['type']; ?></td>
									<td><?php echo $item['date']; ?></td>
									<td><?php echo $item['day']; ?></td>
									<td><?php echo $item['time']; ?></td>
									<td>
										<?php echo $item['opponent']; ?>										
									</td>
									<td>
										<?php if ($item['status'] == 'LIVE' and $information['team']->level == 'V' and $item['contest']->is_scoreable): ?>
								            <a href="<?php echo url('/contests/' . $item['contest']->id . '/submit-scores'); ?>"
								               class="button tooltip submit_scores"
								               style="font-size:8pt;"
								               title="Submit scoring information for this contest.">Submit Scores</a>
								        <?php elseif ($item['status'] == 'DONE' and $information['team']->level == 'V'): ?>
								        	<?php echo $item['results']; ?>
								        <?php else: ?>
								            <div class="button float_right contest_details" style="font-size:7pt;" data-contest="<?php echo $item['contest']->id; ?>">Details</a>
								        <?php endif; ?>
									</td>
									
								</tr>						



							<?php endif; ?>

						<?php endforeach; ?>

						<?php if (count($information['schedule']) == 0): ?>
							<tr>
								<td colspan="6">No contests have been added to your schedule, yet.</td>
							</tr>
						<?php endif; ?>


					</tbody>


				</table>
			<?php else: ?>
				
				<?php echo $__env->make ('teams.meet_scheduler', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
				
				<br />

				<?php $allow_edit = true; ?>
				<?php echo $__env->make ('teams.meet_schedule', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

			<?php endif; ?>

		</div>
		
		<div id="tabs-2">
			
			<a href="<?php echo url('/teams/' . $information['team']->id . '/roster/3'); ?>" class="button print tooltip float_right" style="font-size:9pt; margin-bottom: 0.75em;" title="Print a roster will all team levels combined as a PDF." target="_blank">Multi-Team Roster</a>

			<a href="<?php echo url('/teams/' . $information['team']->id . '/roster/2'); ?>" class="button print tooltip float_right" style="font-size:9pt; margin-bottom: 0.75em; margin-right: 5px;" title="Print this team roster and team photo as a PDF." target="_blank">Program Photo</a>

			<a href="<?php echo url('/teams/' . $information['team']->id . '/roster'); ?>" class="button print tooltip float_right" style="font-size:9pt; margin-bottom: 0.75em; margin-right: 5px;" title="Print this team roster as a PDF." target="_blank">Media Roster</a>

			<h2>Roster</h2>	
			
			<?php echo Form::open(array('url' => url('/teams/edit-roster'), 'class' => 'editRoster', 'id' => 'editRoster')); ?>
				
				<?php echo Form::hidden('team_id', $information['team']->id); ?>
				<?php echo Form::hidden('return_url', url('/teams/' . $information['team']->id . '/edit#tabs-2')); ?>

				<?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; ?>

				<h4><?php echo Helpers::getLevelName ($information['team']->level); ?> Roster</h4>

				<table class="roster">
					<thead class="head ui-widget-header">
						<tr>
							<td class="tooltip" title="Home Jersey Number">H #</td>
							<td class="tooltip" title="Away/Visiting Jersey Number">A #</td>
							<td class="tooltip" title="Is this player a team captain?">C</td>
							<td class="tooltip" title="Player Name">Name</td>
							<td class="tooltip" title="Position">Position</td>
							<td class="tooltip" title="Alternate Position">Alt Position</td>
							<td class="tooltip" title="Grade">Grade</td>
							<td class="tooltip" title="Height (formatted as ft-in, i.e. '6-0')">Height</td>
							<?php if (Helpers::strEqual ($information['activity_program']->activity, array('FBL', 'WRE'))): ?>
								<td class="tooltip" title="Weight (just numbers, i.e. '150')">Weight</td>						
							<?php endif; ?>
							<td></td>
						</tr>
					</thead>

					<tbody>
						<tr class="small gray note">
							<td>1</td>
							<td>21</td>
							<td></td>
							<td>John Doe</td>
							<td>Position 1</td>
							<td>Position 2</td>
							<td>11</td>
							<td>6-0</td>
							<?php if (Helpers::strEqual ($information['activity_program']->activity, array('FBL', 'WRE'))): ?>
								<td>155</td>
							<?php endif; ?>
							<td></td>
						</tr>
						<tr id="new_player_row" class="sample" style="display:none;">
							<?php echo Form::hidden('player_id_X', 'X'); ?>		    				
							<td><?php echo Form::text('home_number_X',
											  '',
											  array('maxlength' => '3',
											  	    'style' => 'width:50px;')); ?></td>
							<td><?php echo Form::text('away_number_X',
											  '',
											  array('maxlength' => '3',
											  	    'style' => 'width:50px;')); ?></td>
							<td><?php echo Form::checkbox ('is_captain_X',
													'1',
													false,
													array('style' => 'text-align:center; width:25px;')); ?></td>
							<td><?php echo Form::text('name_X',
											  '',
											  array('style' => 'width:250px;')); ?></td>
							<td><?php echo Form::select('position_X',
												$information['position_select']); ?></td>
							<td><?php echo Form::select('position_2_X',
												$information['position_select']); ?></td>
							<td><?php echo Form::select('grade_X',
												$information['grade_select']); ?></td>					
							<td><?php echo Form::text('height_X',
												'',
												array('style' => 'width:50px;')); ?></td>
							<?php if (Helpers::strEqual ($information['activity_program']->activity, array('FBL', 'WRE'))): ?>
								<td><?php echo Form::text('weight_X',
												  '',
												  array('style' => 'width:50px;')); ?></td>
							<?php endif; ?>
							<td><div class="button delete notext tooltip" style="width:20px; height:20px; position:relative; top:-1px;" title="Remove this player from the roster." data-player="X"></div></td>
						</tr>

						<?php if (count($information['roster']) > 0): ?>
							<?php foreach ($information['roster'] as $player): ?>
								<tr id="<?php echo 'player_' . $player->id; ?>">
									<?php echo Form::hidden('player_id_' . $player->id, $player->id); ?>
									<td><?php echo Form::text('home_number_' . $player->id,
													  $player->home_number,
													  array('maxlength' => '3',
													  	    'style' => 'width:50px;')); ?></td>
									<td><?php echo Form::text('away_number_' . $player->id,
													  $player->away_number,
													  array('maxlength' => '3',
													  	    'style' => 'width:50px;')); ?></td>
									<td><?php echo Form::checkbox ('is_captain_' . $player->id,
															'1',
															$player->is_captain,
															array('style' => 'text-align:center; width:25px;')); ?></td>
									<td><?php echo Form::text('name_' . $player->id,
													  $player->name,
													  array('style' => 'width:250px;')); ?></td>
									<td><?php echo Form::select('position_' . $player->id,
														$information['position_select'],
														$player->position); ?></td>
									<td><?php echo Form::select('position_2_' . $player->id,
														$information['position_select'],
														$player->position_2); ?></td>
									<td><?php echo Form::select('grade_' . $player->id,
														$information['grade_select'],
														$player->grade); ?></td>					
									<td><?php echo Form::text('height_' . $player->id,
														$player->height,
														array('style' => 'width:50px;')); ?></td>
									<?php if (Helpers::strEqual ($information['activity_program']->activity, array('FBL', 'WRE'))): ?>
										<td><?php echo Form::text('weight_' . $player->id,
															$player->weight,
															array('style' => 'width:50px;')); ?></td>
									<?php endif; ?>
									<td><div class="button delete notext tooltip" style="width:20px; height:20px; position:relative; top:-1px;" title="Remove this player from the roster." data-player="<?php echo $player->id; ?>"></div></td>
								</tr>
							<?php endforeach; ?>
						<?php endif; ?>					

					</tbody>

				</table>

				<br />

				<div class="button add player tooltip" style="font-size:9pt;" title="Add a new player to the roster">Add Player</div>

				<br /><br />

				<?php echo Form::submit('Save', array('class' => 'button float_right tooltip', 'style' => 'position: relative; top: -0.5em;', 'title' => 'Save this form\'s information.')); ?>

				<p class="bold">
					To save your changes, click the "Save" button.
				</p>		

				
			<?php echo Form::close(); ?>
		</div>
		
		<div id="tabs-3">
			<h2>Team Photo</h2>		
			
			<?php $image = ImagesController::getImageURL($information['team']->id, 'PHOTO', 'ANY'); ?>

			<?php echo Form::open(array('url'    => url('/teams/add-photo'),
								'method' => 'post',
								'files'  => true,
								'id'	 => 'upload_image_form')); ?>
				<div class="columns">

					<div style="width:31%; float:left; padding:0 2.25% 0 0; position: relative; min-height: 515px;">
						<h3 style="color: #990000;">Upload a New Team Photo</h3>
				
						<?php echo Form::hidden('team', $information['team']->id); ?>
						<?php echo Form::hidden('type', 'PHOTO'); ?>
						<?php echo Form::hidden('return_url', url('/teams/' . $information['team']->id . '/edit#tabs-3')); ?>

						<?php echo Form::file('photo', array('name' => 'photo',
													 'id'   => 'photo')); ?>

						<br />
						<div class="small gray note">(Images must be less than 4 MB in size and with an extension of .jpg, .jpeg., .gif, or .png)</div>		
						<br /><br />

						<h3 style="color: #990000;">Thumbnail Preview</h3>

						<img id="preview" src="" alt="" title="" style="width: 75%; border: 1px solid #d9e1e0; max-width: 325px;" />			
						<br />
						<div class="small gray note">(Preview may not be available in IE or Safari)</div>		

						<br /><br />

						<div style="float: right; margin-right: 100px;">
							<img id="image_uploading" src="<?php echo asset('images/icons/ajax_loader.gif'); ?>" alt="" title=""  />
						</div>
						
						<?php echo Form::submit('Upload Photo', array('class'    => 'button',
															  'style'    => 'font-size: 10pt;',
															  'id'		 => 'upload_photo')); ?>		

						<br /><br />

						<?php if (Session::has('errors')): ?>                
			                <div class="ui-state-error" style="padding: 2px 4px;"><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 if (!is_null($image)): ?>						 	
							<div id="delete_photo_button" class="button trash" style="position: absolute; bottom: 0; font-size: 9pt;">Delete Team Photo</div>
						<?php endif; ?>

					</div>

					
					<div style="width: 64.5%; float: left; padding: 0 0 0 2%; border-left: 1px solid #990000; min-height: 515px;">												
						<?php if (!is_null($image)): ?>
							<img id="existing_team_photo" src="<?php echo $image; ?>" alt="" title="" style="max-width: 630px;" />						
						<?php else: ?>
							<div style="width: 100%; height: 400px; text-align: center; border: 1px solid #d9e1e0;">
								<br/><br /><br /><br />
								<b>No Team Photo Found</b>
								<br /><br /><br />
								Use the photo upload form to the left<br />
								to upload a team photo.
							</div>
						<?php endif; ?>

					</div>

				</div>

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

			<br class="clear" />

		</div>

	</div>


	<div class="contest_viewer" style="display:none;">
	    <div class="ajax_loader" style="width:16px; height:11px; margin:0 auto; margin-top:6em; background-image: url('<?php echo asset('/images/icons/ajax_loader2.gif'); ?>'); background-repeat:no-repeat;"></div>
	</div>

	<div id="confirm_delete_dialog" title="Delete Team Photo?" data-team="<?php echo $information['team']->id; ?>">
		Are you sure you want to delete this team photo?<br /><br />
		<div class="ui-state-error" style="padding:5px;">
			<div class="ui-icon ui-icon-alert float_left margin-right:1em;"></div>
			Once you delete this photo, it will no longer exist on our server.
		</div>
	</div>	

	<div id="confirm_delete_dialog_meet" title="Delete Meet?" data-team="<?php echo $information['team']->id; ?>">
		Are you sure you want to delete this meet?<br /><br />
		<div class="ui-state-error" style="padding:5px;">
			<div class="ui-icon ui-icon-alert float_left margin-right:1em;"></div>
			If you delete this meet, it will be dropped from your schedule.  Any other teams participating in this meet will also have this meet removed from their schedules.
		</div>
	</div>	

	<div id="confirm_drop_dialog_meet" title="Drom from Meet?" data-team="<?php echo $information['team']->id; ?>">
		Are you sure you want to drop from this meet?<br /><br />
		<div class="ui-state-error" style="padding:5px;">
			<div class="ui-icon ui-icon-alert float_left margin-right:1em;"></div>
			Dropping this meet will remove your team from the list of teams that are participating.
		</div>
	</div>	

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