<?php
	$hidden_icon = asset('/images/icons/hidden_text_16px.png');
	$visible_icon = asset('/images/icons/visible_text_2_16px.png');
?>


<?php $__env->startSection('page_title'); ?>
    <?php echo $info['school']->short_name; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page_sub_title'); ?>    
   Manage <?php echo Session::get('year'); ?>-<?php echo substr(intval(Session::get('year')) + 1, 2, 2); ?> <?php echo $info['school']->name; ?> Staff
<?php $__env->stopSection(); ?>

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

    <style type="text/css">
    	.staff {
    		height: 48px;
    		padding: 2px 0 0 4px;
    		font-size: 9pt;
    		line-height: 13px;  
    		margin-bottom: 4px;  		
    	}

    	.staff .information,
    	.staff .contact,
    	.staff .certifications {    		
    		float: left;		
    	}

    	.staff .information {
    		width: 200px;
    	}

    	.staff .contact {
    		width: 300px;
    	}

    	.staff .certifications {
    		width: 680px;
    	}

    	.staff .information .name {
    		font-weight: bold;
    	}

    	.staff .information .position {
    		font-style: italic;
    	}

    	.staff .information img {
    		vertical-align: middle;
    	}

    	.staff .information .status img {
    		margin-right: 8px;
    	}

    	.staff .information .staff_edit {
    		display: inline-block;
    	}

		.staff_edit_menu {
			position : absolute;
		    z-index : 200;
		  	width : 175px;
		  	height : auto;
		  	padding: 0 !important;
		}    	

    	.menu_item {    		
    		width: 143px;
    		height: 1.25em;    		
    		cursor: pointer;
    	}  

    	.staff .contact img {
    		vertical-align: middle;
    		margin-right: 8px;
    	}  

    	.staff .certifications .record {
    		height: 24px;
    		width: 150px;
    		font-size: 10pt;
    		line-height: 24px;
    		float: left;
    		margin-right: 20px;
    	}

    	.staff .certifications .record img {
    		margin: 4px 8px 4px 4px;
    		float: left;
    	}

    	.staff .certifications .record .completed {
    		font-size: 8pt;
    		color: #666666;
    		float: right;
    		margin-right: 15px;
    	}

    	.success_bar {
    		position: fixed;
    		top: 600px;
    		left: 0;
    		width: 100%;
    		padding: 0.25em 0;
    		line-height: 1.5em;
    		background-color: rgba(176, 255, 190, 0.0);
    		border-bottom: 2px solid rgba(13, 88, 27, 0.50);
    		border-top: 2px solid rgba(13, 88, 27, 0.50);
    		z-index: 500;
    	}

    	.success_bar .message {
    		width: 1200px;
    		margin: 0 auto;
    		font-size: 14pt;
    		color: #151515;
    	}

    	#content .group {
    		width: 1185px;
    		height: auto;    		
    		border: 1px solid #cccccc;
    		margin-bottom: 0.5em;
    		padding: 0.5em 0.5em 0.5em 0.5em;
    	}

    	#content .bar {
    		
    		background: #005fa9; /* Old browsers */
			background: -moz-linear-gradient(top,  #005fa9 0%, #1c43a6 100%); /* FF3.6+ */
			background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#005fa9), color-stop(100%,#1c43a6)); /* Chrome,Safari4+ */
			background: -webkit-linear-gradient(top,  #005fa9 0%,#1c43a6 100%); /* Chrome10+,Safari5.1+ */
			background: -o-linear-gradient(top,  #005fa9 0%,#1c43a6 100%); /* Opera 11.10+ */
			background: -ms-linear-gradient(top,  #005fa9 0%,#1c43a6 100%); /* IE10+ */
			background: linear-gradient(to bottom,  #005fa9 0%,#1c43a6 100%); /* W3C */
			filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#005fa9', endColorstr='#1c43a6',GradientType=0 ); /* IE6-9 */

    		position: absolute; 
    		float: left; 
    		z-index: -1; 
    		top: 0; 
    		left: 0; 
    		height: 25px; 
    		width: 1200px;
    	}

    	#content .group .view_state {
    		display: inline-block;
    		width: 20px;
    		height: 16px;
    		background-image: url('<?php echo asset('/images/icons/bullet_arrow_down.png'); ?>');
    		background-repeat: no-repeat;
    		position: relative;
    		top: -2px;
    	}

    	#content .group .title {
    		display: inline-block;
    		font-size: 10pt;
    		color: #ffffff;
    		font-weight: bold;
    		position: relative;
    		top: -5px;    		
    	}

    	#content .group .people {
    		margin-top: 0.5em;
    	}

    	.page_functions {
    		width: auto !important;
    	}


    </style>

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

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

	// Make this script play well with IE8
	if (typeof String.prototype.trim !== 'function')
	{
		String.prototype.trim = function()
		{
		    return this.replace(/^\s+|\s+$/g, ''); 
		}
	}

	// Clean up any console issues
	if(!window.console)
    {
        window.console = { log: $.noop, group: $.noop, groupEnd: $.noop };            
    }    
	
	// Success bar
	$('.success_bar').animate({ 'top' : 32, 'background-color' : 'rgba(176, 255, 190, 1.0)'}, 1600, 'easeOutQuad', function ()
	{		
		$(this).delay(6000).fadeOut(4000);	

		$(this).hover(function ()
		{
			$(this).stop(true).css('opacity', '1.0');
		},
		function ()
		{
			$(this).fadeOut(4000);
		})
	});
	
	// Help Button
	$('.help_button')
	    .button({ icons : { primary : 'ui-icon-help'}})
	    .css({'margin-right' : '10px', 'font-size' : '9pt'});
	
	// Close Button
	$('.close_button')
	    .button({ icons : { primary : 'ui-icon-circle-close'}})
	    .css({'font-size' : '9pt'});

	// Download Button
	$('.download_button')
	    .button({ 'icons' : { 'primary' : 'ui-icon-arrowthickstop-1-s'}})
	    .css({ 'font-size' : '8pt', 'margin-right' : '10px' })
	    .click(function()
	    {
	    	var href = $(this).attr('data-href');

	    	window.open(href);
		});

	// Legend Button
	$('.legend_information')
		.button({ 'icons' : { 'primary' : ' ui-icon-info'}})
		.css({ 'font-size' : '8pt', 'margin-right' : '10px' })
		.click(function()
		{
			$('<div></div>')
			    .appendTo('body')			    
			    .dialog(
			    {	      		    
	      			resizable: false,
	      			height: 600,
	      			width: 700,
	      			modal: false,	      			
	      			title: 'Manage Staff Legend',
			      	open : function ()
				    	{  
				       		var dialog_object = $(this);				       		

				       		dialog_object.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 : 'http://www.osaa.org/help/training-courses?ajax=true',
				          							dataType : 'html'
				          						})
				          						.done(function (data)
												{
			                                    	dialog_object.html(data);
			                                        
			                                    }).fail(function (jqXHR, status, error)
			                                    {			                                    	
			                                    	var response = jqXHR.responseText;
			                                    	var errorData = $.parseJSON(response);			                                    	
			                                    	console.log(errorData);
			                                    	dialog_object.html('<h3 style="margin: 0.5em 0;">' + errorData.error.type + '</h3>' + errorData.error.message + '<br /><br /><span style="font-size: 9pt;">Line ' + errorData.error.line + ' in ' + errorData.error.file);

			                                    	if (dialog_object.html() == '')
			                                    	{
			                                    		dialog_object.html('There was an error.');
			                                    	}
			                                    });		                
				      	}
				});
		});

	// Expand All Button
	$('.expand_all_button')
		.button({ 'icons' : { 'primary' : 'ui-icon-carat-1-s'}})
		.css({ 'font-size' : '8pt', 'margin-right' : '10px' })
		.click(function ()
		{
			$('#content .group').each(function ()
			{				
				var expand = '<?php echo asset('/images/icons/bullet_arrow_down.png'); ?>';

				$('.view_state', $(this))
					.css({'background-image' : 'url(' + expand + ')'})
					.attr('data-state', 'collapse');

				$(this).css('height', 'auto');
				$(this).css('overflow', '');					
			})
		});

	// Collapse All Button
	$('.collapse_all_button')
		.button({ 'icons' : { 'primary' : 'ui-icon-carat-1-e'}})
		.css({ 'font-size' : '8pt', 'margin-right' : '10px'  })
		.click(function ()
		{
			$('#content .group').each(function ()
			{				
				var collapse = '<?php echo asset('/images/icons/bullet_arrow_right.png'); ?>';

				$('.view_state', $(this))
					.css({'background-image' : 'url(' + collapse + ')'})
					.attr('data-state', 'collapse');

				$(this).css('height', '10px');	
				$(this).css('overflow', 'hidden');			
			})
		});
	
	// Manage Alerts Button
	$('.manage_alerts_button')
		.button({ 'icons' : { 'primary' : 'ui-icon-clock'}})
		.css({ 'font-size' : '8pt'})
		.click(function ()
		{
			$('<div></div>')
			    .appendTo('body')			    
			    .dialog(
			    {	      		    
	      			resizable: false,
	      			height: 400,
	      			width: 550,
	      			modal: true,	      			
	      			title: 'Manage Staff Certification Alerts',
			      	open : function ()
				    	{  
				       		var dialog_object = $(this);				       		

				       		dialog_object.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 : 'http://www.osaa.org/schools/<?php echo $info['school']->id; ?>/manage-alerts',
          							dataType : 'html'
          						})
          						.done(function (data)
								{
                                	dialog_object.html(data);
                                })
                                .fail(function (jqXHR, status, error)
                                {			                                    	
                                	var response = jqXHR.responseText;
                                	var errorData = $.parseJSON(response);			                                    	
                                	console.log(errorData);
                                	dialog_object.html('<h3 style="margin: 0.5em 0;">' + errorData.error.type + '</h3>' + errorData.error.message + '<br /><br /><span style="font-size: 9pt;">Line ' + errorData.error.line + ' in ' + errorData.error.file);

                                	if (dialog_object.html() == '')
                                	{
                                		dialog_object.html('There was an error.');
                                	}
                                })
                                .complete(function()
                                {
                                	$('.toggle_alerts')
                                	    .click(function(event)
                                	    {
                                	    	var link = $(this);

                                	    	var status = link.attr('data-status');

                                	    	event.preventDefault();

								            $('<div></div>')								                
								                .appendTo('body')
								                .dialog(
								                {                       
								                    dialogClass : 'data_confirm',
								                    draggable : true,
								                    resizable : false,
								                    modal : true,
								                    height : 250,
								                    width : 425,                    
								                    title : 'Confirmation',
								                    buttons: [
								                        {
								                            text : "Yes",
								                            'class' : "float_left",
								                            icons : { primary : 'ui-icon-check'},
								                            click : function()
								                                    {                                                       
								                                        var dialog_object = $(this);

								                                        $('<div><div>')
																            .attr('data-sending', 1)
																            .addClass('ui-widget-overlay ui-front')
																            .appendTo('body');
																          
																        $('<div><div>').appendTo('body')
																            .attr('data-sending', 1)
																            .css('width', '225px')
																            .css('height', '170px')
																            .css('text-align', 'center')
																            .css('padding', '0.5em')
																            .position({my : "center center", at : "center center", of : window})
																            .addClass('ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-di    buttons')
																            .html('<br />Updating...<br /><br /><img src="http://www.osaa.org/images/icons/ajax_loader3.gif" /><div style="font-size: 8pt; line-height: 105%; margin-top: 2em;">Please wait while your school\'s preferences are saved...</div>');

								                                        // Execute the toggle                    
																        var jqxhr = $.ajax(
																            {
																                type : 'POST',
																                url : '/schools/<?php echo $info['school']->id; ?>/update-preferences',
																                data : { 'preference' : 'school_staff_certification_alerts',
																                         'property' : 'is_enabled',
																                         'type' : 'BOOL',
																                         'value' : status,
																                         'school_id' : <?php echo $info['school']->id; ?> },
																                dataType : 'html'
																            })
																            .done(function (data)
																            {                                                
																                if (status == 1)
																                {
																                	link.html('Turn alerts off');
																                	link.attr('data-status', 0);
																                	$('.schedule_alert').html('<span style="color: #0d581b;">Next scheduled alert: ' + $('.schedule_alert').attr('data-schedule') + '</span>');     
																                }
																                else
																               	{
																               		link.html('Turn alerts on');
																               		link.attr('data-status', 1);
																               		$('.schedule_alert').html('<span style="color: #990000;">Alerts are turned off.</span>');
																                }																                
																            })
																            .fail(function (jqXHR, status, error)
																            {                                                   
																                var response = jqXHR.responseText;
																                var errorData = $.parseJSON(response);
																                //console.log(errorData);
																                alert("There was an error while trying to toggle the alert status.\n\n" + errorData.error.message + "\n\nThis page will be reloaded.");
																                location.reload();
																            })
																            .complete(function ()
																            {
																            	$('[data-sending]').remove();
																            	dialog_object.dialog("close");
																        	});
								                                    }
								                        },
								                        {
								                            text : "No",
								                            'class' : "float_right",
								                            'data-autofocus' : "true",
								                            icons : { primary : 'ui-icon-close'},
								                            click : function()
								                                    {
								                                        // Close the dialog box
								                                        $(this).dialog("close");                           
								                                    }
								                        }
								                    ],
								                    open : function ()
								                        {  
								                            var dialog_object = $(this);

								                            if (status == 0)
								                            {
																dialog_object.html('<br />Are you sure you want to turn OFF staff certification alerts?<div style="font-size: 9pt; margin-top: 1em;" class="small gray note">Your school will not be sent any certification alerts.  You can turn alerts back ON from this window in the future.</div>');
								                        	}
								                        	else
								                        	{
								                            	dialog_object.html('<br />Are you sure you want to turn ON staff certification alerts?<div style="font-size: 9pt; margin-top: 1em;" class="small gray note">You can turn alerts ON/OFF from this window in the future.</div>');
								                            }
								                            
								                            $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '9pt');
								                            $('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%'); 
								                            $('.data_confirm .ui-widget-header').css('background', '#f6a828 url(http://download.jqueryui.com/themeroller/images/ui-bg_gloss-wave_35_f6a828_500x100.png) 50% 50% repeat-x').css('border-color', '#f6a828');                                     
                                      						$('.data_confirm .ui-widget-content').css('border-color', '#dddddd').css('font-size', '10pt');                                       

								                            $('[data-autofocus="true"]').focus();
								                        },
								                    close : function ()
								                        {
								                            var dialog_object = $(this);
								                            $(dialog_object).remove();
								                        }                
								                });
                                		});


                                	$('.demand_button')
                                	    .button()
                                	    .click(function()
                                	    {
                                	    	var button = $(this);

                                	    	$('<div><div>')
									            .attr('data-sending', 1)
									            .addClass('ui-widget-overlay ui-front')
									            .appendTo('body');
									          
									        $('<div><div>').appendTo('body')
									            .attr('data-sending', 1)
									            .css('width', '225px')
									            .css('height', '170px')
									            .css('text-align', 'center')
									            .css('padding', '0.5em')
									            .position({my : "center center", at : "center center", of : window})
									            .addClass('ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-di    buttons')
									            .html('<br />Sending...<br /><br /><img src="http://www.osaa.org/images/icons/ajax_loader3.gif" /><div style="font-size: 8pt; line-height: 105%; margin-top: 2em;">Please wait while an e-mail is generated...</div>');

									        var url = button.attr('data-href');

									        // Execute link
									        var jqxhr = $.ajax(
									            {
									                type : 'GET',
									                url : url,									                
									                dataType : 'html'
									            })
									            .done(function (data)
									            {                                                
									                if (data == 'success')
									                {
										                $('[data-sending]').remove();

										                $('.demand_status').html('An e-mail was successfully sent.').fadeIn();									                
										                $('.demand_button').button("disable");
										            }
										            else
										           	{
										           		alert("There was an error while trying to send the e-mail.\n\n" + data + "\n\nThis page will be reloaded.");
									                	location.reload();
										            }
									            })
									            .fail(function (jqXHR, status, error)
									            {                                                   
									                var response = jqXHR.responseText;
									                var errorData = $.parseJSON(response);
									                //console.log(errorData);
									                alert("There was an error while trying to send the e-mail.\n\n" + errorData.error.message + "\n\nThis page will be reloaded.");
									                location.reload();
									            });
                                		});
                            	});
				      	}
				});
		});

	// NFHS Sync Button
	$('.sync_button')
		.button({ 'icons' : { 'primary' : 'ui-icon-refresh'}})
		.css({ 'font-size' : '8pt', 'margin-right' : '10px'})
		.click(function ()
		{

		});
	
	// Add New Staff Button
	$('.add_new')
		.button({ 'icons' : { 'primary' : ' ui-icon-plusthick'}})
		.css({ 'font-size' : '8pt', 'margin-right' : '10px' })
		.click(function ()
		{
			var button_obj = $(this);
			var school_id = $(button_obj).attr('data-school-id');

			$('<div></div>')
			    .appendTo('body')			    
			    .dialog(
			    {	      			
	      			resizable: false,
	      			height: 525,
	      			width: 700,
	      			modal: true,	      			
	      			title: 'Add New Staff',
	      			buttons: [
	      				{
	      					text : "Save Changes",
	      		   			'class' : "float_left",
	      		   			icons : { primary : 'ui-icon-disk'},
	      		   		 	click : function()
	      		   		  		  {                   							          
							          if ($('select[name="school_staff_list"]').val() == '')
							          {

								          var name_prefix = ($('input[name="name_prefix"]').val()).trim();
								          var first_name = ($('input[name="first_name"]').val()).trim();
								          var middle_name = ($('input[name="middle_name"]').val()).trim();
								          var last_name = ($('input[name="last_name"]').val()).trim();
								          var name_suffix = ($('input[name="name_suffix"]').val()).trim();								          

								          var name = '';

								          if (name_prefix != '')
								          {
								              name = name_prefix + ' ';
								      	  }

								      	  name = name + first_name + ' ';

								      	  if (middle_name != '')
								      	  {
								      	      name = name + middle_name + ' ';
								      	  }

								      	  name = name + last_name;

								      	  if (name_suffix != '')
								      	  {
								      	      name = name + ' ' + name_suffix;
								      	  }

								          // Confirm the user's choice
							          	  var result = confirm("Are you sure you want to create a new contact with this name?\n\n" + name + "\n\nOnce you create this contact, the name cannot be changed.");
							          }
							          else
							          {
							              var result = true;
							          }

						          	  if (result == true)
						          	  {
						            	  

						            	  $('form', $(this)).submit(); 

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

								          return true;
						              }
						              else
						           	  {
						           		  return false;
						           	  }
							      }
						},												
						{
							text : "Cancel",
							'class' : "float_right",
							'autofocus' : true,
							icons : { primary : 'ui-icon-cancel'},
							click : function()
									{
							        	$(this).dialog( "close" );
							        	$(this).remove();
							          	return false;
							        }
						}
					],
			      	open : function ()
				    	{  
				       		var dialog_object = $(this);				       		

				       		dialog_object.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 : 'http://www.osaa.org/schools/' + school_id + '/activity-staff/new',
				          							dataType : 'html'
				          						})
				          						.done(function (data)
												{
			                                    	dialog_object.html(data);

			                                    	// DEBUG
			                                    	//console.log(staff_info);			                                    	

			                                    	function nameSelect(id)
			                                    	{
			                                    		if (id == 'RESET')
			                                    		{
			                                    			// Clear out any residual staff information
					                                    	$('input[name="name_prefix"]')
					                                    		.val('')
					                                    		.css({'color' : '#000000'})
					                                    		.removeAttr('readonly');
					                                    	
					                                    	$('input[name="first_name"]')
					                                    		.val('')
					                                    		.css({'color' : '#000000'})
					                                    		.removeAttr('readonly');

					                                    	$('input[name="middle_name"]')
					                                    		.val('')
					                                    		.css({'color' : '#000000'})
					                                    		.removeAttr('readonly');

					                                    	$('input[name="last_name"]')
					                                    		.val('')
					                                    		.css({'color' : '#000000'})
					                                    		.removeAttr('readonly');

					                                    	$('input[name="name_suffix"]')
					                                    		.val('')
					                                    		.css({'color' : '#000000'})
					                                    		.removeAttr('readonly');

					                                    	$('select[name="staff_type"]')
					                                    		.val('')
					                                    		.css({'color' : '#000000'})
					                                    		.removeAttr('disabled');

					                                    	$('input[name="email"]')
					                                    		.val('')
					                                    		.css({'color' : '#000000'})
					                                    		.removeAttr('readonly');

					                                    	$('input[name="work_phone"]')
					                                    		.val('')
					                                    		.css({'color' : '#000000'})
					                                    		.removeAttr('readonly');

					                                    	$('input[name="mobile_phone"]')
					                                    		.val('')
					                                    		.css({'color' : '#000000'})
					                                    		.removeAttr('readonly');
			                                    		}
			                                    		else
			                                    		{
			                                    			// Find this staff's information
			                                    			var staff = null;
			                                    			for (var i = 0; i < staff_info.length; i++)
			                                    			{
			                                    				if (staff_info[i].id == id)
			                                    				{
			                                    					var staff = staff_info[i];
			                                    				}
			                                    			}

			                                    			// DEBUG
					                                    	//console.log(staff);

					                                    	// Ensure a staff was found
					                                    	if (staff != null)
					                                    	{
						                                    	// Load this staff's information
						                                    	$('input[name="name_prefix"]')
						                                    		.val(staff.name_prefix)
						                                    		.css({'color' : '#7d7b7d'})
						                                    		.attr('readonly', 'readonly');
						                                    	
						                                    	$('input[name="first_name"]')
						                                    		.val(staff.first_name)
						                                    		.css({'color' : '#7d7b7d'})
						                                    		.attr('readonly', 'readonly');

						                                    	$('input[name="middle_name"]')
						                                    		.val(staff.middle_name)
						                                    		.css({'color' : '#7d7b7d'})
						                                    		.attr('readonly', 'readonly');

						                                    	$('input[name="last_name"]')
						                                    		.val(staff.last_name)
						                                    		.css({'color' : '#7d7b7d'})
						                                    		.attr('readonly', 'readonly');

						                                    	$('input[name="name_suffix"]')
						                                    		.val(staff.name_suffix)
						                                    		.css({'color' : '#7d7b7d'})
						                                    		.attr('readonly', 'readonly');

						                                    	$('select[name="staff_type"]')
						                                    		.val(staff.staff_type)
						                                    		.css({'color' : '#7d7b7d'})
						                                    		.attr('disabled', 'disabled');

						                                    	$('input[name="email"]')
						                                    		.val(staff.email)
						                                    		.css({'color' : '#7d7b7d'})
						                                    		.attr('readonly', 'readonly');

						                                    	$('input[name="work_phone"]')
						                                    		.val(staff.work_phone)
						                                    		.css({'color' : '#7d7b7d'})
						                                    		.attr('readonly', 'readonly');

						                                    	$('input[name="mobile_phone"]')
						                                    		.val(staff.mobile_phone)
						                                    		.css({'color' : '#7d7b7d'})
						                                    		.attr('readonly', 'readonly');
						                                    }
			                                    		}
			                                    	}

			                                    	$('.clear_existing_staff_info')
									          			.button()
									          			.css({'font-size':'8pt'})
									          			.click(function ()
									          			{
									          				$('select[name="school_staff_list"]').val('');

									          				nameSelect('RESET');
									          			});
													
													$('.clear_existing_staff_info').button('disable');

													$('select[name="school_staff_list"]').on('change', function ()
													{
														if ($(this).val() != '')
														{
															$('.clear_existing_staff_info').button('enable');

															nameSelect($(this).val());
														}
														else
														{
															$('.clear_existing_staff_info').button('disable');

															nameSelect('RESET');
														}
													});

			                                        
			                                    }).fail(function (jqXHR, status, error)
			                                    {			                                    	
			                                    	var response = jqXHR.responseText;
			                                    	var errorData = $.parseJSON(response);			                                    	
			                                    	console.log(errorData);
			                                    	dialog_object.html('<h3 style="margin: 0.5em 0;">' + errorData.error.type + '</h3>' + errorData.error.message + '<br /><br /><span style="font-size: 9pt;">Line ' + errorData.error.line + ' in ' + errorData.error.file);

			                                    	if (dialog_object.html() == '')
			                                    	{
			                                    		dialog_object.html('There was an error.');
			                                    	}
			                                    });	
			                			                
			                $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '9pt');
			          		$('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');	

			          		$(this).parent().find('[autofocus]').focus();

			          		
				      	}
				});
		});	

	// Group Functions
	$('#content .group')
		.addClass('ui-corner-all')
		.each(function ()
		{
			$('.staff:odd', $(this)).css('background-color', '#dedede');
		});
	$('#content .group .title')
		.click(function ()
			{
				var collapse = '<?php echo asset('/images/icons/bullet_arrow_right.png'); ?>';
				var expand = '<?php echo asset('/images/icons/bullet_arrow_down.png'); ?>';

				var group = $(this).parents('.group');

				var view_state = $('.view_state', $(group));

				if ($(view_state).attr('data-state') == 'expand')
				{
					$(view_state)
						.css({'background-image' : 'url(' + collapse + ')'})
						.attr('data-state', 'collapse');

					$(group).css('height', '10px');
					$(group).css('overflow', 'hidden');
				}
				else
				{
					$(view_state)
						.css({'background-image' : 'url(' + expand + ')'})
						.attr('data-state', 'expand');

					$(group).css('height', 'auto');					
					$(group).css('overflow', '');					
				}
			})
			.hover(function()
			{
				$(this).css('cursor', 'pointer');
			}, function ()
			{
				$(this).css('cursor', 'auto');
			});



	// Staff Edit Menu
	$('.staff_edit_button')
		.button({'icons' : {'secondary' : 'ui-icon-triangle-1-s'}})
		.css({'font-size' : '7pt'})
		.click(function(event)
		{
			event.stopPropagation();
			$('.staff_edit_menu:visible').hide();

			var button = $(this);

			var menu = button.next();

			if (menu.is(':visible'))
			{
				menu.hide();
			}
			else
			{
				menu.slideDown();
			}
		});
	$('body').click(function()
	{
		$('.staff_edit_menu:visible').hide();
	});	
	$('.staff_edit_menu')
		.menu()		
		.click(function(event)
		{
			//event.stopPropagation();
		})
		.hide();
	

	// Toggle Roster Visibility Option
	$('.menu_item.toggle_roster_visibility')
		.click(function(event)
		{			
			// Do not follow the link
			event.preventDefault();

			// Get the button that was clicked
			var button = $(this);
			var staff_parent_element = $(button.parents('.staff')[0]);

			// Get pertinent information
			var data = {
				staff_id : parseInt(staff_parent_element.attr('data-staff-id')),
				staff_type : staff_parent_element.attr('data-staff-type'),
				roster_visibility : parseInt(button.attr('data-roster-visiblility')),
				school_id : parseInt("<?php echo $info['school']->id; ?>")
			};

			// Show the loading window
			$('<div><div>')
                .attr('data-loading', 1)
                .addClass('ui-widget-overlay ui-front')
                .appendTo('body');
                  
            $('<div><div>').appendTo('body')
                .attr('data-loading', 1)
                .css('width', '225px')
                .css('height', '170px')
                .css('text-align', 'center')
                .css('padding', '0.5em')
                .position({my : "center center", at : "center center", of : window})
                .addClass('ui-dialog ui-widget ui-widget-content ui-corner-all ui-front')
                .html('<br />Processing...<br /><br /><img src="http://www.osaa.org/images/icons/ajax_loader3.gif" /><div style="font-size: 8pt; line-height: 105%; margin-top: 2em;">Please wait while your request is processed, this may take a while ...</div>');

			// Process the request
			var jqxhr = $.ajax({
					type : 'POST',
					url : '<?php echo url('/schools/' . $info['school']->id . '/staff/toggle-roster-visibility'); ?>',
					dataType : 'html',
					data : data
				})
				.done(function (return_data)
				{
	            	// Update the roster visibility icon
	            	var image = $('img.roster_visibility_icon', staff_parent_element);

	            	if (data.roster_visibility === 1)
	            	{
	            		var new_source = "<?php echo asset('/images/icons/roster_shown_16px.png'); ?>";
	            		var new_title = "Shown on rosters";
	            	}
	            	else
	            	{
	            		var new_source = "<?php echo asset('/images/icons/roster_hidden_16px.png'); ?>";
	            		var new_title = "Not shown on rosters";
	            	}

	            	image.attr('src', new_source);
	            	image.attr('title', new_title);

	            	// Update the drop-down option
	            	if (data.roster_visibility === 1)
	            	{
	            		button.attr('data-roster-visiblility', 0);
	            		button.html('<span class="ui-icon ui-icon-person"></span>Hide on Rosters');
	            	}
	            	else
	            	{
	            		button.attr('data-roster-visiblility', 1);
	            		button.html('<span class="ui-icon ui-icon-person"></span>Show on Rosters');
	            	}


	            	// Remove the loading window
	            	$('[data-loading]').remove();

	            	// Show the success message
					var success_message = return_data;
					$('<div></div>')
						.addClass('success_bar')
						.appendTo('body')
						.html('<div class="message">' + success_message + '</div>')		
						.animate({ 'top' : 32, 'background-color' : 'rgba(176, 255, 190, 1.0)'}, 1600, 'easeOutQuad', function ()
						{		
							$(this).delay(6000).fadeOut(4000);	

							$(this).hover(function ()
							{
								$(this).stop(true).css('opacity', '1.0');
							},
							function ()
							{
								$(this).fadeOut(4000);
							})
						});


	            	
	            })
	            .fail(function (jqXHR, status, error)
                {                                                   
                    var response = jqXHR.responseText;
                    var errorData = $.parseJSON(response);
                    //console.log(errorData);
                    alert("There was an error processing the request.\n\n" + errorData.error.message + "\n\nThis page will be reloaded.");
                    location.reload();
                })
                .always(function ()
                {

            	});

		});


	// Edit Staff Contact Option
	$('.menu_item.staff_edit_contact')		
		.click(function (event)
		{
			// Do not follow the link
			event.preventDefault();

			// Get the button that was clicked
			var button = $(this);
			var staff_parent_element = $(button.parents('.staff')[0]);			
			var ap_staff_id = staff_parent_element.attr('data-staff-id');						

			$('<div></div>')
			    .appendTo('body')			    
			    .dialog(
			    {	      			
	      			resizable: false,
	      			height: 560,
	      			width: 725,
	      			modal: true,	      			
	      			title: 'Edit Contact Information',
	      			buttons: [
	      				{
	      					text : "Save Changes",
	      		   			'class' : "float_left",
	      		   			icons : { primary : 'ui-icon-disk'},
	      		   		 	click : function()
	      		   		  		  {                   							          
							          

							          $('form', $(this)).submit();

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

							          return true;
							       }
						},
						{
	      					text : "Replace this Person",
	      		   			'class' : "float_left",
	      		   			'style' : "margin-left: 35px;",
	      		   			icons : { primary : 'ui-icon-closethick'},
	      		   		 	click : function()
	      		   		  		    {                   
							          	// Confirm the user's choice
							          	var result = confirm("Are you sure you want to retire this current person's contact information?\n\nThis will remove the person from his/her current position.  Once this person is removed, you will be able to add a new staff contact as a replacement.");

							          	if (result == true)
							          	{
							            	// Create a flag to retire this staff
							            	var input = $('<input>')
							            				    .attr('type', 'hidden')
							            				    .attr('name', 'replace')
							            				    .val('true');

							            	// Append the flag to the form submission
							            	$('form', $(this)).append($(input));

							            	// Submit the form
							            	$('form', $(this)).submit();

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

									        return true;
							            }
							            else
							           	{
							           		return false;
							           	}
							          
							        }
						},						
						{
							text : "Cancel",
							'class' : "float_right",
							'autofocus' : true,
							icons : { primary : 'ui-icon-cancel'},
							click : function()
									{
							        	$(this).dialog( "close" );
							        	$(this).remove();
							          	return false;
							        }
						}
					],
			      	open : function ()
				    	{  
				       		var dialog_object = $(this);				       		

				       		dialog_object.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 : 'http://www.osaa.org/schools/activity-staff/' + ap_staff_id + '/edit',
				          							dataType : 'html'
				          						})
				          						.done(function (data)
												{
			                                    	dialog_object.html(data);
			                                        
			                                    }).fail(function (jqXHR, status, error)
			                                    {			                                    	
			                                    	var response = jqXHR.responseText;
			                                    	var errorData = $.parseJSON(response);			                                    	
			                                    	console.log(errorData);
			                                    	dialog_object.html('<h3 style="margin: 0.5em 0;">' + errorData.error.type + '</h3>' + errorData.error.message + '<br /><br /><span style="font-size: 9pt;">Line ' + errorData.error.line + ' in ' + errorData.error.file);

			                                    	if (dialog_object.html() == '')
			                                    	{
			                                    		dialog_object.html('There was an error.');
			                                    	}
			                                    });	
			                			                
			                $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '9pt');
			          		$('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');	

			          		$(this).parent().find('[autofocus]').focus();		      
				      	}
				});
		});

	// Remove Staff from Sport Option
	$('.menu_item.remove_from_sport')
		.click(function(event)
		{			
			// Do not follow the link
			event.preventDefault();

			// Get the button that was clicked
			var button = $(this);
			var staff_parent_element = $(button.parents('.staff')[0]);
			var staff_name = $('.name', staff_parent_element).text();

			console.log(staff_name);

			return;

			// Get pertinent information
			var data = {
				staff_id : parseInt(staff_parent_element.attr('data-staff-id')),
				staff_type : staff_parent_element.attr('data-staff-type'),				
				school_id : parseInt("<?php echo $info['school']->id; ?>")
			};

			// Show a confirm dialog
			$('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    modal : true,
                    draggable : true,
                    resizable : false,
                    height : 375,
                    width : 600,                    
                    title : 'Confirm Removal',
                    buttons: [
                        {
                            text : "Delete",
                            'class' : "float_left",
                            icons : { primary : 'ui-icon-trash'},
                            click : function()
                                    {                                                       
                                        var reason = $('[name="delete_notes"]').val();

                                        if (reason == '')
                                        {
                                            alert('In order to delete this report, you must provide a reason.');
                                            return;
                                        }
                                        

                                        

                                        $('<div><div>')
                                            .addClass('ui-widget-overlay ui-front')
                                            .appendTo('body');
                                          
                                        $('<div><div>').appendTo('body')
                                            .css('width', '225px')
                                            .css('height', '170px')
                                            .css('text-align', 'center')
                                            .css('padding', '0.5em')
                                            .position({my : "center center", at : "center center", of : window})
                                            .addClass('ui-dialog ui-widget ui-widget-content ui-corner-all ui-front')
                                            .html('<br />Deleting...<br /><br /><img src="http://www.osaa.org/images/icons/ajax_loader3.gif" /><div style="font-size: 8pt; line-height: 105%; margin-top: 2em;">Please wait, this may take a while to process...</div>');

                                        // Submit the change
                                        var jqxhr = $.ajax(
                                            {
                                                type : 'POST',
                                                url : 'URL',
                                                data : data,
                                                dataType : 'html'
                                            })
                                            .done(function (data)
                                            {                                                
                                                
                                            })
                                            .fail(function (jqXHR, status, error)
                                            {                                                   
                                                var response = jqXHR.responseText;
                                                var errorData = $.parseJSON(response);
                                                //console.log(errorData);
                                                alert ("There was an error deleting the report.\n\nThis page will be reloaded.");
                                                location.reload();
                                            });              
                                    }
                        },                        
                        {
                            text : "Cancel",
                            'class' : "float_right",
                            'data-autofocus' : "true",
                            icons : { primary : 'ui-icon-cancel'},
                            click : function()
                                    {
                                        // Close the dialog box
                                        $(this).dialog("close"); 
                                    }
                        }
                    ],
                    open : function ()
                        {  
                            var dialog_object = $(this);

                            var html = '<div style="font-size: 10pt; margin: 1em 0;">';
                            html += '<span class="ui-icon ui-icon-alert" style="display: inline-block; vertical-align: middle; margin-right: 4px;"></span>';
                            html += '<b>Are you sure you want to delete this ejection report?</b>';
                            html += '<br /><br />';
                            html += '<div class="small gray">This cannot be undone.  If you delete this report, your form cannot be reinstated.  If you do want to delete this form, please provide a reason below.</div>';
                            html += '<br />Suggested Reasons:';
                            html += '<select name="delete_reasons" style="margin-left: 4px;">';
                            html += '<option value=""></option>';
                            html += '<option value="This is a duplicate ejection report.">Duplicate Ejection Report</option>';                                                      

                            
                            html += '</select>';
                            
                            html += '<br /><br /><b>Reason for Deletion</b><br />';
                            html += '<textarea name="delete_notes" style="width: 100%; height: 4em;"></textarea>'
                            html += '</div>';

                            dialog_object.html(html);
                            
                            $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '9pt');
                            $('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');   

                            $('[data-autofocus="true"]').focus();

                            $('[name="delete_reasons"]', dialog_object).change(function()
                            {
                                var value = $(this).val();

                                $('[name="delete_notes"]').text(value);
                            });
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);
                            $(dialog_object).remove();
                        }                
                });

			// Show the loading window
			$('<div><div>')
                .attr('data-loading', 1)
                .addClass('ui-widget-overlay ui-front')
                .appendTo('body');
                  
            $('<div><div>').appendTo('body')
                .attr('data-loading', 1)
                .css('width', '225px')
                .css('height', '170px')
                .css('text-align', 'center')
                .css('padding', '0.5em')
                .position({my : "center center", at : "center center", of : window})
                .addClass('ui-dialog ui-widget ui-widget-content ui-corner-all ui-front')
                .html('<br />Processing...<br /><br /><img src="http://www.osaa.org/images/icons/ajax_loader3.gif" /><div style="font-size: 8pt; line-height: 105%; margin-top: 2em;">Please wait while your request is processed, this may take a while ...</div>');

			// Process the request
			var jqxhr = $.ajax({
					type : 'POST',
					url : '<?php echo url('/schools/' . $info['school']->id . '/staff/toggle-roster-visibility'); ?>',
					dataType : 'html',
					data : data
				})
				.done(function (return_data)
				{
	            	// Update the roster visibility icon
	            	var image = $('img.roster_visibility_icon', staff_parent_element);

	            	if (data.roster_visibility === 1)
	            	{
	            		var new_source = "<?php echo asset('/images/icons/roster_shown_16px.png'); ?>";
	            		var new_title = "Shown on rosters";
	            	}
	            	else
	            	{
	            		var new_source = "<?php echo asset('/images/icons/roster_hidden_16px.png'); ?>";
	            		var new_title = "Not shown on rosters";
	            	}

	            	image.attr('src', new_source);
	            	image.attr('title', new_title);

	            	// Update the drop-down option
	            	if (data.roster_visibility === 1)
	            	{
	            		button.attr('data-roster-visiblility', 0);
	            		button.html('<span class="ui-icon ui-icon-person"></span>Hide on Rosters');
	            	}
	            	else
	            	{
	            		button.attr('data-roster-visiblility', 1);
	            		button.html('<span class="ui-icon ui-icon-person"></span>Show on Rosters');
	            	}


	            	// Remove the loading window
	            	$('[data-loading]').remove();

	            	// Show the success message
					var success_message = return_data;
					$('<div></div>')
						.addClass('success_bar')
						.appendTo('body')
						.html('<div class="message">' + success_message + '</div>')		
						.animate({ 'top' : 32, 'background-color' : 'rgba(176, 255, 190, 1.0)'}, 1600, 'easeOutQuad', function ()
						{		
							$(this).delay(6000).fadeOut(4000);	

							$(this).hover(function ()
							{
								$(this).stop(true).css('opacity', '1.0');
							},
							function ()
							{
								$(this).fadeOut(4000);
							})
						});


	            	
	            })
	            .fail(function (jqXHR, status, error)
                {                                                   
                    var response = jqXHR.responseText;
                    var errorData = $.parseJSON(response);
                    //console.log(errorData);
                    alert("There was an error processing the request.\n\n" + errorData.error.message + "\n\nThis page will be reloaded.");
                    location.reload();
                })
                .always(function ()
                {

            	});

		});





	// Course Record Behavior - REDO
	$('.course_record')
		.hover(function()
		{
			$(this).css({'border-color' : '#ff0000',
						 'cursor' : 'pointer'});

		},
		function ()
		{
			$(this).css({'border-color' : 'transparent',
						 'cursor' : 'auto'});
		})
		.click(function ()
		{
			var button_obj = $(this);
			var record_id = $(button_obj).attr('data-record-id');
			var staff_id = $(button_obj).attr('data-staff-id');
			var course_slug = $(button_obj).attr('data-course-slug');

			$('<div></div>')
			    .appendTo('body')			    
			    .dialog(
			    {	      			
	      			resizable: false,
	      			height: 525,
	      			width: 700,
	      			modal: true,	      			
	      			title: 'Edit Training Course Record',
	      			buttons: [
	      				{
	      					text : "Save Changes",
	      		   			'class' : "float_left",
	      		   			icons : { primary : 'ui-icon-disk'},
	      		   		 	click : function()
	      		   		  		  {                   							          
							          var completion_date = $('input[name="completion_date"]').val();

							          if (completion_date == '')
							          {
							              alert('You must provide a completion date in MM/DD/YYYY format.');
							              return false;
							      	  }

							          $('form', $(this)).submit();

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

							          return true;
							       }
						},	
						{
	      					text : "Remove Certification Record",
	      		   			'class' : "float_left",
	      		   			'style' : "margin-left: 35px;",
	      		   			icons : { primary : 'ui-icon-closethick'},
	      		   		 	click : function()
	      		   		  		    {                   
							          	// Confirm the user's choice
							          	var result = confirm("Are you sure you want to remove this training course certification record?");

							          	if (result == true)
							          	{
							            	// Create a flag to retire this staff
							            	var input = $('<input>')
							            				    .attr('type', 'hidden')
							            				    .attr('name', 'remove')
							            				    .val('true');

							            	// Append the flag to the form submission
							            	$('form', $(this)).append($(input));

							            	// Submit the form
							            	$('form', $(this)).submit();

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

									        return true;
							            }
							            else
							           	{
							           		return false;
							           	}
							          
							        }
						},											
						{
							text : "Cancel",
							'class' : "float_right",
							'autofocus' : true,
							icons : { primary : 'ui-icon-cancel'},
							click : function()
									{
							        	$(this).dialog( "close" );
							        	$(this).remove();
							          	return false;
							        }
						}
					],
			      	open : function ()
				    	{  
				       		var dialog_object = $(this);				       		

				       		dialog_object.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 : 'http://www.osaa.org/schools/course-records/edit',
				          							data : { 'record_id' : record_id,
				          							         'staff_id' : staff_id,
				          									 'course_slug' : course_slug},
				          							dataType : 'html'
				          						})
				          						.done(function (data)
												{
			                                    	dialog_object.html(data);
			                                    	$('input[data-datepicker="true"]', dialog_object)
			          									.datepicker({dateFormat : 'm/d/yy',changeYear:true});
			                                        
			                                    }).fail(function (jqXHR, status, error)
			                                    {			                                    	
			                                    	var response = jqXHR.responseText;
			                                    	var errorData = $.parseJSON(response);			                                    	
			                                    	console.log(errorData);
			                                    	dialog_object.html('<h3 style="margin: 0.5em 0;">' + errorData.error.type + '</h3>' + errorData.error.message + '<br /><br /><span style="font-size: 9pt;">Line ' + errorData.error.line + ' in ' + errorData.error.file);

			                                    	if (dialog_object.html() == '')
			                                    	{
			                                    		dialog_object.html('There was an error.');
			                                    	}
			                                    });	
			                			                
			                $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '9pt');
			          		$('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');				          		

			          		$(this).parent().find('[autofocus]').focus();		      
				      	}
				});
		});


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

<?php $__env->startSection('page_functions'); ?>  
	
    <a href="<?php echo asset('/docs/osaainfo/13-14OSAAAccountInstructions.pdf'); ?>" target="_blank" class="help_button">Help</a>
    <a href="<?php echo url('/schools/' . $info['school']->id); ?>" class="close_button">Close</a>    

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

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

 	<?php /*  Success Bar  */ ?>
 	<?php if (Session::has('success')): ?>
		<div class="success_bar">
			<div class="message">				
				<?php echo Session::get('success'); ?>
			</div>			
		</div>
	<?php endif; ?> 
	
	<?php /*  Utility Buttons  */ ?>	
	<div style="font-size: 9pt; margin-bottom: 0.75em;">
		<div class="add_new" data-school-id="<?php echo $info['school']->id; ?>">Add New Staff</div>
		<div class="legend_information">Legend</div>
		<div class="expand_all_button">Expand All</div>
		<div class="collapse_all_button">Collapse All</div>
		<div class="sync_button">NFHS Sync</div>
		<div class="download_button" data-href="<?php echo url('/schools/' . $info['school']->id . '/download-activity-program-staff'); ?>">Download</div>
		<div class="manage_alerts_button">Manage Alerts</div>
	</div>		

	<?php if (count($info['ad_staff_objects']) > 0): ?>
		<div class="group" style="position: relative;">

			<div class="bar ui-corner-top"></div>
			<div class="view_state" data-state="expand"></div>
			<div class="title">Athletic Director</div>
				
			<div class="people">

				<?php foreach ($info['ad_staff_objects'] as $staff): ?>
			
					<div class="staff" data-staff-type="school_staff" data-staff-id="<?php echo $staff->school_staff->id; ?>">
						
						<div class="information">
							<div class="name"><?php echo $staff->school_staff->getDisplayName(); ?></div>
							<div class="position">Athletic Director</div>
							<div class="status">
								<?php if ($staff->is_on_rosters): ?>
									<img src="<?php echo asset('/images/icons/roster_shown_16px.png'); ?>" alt="" title="Shown on rosters" class="roster_visibility_icon" />
								<?php else: ?>
									<img src="<?php echo asset('/images/icons/roster_hidden_16px.png'); ?>" alt="" title="Not shown on rosters" class="roster_visibility_icon" />
								<?php endif; ?>

								<?php if (Helpers::strEqual($staff->certification_status, 'OK')): ?>
									<img src="<?php echo asset('/images/icons/certification_ok_16px.png'); ?>" alt="" title="This staff is wholly certified." />
								<?php elseif (Helpers::strEqual($staff->certification_status, 'WARNING')): ?>
									<img src="<?php echo asset('/images/icons/certification_warning_16px.png'); ?>" alt="" title="This staff is certified, but a training course is about to expire within the next three months." />
								<?php else: ?>
									<img src="<?php echo asset('/images/icons/certification_alert_16px.png'); ?>" alt="" title="This staff is missing a required certification." />
								<?php endif; ?>

								<div class="staff_edit">
									<div class="staff_edit_button">Manage</div>
									<ul class="staff_edit_menu">
										<li><a href="<?php echo url('/schools/' . $info['school']->id . '?function=edit_staff&amp;function_data=' . $staff->school_staff->id); ?>" class="menu_item"><span class="ui-icon ui-icon-contact"></span>Edit Name/Contact</a></li>
										<?php if ($staff->is_on_rosters): ?>
											<li><a href="#" class="menu_item toggle_roster_visibility" data-roster-visiblility="0"><span class="ui-icon ui-icon-person"></span>Hide on Rosters</a></li>
										<?php else: ?>
											<li><a href="#" class="menu_item toggle_roster_visibility" data-roster-visiblility="1"><span class="ui-icon ui-icon-person"></span>Show on Rosters</a></li>
										<?php endif; ?>
										<li><a href="#" class="menu_item"><span class="ui-icon ui-icon-clipboard"></span>Edit Certifications</a></li>
										<li><a href="<?php echo url('/schools/' . $info['school']->id . '?function=edit_staff&amp;function_data=' . $staff->school_staff->id); ?>" class="menu_item"><span class="ui-icon ui-icon-circle-minus"></span>Remove Staff</a></li>
									</ul>								
								</div>

							</div>
						</div>

						<div class="contact">							
							<img src="<?php echo $visible_icon; ?>" alt="" title="AD email address is always public." />
							<?php if (!Helpers::strIsEmpty($staff->school_staff->email)): ?>								
								<?php echo $staff->school_staff->getDisplayEmail(); ?>
							<?php else: ?>
							    No Email Address
							<?php endif; ?>

							<br />

							<img src="<?php echo $visible_icon; ?>" alt="" title="AD work phone number is always public." />
							<?php if (!Helpers::strIsEmpty($staff->school_staff->getDisplayPhone('WORK'))): ?>
								W: <?php echo $staff->school_staff->getDisplayPhone('WORK'); ?>
							<?php else: ?>
								No Work Phone
							<?php endif; ?>	

							<br />							

							<img src="<?php echo $hidden_icon; ?>" alt="" title="AD mobile phone number is always private." />
							<?php if (!Helpers::strIsEmpty($staff->school_staff->getDisplayPhone('MOBILE'))): ?>								
								M: <?php echo $staff->school_staff->getDisplayPhone('MOBILE'); ?>
							<?php else: ?>								
								No Mobile Phone
							<?php endif; ?>	
						</div>

						<div class="certifications">
							<?php if (count($staff->courses) > 0): ?>

								<?php foreach ($staff->courses as $count => $course): ?>

									<?php
										$training_course = $info['courses']->filter(function($c) use($course)
										{
											if ($c->slug == $course->course_slug)
											{
												return true;
											}
											else
											{
												return false;
											}
										})->first();

										//Helpers::debugVar($course);

										$short_name = $training_course->short_name;
										$name = $training_course->name;
										$display_date = (property_exists($course, 'display_date')) ? $course->display_date : null;

										if ($course->is_complete)
										{
											$icon = asset('/images/icons/check_16px.png');
											$title = $name . ' certification is up-to-date.';

											if ($course->is_soon)
											{
												$icon = asset('/images/icons/almost_16px.png');
											}
										}
										elseif (!$course->is_required)
										{
											$icon = asset('/images/icons/blank_16px.png');
											$title = $name . ' certification is not required.';
										}
										else
										{
											$icon = asset('/images/icons/missing_16px.png');
											$title = $name . ' certification requirement is missing.';
										}
									?>											

									
									<div class="record">

										<img src="<?php echo $icon; ?>" alt="" title="<?php echo $title; ?>" />

										<?php echo $short_name; ?>

										<?php if (!is_null($display_date)): ?>
											<div class="completed"><?php echo $display_date; ?></div>
										<?php endif; ?>
										
									</div>

								<?php endforeach; ?>
							<?php endif; ?>
						</div>
					</div>
				<?php endforeach; ?>
			</div>
		</div>
			
	<?php endif; ?>
	
	<?php if (count($info['staff_objects']) > 0): ?>
		<?php foreach ($info['staff_objects'] as $staff_object): ?>
			<div class="group" style="position: relative;">

				<div class="bar ui-corner-top"></div>
				<div class="view_state" data-state="expand"></div>
				<div class="title"><?php echo $staff_object->activity->name; ?></div>
				
				<div class="people">

					<?php if (count($staff_object->activity_program_staff) > 0): ?>
						<?php foreach ($staff_object->activity_program_staff as $staff): ?>

							<div class="staff" data-staff-type="activity_program_staff" data-staff-id="<?php echo $staff->activity_program_staff->id; ?>">
						
								<div class="information">
									<div class="name"><?php echo $staff->school_staff->getDisplayName(); ?></div>
									<div class="position">
										<?php if (!Helpers::strEqual($staff->activity_program_staff->level, 'V')): ?>
											<?php echo $staff->activity_program_staff->level; ?>
										<?php endif; ?>

										<?php echo $staff->activity_program_staff->getDisplayRole(); ?>
										
										<?php if (!Helpers::strIsEmpty($staff->activity_program_staff->alt_title)): ?>
											(<?php echo $staff->activity_program_staff->alt_title; ?>)
										<?php endif; ?>										
									</div>
									<div class="status">
										<?php if ($staff->is_on_rosters): ?>
											<img src="<?php echo asset('/images/icons/roster_shown_16px.png'); ?>" alt="" title="Shown on rosters" class="roster_visibility_icon" />
										<?php else: ?>
											<img src="<?php echo asset('/images/icons/roster_hidden_16px.png'); ?>" alt="" title="Not shown on rosters" class="roster_visibility_icon" />
										<?php endif; ?>

										<?php if (Helpers::strEqual($staff->certification_status, 'OK')): ?>
											<img src="<?php echo asset('/images/icons/certification_ok_16px.png'); ?>" alt="" title="This staff is wholly certified." />
										<?php elseif (Helpers::strEqual($staff->certification_status, 'WARNING')): ?>
											<img src="<?php echo asset('/images/icons/certification_warning_16px.png'); ?>" alt="" title="This staff is certified, but a training course is about to expire within the next three months." />
										<?php else: ?>
											<img src="<?php echo asset('/images/icons/certification_alert_16px.png'); ?>" alt="" title="This staff is missing a required certification." />
										<?php endif; ?>

										<div class="staff_edit">
											<div class="staff_edit_button">Manage</div>
											<ul class="staff_edit_menu">
												<li><a href="#" class="menu_item staff_edit_contact"><span class="ui-icon ui-icon-contact"></span>Edit Name/Contact</a></li>
												<?php if ($staff->is_on_rosters): ?>
													<li><a href="#" class="menu_item toggle_roster_visibility" data-roster-visiblility="0"><span class="ui-icon ui-icon-person"></span>Hide on Rosters</a></li>
												<?php else: ?>
													<li><a href="#" class="menu_item toggle_roster_visibility" data-roster-visiblility="1"><span class="ui-icon ui-icon-person"></span>Show on Rosters</a></li>
												<?php endif; ?>
												<li><a href="#" class="menu_item"><span class="ui-icon ui-icon-clipboard"></span>Edit Certifications</a></li>
												<li><a href="#" class="menu_item remove_from_sport"><span class="ui-icon ui-icon-circle-minus"></span>Remove from Sport</a></li>
											</ul>								
										</div>

									</div>
								</div>

								<div class="contact">							
									<?php if ($staff->activity_program_staff->is_email_public): ?>
										<img src="<?php echo $visible_icon; ?>" alt="" title="Email address is public." />
									<?php else: ?>
										<img src="<?php echo $hidden_icon; ?>" alt="" title="Email address is not public." />
									<?php endif; ?>

									<?php if (!Helpers::strIsEmpty($staff->school_staff->email)): ?>								
										<?php echo $staff->school_staff->getDisplayEmail(); ?>
									<?php else: ?>
									    No Email Address
									<?php endif; ?>

									<br />

									<?php if ($staff->activity_program_staff->is_work_phone_public): ?>
										<img src="<?php echo $visible_icon; ?>" alt="" title="Work phone number is public." />
									<?php else: ?>
										<img src="<?php echo $hidden_icon; ?>" alt="" title="Work Phone number is not public." />
									<?php endif; ?>
									
									<?php if (!Helpers::strIsEmpty($staff->school_staff->getDisplayPhone('WORK'))): ?>
										W: <?php echo $staff->school_staff->getDisplayPhone('WORK'); ?>
									<?php else: ?>
										No Work Phone
									<?php endif; ?>	

									<br />							

									<img src="<?php echo $hidden_icon; ?>" alt="" title="Mobile phone number is always private." />
									<?php if (!Helpers::strIsEmpty($staff->school_staff->getDisplayPhone('MOBILE'))): ?>								
										M: <?php echo $staff->school_staff->getDisplayPhone('MOBILE'); ?>
									<?php else: ?>								
										No Mobile Phone
									<?php endif; ?>	
								</div>

								<div class="certifications">
									<?php if (count($staff->courses) > 0): ?>

										<?php foreach ($staff->courses as $count => $course): ?>

											<?php
												$training_course = $info['courses']->filter(function($c) use($course)
												{
													if ($c->slug == $course->course_slug)
													{
														return true;
													}
													else
													{
														return false;
													}
												})->first();

												//Helpers::debugVar($course);

												$short_name = $training_course->short_name;
												$name = $training_course->name;
												$display_date = (property_exists($course, 'display_date')) ? $course->display_date : null;

												if ($course->is_complete)
												{
													$icon = asset('/images/icons/check_16px.png');
													$title = $name . ' certification is up-to-date.';

													if ($course->is_soon)
													{
														$icon = asset('/images/icons/almost_16px.png');
													}
												}
												elseif (!$course->is_required)
												{
													$icon = asset('/images/icons/blank_16px.png');
													$title = $name . ' certification is not required.';
												}
												else
												{
													$icon = asset('/images/icons/missing_16px.png');
													$title = $name . ' certification requirement is missing.';
												}
											?>											

											
											<div class="record">

												<img src="<?php echo $icon; ?>" alt="" title="<?php echo $title; ?>" />

												<?php echo $short_name; ?>

												<?php if (!is_null($display_date)): ?>
													<div class="completed"><?php echo $display_date; ?></div>
												<?php endif; ?>
												
											</div>

										<?php endforeach; ?>
									<?php endif; ?>
								</div>
							</div>
						<?php endforeach; ?>
					<?php else: ?>
						No staff listed for this activity program.
					<?php endif; ?>
				</div>				
			</div>
		<?php endforeach; ?>
	<?php endif; ?>

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