<?php $__env->startSection('page_title'); ?>
    OSAA - My Account
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page_sub_title'); ?>    
    My OSAA Account
<?php $__env->stopSection(); ?>

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

    <?php
        GeneralController::getLiveAlert();
    ?>
    
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
    @parent
    
    <style type="text/css">        

        .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;
        }

        .odd {
            background-color: #dddddd;
        }

        h3 {
            color: #990000 !important;
        }

        .page_functions {
            width: auto !important;
        }  

        label, .label {            
            font-weight: bold;            
            float: left;
            width: 125px;            
        }        

        table {
            border-collapse: collapse;
        }

        .bia_table {            
            width: 100%;
            font-size: 10pt;
        }

        .bia_table thead {
            background-color: #005FA9;
            color: #ffffff;
        }

        .bia_table thead th {            
            padding: 4px 2px;
            text-align: left;
        }

        .bia_table tbody tr {
            line-height: 2em;
        }

        .school_tab {            
            position: relative;
            min-height: 580px;
        }

        .my_school {
            margin-top: 0.5em;
            width: 100%;
            min-height: 510px;
        }

        .ui-tabs-vertical { width: 100%; }
        .ui-tabs-vertical .ui-tabs-nav { padding: .2em .1em .2em .2em; float: left; width: 12em;}
        .ui-tabs-vertical .ui-tabs-nav li {clear: left; width: 100%; border-bottom-width: 1px !important; border-right-width: 0 !important; margin: 0 -1px .2em 0;}
        .ui-tabs-vertical .ui-tabs-nav li a { display:block; width: 122px;}
        .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-active { padding-bottom: 0; padding-right: .1em; border-right-width: 1px; margin-bottom: 0.2em;}
        .ui-tabs-vertical .ui-tabs-panel { padding: 0 0.5em 1em 0.5em; float: right; width: 80%;}

        .school_logo {
            float: right;
            width: 150px;            
            margin-left: 40px;
            margin-right: 10px;
            text-align: center;
        }

        img.construction {
            -webkit-filter: brightness(250%);
        }

        .form_link {
            width: 300px;
        }

        #user_lookup_results {
            overflow-y: auto;
            overflow-x: hidden;
            border: 1px solid #cccccc;
            height: 390px;
            margin-top: 0.5em;
        }

        .user_lookup_result_item {
            height: 4.5em;
            padding: 0.25em 0.25em 0.25em 15px;
            border-bottom: 1px solid #666666;
            position: relative;  
            overflow-x: hidden;          
            overflow-y: auto;
        }

        .user_lookup_result_item.account,
        .user_lookup_result_item.user_item_hover.account {
            border-left: 4px solid #b0dcff; 
        }        
        .user_lookup_result_item.contact,
        .user_lookup_result_item.user_item_hover.contact {
            border-left: 4px solid #b0ffbe; 
        }

        .user_lookup_result_item.user_item_hover {
            font-weight: normal;
            color: inherit;
            border-left: none;
            border-right: none;
            border-top: none;
            text-decoration: inherit;
        }

        .user_lookup_result_item_name {
            font-weight: bold;
        }

        .user_lookup_result_item_email {
            font-size: 9pt;
        }

        .user_lookup_result_item_id {
            position: absolute;
            top: 0.25em;
            right: 0.25em;
            font-size: 8pt;
        }

        .user_lookup_result_item_user_info {
            position: absolute;
            top: 0.25em;
            left: 300px;
            font-size: 8pt;
            line-height: 1.1em;
            color: #565656;
        }

        .user_lookup_result_item_user_needs_reset {
            background-image: url("<?php echo asset('/images/icons/red_flag_16px.png'); ?>");
            background-repeat: no-repeat;
            display: block;
            position: absolute;
            width: 16px;
            height: 16px;
            top: 10px;
            right: 50px;
        }

        .user_lookup_result_item_roles {
            clear: both;
            padding-top: 0.25em;
            font-size: 9pt;
            line-height: 1.1em;
        }

    </style>

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

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

    if(!window.console)
    {
        window.console = { log: $.noop, group: $.noop, groupEnd: $.noop };            
    }    

    $('.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);
        })
    });

    // Table row highlighter
    function colorRows ()
    {       
        $('table').each(function ()
        {
            var i = 0;

            $('tbody tr', $(this)).each(function ()
            {
                if (i % 2 == 1)
                {
                    $(this).addClass('odd');
                }
                else
                {
                    $(this).removeClass('odd');
                }
                i = i + 1;
            });     
        });
    }   
    colorRows();

    /* 
     * Custom tooltip items
     */
    $('[data-tooltip]').each(function ()
    {
        var item = $(this);

        var help = item.attr('data-tooltip');
        
        item.tooltip({'content' : help, 'items' : item});
    });       
    

    /* Set up the tabs for each school, last tab (index = -2) may be default if specified */
    /*
     * TODO: test this with new changes
     */
    $('.tabs').tabs(<?php if (Input::has('add-school')): ?> {active:-2} <?php endif; ?>);   
    $('.vertical_tabs')
        .tabs({"active" : <?php echo $info['preferred_landing_sub_tab']; ?> })
        .addClass("ui-tabs-vertical ui-helper-clearfix");
    $('.vertical_tabs li, .vertical_tabs li a')
        .removeClass("ui-corner-top")
        .removeClass("ui-corner-right")
        .addClass("ui-corner-left");

    /* Once a role is selected, check to see if an activity can be selected or not */
    $('#role').change (function updateRole ()
    {
        var role_slug = $(this).find(":selected").val();

        var no_act = ['Prin.', 'Asst. Prin.', 'AD', 'Asst. AD', 'Act. Dir.', 'Asst. Act. Dir.', 'Ath. Sec.', 'Act. Sec.', 'AT', 'Doc.', 'Contact'];

        if ($.inArray(role_slug, no_act) < 0)
        {
            $("#activity").removeAttr('disabled');
        }
        else
        {
            $('#activity').attr('disabled', 'disabled');
        }       
    });    

    // Change password button
    $('.change_password_button')
        .button({'icons' : {'primary' : "ui-icon-locked"}});

    // Heat index calculator button
    $('.heat_index_calcualtor')
        .css({'font-size' : '9pt',
              'float' : 'right'})
        .button();


    <?php /*  OSAA User Scripts  */ ?>
    <?php if ($info['user_access']->osaa): ?>
        $('.osaa_jump_button')
            .css({'font-size' : '9pt',
                  'margin-right' : '10px'})
            .button();

        /*
         * User search function
         */
        function lookupUser(options)
        {
            // Change to a busy cursor
            $('*').css({'cursor':'wait'});
            
            // Remove any error state on the results
            $('#user_lookup_results')
                .removeClass('ui-state-error');

            // Get matches
            var jqxhr = $.ajax(
                {
                    type : 'POST',
                    url : '<?php echo url('/admin/lookup/users'); ?>',
                    data : options,
                    dataType : 'html'
                })
                .done(function (return_data)
                {                               
                    // Reset the cursor
                    $('*').css({'cursor':''});
                    
                    // Parse the data
                    var parsed_return_data = $.parseJSON(return_data);
                    console.log(parsed_return_data);

                    if (parsed_return_data.status == 'ERROR')
                    {
                        $('#user_lookup_results')
                            .html(parsed_return_data.error)
                            .addClass('ui-state-error');
                    }
                    else
                    {
                        if (parsed_return_data.results.length > 0)
                        {
                            showUserLookupResults(parsed_return_data);
                        }
                        else
                        {
                            $('#user_lookup_results').html('');
                        }
                    }                    
                })
                .fail(function (jqXHR, status, error)
                {                                                   
                    $('*').css({'cursor':''});
                    
                    var response = jqXHR.responseText;
                    var errorData = $.parseJSON(response);
                    console.log(errorData);
                    alert("An error was encountered while searching.\n\n" + errorData.error.message + "\n\nThis page will be reloaded.");
                    location.reload();
                }); 
        }

        // User search field is updated
        $('#user_lookup_search').on('keyup keypress', function()
        {
            handleUserLookupChange($(this));
        });

        // Filter options change
        $('#user_lookup_include_contacts, #user_lookup_include_accounts, #user_lookup_include_retired').click(function()
        {
            var field = $('#user_lookup_search');
            handleUserLookupChange(field);
        });

        function handleUserLookupChange (field)
        {
            clearTimeout(handleUserLookupChange.timeout);
            handleUserLookupChange.timeout = setTimeout(function (){                
                var term = field.val();
                var include_contacts = $('#user_lookup_include_contacts').is(':checked');
                var include_accounts = $('#user_lookup_include_accounts').is(':checked');
                var include_retired = $('#user_lookup_include_retired').is(':checked');

                // Construct a data object
                var options = {
                    term : term,
                    include_contacts : include_contacts,
                    include_accounts : include_accounts,
                    include_retired : include_retired
                };

                // Lookup if the search term is at least 2 characters
                if (options.term.length >= 2)
                {                    
                    lookupUser(options);
                }                    
            }, 150);
        }

        function showUserLookupResults(data)
        {
            var html = '';

            for (var i = 0; i < data.results.length; i++)
            {
                var result = data.results[i];

                html += '<div class="user_lookup_result_item ' + result.type.toLowerCase() + '" data-model="' + result.model + '" data-id="' + result.id + '">';
                html += '<div class="user_lookup_result_item_name">' + result.name + '</div>';
                html += '<div class="user_lookup_result_item_id">' + result.id + '</div>';
                
                if (result.email != null)
                {
                    html += '<div class="user_lookup_result_item_email"><a href="mailto:' + result.email + '">' + result.email + '</a></div>';
                }
                else
                {
                    html += '<div class="user_lookup_result_item_email">No Email Listed</div>';
                }
                
                if (result.type == "CONTACT")
                {
                    html += '<div class="user_lookup_result_item_user_info">';
                    if (result.work != null)
                    {
                        html += '<span style="display: inline-block; width: 110px;">Work Phone:</span>' + result.work + '<br />';
                    }
                    if (result.mobile != null)
                    {
                        html += '<span style="display: inline-block; width: 110px;">Mobile Phone:</span>' + result.mobile + '<br />';
                    }
                    
                    html += '</div>';


                    html += '<div class="user_lookup_result_item_roles">';
                    html += '<b>' + result.entity + '</b>: ';

                    for (var j = 0; j < result.roles.length; j++)
                    {
                        html += result.roles[j];

                        if (j < (result.roles.length - 1))
                        {
                            html += '; ';
                        }
                    }

                    html += '</div>';
                }

                if (result.type == "ACCOUNT")
                {
                    html += '<div class="user_lookup_result_item_user_info">';
                    html += '<span style="display: inline-block; width: 110px;">Account Created:</span>' + result.created_at + '<br />';
                    html += '<span style="display: inline-block; width: 110px;">Account Updated:</span>' + result.updated_at + '<br />';
                    html += '<span style="display: inline-block; width: 110px;">Last Login:</span>' + result.last_login_at;
                    html += '</div>';

                    if (result.is_need_reset)
                    {
                        html += '<div class="user_lookup_result_item_user_needs_reset"></div>';
                    }                

                    html += '<div class="user_lookup_result_item_roles">';
                    
                    if (result.schools_roles.length > 0)
                    {
                        html += '<b>Roles: </b>';

                        for (var j = 0; j < result.schools_roles.length; j++)
                        {
                            html += result.schools_roles[j];

                            if (j < (result.schools_roles.length - 1))
                            {
                                html += '; ';
                            }
                        }

                        html += '<br />';
                    }

                    if (result.is_commissioner)
                    {
                        html += '<b>Commissioner: </b>';

                        for (var j = 0; j < result.associations.length; j++)
                        {
                            html += result.associations[j];

                            if (j < (result.associations.length - 1))
                            {
                                html += '; ';
                            }
                        }

                        html += '<br />';
                    }

                    if (result.is_bia_assessor)
                    {
                        html += '<b>BIA Assessor</b>';
                    }
                }

                html += '</div>';

                html += '</div>';
            }

            $('#user_lookup_results').html(html);

            // Bind handlers if there were any results
            if (data.results.length > 0)
            {
                $('#user_lookup_results .user_lookup_result_item').each(function(index)
                {
                    var item = $(this);                    

                    item.hover(function()
                    {
                        $(this)
                            .addClass('user_item_hover ui-state-default')
                            .css({'cursor' : 'pointer'});
                    },
                    function()
                    {
                        $(this)
                            .removeClass('user_item_hover ui-state-default')
                            .css({'cursor' : ''});
                    });
                });
            }
        }


    <?php endif; ?>


    <?php /*  BIA Assessor Scripts  */ ?>
    <?php if ($info['user_access']->bia): ?>

        $('#new_bia_form_button')
            .css({'float' : 'right',
                  'margin-top' : '1em'})
            .button({ icons : { primary : 'ui-icon-plusthick'}});

        <?php /*  Closes?  */ ?>
        <?php if (false): ?>
            $('#new_bia_form_button')            
                .button('disable');
        <?php endif; ?>

        $('.bia_print')
            .css({'width' : '16px',
                  'height' : '16px',
                  'margin-right' : '5px'})
            .button({ icons : { primary : 'ui-icon-print'},
                      text : false})
            .click(function ()
            {
                var button = $(this);
                var row = button.parents('tr');
                var record = row.attr('data-record');

                window.open('<?php echo url('/forms/bia'); ?>/' + record + '/print'); 
            });

        $('.bia_edit')
            .css({'width' : '16px',
                  'height' : '16px'})
            .button({ icons : { primary : 'ui-icon-pencil'},
                      text : false})
            .click(function()
            {
                var button = $(this);

                var row = button.parents('tr');
                
                var original_background_color = row.css('background-color');            
                
                var record = row.attr('data-record');            

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

                row.css({'background-color':'yellow'});

                if (status == 'WORK' || status == 'INSF' || <?php echo (Auth::user()->isOsaaUser()) ? 1 : 0; ?>)
                {                            
                    window.location = "<?php echo url('/forms/bia'); ?>/" + record + "/edit";
                }
                else
                {
                    $('<div></div>')
                        .appendTo('body')
                        .dialog(
                        {                       
                            draggable : true,
                            resizable : false,
                            modal : true,
                            height : 200,
                            width : 400,                    
                            title : 'Unable to Edit',
                            buttons: [                                
                                {
                                    text : "Ok",
                                    'class' : "float_right",
                                    'data-autofocus' : "true",
                                    icons : { primary : 'ui-icon-check'},
                                    click : function()
                                            {
                                                // Close the dialog box
                                                $(this).dialog("close");                           
                                            }
                                }
                            ],
                            open : function ()
                                {  
                                    var dialog_object = $(this);

                                    dialog_object.html('<br />You cannot edit this record.');
                                    
                                    $('.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();
                                },
                            close : function ()
                                {
                                    var dialog_object = $(this);

                                    row.css({'background-color':original_background_color});

                                    $(dialog_object).remove();
                                }                
                        });
                    
                }

            });

        $('.bia_delete')
            .css({'width' : '16px',
                  'height' : '16px',
                  'margin-left' : '5px'})
            .button({ icons : { primary : 'ui-icon-trash'},
                      text : false})
            .click(function()
            {
                var button = $(this);

                var row = button.parents('tr');
                
                var original_background_color = row.css('background-color');            
                
                var record = row.attr('data-record');            

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

                row.css({'background-color':'yellow'});

                if (status == 'WORK' || status == 'INSF' || <?php echo (Auth::user()->isOsaaUser()) ? 1 : 0; ?>)
                {                            
                    $('<div></div>')
                        .appendTo('body')
                        .dialog(
                        {                       
                            draggable : true,
                            resizable : false,
                            modal : true,
                            height : 250,
                            width : 400,                    
                            title : 'Confirm Deletion',
                            buttons: [
                                {
                                    text : "Delete",
                                    'class' : "float_left",
                                    icons : { primary : 'ui-icon-check'},
                                    click : function()
                                            {                                                       
                                                var data = { record : record };

                                                $('<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 ui-dialog-buttons')
                                                               .html('<br />Working...<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 : '<?php echo url('/forms/bia/delete-form'); ?>',
                                                        data : data,
                                                        dataType : 'html'
                                                    })
                                                    .done(function (data)
                                                    {                               
                                                        console.log('Deletion was successful.');
                                                        
                                                        // Reload of refresh is specified                                                
                                                        location.reload();                                                
                                                    })
                                                    .fail(function (jqXHR, status, error)
                                                    {                                                   
                                                        var response = jqXHR.responseText;
                                                        var errorData = $.parseJSON(response);
                                                        console.log(errorData);
                                                        alert ("There was an error deleting the record.\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);

                                    dialog_object.html('<br />Are you sure you want to delete this form with ID = ' + record + '?<br /><br /><div class="ui-state-error" style="font-size: 10.5pt;"><span class="ui-icon ui-icon-alert box_icon"></span> <b>Warning</b><br />If you delete this form, it will no longer exist.</div>');
                                    
                                    $('.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();
                                },
                            close : function ()
                                {
                                    var dialog_object = $(this);

                                    row.css({'background-color':original_background_color});

                                    $(dialog_object).remove();
                                }                
                        });
                    
                }
                else
                {
                    $('<div></div>')
                        .appendTo('body')
                        .dialog(
                        {                       
                            draggable : true,
                            resizable : false,
                            modal : true,
                            height : 200,
                            width : 400,                    
                            title : 'Unable to Delete',
                            buttons: [                                
                                {
                                    text : "Ok",
                                    'class' : "float_right",
                                    'data-autofocus' : "true",
                                    icons : { primary : 'ui-icon-check'},
                                    click : function()
                                            {
                                                // Close the dialog box
                                                $(this).dialog("close");                           
                                            }
                                }
                            ],
                            open : function ()
                                {  
                                    var dialog_object = $(this);

                                    dialog_object.html('<br />You cannot delete this record.');
                                    
                                    $('.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();
                                },
                            close : function ()
                                {
                                    var dialog_object = $(this);

                                    row.css({'background-color':original_background_color});

                                    $(dialog_object).remove();
                                }                
                        });
                    
                }

            });

    <?php endif; ?>
    

    <?php /*  Commissioner Scripts  */ ?>
    <?php if ($info['user_access']->commissioner): ?>
        $('.new_ejection_button')
            .css({'float' : 'right', 'margin-top' : '1em'})
            .button({ icons : { primary : 'ui-icon-plusthick'}});
    <?php endif; ?>   
    

    <?php /*  School Scripts  */ ?>
    <?php if ($info['user_access']->school): ?>

        // Submit scores button
        $('.submit_scores')
            .css({'font-size' : '9pt', 'position' : 'absolute', 'top' : '325px', 'left' : '50px', 'z-index' : '2', 'width' : '100px'})
            .button({'icons' : {'primary' : 'ui-icon-circle-arrow-e' }});

        // Add team button
        $('.add_team_button')
            .css({'width' : '16px', 'height' : '16px'})
            .button({'icons' : {'primary' : "ui-icon-plus"},
                     'text' : false});  

        // View team button
        $('.view_team_button')  
            .css({'margin-right' : '4px',
                  'width' : '45px',
                  'height' : '16px',
                  'font-size' : '7pt'})
            .button();

        // Edit team button
        $('.edit_team_button')  
            .css({'margin-right' : '4px',
                  'width' : '45px',
                  'height' : '16px',
                  'font-size' : '7pt'})
            .button({'icons' : {'primary' : 'ui-icon-pencil'}});

        $('.view_school_button')
            .css({'font-size' : '9pt'})
            .button({'icons' : {'primary' : 'ui-icon-home' }});

        $('.edit_school_information_button')
            .css({'font-size' : '9pt',
                  'margin-left' : '20px'})
            .button({'icons' : {'primary' : 'ui-icon-pencil' }});

        $('.manage_staff_button')
            .css({'font-size' : '9pt',
                  'margin-left' : '20px'})
            .button({'icons' : {'primary' : 'ui-icon-person' }});        

        $('.eligibility_forms_button')
            .css({'font-size' : '9pt',
                  'float' : 'right',
                  'margin-top' : '1em'})
            .button();

        /*
         * School key codes button
         */
        $('.school_key_codes_button')
            .css({'font-size' : '9pt',
                  'margin-left' : '20px'})
            .button({'icons' : {'primary' : 'ui-icon-key' }})
            .click(function(event)
            {
                event.preventDefault();

                var button = $(this);
                var school_id = button.attr('data-school-id');
                var school_name = button.attr('data-school-name');
                var admin_code = button.attr('data-admin-code');
                var non_admin_code = button.attr('data-non-admin-code');

                $('<div></div>')
                    .appendTo('body')
                    .dialog(
                    {                       
                        modal : true,
                        draggable : true,
                        resizable : false,
                        height : 350,
                        width : 475,                    
                        title : 'School Key Codes',                        
                        open : function ()
                            {  
                                var dialog_object = $(this);

                                var html = '<div style="font-size: 10pt; margin: 1em 0;">';
                                html += '<div style="font-weight: bold; display: inline-block; width: 290px;">Non-Administrator/Coach Key Code:</div><span style="font-size: 12pt; letter-spacing: 1px; font-family: monospace;">' + non_admin_code + '</span><br />';
                                html += '<div class="small" style="line-height: 1.15em; margin-top: 0.5em;">Give this code out to any user requesting coach or team related privileges.  Grants access to <b>schedules</b>, <b>rosters</b>, and <b>scores</b> to a user for a specific team.</div><br /><br />';
                                html += '<div style="font-weight: bold; display: inline-block; width: 290px;">Administrator Key Code:</div><span style="font-size: 12pt; letter-spacing: 1px; font-family: monospace;">' + admin_code + '</span><br />';
                                html += '<div class="small" style="line-height: 1.15em; margin-top: 0.5em;"><span class="ui-icon ui-icon-alert" style="display: inline-block; vertical-align: middle;"></span> Only give this code out to your school administrators and administrative assistants.</span>  Grants access to everything related to your school including <b>forms</b>, <b>information</b>, and <b>schedules</b>, <b>rosters</b>, and <b>scores</b> for every team.  Administrators can also <b>manage staff</b>.</div><br /><br />';
                                html += '<div class="small gray note">Please note, your school\'s key codes are NOT account passwords.  Each user has their own personal password that he/she choose when they initially created their OSAA website account.</div>';
                                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();                                
                            },
                        close : function ()
                            {
                                var dialog_object = $(this);
                                $(dialog_object).remove();
                            }                
                    });


            });

        /*
         * Remove role
         */
        $('.remove_role img')
            .css({'vertical-align' : 'middle', 'margin-right' : '2px'}); 
        $('.remove_role')
            .click(function(event)
            {
                event.preventDefault();

                var item = $(this);                
                var row = item.parents('tr');

                row.addClass('ui-state-highlight');

                var school_id = item.attr('data-school-id');
                var school_name = item.attr('data-school-name');
                var role_name = item.attr('data-role-name');
                var activity = item.attr('data-role-activity');
                var user_id = <?php echo Auth::user()->id; ?>;
                var record_id = item.attr('data-record-id');
                
                $('<div></div>')
                    .appendTo('body')
                    .dialog(
                    {                       
                        modal : true,
                        draggable : true,
                        resizable : false,
                        height : 275,
                        width : 450,                    
                        title : 'Confirmation',
                        buttons: [
                            {
                                text : "Remove Role",
                                'class' : "float_left",
                                icons : { primary : 'ui-icon-circle-minus'},
                                click : function()
                                        {                                          
                                            var data = {
                                                'school' : school_id,                                                     
                                                'user' : user_id,
                                                'school_user' : record_id                                                
                                            };                                        

                                            $('<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 />Removing Role...<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 : '<?php echo url('/account/remove-school-role'); ?>',
                                                    data : data,
                                                    dataType : 'html'
                                                })
                                                .done(function (data)
                                                {                                                
                                                    // Success   
                                                    if (data == 'success')
                                                    {
                                                        window.location.href = "<?php echo url('/account'); ?>";
                                                    }
                                                    else
                                                    {
                                                        alert ("There was an error removing this role.\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 removing this role.\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 remove your ' + activity + ' ' + role_name + ' role at ' + school_name + ' from your account?</b>';
                                html += '<br /><br />';
                                html += '<div class="small gray">This will remove your ' + activity + ' ' + role_name + ' association with this school.  If you wish to undo this action at a later point in time, you will need your school\'s key code in order to rejoin your account with this school/role.</div>';
                                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();                                
                            },
                        close : function ()
                            {
                                row.removeClass('ui-state-highlight');
                                var dialog_object = $(this);
                                $(dialog_object).remove();
                            }                
                    });
            });

        /*
         * Remove school role
         */
        $('.remove_school_user img')
            .css({'vertical-align' : 'middle', 'margin-right' : '2px'}); 
        $('.remove_school_user')
            .click(function(event)
            {
                event.preventDefault();

                var item = $(this);                
                var row = item.parents('tr');

                row.addClass('ui-state-highlight');

                var record_id = item.attr('data-record-id');
                var school_id = item.attr('data-school-id');
                var school_name = item.attr('data-school-name');
                var role_name = item.attr('data-role-name');
                var activity = item.attr('data-role-activity');
                var requesting_user_id = <?php echo Auth::user()->id; ?>;
                var user_id = item.attr('data-user-id');
                var user_name = item.attr('data-user-name');
                
                $('<div></div>')
                    .appendTo('body')
                    .dialog(
                    {                       
                        modal : true,
                        draggable : true,
                        resizable : false,
                        height : 300,
                        width : 500,                    
                        title : 'Confirmation',
                        buttons: [
                            {
                                text : "Remove School User",
                                'class' : "float_left",
                                icons : { primary : 'ui-icon-circle-minus'},
                                click : function()
                                        {                                          
                                            var data = {
                                                'school' : school_id,                                                     
                                                'user' : user_id,
                                                'requester' : requesting_user_id,
                                                'school_user' : record_id                                                
                                            };                                        

                                            $('<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 />Removing User...<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 : '<?php echo url('/account/remove-school-user'); ?>',
                                                    data : data,
                                                    dataType : 'html'
                                                })
                                                .done(function (data)
                                                {                                                
                                                    // Success   
                                                    if (data == 'success')
                                                    {
                                                        window.location.href = "<?php echo url('/account'); ?>";
                                                    }
                                                    else
                                                    {
                                                        alert ("There was an error removing this school user.\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 removing this school user.\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 remove ' + user_name + ' from the role of ' + role_name + ' from ' + school_name + '?</b>';
                                html += '<br /><br />';
                                html += '<div class="small gray">This will remove access from ' + user_name + ' who will no longer be able to access features related to the role of ' + role_name + ' at ' + school_name + '.  If you wish to undo this action at a later point in time, ' + user_name + ' will need your school\'s key code in order to rejoin their account with this school/role.</div>';
                                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();                                
                            },
                        close : function ()
                            {
                                row.removeClass('ui-state-highlight');
                                var dialog_object = $(this);
                                $(dialog_object).remove();
                            }                
                    });
            });


        /* 
         * Remove school
         */
        $('.remove_school')
            .css({'font-size' : '9pt',
                  'float' : 'right'})
            .button({ icons : { primary : 'ui-icon-circle-minus' }})
            .click(function(event)
            {
                event.preventDefault();

                var button = $(this);            
                button.blur();

                var school_id = button.attr('data-school-id');
                var school_name = button.attr('data-school-name');
                var user_id = <?php echo Auth::user()->id; ?>;
                
                $('<div></div>')
                    .appendTo('body')
                    .dialog(
                    {                       
                        modal : true,
                        draggable : true,
                        resizable : false,
                        height : 275,
                        width : 450,                    
                        title : 'Confirmation',
                        buttons: [
                            {
                                text : "Remove School",
                                'class' : "float_left",
                                icons : { primary : 'ui-icon-circle-minus'},
                                click : function()
                                        {                                          
                                            var data = {
                                                'school' : school_id,                                                     
                                                'user' : user_id
                                            };                                        

                                            $('<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 />Removing School...<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 : '<?php echo url('/account/remove-school'); ?>',
                                                    data : data,
                                                    dataType : 'html'
                                                })
                                                .done(function (data)
                                                {                                                
                                                    // Success   
                                                    if (data == 'success')
                                                    {
                                                        window.location.href = "<?php echo url('/account'); ?>";
                                                    }
                                                    else
                                                    {
                                                        alert ("There was an error removing this school.\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 removing this school.\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 remove ' + school_name + ' and all of your associated roles from your account?</b>';
                                html += '<br /><br />';
                                html += '<div class="small gray">This will remove your association with this school.  If you wish to undo this action at a later point in time, you will need your school\'s key code in order to rejoin your account to this school.</div>';
                                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();                                
                            },
                        close : function ()
                            {
                                var dialog_object = $(this);
                                $(dialog_object).remove();
                            }                
                    });                
            });


        // Update association member ADM number
        $('.update_assoc_adm')
            .button()
            .css({'font-size' : '9pt',
                  'float' : 'right',
                  'margin-top' : '0.6em'})
            .click(function ()
            {
                var id = $(this).attr('data-school');

                var v = $('input[data-school="' + id + '"]').val();

                if ($.isNumeric(v) && parseInt(v) > 0)
                {
                    v = parseInt(v);                

                    var jqxhr = $.ajax(
                                    {
                                        type : 'POST',
                                        url : '/account/update-associate-enrollment',
                                        data : { 'school' : id,
                                                 'enrollment' : v},
                                        dataType : 'html',
                                        error : function () { alert('There was an error saving your enrollment number.'); },
                                        success : function () { location.reload(); }
                                    });
                                    
                }
            });


        /* savePreferences
         *
         * Given a form field and a value, this function will do a
         * JSON POST request to save the user's preferences.  The optional
         * third parameter will determine if the page will be reloaded or not.
         */
        function savePreferences(field, value, type, reload)
        {
            // Ensure the field and value parameters are provided
            if (typeof field == 'undefined' || typeof value == 'undefined' || typeof type == 'undefined')
            {
                alert('Scripting error.  Unable to save preferences.');
            }

            // Get the optional reload parameter
            reload = typeof reload !== 'undefined' ? reload : false;

            // Get the user's ID
            var user_id = <?php echo Auth::user()->id; ?>;

            $('*').css({'cursor':'wait'});

            var jqxhr = $.ajax(
            {
                type : 'POST',                      
                url : '<?php echo url('/account/preferences'); ?>',
                data : { 'user'  : user_id,
                         'field' : field,
                         'value' : value,
                         'type'  : type },
                dataType : 'html'
            })
            .done(function(returned_data)
            {                               
                // Success
                //console.log("Successfully saved {'" + user_id + "|" + field + "' : '" + value + "'}");
                
                var info = $.parseJSON(returned_data);
                
                if (info.force_reload)
                {
                    reload = true;
                }

            })
            .fail(function(jqXHR, status, error)
            {                                                   
                // Error
                var response = jqXHR.responseText;
                var errorData = $.parseJSON(response);
                //console.log(errorData);
                alert("There was an error saving your preferences.\n\n" + errorData.error.message + "\n\nPlease try again.  Please note, that if you try to reload this page, your unsaved data will be lost.");
            })
            .complete(function ()
            {
                // Reload if necessary
                if (reload)
                {
                    location.reload();
                }
                else
                {
                    $('*').css({'cursor':''});
                }
            });
        }   
       

        // Autosave select fields    
        $('select[data-autosave]').on('change', function(event)
        {
            var select_field = $(this);
            var selected = $(':selected', select_field);
            var value = selected.val();
            var original_value = select_field.attr('data-original'); 
            var field = select_field.attr('data-field');
            var type = select_field.attr('data-type');                        
         
            var readonly_attr = select_field.attr('readonly');            
            if (typeof readonly_attr !== typeof undefined && readonly_attr !== false)
            {
                return false;
            }

            var reload = false;
            var reload_attr = select_field.attr('data-reload');            
            if (typeof reload_attr !== typeof undefined && reload_attr !== false)
            {
                reload = true;
            }

            if (value != original_value)
            {
                savePreferences(field, value, type, reload);
                select_field.attr('data-original', value);
            }
        });
        

    <?php endif; ?>

    
     

    

    


    $('.form_link').hover(function ()
        {
            if (!$(this).hasClass('unavailable') && !$(this).hasClass('closed'))
            {
                $(this).addClass('hover');
            }
        }, 
        function ()
        {
            $(this).removeClass('hover');
        }).click(function ()
        {
            if (!$(this).hasClass('unavailable') && !$(this).hasClass('closed'))
            {
                var link = $(this).attr('data-link');
                window.location = link;
            }            
        });

    


    $('.button.setup_bia_account')
        .click(function ()
        {
            $('<div></div>')
                .appendTo('body')
                .dialog({
                    autoOpen: true,
                    draggable: false,
                    resizable: false,
                    modal: true,
                    height: 460,
                    width: 700,
                    title: 'Setup Your BIA Assessor Account',                    
                    buttons: [
                        {
                            text : "Go",
                            'class' : "float_left",
                            icons : { primary : 'ui-icon-check'},
                            click : function()
                                  {
                                      // Ensure all fields have a value
                                      var ok = '';
                                      $('input[data-required="true"]', '#bia_form').each(function ()
                                      {
                                          var field = $(this);

                                          if (field.val() == '' || (field.has('[data-placeholder]') && field.val() == field.attr('data-placeholder')))
                                          {
                                              if (ok == '')
                                              {
                                                  ok = $(this);
                                              }
                                          }
                                      });                                      

                                      if (ok != '')
                                      {
                                          alert('The form is missing some required information.  Please provide an entry for all of the form fields.');
                                          ok.focus();
                                          return false;
                                      }

                                      // Ensure the phone number is at least 10 digits
                                      var number = $('input[name="phone"]', '#bia_form').val();
                                      number = number.replace(/[^0-9]/g, '');
                                      if (number.length < 10)
                                      {
                                          alert('The phone number you entered is not formatted correctly.  It must be at least 10 digits.  Be sure to include the area code.');
                                          $('input[name="phone"]', '#bia_form').focus();
                                          return false;
                                      }

                                      // Ensure the ZIP code is 5 digits
                                      var zip = $('input[name="zip"]', '#bia_form').val();
                                      zip = zip.replace(/[^0-9]/g, '');
                                      if (zip.match(/[0-9]{5}/) == null)
                                      {
                                          alert('The zip code you entered is not formatted correctly.  It must be exactly 5 digits.');
                                          $('input[name="zip"]', '#bia_form').focus();
                                          return false;
                                      }                                      

                                      $('<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 ui-dialog-buttons')
                                                     .html('<br />Working...<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>');


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

                                      $(this).dialog("close");
                                      $(this).remove();                                   
                                   }
                        },                        
                        {
                            text : "Cancel",                            
                            'class' : "float_right",                            
                            icons : { primary : 'ui-icon-cancel'},
                            click : function()
                                    {
                                        $(this).dialog( "close");;
                                        $(this).remove();
                                    }
                        }
                     ],
                     open : function ()
                     {                   
                          $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '10pt');
                          $('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');

                          
                          $(this).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 info = $(this);

                          var jqxhr = $.ajax(
                                {
                                    type : 'GET',
                                    url : '/account/setup-bia-account',
                                    dataType : 'html'
                                })
                                .done(function (data)
                                {
                                    $(info).html(data);
                                    
                                    // Placeholder functionality
                                    $('[data-placeholder]', info).focus(function()
                                    {
                                        var input = $(this);
                                        if (input.val() == input.attr('data-placeholder'))
                                        {
                                            input.val('');
                                            input.removeClass('placeholder');
                                        }
                                    }).blur(function()
                                    {
                                        var input = $(this);
                                        if (input.val() == '' || input.val() == input.attr('data-placeholder'))
                                        {
                                            input.addClass('placeholder');
                                            input.val(input.attr('data-placeholder'));
                                        }
                                    }).blur();
                                    $('[data-placeholder]', info).parents('form').submit(function()
                                    {
                                        $(this).find('[data-placeholder]', info).each(function()
                                        {
                                            var input = $(this);
                                            if (input.val() == input.attr('data-placeholder'))
                                            {
                                                input.val('');
                                            }
                                        })
                                    });

                                    $('[autofocus]', info).focus();
                                })
                                .fail(function ()
                                {
                                    $(info).html('There was an error.');
                                });                          
                      }
                }); 
                 
        });

    $('.button.manage_assoc')
        .click(function ()
        {
            $('<div></div>')
                .appendTo('body')
                .dialog({
                    autoOpen: true,
                    draggable: false,
                    resizable: false,
                    height: 360,
                    width: 550,
                    title: 'Manage an Associate Member School',
                    modal: true,
                    buttons: [
                        {
                            text : "Add",
                            'class' : "float_left",
                            icons : { primary : 'ui-icon-plus'},
                            click : function()
                                  {
                                      $('<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 ui-dialog-buttons')
                                                     .html('<br />Working...<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>');

                                      $(this).parent().find('form').submit();

                                      $(this).dialog("close");
                                      $(this).remove();                                   
                                   }
                        },                        
                        {
                            text : "Cancel",                            
                            'class' : "float_right",                            
                            icons : { primary : 'ui-icon-cancel'},
                            click : function()
                                    {
                                        $(this).dialog( "close");;
                                        $(this).remove();
                                    }
                        }
                     ],
                     open : function ()
                     {                   
                          $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '10pt');
                          $('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');

                          
                          $(this).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 info = $(this);

                          var jqxhr = $.ajax(
                                {
                                    type : 'GET',
                                    url : '/account/add-associate-member-school',
                                    dataType : 'html'
                                })
                                .done(function (data)
                                {
                                    $(info).html(data);
                                    $('.button').button();
                                })
                                .fail(function ()
                                {
                                    $(info).html('There was an error.');
                                });

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


    
    /*
     * Heat Index Unsubscribe Button
     */
    $('.heat_index_unsubscribe_button')        
        .css({'vertical-align' : 'middle', 'margin-right' : '2px'})
        .click(function (event)
        {
            event.preventDefault();

            var button_object = $(this);
            var subscription_id = $(button_object).attr('data-subscription');

            var row = button_object.parents('tr');
            row.addClass('ui-state-highlight');            

            $('<div></div>')
                .appendTo('body')               
                .dialog(
                {                   
                    resizable: false,
                    height: 200,
                    width: 250,
                    modal: true,                   
                    title: 'Are You Sure?',
                    open : function ()
                        {  
                            var dialog_object = $(this);                            

                            dialog_object.html('<div style="text-align: center; margin-top: 1em;">Are you sure you want to unsubscribe?</div>');

                            $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '8pt');
                            $('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');
                        },
                    buttons: [
                        {                            
                            text : "Yes",
                            'class' : "float_left",
                            icons : { primary : 'ui-icon-check'},
                            click : function()
                                  {                   
                                      var dialog_object = $(this);

                                      $('<div><div>')
                                          .attr('data-unsubscribing', 1)
                                          .addClass('ui-widget-overlay ui-front')
                                          .appendTo('body');
                                        
                                      $('<div><div>').appendTo('body')
                                          .attr('data-unsubscribing', 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 />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 you are unsubscribed from that area...</div>');

                                      var jqxhr = $.ajax({type : 'POST',
                                                          url : 'http://www.osaa.org/heat-index/unsubscribe',
                                                          data : {'subscription_id' : subscription_id},
                                                          dataType : 'html'})
                                                    .done(function ()
                                                    {
                                                        // Remove the subscription's row
                                                        row.remove();

                                                        // Table row highlighter
                                                        function colorRows ()
                                                        {       
                                                            $('table').each(function ()
                                                            {
                                                                var i = 0;

                                                                $('tbody tr', $(this)).each(function ()
                                                                {
                                                                    if (i % 2 == 1)
                                                                    {
                                                                        $(this).addClass('odd');
                                                                    }
                                                                    else
                                                                    {
                                                                        $(this).removeClass('odd');
                                                                    }
                                                                    i = i + 1;
                                                                });     
                                                            });
                                                        }   
                                                        colorRows();

                                                        $('[data-unsubscribing]').remove();

                                                        $(dialog_object).dialog("close");
                                                    })
                                                    .fail(function (jqXHR, status, error)
                                                    {                                                   
                                                        alert('There was an error processing your request to unsubscribe.');
                                                    })
                                                    .always(function ()
                                                    {                                                        
                                                        $(dialog_object).dialog("close");                                                        
                                                    });

                                      return true;
                                   }
                        },
                        {
                            text : "No",
                            'class' : "float_right",
                            icons : { primary : 'ui-icon-cancel'},
                            click : function()
                                    {
                                        $(this).dialog( "close" );                                         
                                    }
                        }
                    ],
                    close : function()
                        {
                            row.removeClass('ui-state-highlight');
                            $(this).remove();
                        }                    
                });
        });   
    

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

<?php $__env->startSection('page_functions'); ?>
   
    <div style="padding-top: 8px; font-weight: bold; font-size: 12pt; color: #1c43a6;">
        Hello, <?php echo $info['user_name']; ?>
    </div>

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


<?php $__env->startSection('main_content'); ?>    		
	
   <?php if (Session::has('success')): ?>
        <div class="success_bar">
            <div class="message">               
                <?php echo Session::get('success'); ?>
            </div>          
        </div>
    <?php endif; ?>	 
	

    <div class="tabs my_schools">
        <ul style="padding-left:5px;">
            
            <?php if ($info['user_access']->osaa): ?>
                <li><a href="#osaa-dashboard" data-tooltip="OSAA Staff Dashboard">OSAA Staff</a>
            <?php endif; ?>

            <?php if ($info['user_access']->bia): ?>
                <li><a href="#bia" data-tooltip="BIA Assessor Dashboard">BIA Assessor</a>
            <?php endif; ?>

            <?php if ($info['user_access']->commissioner): ?>
                <li><a href="#commissioner" data-tooltip="Commissioner's Dashboard">Commissioner of Officials</a>
            <?php endif; ?>

            <?php if ($info['user_access']->school): ?>
                <?php foreach ($info['school_objects'] as $school_object): ?>
                    <li>
                        <a href="#school-<?php echo $school_object->school->id; ?>" data-tooltip="<?php echo $school_object->school->name; ?> Dashboard"><?php echo $school_object->school->short_name; ?></a>
                    </li>
                <?php endforeach; ?>
            <?php endif; ?>

            
            <li data-tooltip="OSAA Heat Index Notifications">
                <a href="#heat-index" style="background-image:url('<?php echo asset('/images/icons/heat_index_24px.png'); ?>'); background-repeat:no-repeat; background-position:center;">&nbsp;</a>
            </li>

            <li data-tooltip="Add a School or New Role">
                <a href="#new-role" style="background-image:url('<?php echo asset('/images/icons/add_icon_24px.png'); ?>'); background-repeat:no-repeat; background-position:center;">&nbsp;</a>
            </li>

            <li data-tooltip="My Profile">
                <a href="#profile" style="background-image:url('<?php echo asset('/images/icons/settings_2_24px.png'); ?>'); background-repeat:no-repeat; background-position:center;">&nbsp;</a>
            </li>

        </ul>

        <?php /*  OSAA Dashboard  */ ?>
        <?php if ($info['user_access']->osaa): ?>
            <div id="osaa-dashboard">

                <?php echo $__env->make ('admin.osaa_dashboard_slice', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>


            </div>
        <?php endif; ?>
        <?php /*  End OSAA Dashboard  */ ?>


        <?php /*  BIA Assessor Dashboard  */ ?>
        <?php if ($info['user_access']->bia): ?>
            <div id="bia">
                
                <a id="new_bia_form_button" href="<?php echo url('/forms/bia/create'); ?>">New BIA Reconciliation</a>
                
                <h2>Wrestling BIA Assessor Dashboard</h2>

                <?php
                    $forms = biaform::where('assessor', '=', Auth::user()->getBiaAssessorId())
                                    ->where('school_year', '=', Session::get('year'))
                                    ->whereNull('deleted_at')
                                    ->get();
                ?>

                <h3 style="color: #990000;">BIA Assessment Reconciliation Reports</h3>
                <?php if (count($forms) > 0): ?>

                    <table class="bia_table">

                        <thead>
                            <tr>
                                <th>ID #</th>
                                <th>Status</th>
                                <th>Total - $</th>
                                <th>Created At</th>
                                <th>Received At</th>
                                <th>Paid At</th>
                                <th></th>
                            </tr>
                        </thead>

                        <tbody>

                            <?php foreach ($forms as $form): ?>

                                <tr data-record="<?php echo $form->id; ?>" data-status="<?php echo $form->status; ?>">
                                    <td><?php echo $form->id; ?></td>
                                    <td><?php echo $form->status; ?></td>
                                    <td>$<?php echo number_format($form->total_amount, 2); ?></td>
                                    <td><?php echo $form->created_at; ?></td>
                                    <td><?php echo $form->received_at; ?></td>
                                    <td><?php echo $form->paid_at; ?></td>
                                    <td style="text-align: right; padding-right: 5px;">
                                        <?php if (Helpers::strEqual($form->status, array('PEND', 'INSF', 'RECD', 'DONE'))): ?>
                                            <div class="bia_print"></div>
                                        <?php endif; ?>                                        
                                        <div class="bia_edit"></div>
                                        <div class="bia_delete"></div>
                                    </td>
                                </tr>

                            <?php endforeach; ?>

                        </tbody>

                    </table>                                       

                <?php else: ?>
                    You have no BIA Assessment Reconciliation Report forms on record to display.
                <?php endif; ?>

                <div style="font-size: 9pt; margin-top: 1em;">
                    <div class="columns">
                        <div class="half">
                            <span class="ui-icon ui-icon-info float_left" style="vertical-align: middle;"></span><b>Status Legend</b><br />
                            WORK - Work in progress, form is not yet submitted<br />
                            PEND - Pending, form was submitted, waiting for supplemental material(s)<br />
                            INSF - Form has been submitted, but there is missing information<br />
                            RECD - Form has been received<br />                            
                            DONE - Form has been processed and payment posted<br />
                        </div>

                        <div class="half">
                            <span class="ui-icon ui-icon-help float_left" style="vertical-align: middle;"></span><b>Help</b><br />
                            To create a new BIA Assessment Reconciliation Report form, click the "+ New BIA Reconciliation" button located in the upper-right.<br /><br />
                            Click the button with the printer icon to print the report form.  Click the button with the pencil icon to edit a report form.  Click the button with the trash icon to delete a report form.
                        </div>
                    </div>
                </div>

            </div>
        <?php endif; ?>
        <?php /*  End BIA Assessor Dashboard  */ ?>


        <?php /*  Commissioner's Dashboard  */ ?>
        <?php if ($info['user_access']->commissioner): ?>

            <div id="commissioner">                
                <a href="<?php echo url('/forms/ejection'); ?>" class="new_ejection_button" style="float: right;">New Ejection Report</a>

                <h2>OSAA Commissioner Dashboard</h2>                
                
                <?php
                    $oas = officialsassociation::whereIn('id', function($query)
                                                 {
                                                     $query->select('officials_association')
                                                           ->from('officials_associations_users')
                                                           ->where('user', '=', Auth::user()->id)
                                                           ->where('role', '=', 'Cmsh.')
                                                           ->where('is_retired', '=', 0);
                                                 })
                                               ->get();

                    $forms = ejection::whereIn('officials_association', $oas->lists('id'))
                                     ->whereNotIn('ejection_status', array('WTDN'))
                                     ->get();
                ?>

                <h3 style="color: #990000;">Officials Association</h3>
                <?php if (count($oas) == 1): ?>
                    Your account is currently linked to the following Officials Association as the Commissioner:<br />
                    <ul>
                        <li><?php echo $oas->first()->name; ?></li>
                    </ul>
                <?php elseif (count($oas) > 1): ?>
                    Your account is currently linked to the following Officials Associations as the Commissioner:<br />
                    <ul>
                        <?php foreach ($oas as $oa): ?>
                            <li><?php echo $oa->name; ?></li>
                        <?php endforeach; ?>
                    </ul>
                <?php else: ?>
                    Your account is not associated to any Officials Association as a Commissioner.<br />
                <?php endif; ?>

                <br />

                <h3 style="color: #990000;">Associated Ejection Reports</h3>

                <?php if (count($forms) > 0): ?>

                    <div style="max-height: 400px; overflow-x: hidden; overflow-y: auto;">
                    <table class="bia_table">

                        <thead>
                            <tr>
                                <th>ID #</th>
                                <th>Act.</th>
                                <th>Status</th>                                
                                <th>School</th>
                                <th>Contest Date</th>
                                <th>Updated At</th>                                
                            </tr>
                        </thead>

                        <tbody>

                            <?php foreach ($forms as $form): ?>

                                <?php
                                    $object = $form->getObject();
                                ?>

                                <tr>
                                    <td><a href="<?php echo url('/forms/ejection/' . $form->id); ?>" style="font-weight: bold;"><?php echo $form->id; ?></a></td>
                                    <td><?php echo !is_null($form->activity) ? $form->activity : '- '; ?></td>
                                    <td><?php echo $form->ejection_status; ?></td>                                    
                                    <td><?php echo (!is_null($object->host_school)) ? $object->host_school->short_name : '- -'; ?></td>
                                    <td><?php echo (!is_null($object->data->contest->date)) ? date('l n/j/y', strtotime($object->data->contest->date)) : '- -'; ?></td>                                    
                                    <td><?php echo date('l n/j/y g:ia', strtotime($form->updated_at)); ?></td>                                    
                                </tr>

                            <?php endforeach; ?>

                        </tbody>

                    </table>
                    </div>                                       

                <?php else: ?>
                    You have no ejection reports in the database.
                <?php endif; ?>

                <div style="font-size: 9pt; margin-top: 1em;">
                    <div class="columns">
                        <div class="half">
                            <span class="ui-icon ui-icon-info float_left" style="vertical-align: middle;"></span><b>Status Legend</b><br />
                            WORK - An official has created an ejection report and is still working on it<br />
                            CMSH - Report is waiting for your review; the school has not been notified<br />
                            SUBT - Report has been submitted to the school, the OSAA has been notified                            
                        </div>

                        <div class="half">
                            <span class="ui-icon ui-icon-help float_left" style="vertical-align: middle;"></span><b>Help</b><br />
                            To create a new online ejection report, click the <b>+ New Ejection Report</b> button located in the upper-right.<br /><br />
                            Click the ID number of a listed ejection report to view that online form and make any changes.
                        </div>
                    </div>
                </div>

                <br class="clear" />

            </div>

        <?php endif; ?>
        <?php /*  End Commissioner's Dashboard  */ ?>

        <?php /*  Schools Dashboards  */ ?>
        <?php if ($info['user_access']->school): ?>

            <?php /*  Process each school this user is associated with  */ ?>
            <?php foreach ($info['school_objects'] as $school_object): ?>
                <div id="school-<?php echo $school_object->school->id; ?>" class="school_tab">
                    
                    <a href="#" class="remove_school" data-school-id="<?php echo $school_object->school->id; ?>" data-school-name="<?php echo $school_object->school->name; ?>" data-tooltip="Remove This School From Your Account">Remove School</a>

                    <?php if (!is_null($school_object->demographic) and Auth::user()->canAccessSchoolTask($school_object->school->id, 'SCORE') and !$school_object->demographic->is_associate_member): ?>
                        <a href="<?php echo url('/account/missing-scores'); ?>" class="submit_scores" data-tooltip="Submit Missing Scores">Submit Missing Scores</a>
                    <?php endif; ?>

                    <h2><?php echo $school_object->school->name; ?></h2>
                    
                    <b>Your <?php echo (count($school_object->roles) > 1) ? 'roles' : 'role'; ?> with this school:</b> <?php echo Helpers::arrayToList($school_object->roles); ?>

                    <div class="vertical_tabs my_school">
                        <ul style="padding-left: 5px; font-size: 9pt; height: 502px; list-style-type: none !important;">
                            <li><a href="#info-<?php echo $school_object->school->id; ?>">My School</a></li>
                            <?php if (!is_null($school_object->demographic) and !$school_object->demographic->is_associate_member): ?>
                                <li><a href="#programs-<?php echo $school_object->school->id; ?>">Activity Programs</a></li>
                                <?php if ($school_object->is_admin): ?>
                                    <li><a href="#eligibilities-<?php echo $school_object->school->id; ?>">Eligibility Forms</a></li>                            
                                    <li><a href="#seasonal-<?php echo $school_object->school->id; ?>">Seasonal Forms</a></li>
                                    <li><a href="#all-state-<?php echo $school_object->school->id; ?>">Academic All-State</a></li>                            
                                    <li><a href="#ejections-<?php echo $school_object->school->id; ?>">Ejection Reports</a></li>
                                    <li><a href="#users-<?php echo $school_object->school->id; ?>">School Users</a></li>
                                <?php endif; ?>
                            <?php endif; ?>
                        </ul>

                        <!-- School Information -->
                        <div id="info-<?php echo $school_object->school->id; ?>">
                            <h2>School Information</h2>
                            
                            <div class="school_logo">
                                <b>School Logo</b><br />
                                <img src="<?php echo $school_object->school_logo; ?>" alt="" title="" class="tooltip" style="width: 128px; height: 128px;" /><br />
                                <div class="small note">
                                    Email logo changes to <a href="mailto: support@osaa.org">OSAA Support</a>.
                                </div>
                            </div>

                            <div class="label">School Name</div><?php echo $school_object->school->name; ?><br />
                            <div class="label">Short Name</div><?php echo $school_object->school->short_name; ?>

                            <div style="display: inline-block; margin-left: 150px;">
                                <div class="label">HyTEK Code</div>
                                <?php echo $school_object->school->hytek_code; ?>
                            </div>

                            <br /><br />

                            <div class="label">School District</div><?php echo (!is_null($school_object->school_district)) ? $school_object->school_district->name : '- -'; ?><br />

                            <?php /*  Full Members  */ ?>
                            <?php if (!is_null($school_object->demographic) and !$school_object->demographic->is_associate_member): ?>
                                <br />
                                <div class="label">Type</div><?php echo $school_object->school_type->name; ?><br />
                                <div class="label">Classification</div><?php echo $school_object->classification; ?><br />
                                
                                <div class="label">League</div><?php echo preg_replace('/\(.*\)/', '', $school_object->league->slug); ?> <?php echo $school_object->league->name; ?><br />

                            <?php /*  Associate Members  */ ?>
                            <?php else: ?>
                                <?php
                                    $assoc_adm_box_class = 'online_form_instructions';

                                    if (!is_null($school_object->demographic) and is_null($school_object->demographic->enrollment))
                                    {
                                        $assoc_adm_box_class .= ' ui-state-highlight';
                                    }
                                ?>

                                <div class="ui-corner-all <?php echo $assoc_adm_box_class; ?>" style="margin-top: 1em; width: 450px;">

                                    <div class="update_assoc_adm" data-school="<?php echo $school_object->school->id; ?>">Update</div>

                                    <b>Associate Member</b><br />
                                    <small>Student Enrollment:</small>
                                    <input type="text" id="associate_adm" name="associate_adm" data-school="<?php echo $school_object->school->id; ?>" style="width: 45px; font-size: 10pt;" value="<?php echo (!is_null($school_object->demographic)) ? $school_object->demographic->enrollment : null; ?>" />
                                    
                                    <div style="font-size: 8pt; margin-top: 0.5em;">
                                        Please enter in the number of students enrolled during the <?php echo Session::get('year'); ?>-<?php echo (intval(Session::get('year')) + 1); ?> school year.
                                    </div>

                                </div>
                            <?php endif; ?>

                            <br />                            

                            <div class="label">Mascot</div><?php echo $school_object->mascot->name; ?><br />

                            <br />

                            <div class="label">School Colors</div>
                            <div style="height: 26px; display: inline-block; margin: -0.25em 0 0.25em 0;">
                                <?php if (count($school_object->colors) > 0): ?>
                                    <?php foreach ($school_object->colors as $color): ?>
                                         <div style="float: left; margin-right: 5px; width: 24px; height: 24px; background-color: #<?php echo $color->hex; ?>; border: 1px solid #d9e1e0;" data-tooltip="<?php echo $color->name; ?>"></div>
                                    <?php endforeach; ?>
                                <?php else: ?>
                                    None
                                <?php endif; ?>
                            </div>

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

                            <a href="<?php echo url('/schools/' . $school_object->school->id); ?>" class="view_school_button">View School Page</a>

                            <?php if ($school_object->is_admin): ?>
                                <a href="<?php echo url('/schools/' . $school_object->school->id . '/edit'); ?>" class="edit_school_information_button">Edit School Information</a>

                                <a href="<?php echo url('/schools/' . $school_object->school->id); ?>" class="manage_staff_button">Manage Staff</a>

                                <a href="#" class="school_key_codes_button" data-school-id="<?php echo $school_object->school->id; ?>" data-school-name="<?php echo $school_object->school->name; ?>" data-admin-code="<?php echo $school_object->school->key_code; ?>" data-non-admin-code="<?php echo substr($school_object->school->key_code, 0, 4); ?>">School Key Codes</a>
                            <?php endif; ?>

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

                            <h4>Your User Account Roles at <?php echo $school_object->school->short_name; ?></h4>
                            <table class="bia_table" style="font-size: 9pt;">
                                <thead>
                                    <tr>
                                        <th>RID #</th>
                                        <th>Role</th>
                                        <th>Alternate Title</th>
                                        <th>Activity</th>
                                        <th>Created</th> 
                                        <th></th>                                       
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php foreach ($school_object->school_roles as $school_role): ?>
                                        <tr>
                                            <td><?php echo $school_role->id; ?></td>
                                            <td><?php echo $school_role->role->name; ?></td>
                                            <td><?php echo $school_role->alternate_title; ?></td>
                                            <td><?php echo Helpers::getActivityName($school_role->activity); ?></td>
                                            <td><?php echo date('n/j/Y g:ia', strtotime($school_role->created_at)); ?></td>
                                            <td style="text-align: right;">
                                                <a href="#"
                                                   class="remove_role"
                                                   data-record-id="<?php echo $school_role->id; ?>"
                                                   data-school-id="<?php echo $school_object->school->id; ?>"
                                                   data-school-name="<?php echo $school_object->school->name; ?>"
                                                   data-role-name="<?php echo $school_role->role->name; ?>"
                                                   data-role-activity="<?php echo (!Helpers::strIsEmpty($school_role->activity)) ? Helpers::getActivityName($school_role->activity) : null; ?>"><img src="<?php echo asset('images/icons/missing_16px.png'); ?>" alt="" title="" data-tooltip="Remove This Role" /></a>
                                            </td>
                                        </tr>
                                    <?php endforeach; ?>
                                </tbody>
                            </table> 
                        </div>
                        <!-- End School Information -->

                        <?php if (!is_null($school_object->demographic) and !$school_object->demographic->is_associate_member): ?>

                            <!-- Activity Programs -->
                            <div id="programs-<?php echo $school_object->school->id; ?>">
                                <a href="<?php echo url('governance/forms'); ?>" style="float: right; font-size: 8pt; margin-top: 1em;">&raquo; Add a new activity program</a>

                                <h2>Activity Programs for the <?php echo Session::get('year'); ?>-<?php echo (intval(substr(Session::get('year'), 2, 2)) + 1); ?> School Year</h2>
                                
                                <?php foreach (array('F' => 'Fall', 'W' => 'Winter', 'S' => 'Spring') as $season_slug => $season_name): ?>
                                    <h3><?php echo $season_name; ?></h3>

                                    <?php if (count($school_object->activity_program_items[$season_slug]) > 0): ?>

                                        <table class="bia_table" style="font-size: 9pt;">
                                            <thead>
                                                <tr>
                                                    <th style="width: 150px;">Activity</th>
                                                    <th style="width: 55px;">Abbr</th>
                                                    <th style="width: 230px;">League</th>
                                                    <th style="">Teams</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php foreach ($school_object->activity_program_items[$season_slug] as $item): ?>
                                                    <tr>
                                                        <td><?php echo $item->activity; ?></td>
                                                        <td><?php echo $item->activity_program->activity; ?></td>
                                                        <td style="line-height: 1.15em;">
                                                            <?php if (!is_null($item->league)): ?>
                                                                <?php echo preg_replace('/\(.*\)/', '', $item->league->slug); ?> <?php echo $item->league->name; ?>
                                                            <?php else: ?>
                                                                Independent
                                                            <?php endif; ?>
                                                        </td>
                                                        <td>
                                                            <?php if (count($item->teams) > 0): ?>
                                                            
                                                                <?php foreach ($item->teams as $team): ?>

                                                                    <?php if (Auth::user()->canAccessTeamTask($item->activity_program->id, 'SCHD', true) or
                                                                         Auth::user()->canAccessTeamTask($item->activity_program->id, 'ROST', true)): ?>

                                                                         <a href="<?php echo url('/teams/' . $team->id . '/edit'); ?>" class="edit_team_button"><?php echo $team->level; ?></a>

                                                                    <?php else: ?>

                                                                        <a href="<?php echo url('/teams/' . $team->id); ?>" class="view_team_button"><?php echo $team->level; ?></a>                                                

                                                                    <?php endif; ?>
                                                                <?php endforeach; ?>                                            
                                                                                                       
                                                            <?php endif; ?>                  
                                                            
                                                            <?php if (Auth::user()->canAccessTeamTask($item->activity_program->id, 'ADMIN', true) and
                                                                 count($item->teams) < 5 and
                                                                 Helpers::strEqual($item->activity_type, 'TS')): ?>
                                                                 <a href="<?php echo url('teams/add/' . $item->activity_program->id); ?>" class="add_team_button" data-tooltip="Add Another <?php echo $item->activity; ?> Team"></a>
                                                            <?php endif; ?>
                                                        </td>
                                                    </tr>
                                                <?php endforeach; ?>
                                            </tbody>
                                        </table>

                                    <?php else: ?>
                                        <?php if (intval(Session::get('year')) != intval(Helpers::getCurrentYear())): ?>
                                            <?php if (intval(Session::get('year')) > intval(Helpers::getCurrentYear())): ?>  
                                                There are no <?php echo strtolower($season_name); ?> activity program offerings for <?php echo $school_object->school->short_name; ?> at this time because <?php echo Session::get('year'); ?>-<?php echo substr(intval(Session::get('year')) + 1, 2, 2); ?> <?php echo strtolower($season_name); ?> special districts have not yet been approved by the OSAA Executive Board.
                                            <?php else: ?>
                                                There are no <?php echo strtolower($season_name); ?> activity program offerings for <?php echo $school_object->school->short_name; ?>.
                                            <?php endif; ?>
                                        <?php else: ?>
                                            There are no <?php echo strtolower($season_name); ?> activity program offerings for <?php echo $school_object->school->short_name; ?>.
                                        <?php endif; ?>
                                        
                                        <br />
                                    <?php endif; ?>

                                    <br class="clear" />

                                <?php endforeach; ?>
                            </div>     
                            <!-- End Activity Programs -->                   

                            <?php if ($school_object->is_admin): ?>
                                
                                <!-- Eligibility Forms -->
                                <div id="eligibilities-<?php echo $school_object->school->id; ?>">
                                    <a href="<?php echo url('/forms/eligibility'); ?>" class="eligibility_forms_button">Student Eligibility Forms</a>

                                    <h2>Eligibility Forms for <?php echo $school_object->school->short_name; ?></h2>
                                    
                                    <br />

                                    <table class="bia_table" style="font-size: 9pt;">
                                        <thead>
                                            <tr>
                                                <td>ID #</td>
                                                <th>Student</th>
                                                <th>Year</th>
                                                <th>Waiver Type</th>
                                                <th>Status</th>
                                                <th></th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php if (count($school_object->eligibilities) > 0): ?>
                                                <?php foreach ($school_object->eligibilities as $waiver): ?>
                                                    <tr>
                                                        <td><?php echo $waiver->id; ?></td>
                                                        <td><?php echo $waiver->student; ?></td>
                                                        <td><?php echo $waiver->year; ?></td>
                                                        <td><?php echo $waiver->type; ?></td>
                                                        <td><?php echo $waiver->status; ?></td>
                                                        <td><a href="<?php echo url('/forms/eligibility/' . $waiver->id); ?>" target="_blank">View</a></td>
                                                    </tr>
                                                <?php endforeach; ?>
                                            <?php else: ?>
                                                <tr>
                                                    <td colspan="6">There are no student eligibility waivers to display.</td>
                                                </tr>
                                            <?php endif; ?>
                                        </tbody>
                                    </table>                                    
                                </div>
                                <!-- End Eligibility Forms -->

                                <!-- Seasonal Forms -->
                                <div id="seasonal-<?php echo $school_object->school->id; ?>">
                                    <h2>Required Seasonal Forms</h2>

                                    <div style="float: left; margin-right: 80px;">

                                        <?php foreach (array('F' => 'Fall', 'W' => 'Winter', 'S' => 'Spring') as $season_slug => $season_name): ?>
                                            <h3><?php echo $season_name; ?></h3>
                                            <?php if (!is_null($school_object->seasonal_forms[$season_slug])): ?>
                                                
                                                <div class="form_link ui-corner-all <?php echo $school_object->seasonal_forms[$season_slug]->status; ?>" data-link="<?php echo $school_object->seasonal_forms[$season_slug]->link; ?>">
                                                    <?php if (!is_null($school_object->seasonal_forms[$season_slug]->img)): ?>
                                                        <div class="icon"><img src="<?php echo asset('/images/icons/' . $school_object->seasonal_forms[$season_slug]->img); ?>" alt="" title="" /></div>
                                                    <?php endif; ?>
                                                    <div class="name"><?php echo $school_object->seasonal_forms[$season_slug]->name; ?></div>
                                                    <div class="date"><?php echo $school_object->seasonal_forms[$season_slug]->date_info; ?></div>
                                                </div>
                                                
                                            <?php else: ?>
                                                This form does not exist.
                                            <?php endif; ?>

                                            <br class="clear" />
                                        <?php endforeach; ?>                                    
                                    </div>

                                    <div style="float: left; width: 385px;">
                                        <br /><b>What Are These Forms?</b><br />
                                        Every season, each full member school is required to submit a <i>Seasonal Participation and Preselection</i> form.

                                        <br /><br />

                                        These new Seasonal forms replace the old Participation and Preselection forms. On these form, you will need to provide the number of students that represented your school for each of the sports and/or activities offered during that season (fall, winter, or spring). You must also indicate which sports or activities your school will be offering in the next school year.  
                                    </div>
                                </div>
                                <!-- End Seasonal Forms -->

                                <!-- Academic All-State Forms -->
                                <div id="all-state-<?php echo $school_object->school->id; ?>">
                                    <h2>Optional Academic All-State Nomination Forms</h2>

                                    <div style="float: left; margin-right: 80px;">

                                        <?php foreach (array('F' => 'Fall', 'W' => 'Winter', 'S' => 'Spring') as $season_slug => $season_name): ?>
                                            <h3><?php echo $season_name; ?></h3>
                                            <?php if (count($school_object->all_state_forms[$season_slug]) > 0): ?>
                                                
                                                <?php foreach ($school_object->all_state_forms[$season_slug] as $item): ?>
                                                    <div class="form_link ui-corner-all <?php echo $item->status; ?>" data-link="<?php echo $item->link; ?>">
                                                        <?php if (!is_null($item->img)): ?>
                                                            <div class="icon"><img src="<?php echo asset('/images/icons/' . $item->img); ?>" alt="" title="" /></div>
                                                        <?php endif; ?>
                                                        <div class="name"><?php echo $item->name; ?></div>
                                                        <div class="date"><?php echo $item->date_info; ?></div>
                                                    </div>
                                                <?php endforeach; ?>
                                                
                                                <a href="http://www.osaa.org/reports/all-state-by-school/<?php echo strtolower($season_slug); ?>/<?php echo $school_object->school->short_name; ?>" target="_blank" style="font-size: 8pt;">&raquo; Download <?php echo $season_name; ?> Entries</a><br />
                                            <?php else: ?>
                                                No forms to display for this season.
                                            <?php endif; ?>

                                            <br class="clear" />
                                        <?php endforeach; ?>                                    
                                    </div>

                                    <div style="float: left; width: 385px;">
                                        <img src="<?php echo asset('/images/icons/all_state_128px.png'); ?>" alt="" title="" style="margin-left: 128px;" />

                                        <br /><br />

                                        <b>What Are These Forms?</b><br />
                                        Every season, each full member school has the option to submit an <i>OSAA Academic All-State Nomination Form</i> for each hosted activity.

                                        <br /><br />

                                        On these forms, you will list the entire varsity team only. You do not include sub-varsity participants.  Do not combine boys and girl teams, each activity has a separate form.

                                        <br /><br />

                                        Use the most recent unweighted semester/trimester grades included on each student's transcript. Do not use cumulative GPA.  Be sure to include all co-op students and their GPA from his/her cooperating school.

                                        <br /><br />

                                        If a student's grades were not earned at your high school or cooperating high school during the previous semester/trimester, please list his/her name and leave the GPA field blank. (For example: first term freshman, home school students, new exchange students, new transfer students.)

                                        <br /><br />

                                        There must be a minimum of 5 students with a GPA entry in order to submit a form.

                                        <br /><br />

                                        
                                    </div>
                                </div>
                                <!-- Academic All-State Forms -->

                                <!-- Ejections -->
                                <div id="ejections-<?php echo $school_object->school->id; ?>">
                                    <h2>Ejection Reports for <?php echo $school_object->school->short_name; ?></h2>
                                    
                                    <br />

                                    <table class="bia_table" style="font-size: 9pt;">
                                        <thead>
                                            <tr>
                                                <td>ID #</td>
                                                <th>Status</th>
                                                <th>Activity</th>                                                
                                                <th>Name</th>
                                                <th>Type</th>
                                                <th></th>                                            
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php if (count($school_object->ejections) > 0): ?>
                                                <?php foreach ($school_object->ejections as $ejection): ?>
                                                    <tr>
                                                        <td><?php echo $ejection->id; ?></td>
                                                        <td><?php echo $ejection->status; ?></td>
                                                        <td><?php echo $ejection->activity; ?> - <?php echo $ejection->level; ?></td>
                                                        <td>
                                                            <?php echo $ejection->type; ?>
                                                            <?php echo $ejection->ejected->name; ?> 
                                                            <?php if (Helpers::strEqual($ejection->type, 'PLAYER')): ?>
                                                                (#<?php echo $ejection->ejected->jersey; ?>)
                                                            <?php endif; ?>
                                                        </td>
                                                        <td><?php echo $ejection->reason; ?></td>
                                                        <td><a href="<?php echo url('/forms/ejection/' . $ejection->id); ?>?view=<?php echo $ejection->access_code; ?>" target="_blank">View</a></td>
                                                    </tr>
                                                <?php endforeach; ?>
                                            <?php else: ?>
                                                <tr>
                                                    <td colspan="6">There are no ejection reports to display.</td>
                                                </tr>
                                            <?php endif; ?>
                                        </tbody>
                                    </table>                                    
                                </div>
                                <!-- End Ejections -->

                                <!-- School Users -->
                                <div id="users-<?php echo $school_object->school->id; ?>">
                                    <h2>School Users</h2>
                                    
                                    <br />                                    

                                    Below is a list of OSAA Website user accounts that have coach or administrative access to <?php echo $school_object->school->short_name; ?>.  This table does not represent your school's staff or contacts.  This list shows which user accounts have access to certain forms and features on behalf of your school.

                                    <br /><br />

                                    <table class="bia_table" style="font-size: 9pt;">
                                        <thead>
                                            <tr>
                                                <th>User Name</th>
                                                <th>E-Mail / Login</th>
                                                <th>Role</th>                                                
                                                <th>Access</th>
                                                <th></th>                                            
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php if (count($school_object->school_users) > 0): ?>
                                                <?php foreach ($school_object->school_users as $school_user): ?>
                                                    <?php foreach ($school_user->roles as $role): ?>
                                                        <tr>
                                                            <td><?php echo $school_user->last_name; ?>, <?php echo $school_user->first_name; ?></td>
                                                            <td><?php echo $school_user->email; ?></td>
                                                            <td>
                                                                <?php if (!Helpers::strIsEmpty($role->alternate_title)): ?>
                                                                    <?php echo $role->alternate_title; ?>
                                                                <?php else: ?>
                                                                    <?php echo $info['school_roles'][$role->role]->name; ?>
                                                                    <?php if (!Helpers::strIsEmpty($role->activity)): ?>
                                                                        - <?php echo Helpers::getActivityName($role->activity); ?>
                                                                    <?php endif; ?>                                                                
                                                                <?php endif; ?>
                                                            </td>                                                            
                                                            <td><?php echo str_replace(',', ', ', $info['school_roles'][$role->role]->permissions_list); ?></td>
                                                            <td style="text-align: right;">                                                                
                                                                <a href="#"
                                                                   class="remove_school_user"
                                                                   data-record-id="<?php echo $role->id; ?>"
                                                                   data-school-id="<?php echo $school_object->school->id; ?>"
                                                                   data-school-name="<?php echo $school_object->school->name; ?>"
                                                                   data-user-id="<?php echo $role->user; ?>"
                                                                   data-user-name="<?php echo $school_user->first_name; ?> <?php echo $school_user->last_name; ?>"
                                                                   data-role-name="<?php echo $info['school_roles'][$role->role]->name; ?><?php if (!Helpers::strIsEmpty($role->activity)): ?> - <?php echo Helpers::getActivityName($role->activity); ?><?php endif; ?>"><img src="<?php echo asset('images/icons/missing_16px.png'); ?>" alt="" title="" data-tooltip="Remove This Role" /></a>
                                                            </td>                                                            
                                                        </tr>
                                                    <?php endforeach; ?>
                                                <?php endforeach; ?>
                                            <?php else: ?>
                                                <tr>
                                                    <td colspan="5">There are no school users to display.  This should not have happened.</td>
                                                </tr>
                                            <?php endif; ?>
                                        </tbody>
                                    </table> 

                                    <br />

                                    <div class="small">
                                        <b>Access Legend</b><br />
                                        ADMIN - Administrative Access (online forms, ejections, eligibilities, all schedules, all scores, all rosters)<br />
                                        SCHD - Schedule Access (can add/edit/delete contests on schedules for linked activity teams)<br />
                                        ROST - Roster Access (can add/edit/delete rosters and photos for linked activity teams)<br />
                                        SCORE - Score Access (can submit/edit contest scores for linked activity teams)<br />
                                    </div>
                                </div>
                                <!-- End School Users -->
                            <?php endif; ?>
                        <?php endif; ?>

                    </div>

                </div>
                
            <?php endforeach; ?>
            <?php /*  End processing schools  */ ?>

        <?php endif; ?>
        <?php /*  End School Dashboards  */ ?>


        <?php /*  Heat Index  */ ?>
        <div id="heat-index">
            
            <a href="<?php echo url('/heat-index'); ?>" class="heat_index_calcualtor">Heat Index Calculator</a>

            <h1>OSAA Heat Index Notifications</h1>
            
            <h2>Subscriptions</h2>

            <?php if (count($info['heat_index_subscriptions']) > 0): ?>

                <p>
                    Your user account is currently subscribed to receive OSAA Heat Index Notifications for the following areas.  To unsubscribe from an area and stop receiving alters, click the red X icon for the respective row.
                </p>

                <table class="bia_table">
                    <thead>
                        <tr>
                            <th style="padding-left: 2px;">Location Name</th>                            
                            <th>Email</th>
                            <th>SMS</th>
                            <th>Subscribed</th>
                            <th></th>
                        </tr>
                    </thead>

                    <tbody>                        
                        <?php foreach ($info['heat_index_subscriptions'] as $subscription): ?>
                            <tr style="line-height: 2em;">
                                <td><a href="<?php echo url('/heat-index?place=' . urlencode($subscription->area_model->name)); ?>"><?php echo $subscription->area_model->name; ?></a></td>
                                <td><?php echo ($subscription->is_notify_email) ? 'Yes' : 'No'; ?></td>
                                <td><?php echo ($subscription->is_notify_sms) ? 'Yes' : 'No'; ?></td>
                                <td><?php echo date('n/j/y g:i a', strtotime($subscription->created_at)); ?></td>
                                <td style="text-align: right;"><a href="#"
                                       class="heat_index_unsubscribe_button"
                                       data-tooltip="Unsubscribe"
                                       data-subscription="<?php echo $subscription->id; ?>"><img src="<?php echo asset('images/icons/missing_16px.png'); ?>" alt="" title="" style="vertical-align: middle;" /></a></td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>

                <br />

            <?php else: ?>

                <p>
                    Your user account is not currently subscribed to receive any OSAA Heat Index Notifications.
                </p>

            <?php endif; ?>

            <br class="clear" />
        </div>
        <?php /*  End Heat Index  */ ?>


        <?php /*  Add School/Role  */ ?>
        <div id="new-role">
            <h1>Add a School or New Role</h1>
            <p>                
                <?php if (count ($info['school_objects']) > 0): ?>
                    To add yourself to another school, 
                <?php else: ?>
                    To add yourself to a school,
                <?php endif; ?>
                please fill in all of the following items.  You can also use this form to add yourself to the same school but in a different role.               
            </p>

            <div class="columns">

                <div class="half">
                    <h2>Add School/Role</h2>
                    
                    <?php echo Form::open(array('url' => url('/account/add-school'), 'class' => 'login')); ?>

                    <?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::label('school', 'School', array('class' => 'input_label')); ?>
                    <?php

                        $sel_school_ids = DB::table('school_demographics')
                                            ->select(array('school'))
                                            ->where('is_associate_member', '=', 0)
                                            ->where('school_year', '=', Session::get('year'))
                                            ->where('is_retired', '=', 0)
                                            ->lists('school');

                        $sel_schools = school::whereIn('id', $sel_school_ids)
                                             ->whereNotNull('key_code')
                                             ->orderBy('name')
                                             ->get();

                        $select = array();

                        foreach ($sel_schools as $school)
                        {
                            $select[$school->id] = $school->name;
                        }

                        unset ($sel_schools);

                    ?>
                    <?php echo Form::select('school', $select, isset ($schools[0]) ? $schools[0]->id : null, array('style' => 'width:275px;')); ?>

                    <br /><br />

                    <?php echo Form::label('role', 'Role', array('class' => 'input_label')); ?>
                    <?php

                        $sel_roles = role::where('entity_type', '=', 'S')->orderBy('name')->get();

                        $select = array();

                        foreach ($sel_roles as $role)
                        {
                            $select[$role->slug] = $role->name;                            
                        }

                        unset ($sel_roles);

                    ?>
                    <?php echo Form::select('role', $select, null, array('style' => 'width:275px;')); ?>


                    <br /><br />

                    <?php echo Form::label('activity', 'Activity', array('class' => 'input_label')); ?>
                    <?php

                        $sel_activities = activity::orderBy('id')->get();

                        $select = array();

                        foreach ($sel_activities as $activity)
                        {
                            $select[$activity->slug] = $activity->name;
                        }

                        unset ($sel_activities);

                    ?>
                    <?php echo Form::select('activity', $select, null, array('disabled', 'style' => 'width:275px;')); ?>


                    <br /><br />

                    <?php echo Form::label('key', 'Key Code', array('class' => 'input_label')); ?>
                    <?php echo Form::password('key', array('style' => 'width:125px;')); ?>

                    <br /><br />
                   
                    <?php echo Form::submit('Add', array('class' => 'submit', 'style' => 'margin-left:377px;')); ?>


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

                    <br />                    
                    <div class="horizontal_divider" style="margin-right: auto; margin-left: auto;"></div>
                    <br />

                    <h2>Associate Members</h2>
                    <div class="button manage_assoc" style="font-size: 8pt;">Manage an Associate Member School</div>
                    <p style="font-size: 9pt; margin-top: 0.5em;">
                        Click this button to use your school ID and key code to link your account to an Associate Member school.
                    </p>

                    <br />                    
                    <div class="horizontal_divider" style="margin-right: auto; margin-left: auto;"></div>
                    <br />

                    <h2>Wrestling BIA Assessors</h2>
                    <?php if (!Auth::user()->isBiaUser()): ?>                    
                        <div class="button setup_bia_account" style="font-size: 8pt;">Setup BIA Assessor Account</div>
                        <p style="font-size: 9pt; margin-top: 0.5em;">
                            Click this button to setup your OSAA user account as a wrestling BIA Assessor.
                        </p>
                    <?php else: ?>
                        <p style="font-size: 9pt; margin-top: 0.5em;">
                            Your account is already setup as an BIA Assessor Account.  No further action is required.
                        </p>
                    <?php endif; ?>

                </div>

                <div class="half">
                    <h3>Here's what you'll need:</h3>
                    <ul>
                        <li><b>School</b><br /><span class="small gray note">Select a school from the drop-down list.</span></li>
                        
                        <li><b>Role/Activity</b><br /><span class="small gray note">What will you be doing with this school?  Are you an Athletic Director?  Are you a soccer coach?  Pick the best role/activity combination that applies to you for this school. Some roles are not tied to a specific activity.</span></li>

                        <li><b>School Key Code</b><br /><span class="small gray note">This code is required to help ensure submissions are authentic. Each school has two key codes: administrator and coach.  Some roles, like AD or Principal, require you to enter the administrator key code.  Other roles just need the non-administrative, or coach, key code in order to gain access.</span></li>
                    </ul>

                    <h3>How do I get my school's key code?</h3>
                    <p>
                        Your school administrator can provide you with your school's key code if you don't know it.  Key codes were given to each school during the fall administrator workshops.  Administrators can also view their school's key codes from the "My Account" page by clicking the key icon.
                    </p>

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

                    <h3>You'll need a BIA key code</h3>
                    <p>
                        Anyone can create an OSAA user account, but only certain people are authorized to setup a BIA Assessor account.  In order to complete this process, you'll need a special BIA key code in order to setup your account as a BIA Assessor.
                    </p>

                </div>                   


            </div>

            <br class="clear" />
        </div>
        <?php /*  End Add School/Role  */ ?>


        <?php /*  My Profile Tab  */ ?>
        <div id="profile">
            <h1>My Profile Information</h1>

            <h2>User Information</h2>

            <img src="<?php echo asset('/images/icons/contact_card_2_96px.png'); ?>" alt="" title="" style="float: left; margin: 0 40px 0.5em 0; padding: 0 4px; border: 1px solid #cccccc;" />

            <div class="columns">
                <div class="third">
                    <div class="label">First Name:</div><?php echo (!Helpers::strIsEmpty(Auth::user()->first_name)) ? Auth::user()->first_name : '- -'; ?><br />
                    <div class="label">Middle Name:</div><?php echo (!Helpers::strIsEmpty(Auth::user()->middle_name)) ? Auth::user()->middle_name : '- -'; ?><br />
                    <div class="label">Last Name:</div><?php echo (!Helpers::strIsEmpty(Auth::user()->last_name)) ? Auth::user()->last_name : '- -'; ?><br />

                    <br /><br />

                    <div class="label" style="width: auto; margin-right: 10px;">Account Created:</div><?php echo date('n/j/Y', strtotime(Auth::user()->created_at)); ?>

                </div>

                <div class="half">
                    <div class="label">Nick Name:</div><?php echo (!Helpers::strIsEmpty(Auth::user()->nick_name)) ? Auth::user()->nick_name : '- -'; ?><br />

                    <br />

                    <div class="label">E-Mail:</div><?php echo Auth::user()->email; ?><br /><br />

                    <br />

                    <div class="label">User ID:</div><?php echo Auth::user()->id; ?>


                </div>
            </div>

            <br class="clear" /><br />            
            
            <a href="<?php echo url('/account/reset-password?change-password=true'); ?>" class="change_password_button" style="font-size: 9pt;" data-tooltip="Change Your Account Password">Change Password</a>

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

            <p class="gray note">
                For changes to other account information, like your name or e-mail address, contact <a href="mailto: support@osaa.org">OSAA Support</a>.
            </p>

            <br class="clear" />

            <h2>User Preferences</h2>
            <?php echo Form::label('preferred_landing_sub_tab', 'Preferred School Landing Tab', array('style' => 'width: auto; margin-right: 15px;')); ?>
            <?php echo Form::select('preferred_landing_sub_tab',
                            $info['tab_options'],
                            $info['preferred_landing_sub_tab'],
                            array('data-autosave' => true,
                                  'data-original' => $info['preferred_landing_sub_tab'],
                                  'data-field'    => 'preferred_landing_sub_tab',
                                  'data-type'     => 'INT',
                                  'data-reload'   => true)); ?>    
            <br />
            <span class="small gray note">Use this setting to change which sub-tab is viewed when you load your My Account page.  The default option is the "My School" sub-tab.

        </div>
        <?php /*  End My Profile Tab  */ ?>

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