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

    <script src="<?php echo asset('/scripts/jquery.maskedinput.min.js'); ?>" type="text/javascript"></script>
    
    <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;
        }

        .odd2 {
            background-color: #efefef;
        }

        .unsubmitted {
            background-color: #ffefb0;
        }

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

        /* Help Dialog */
        .help_dialog {
            font-size: 10pt;
        }

        .help_dialog h1 {
            font-size: 14pt;
            color: #005fa9 !important;
            margin: 1em 0 1em 0;
        }

        .help_dialog h2 {
            font-size: 12pt;
            color: #1C43A6 !important;
            margin: 1em 0 0.5em 0;
        }

        .help_dialog h3 {
            font-size: 10pt;
            color: #000000 !important;
            margin: 0.75em 0 0em 0;
        }

        .help_dialog ul, ol {
            margin-left: 28px;
        }

        .help_dialog dl dt {
            float: left;
            width: 200px;
            text-align: right;
            margin-right: 20px;
            font-weight: bold;
            clear: both;
        }

        .step-wise-form-data {
            font-family: monospace;
            font-size: 8pt;
        }

        .step-wise-form-data .data-point {
            width: 150px;
            float: left;
        }

        .step-wise-results {
            font-family: monospace;
            font-size: 8pt;
            background-color: #ffffff;
            color: #222222;
            width: 100%;
            height: 32em;
            border: 1px solid #999999;
            overflow-x: hidden;
            overflow-y: scroll;
            margin-top: 1em;
        }

        .step-wise-status {
            position: absolute;
            top: 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[data-activity-program-id]', $(this)).each(function ()
            {
                if (i % 2 == 1)
                {
                    $(this).addClass('odd');
                }
                else
                {
                    $(this).removeClass('odd');
                }
                i = i + 1;
            });     


            $('tbody tr[data-activity-program-id]', $(this)).each(function ()
            {
                if (i % 2 == 1)
                {
                    $(this).addClass('odd');
                    $(this).next().addClass('odd');
                }
                else
                {
                    $(this).removeClass('odd');
                    $(this).next().removeClass('odd');
                }
                i = i + 1;
            });

            var i = 0;

            $('tbody tr[data-color-rows]', $(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});
    });       
    
    $('a.disabled, a[disabled]').on('click', function(event)
    {
        event.preventDefault();
    });

    /* 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");

    <?php if (!Helpers::strIsEmpty($info['jump_to_sub_tab'])): ?>

        var sub_tab_id = "<?php echo $info['jump_to_sub_tab']; ?>";
        var sub_tabs = $('a[href="#' + sub_tab_id + '"]').parents('.vertical_tabs');
        var sub_tab_index = $('a[href="#' + sub_tab_id + '"]').attr('data-sub-tab-index');
        sub_tabs.tabs({active:sub_tab_index});

    <?php endif; ?>

    /* 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', 'Dist. Admin', 'Media'];

        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();

        $('.osaa_jump_button[data-font-size]').each(function(index, item)
        {
            $(item).css({'font-size' : $(item).attr('data-font-size')});
        });            

        $('.osaa_jump_button[data-disabled]')
            .button('disable');

        $('a[data-submit]').click(function(event)
        {
            event.preventDefault();

            var button = $(this);
            var form = button.parents('form')[0];
            var action = $(form).attr('action');            
            var new_action = action;

            if (button.has('[data-form-url]'))
            {                
                new_action = button.attr('data-form-url');                
            }

            if (new_action != action)
            {
                $(form).attr('action', new_action);
            }

            form.submit();

            if (new_action != action)
            {
                $(form).attr('action', action);
            }
        });

        $('a[data-reset]').click(function(event)
        {
            event.preventDefault();

            var button = $(this);
            var form = button.parents('form')[0];

            form.reset();
        });

        /*
         * 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' : ''});
                    });
                });
            }
        }

        $('a.rankings_functions').click(function(event)
        {
            event.preventDefault();

            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    draggable : true,
                    resizable : false,
                    modal : true,
                    height : 500,
                    width : 800,                    
                    title : 'Calculate Rankings',                    
                    open : function ()
                        {  
                            var dialog_object = $(this);

                            $(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 jqxhr = $.ajax(
                                {
                                    type : 'GET',
                                    url : '<?php echo url('/admin/rankings/tools'); ?>',
                                    dataType : 'html'
                                })
                                .done(function (data)
                                {
                                    $(dialog_object).html(data);
                                })
                                .fail(function (jqXHR, status, error)
                                {                                                   
                                    var response = jqXHR.responseText;
                                    var errorData = $.parseJSON(response);
                                    console.log(errorData);
                                    $(dialog_object).html(errorData.error.message);
                                });              
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);
                            $(dialog_object).remove();
                        }
                });

        });

        $('a[data-step-wise]').click(function(event)
        {
            event.preventDefault();

            var button = $(this);
            var form = $(button.parents('form')[0]);

            var step = 0;
            var abort = false;
            var executing = false;

            var form_data = {
                year : parseInt($('select[name="year"] option:selected', form).val()),
                season : $('select[name="season"] option:selected', form).val(),
                activity : $('select[name="activity"] option:selected', form).val(),
                division : $('select[name="division"] option:selected', form).val(),
                rpi : $('input[name="rpi"]', form).val(),
                combo : $('input[name="combo"]', form).val(),
                tie : $('input[name="tie"]', form).val(),
                variant : $('select[name="variant"] option:selected', form).val(),
                'no-truncate' : $('input[name="no-truncate"]', form).is(':checked'),
                debug : true,
                limit : parseInt($('input[name="limit"]', form).val()),
                'step-wise' : step
            };

            function runStep(run_step)
            {
                console.log('Step = ' + run_step);
                form_data['step-wise'] = run_step;

                var dialog_object = $('.step-wise-dialog');

                var jqxhr = $.ajax(
                    {
                        type : form.attr('method'),
                        url : form.attr('action'),                        
                        dataType : 'text',
                        data : form_data
                    })
                    .done(function (data)
                    {
                        var json_data = $.parseJSON(data);

                        var next_step = parseInt(json_data.next_step);
                        var line = json_data.line;
                        
                        console.log(json_data);

                        step = next_step;
                        $('[name="data-step"]', dialog_object).html(step);

                        $('.step-wise-results', dialog_object).append(line + '<br />');

                        // Scroll to the next line
                        var box = $('.step-wise-results', dialog_object)[0];                                     
                        box.scrollTop = box.scrollHeight - box.clientHeight;

                        // Check to see if we are finishing
                        if (next_step < 1)
                        {
                            $('.step-wise-status').html('Finished processing <img src="<?php echo asset('/images/icons/assignment_confirmed_16px.png'); ?>" alt="" title="" style="height: 1em; vertical-align: middle;" />');
                            executing = false;                            
                            return;
                        }
                        else
                        {                            
                            if (abort)
                            {
                                $('.step-wise-status').html('Execution was stopped <img src="<?php echo asset('/images/icons/missing_16px.png'); ?>" alt="" title="" style="height: 1em; vertical-align: middle;" />');                                
                                return;
                            }
                            return runStep(step);
                        }
                    })
                    .fail(function (jqXHR, status, error)
                    {                                                   
                        var response = jqXHR.responseText;
                        var errorData = $.parseJSON(response);                        

                        $('.step-wise-results', dialog_object).append(errorData.error.message + '<br />');

                        // Scroll to the next line
                        var box = $('.step-wise-results', dialog_object)[0];                                     
                        box.scrollTop = box.scrollHeight - box.clientHeight;

                        abort = true;
                        executing = false;
                        return;
                    });
            }

            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    draggable : true,
                    resizable : false,
                    modal : true,
                    height : 550,
                    width : 800,
                    dialogClass : 'step-wise-dialog',
                    title : 'Step-Wise Rankings Simulation',                    
                    buttons: [                                
                        {
                            text : "Execute",
                            'class' : "float_right",
                            'data-autofocus' : "true",
                            icons : { primary : 'ui-icon-play'},
                            click : function()
                            {
                                $('.step-wise-status').html('Executing simulation <img src="<?php echo asset('/images/icons/ajax_loader2.gif'); ?>" alt="" title="" style="height: 1em; vertical-align: middle;" />');
                                abort = false;
                                executing = true;
                                runStep(step);
                            }
                        },
                        {
                            text : "Stop",
                            'class' : "float_right",                            
                            icons : { primary : 'ui-icon-stop'},
                            'style' : 'margin-right: 20px;',
                            click : function()
                            {
                                if (!executing)
                                {
                                    return;
                                }

                                $('.step-wise-status').html('Aborting execution <img src="<?php echo asset('/images/icons/ajax_loader2.gif'); ?>" alt="" title="" style="height: 1em; vertical-align: middle;" />');
                                abort = true;
                                return;
                            }
                        },
                        {
                            text : "Clear",
                            'class' : "float_right",                            
                            icons : { primary : 'ui-icon-cancel'},
                            'style' : 'margin-right: 20px;',
                            click : function()
                            {
                                $('.step-wise-results', '.step-wise-dialog').html('');
                                return;
                            }
                        }
                    ],
                    open : function ()
                        {
                            var dialog_object = $(this);

                            var html = '<div class="step-wise-form-data">';
                            html += '<div class="data-point">Year: <b>' + form_data.year + '</b></div>';
                            html += '<div class="data-point">Season: <b>' + form_data.season + '</b></div>';
                            html += '<div class="data-point">Sport: <b>' + form_data.activity + '</b></div>';
                            html += '<div class="data-point">Division: <b>' + form_data.division + '</b></div>';                            
                            html += '<br class="clear" />';
                            html += '<div class="data-point">RPI Weights: <b>' + form_data.rpi + '</b></div>';                            
                            html += '<div class="data-point">RPI:Colley: <b>' + form_data.combo + '</b></div>';
                            html += '<div class="data-point">Tie Breaker: <b>' + form_data.tie + '</b></div>';                            
                            html += '<div class="data-point" style="width: 300px;">Variant: <b>' + form_data.variant + '</b></div>';                            
                            html += '<br class="clear" />';
                            html += '<div class="data-point">Do Not Truncate: <b>' + form_data['no-truncate'] + '</b></div>';
                            html += '<div class="data-point">Debug: <b>' + form_data.debug + '</b></div>';
                            html += '<div class="data-point">Limit: <b>' + form_data.limit + '</b></div>';
                            html += '<div class="data-point">Step-Wise: <b><span name="data-step">' + step + '</span></b></div>';
                            html += '</div>';
                            html += '<br class="clear" />';
                            html += '<div class="step-wise-results"></div>';

                            dialog_object.html(html);

                            $('.ui-dialog-buttonpane', dialog_object.parents('.ui-dialog')).css({'padding' : '0 0.5em', 'font-size' : '9pt', 'position' : 'relative'});
                            $('.ui-dialog-buttonpane .ui-dialog-buttonset', dialog_object.parents('.ui-dialog')).css({'width' : '100%'});
                            $('.ui-dialog-buttonpane', dialog_object.parents('.ui-dialog')).append('<div class="step-wise-status">Ready to execute step-wise simulation</div>');

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


    <?php endif; ?>

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

        /*
         * Upload photo preview
         */
        function readURL(input) {
            if (input.files && input.files[0])
            {
                var reader = new FileReader();

                reader.onload = function(e)
                {   
                    $('#news_author_photo')
                        .attr('src', e.target.result);
                };

                reader.readAsDataURL(input.files[0]);
            }
        }
        $("#news_author_photo_upload_field").change(function()
        {
            //$('[name="news_author_photo_preview_text"]').remove();
            $('[name="news_author_photo_preview_text"]').html('');

            readURL(this);
            
            $('[name="news_author_photo_preview_text"]').html('Here\'s a preview of your photo.  Be sure to save this image by clicking the <b>Upload Photo</b> button below.');
            $('[data-action="upload_news_author_photo"]').button('enable');        
        });

        /*
         * Upload photo button
         */
        $('[data-action="upload_news_author_photo"]')
            .css({'font-size' : '8pt'})
            .button()
            .on('click', function(event)
            {
                event.preventDefault();
                $('[data-action="delete_news_author_photo"]').button('enable');

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

                var form = $('#edit-news-author');

                form.submit();

            });
        $('[data-action="upload_news_author_photo"]').button('disable');

        /*
         * Delete photo button     
         */
        $('[data-action="delete_news_author_photo"]')
            .css({'font-size' : '8pt', 'margin-left' : '25px'})
            .button()
            .on('click', function(event)
            {
                event.preventDefault();

                var button = $(this);            
                button.blur();            
                                        
                $('<div></div>')
                    .appendTo('body')
                    .dialog(
                    {                       
                        modal : true,
                        draggable : true,
                        resizable : false,                    
                        height : 225,
                        width : 400,                    
                        title : 'Confirm Photo Deletion',
                        buttons: [
                            {
                                text : "Delete",
                                'class' : "float_left",
                                icons : { primary : 'ui-icon-check'},
                                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')
                                                .html('<br />Deleting...<br /><br /><img src="http://www.osaa.org/images/icons/ajax_loader3.gif" /><div style="font-size: 8pt; line-height: 105%; margin-top: 2em;">Please wait, this may take a while to process...</div>');

                                            var data = {
                                                author_id : <?php echo $info['author']->id; ?>
                                            };

                                            // Submit the change
                                            var jqxhr = $.ajax(
                                                {
                                                    type : 'POST',
                                                    url : '<?php echo url('/today/authors/' . $info['author']->id . '/delete-photo'); ?>',
                                                    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 file.\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 your photo?<br /><br /><div class="small gray">This cannot be undone.</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.removeClass('ui-state-highlight');

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

        <?php if (Helpers::strIsEmpty($info['author']->photo_path)): ?>
            $('[data-action="delete_news_author_photo"]').button('disable');        
        <?php endif; ?>


        $('#new_osaa_today_button')
            .css({'float' : 'right',
                  'margin-top' : '1em'})
            .button({ icons : { primary : 'ui-icon-plusthick'}})
            .on('click', function(event)
            {
                event.preventDefault();

                var button = $(this);
                var href = button.attr('href');

                $('<div></div>')
                    .appendTo('body')
                    .dialog(
                    {                       
                        draggable : true,
                        resizable : false,
                        modal : true,
                        height : 250,
                        width : 400,                    
                        title : 'Create a New Article',
                        buttons: [
                            {
                                text : "Create",
                                'class' : "float_left",
                                icons : { primary : 'ui-icon-check'},
                                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>');

                                            window.location = href;
                                        }
                            },
                            {
                                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 create a new OSAAtoday article?<br />');
                                
                                $('.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();
                            }                
                    });
            });

        /* saveNewsAuthorData
         *
         * Given a form field and a value, this function will do a
         * JSON POST request to save the form's information.  The optional
         * third parameter will determine if the page will be reloaded or not.
         */
        function saveNewsAuthorData(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 form data.');
            }

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

            // Get the form ID (same across all pages for this form)
            var author_id = <?php echo $info['author']->id; ?>;

            //console.log("Attempting to save {'" + author_id + "|" + field + "' : '" + value + "'}");

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

            var jqxhr = $.ajax(
            {
                type : 'POST',                      
                url : '<?php echo url('/today/authors/'); ?>/' + author_id + '/update',
                data : { 'field'     : field,
                         'value'     : value,
                         'type'      : type,
                         'author_id' : author_id },
                dataType : 'html'
            })
            .done(function(returned_data)
            {                               
                // Success
                //console.log("Successfully saved {'" + author_id + "|" + field + "' : '" + value + "'}");
                
                var info = $.parseJSON(returned_data);            

                if (info.force_reload)
                {
                    reload = true;
                }

                // Show success message
                $('<div class="success_bar"><div class="message">Your OSAAtoday news author profile was successfully saved.</div></div>').prependTo('.main_content');
                $('.success_bar').animate({ 'top' : 32, 'background-color' : 'rgba(176, 255, 190, 1.0)'}, 1600, 'easeOutQuad', function ()
                {       
                    $(this).delay(6000).fadeOut(4000, function() { $(this).remove(); });  

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

            })
            .fail(function(jqXHR, status, error)
            {                                                   
                // Error
                var response = jqXHR.responseText;
                var errorData = $.parseJSON(response);
                //console.log(errorData);
                alert("There was an error saving this form's data.\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 text fields
        function autoSaveTextField(input_field)
        {
            clearTimeout(autoSaveTextField.timeout);
            autoSaveTextField.timeout = setTimeout(function (){
                
                var value = input_field.val();                
                var field = input_field.attr('data-autosave-news');
                var type = input_field.attr('data-type');                        
                
                var readonly_attr = input_field.attr('readonly');            
                if (typeof readonly_attr !== typeof undefined && readonly_attr !== false)
                {
                    return false;
                }

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

                saveNewsAuthorData(field, value, type, reload);                
            }, 50);
        }

        // Autosave text fields and textareas
        $('input[type="text"][data-autosave-news]').on('change blur autocompletechange autocompleteselect', function (event)
        {            
            autoSaveTextField ($(this));
        });
        $('textarea[data-autosave-news]').on('change blur autocompletechange autocompleteselect', function (event)
        {            
            autoSaveTextField ($(this));
        });  
    <?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']->loa): ?>

        /*
         * New Ejection Report Button
         */
        $('.new_ejection_button')
            .css({'float' : 'right', 'margin-top' : '1em'})
            .button({ icons : { primary : 'ui-icon-plusthick'}});

        /* 
         * LOA Access Code Dialog
         */
        $('a[data-action="action-legend"]').click(function(event)
        {
            event.preventDefault();

            var link = $(this);            

            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    draggable : true,
                    resizable : false,
                    modal : true,
                    height : 250,
                    width : 500,                    
                    title : "User Access Legend",
                    open : function ()
                        {  
                            var dialog_object = $(this);

                            var html = '<div class="help_dialog">';

                            html += '<h1>User Access Legend</h1>';
                            html += '<table style="font-size: 8pt;">';
                            html += '<tr>';
                            html += '<td style="width: 75px; border-bottom: 1px solid #000000; line-height: 1.15em; font-weight: bold; text-align: left;">User<br />Access</td>';
                            html += '<td style="width: 100px; border-bottom: 1px solid #000000; line-height: 1.15em; font-weight: bold; text-align: center;">Association<br />Details</td>';
                            html += '<td style="width: 100px; border-bottom: 1px solid #000000; line-height: 1.15em; font-weight: bold; text-align: center;">Ejection<br />Reports</td>';
                            html += '<td style="width: 100px; border-bottom: 1px solid #000000; line-height: 1.15em; font-weight: bold; text-align: center;">Reimbursement<br />Records</td>';
                            html += '<td style="width: 100px; border-bottom: 1px solid #000000; line-height: 1.15em; font-weight: bold; text-align: center;">School<br />Contacts</td>';
                            html += '</tr>';
                            html += '<tr style="line-height: 2em;">';
                            html += '<td>FULL</td>';
                            html += '<td style="text-align: center;">Edit/View</td>';
                            html += '<td style="text-align: center;">Edit/View</td>';
                            html += '<td style="text-align: center;">Edit/View</td>';
                            html += '<td style="text-align: center;">View</td>';
                            html += '</tr>';
                            html += '<tr style="line-height: 2em; background-color: #dedede;">';
                            html += '<td>MANAGE</td>';
                            html += '<td style="text-align: center;">Edit/View</td>';
                            html += '<td style="text-align: center;">View</td>';
                            html += '<td style="text-align: center;">View</td>';
                            html += '<td style="text-align: center;">View</td>';
                            html += '</tr>';
                            html += '<tr style="line-height: 2em;">';
                            html += '<td>FINANCE</td>';
                            html += '<td style="text-align: center;">View</td>';
                            html += '<td style="text-align: center;">View</td>';
                            html += '<td style="text-align: center;">Edit/View</td>';
                            html += '<td style="text-align: center;">View</td>';
                            html += '</tr>';
                            html += '<tr style="line-height: 2em; background-color: #dedede;">';
                            html += '<td>NONE</td>';
                            html += '<td style="text-align: center;">View</td>';
                            html += '<td style="text-align: center;">View</td>';
                            html += '<td style="text-align: center;">View</td>';
                            html += '<td style="text-align: center;">View</td>';
                            html += '</tr>';
                            html += '</table>';

                            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"]', dialog_object).focus();
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);                            
                            $(dialog_object).remove();
                        }
                });
        });

                                        
           


        /* 
         * LOA Access Code Dialog
         */
        $('[data-action="show_loa_access_code"]').click(function(event)
        {
            event.preventDefault();

            var link = $(this);
            
            var access_code = link.attr('data-access-code');
            var loa_id = link.attr('data-loa-id');
            var loa_name = link.attr('data-loa-name');

            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    draggable : true,
                    resizable : false,
                    modal : true,
                    height : 450,
                    width : 600,                    
                    title : loa_name + " Access Code",
                    open : function ()
                        {  
                            var dialog_object = $(this);

                            var html = '<div class="help_dialog">';

                            html += '<h1>Access Code</h1>';                            
                            html += 'Other users can link their OSAA Website user accounts to your local officials association by entering in your association\'s <b>ID Number</b> and <b>Access Code</b>.<br /><br />';
                            html += 'Share this information with your local executive board members if you want them to have access to certain features on your OSAA Commissioner Dashboard.<br /><br />';
                            html += '<table style="width: 100%;"><tr><td style="text-align: center; font-weight: bold; width: 50%;">ID Number</td><td style="text-align: center; font-weight: bold; width: 50%;">Access Code</td></tr>';
                            html += '<tr><td style="text-align: center; font-family: monospace; letter-spacing: 2px; font-size: 11pt;">' + loa_id + '</td><td style="text-align: center; font-family: monospace; letter-spacing: 2px; font-size: 11pt;">' + access_code + '</td></tr>';
                            html += '</table><br />';                            
                            html += '<h2>To Gain Access</h2>';
                            html += '<ol>';
                            html += '<li>Create an OSAA Website user account, <a href="<?php echo url('/account/register'); ?>" target="_blank"><?php echo url('/account/register'); ?></a></li>';
                            html += '<li>Enter in your email address and a password of your choice</li>';
                            html += '<li>Skip "Link to a School" by checking the box at the bottom, "I do not have a key code right now..."</li>';
                            html += '<li>Under "Local Officials Association", click the button to "Add an Officials Association Role"</li>';
                            html += '<li>Select a role then provide your association\'s <b>ID Number</b> and <b>Access Code</b></li>';
                            html += '</ol>';
                            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"]', dialog_object).focus();
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);                            
                            $(dialog_object).remove();
                        }
                });
        });


        /*
         * Remove LOA user
         */
        $('.remove_loa_user img')
            .css({'vertical-align' : 'middle', 'margin-right' : '2px'}); 
        $('.remove_loa_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 loa_id = item.attr('data-loa-id');
                var loa_name = item.attr('data-loa-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');
                var redirect_url = item.attr('data-href-return');
                
                $('<div></div>')
                    .appendTo('body')
                    .dialog(
                    {                       
                        modal : true,
                        draggable : true,
                        resizable : false,
                        height : 325,
                        width : 550,                    
                        title : 'Confirmation',
                        buttons: [
                            {
                                text : "Remove LOA User",
                                'class' : "float_left",
                                icons : { primary : 'ui-icon-circle-minus'},
                                click : function()
                                        {                                          
                                            var data = {
                                                'loa' : loa_id,                                                     
                                                'user' : user_id,
                                                'requester' : requesting_user_id,
                                                'loa_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-loa-user'); ?>',
                                                    data : data,
                                                    dataType : 'html'
                                                })
                                                .done(function (data)
                                                {                                                
                                                    // Success   
                                                    if (data == 'success')
                                                    {
                                                        window.location.href = redirect_url;
                                                        location.reload();
                                                    }
                                                    else
                                                    {
                                                        alert ("There was an error removing this LOA 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 LOA 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 ' + loa_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 + ' with ' + loa_name + '.  If you wish to undo this action at a later point in time, ' + user_name + ' will need your associations\'s ID Number and Access Code in order to rejoin their account with this association/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();
                            }                
                    });
            });

        /* 
         * Edit Reimbursement Record
         */
        $('a[data-dialog="officials_championship_record"]').click(function(event)
        {
            event.preventDefault();

            var link = $(this);
            var row = link.parents('tr');
            var record_id = row.attr('data-record-id');
            var matchup_id = row.attr('data-matchup-id');

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

            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    draggable : true,
                    resizable : false,
                    modal : true,
                    height : 650,
                    width : 750,                    
                    title : 'View/Edit OSAA Playoff Reimbursement Record ID# ' + record_id,                   
                    buttons: [
                        {
                            text : "Save & Submit",
                            'class' : "float_left",
                            icons : { primary : 'ui-icon-disk'},
                            click : function()
                                    {                                                       
                                        var result = confirm("Are you sure the information provided on this form is correct?  By submitting this form, you as the Commissioner/Treasurer have verified the information is accurate.");

                                        if (result == false)
                                        {
                                            return;
                                        }

                                        $('<div><div>').addClass('ui-widget-overlay ui-front')
                                                       .appendTo('body');
                                        
                                        $('<div><div>').appendTo('body')
                                                       .css('width', '225px')
                                                       .css('height', '170px')
                                                       .css('text-align', 'center')
                                                       .css('padding', '0.5em')
                                                       .position({my : "center center", at : "center center", of : window})
                                                       .addClass('ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-dialog-buttons')
                                                       .html('<br />Saving...<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 and update the database.</div>');

                                        // Submit the form
                                        var form = $('#verify_assignment_form');
                                        form.submit();
                                    }
                        },                                                                                  
                        {
                            text : "Close",
                            'class' : "float_right",
                            'data-autofocus' : "true",
                            icons : { primary : 'ui-icon-close'},
                            click : function()
                                    {
                                        // Close the dialog box
                                        $(this).dialog("close");                           
                                    }
                        }
                    ],
                    open : function ()
                        {  
                            var dialog_object = $(this);

                            dialog_object.html("<div class='ajax_loader' style='width:16px; height:11px; margin:4em auto; background-image: url(http://www.osaa.org/images/icons/ajax_loader2.gif); background-repeat:no-repeat;'></div>");

                            var jqxhr = $.ajax(
                                      {
                                          type : 'GET',
                                          url : '<?php echo url('brackets/matchups'); ?>/' + matchup_id + '/assignments/' + record_id + '/verify',
                                          dataType : 'html'
                                      })
                                      .done(function (returned_data)
                                      {                               
                                          dialog_object.html(returned_data);
                                      })                                                                            
                                      .fail(function (jqXHR, status, error)
                                      {                                                   
                                          var response = jqXHR.responseText;
                                          var errorData = $.parseJSON(response);
                                          console.log(errorData);
                                          dialog_object.html("There was an error loading the information.<br /><br />" + errorData.error.message);
                                          $(".ui-dialog-buttonpane button:contains('Save')").button("disable");
                                          $(".ui-dialog-buttonpane button:contains('Delete')").button("disable");
                                      })              
                                      .complete(function ()
                                      {
                                          // Gray out read-only text fields
                                          $('input[type="text"][readonly]')
                                              .css({'background-color' : '#dedede'});


                                          // Check verification allowance
                                          var form = $('#verify_assignment_form');
                                          if (form.attr('data-allow-verify') != 1)
                                          {
                                              $(".ui-dialog-buttonpane button:contains('Save')").button("disable");

                                              alert('You will not be able to save changes or submit this reimbursement until after the contest is completed.');
                                          }                      

                                          // Format miles input to numbers only
                                          $('input[name="miles"]')
                                              .mask("9?999")
                                              .on('change blur', function()
                                              {
                                                  var field = $(this);

                                                  if (field.val() == "" || isNaN(field.val()))
                                                  {
                                                      field.val(0);
                                                  }

                                                  calculateMileage();
                                              });                                         

                                          // Format meal requests as single integers only
                                          $('input[data-format="integer"]')
                                              .mask("9?9")
                                              .on('change blur', function()
                                              {
                                                  var field = $(this);

                                                  if (field.val() == "" || isNaN(field.val()))
                                                  {
                                                      field.val(0);
                                                  }

                                                  calculateMeals();
                                              });

                                          // Calculate meals
                                          function calculateMeals()
                                          {
                                              var rates = {
                                                  breakfast : 8.00,
                                                  lunch : 10.00,
                                                  dinner : 15.00
                                              };
                                              
                                              var breakfast = parseInt($('[name="breakfast"]').val()) * rates.breakfast;                                              

                                              var lunch = parseInt($('[name="lunch"]').val()) * rates.lunch;

                                              var dinner = parseInt($('[name="dinner"]').val()) * rates.dinner;

                                              var meals = breakfast + lunch + dinner;

                                              $('[data-fee="meals"]').html('$' + meals.toFixed(2));                                          

                                              updateTotal();
                                          }

                                          calculateMeals();                                          

                                          // Calculate mileage
                                          function calculateMileage()
                                          {
                                              //var number = parseInt($('[data-fee="number"]').html());
                                              var number = parseInt(form.attr('data-mileage-number'));


                                              if (form.attr('data-allow-miles') == 1)
                                              {
                                                  var miles = parseInt($('input[name="miles"]').val());                                                  

                                                  // Get the minimum mileage and mileage rates                                              
                                                  var minimum_mileage = number * 5.00;
                                                  var mileage_rate = 0.50;
                                                  
                                                  var activity = form.attr('data-activity-slug');

                                                  if (activity == "fbl" && miles <= 60)
                                                  {
                                                      // Alternate mileage rate for football
                                                      mileage_rate = 0.75;       
                                                  }
                                                  
                                                  // Calculate the mileage amount
                                                  var mileage_amount = miles * mileage_rate;

                                                  // Check to ensure mileage is at least the minimum
                                                  if (mileage_amount < minimum_mileage)
                                                  {
                                                      mileage_amount = minimum_mileage;
                                                  }
                                              }
                                              else
                                              {
                                                  var mileage_amount = 0.00;
                                              }

                                              $('[data-fee="miles"]').html('$' + mileage_amount.toFixed(2));

                                              updateTotal();
                                          }

                                          calculateMileage();

                                          // Update total
                                          function updateTotal()
                                          {
                                              //var form = $('#verify_assignment_form');
                                              
                                              var game_fee = $('[data-fee="game"]').html();                                              
                                              game_fee = parseFloat(game_fee.replace("$", ""));

                                              var assign_fee = $('[data-fee="assign"]').html();                                              
                                              assign_fee = parseFloat(assign_fee.replace("$", ""));

                                              var meal_fee = $('[data-fee="meals"]').html();
                                              meal_fee = parseFloat(meal_fee.replace("$", ""));                                              

                                              var miles_fee = $('[data-fee="miles"]').html();
                                              miles_fee = parseFloat(miles_fee.replace("$", ""));

                                              var other_fee = $('[data-fee="other"]').html();
                                              other_fee = parseFloat(other_fee.replace("$", ""));                                              

                                              var total_fee = game_fee + assign_fee + meal_fee + miles_fee + other_fee;

                                              $('[data-fee="total"]').html('$' + total_fee.toFixed(2));
                                          }
                                      });   


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

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

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

            /*
             * LOA Chooser for OSAA Staff
             */
            $('select[name="view-association"]').on('change', function()
            {
                var form = $(this).parents('form');
                form.submit();
            });

        <?php endif; ?>

    <?php endif; ?>   
    

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

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

        // Pitch count button
        $('.pitch_counts')
            .css({'font-size' : '9pt', 'position' : 'absolute', 'top' : '425px', 'left' : '50px', 'z-index' : '2', 'width' : '100px'})
            .button({'icons' : {'primary' : 'ui-icon-person' }});

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

    /*
     * Add LOA access
     */
    $('.button.join_loa_user')
        .button()
        .click(function ()
        {
            $('<div></div>')
                .appendTo('body')
                .dialog({
                    autoOpen: true,
                    draggable: false,
                    resizable: false,
                    height: 360,
                    width: 550,
                    title: 'Add an Officials Association Role',
                    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-officials-association-role',
                                    dataType : 'html'
                                })
                                .done(function (data)
                                {
                                    $(info).html(data);
                                    $('.button').button();
                                    $('[data-autofocus]', info).focus();
                                })
                                .fail(function ()
                                {
                                    $(info).html('There was an error.');
                                });

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


    /*
     * Add OSAAtoday access
     */
    $('.button.join_osaa_today')
        .button()
        .click(function ()
        {
            $('<div></div>')
                .appendTo('body')
                .dialog({
                    autoOpen: true,
                    draggable: false,
                    resizable: false,
                    height: 360,
                    width: 550,
                    title: 'Add an OSAAtoday Author Role',
                    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-news-author-role',
                                    dataType : 'html'
                                })
                                .done(function (data)
                                {
                                    $(info).html(data);
                                    $('.button').button();
                                    $('[data-autofocus]', info).focus();
                                })
                                .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']->today): ?>
                <li><a href="#osaa-today" data-tooltip="OSAAtoday Dashboard">OSAAtoday</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']->loa): ?>
                <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; ?>

            
            <?php /*  Restrict special committee login: info@osaa.org, from subscribing to heat index alerts or adding school roles  */ ?>
            <?php if (Auth::user()->id != 9338): ?>
                <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>
            <?php endif; ?>

            <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 /*  OSAAtoday Dashboard  */ ?>
        <?php if ($info['user_access']->today): ?>
            <div id="osaa-today">

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

            </div>
        <?php endif; ?>
        <?php /*  End OSAAtoday 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']->loa): ?>

            <div id="commissioner" style="position: relative;">                
                
                <?php echo $__env->make ('accounts.commissioner_dashboard_slice', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

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


                    <?php if (!is_null($school_object->demographic) and Auth::user()->canAccessSchoolTask($school_object->school->id, 'SCORE') and !$school_object->demographic->is_associate_member and count(Auth::user()->getBaseballTeamObjects()) > 0): ?>
                        <?php
                            $baseball_objects = Auth::user()->getBaseballTeamObjects();
                        ?>

                        <a href="<?php echo url('/teams/' . $baseball_objects[0]->activity_program->id . '#tabs-pitch-counts'); ?>" class="pitch_counts" data-tooltip="View/Edit Baseball Pitching Counts">View/Edit Pitch Counts</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="#tickets-<?php echo $school_object->school->id; ?>">Ticket 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 . '/edit-staff'); ?>" 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; ?>">
                                <div style="float: right; font-size: 8pt; margin-top: 1em;">
                                    <a href="<?php echo url('/governance/forms'); ?>" style="">&raquo; Add a new activity program</a><br />
                                    <a href="<?php echo url('/forms/coop-application'); ?>" style="">&raquo; Add/view coop applications</a>
                                </div>

                                <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 data-activity-program-id="<?php echo $item->activity_program->id; ?>">
                                                        <td><b><?php echo $item->activity; ?></b></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 if (Helpers::strEqual($item->activity_program->activity, array('FBL', 'VBL', 'BSC', 'GSC', 'BBX', 'GBX', 'WRE', 'BBL', 'SBL'))): ?>
                                                        <tr>
                                                            <?php if (is_null($item->loa)): ?>
                                                                <td colspan="4">
                                                                    Local officials association is not assigned.  Please contact the OSAA office at (503) 682-6722 x228.
                                                                </td>
                                                            <?php else: ?>
                                                                <?php /*  LOA  */ ?>
                                                                <td colspan="3">
                                                                    Officials: <?php echo $item->loa->name; ?>
                                                                </td>
                                                                
                                                                <?php /*  LOA Commissioner  */ ?>
                                                                <td>                                                                    
                                                                    <?php if (!is_null($item->loa->commissioner)): ?>
                                                                        Commissioner: <a href="mailto:<?php echo $item->loa->commissioner->email; ?>"><?php echo $item->loa->commissioner->name; ?></a>
                                                                        <?php /* 
                                                                        <?php if ($item->loa->commissioner->phone !== false and !is_null($item->loa->commissioner->phone)): ?>
                                                                            | <?php echo $item->loa->commissioner->phone->number; ?>
                                                                        <?php endif; ?>
                                                                         */ ?>
                                                                    <?php endif; ?>
                                                                </td>
                                                            <?php endif; ?>
                                                        </tr>
                                                    <?php endif; ?>
                                                <?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 data-color-rows="1">
                                                        <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 forms, 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.  

                                        <br /><br />

                                        &raquo; <a href="<?php echo url('/schools/participation'); ?>">Participation Records</a>
                                    </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; ?>
                                                
                                                <?php
                                                    if (Helpers::getCurrentYear() != Session::get('year'))
                                                    {
                                                        $year = '?year=' . Session::get('year');
                                                    }
                                                    else
                                                    {
                                                        $year = null;
                                                    }
                                                ?>
                                                <a href="http://www.osaa.org/reports/all-state-by-school/<?php echo strtolower($season_slug); ?>/<?php echo $school_object->school->short_name; ?><?php echo $year; ?>" 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, transcripted 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 transcripted grading period, 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 data-color-rows="1">
                                                        <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 -->


                                <!-- Ticket Reports -->
                                <div id="tickets-<?php echo $school_object->school->id; ?>">
                                    <h2>Event Management &amp; Ticket Reports</h2>

                                    <p>
                                       The following table includes all <?php echo Session::get('year'); ?>-<?php echo substr((intval(Session::get('year')) + 1), 2, 2); ?> OSAA playoff home contests hosted by <?php echo $school_object->school->short_name; ?>.  To receive OSAA reimbursement, these forms must be completed.  League playoff and play-in contests are not reimbursed by the OSAA.  Please submit within <u>one week</u> of the contest.
                                    </p>                                    
                                    <p>
                                        &raquo; <a href="<?php echo asset('/docs/osaainfo/Event Management & Ticket Report Instructions.pdf'); ?>" target="_blank">Event Management &amp; Ticket Report Instructions</a>
                                    </p>

                                    <table class="bia_table" style="font-size: 9pt;">
                                        <thead>
                                            <tr>                                                
                                                <th>Status</th>
                                                <th></th>
                                                <th>Activity</th>                                                
                                                <th>Round</th>
                                                <th>Date</th>
                                                <th>Teams</th>
                                                <th></th>                                            
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php if (count($school_object->ticket_reports) > 0): ?>
                                                <?php foreach ($school_object->ticket_reports as $tr_object): ?>
                                                    <tr data-color-rows="1">
                                                        
                                                        <td>
                                                            <?php if (is_null($tr_object->status)): ?>
                                                                <a href="<?php echo url('/forms/ticket-report/' . $tr_object->matchup_id . '/create?school=' . $school_object->school->id); ?>">&raquo; Start Form</a>
                                                                </td>
                                                                <td>
                                                                <img src="<?php echo asset('/images/icons/never_started_16px.png'); ?>" alt="" title="Never Started" style="vertical-align: middle;" />                                                                    
                                                            <?php elseif (Helpers::strEqual($tr_object->status, 'WORK')): ?>
                                                                <a href="<?php echo url('/forms/ticket-report/' . $tr_object->id . '/edit?matchup=' . $tr_object->matchup_id); ?>">&raquo; Edit Form</a>
                                                                </td>
                                                                <td>
                                                                <img src="<?php echo asset('/images/icons/pending_16px.png'); ?>" alt="" title="Not Submitted" style="vertical-align: middle;" />                                                                    
                                                            <?php elseif (Helpers::strEqual($tr_object->status, 'SUBT')): ?>
                                                                Submitted <?php echo date('n/j', strtotime($tr_object->submitted_at)); ?>
                                                                </td>
                                                                <td>
                                                                <img src="<?php echo asset('/images/icons/incomplete_16px.png'); ?>" alt="" title="Submitted" style="vertical-align: middle;" /> 
                                                            <?php else: ?>
                                                                Finished <?php echo date('n/j', strtotime($tr_object->submitted_at)); ?>
                                                                </td>
                                                                <td>
                                                                <img src="<?php echo asset('/images/icons/finished_16px.png'); ?>" alt="" title="Finished" style="vertical-align: middle;" /> 
                                                            <?php endif; ?>
                                                        </td>
                                                        <td><?php echo $tr_object->division; ?> <?php echo $tr_object->activity; ?></td>
                                                        <td><?php echo $tr_object->round; ?></td>
                                                        <td><?php echo date('D n/j/Y', strtotime($tr_object->start_at)); ?></td>
                                                        <td><?php echo $tr_object->teams; ?></td>

                                                        <td>
                                                            <?php if ($tr_object->is_late): ?>
                                                                <span class="important bold">LATE</span>
                                                            <?php endif; ?>

                                                            <?php if (Helpers::strEqual($tr_object->status, 'SUBT')): ?>
                                                                <a href="<?php echo url('/forms/ticket-report/' . $tr_object->id . '/print'); ?>" target="_blank" style="font-weight: bold;">Print</a>
                                                            <?php endif; ?>
                                                        </td>   

                                                    </tr>
                                                <?php endforeach; ?>
                                            <?php else: ?>
                                                <tr>
                                                    <td colspan="7">There are no OSAA playoff event management &amp; ticket reports to display.</td>
                                                </tr>
                                            <?php endif; ?>
                                        </tbody>
                                    </table>                                    
                                </div>
                                <!-- End Ticket Reports -->

                                <!-- 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
                                                $row_index = 0;
                                            ?>
                                            <?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 <?php if ($row_index++ % 2 == 0): ?> class="odd" <?php endif; ?>>
                                                            <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 if (Auth::user()->id != 9338): ?>
            <?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 alerts, click the red X icon for the respective row.  Forecasts are calculated daily beginning at 10:30am and alert notifications are sent out starting at 11:00am.
                    </p>

                    <table class="bia_table">
                        <thead>
                            <tr>
                                <th style="padding-left: 2px;">Location Name</th>                            
                                <th>Today's Status</th>
                                <th>Notified</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;" data-heat-index-area="<?php echo $subscription->area_model->id; ?>">
                                    <td><a href="<?php echo url('/heat-index?place=' . urlencode($subscription->area_model->name)); ?>"><?php echo $subscription->area_model->name; ?></a></td>
                                    <td>
                                        <?php if (is_null($subscription->forecast)): ?>
                                            <img src="<?php echo asset('/images/icons/ajax_loader2.gif'); ?>" alt="" title="" style="vertical-align: middle;" />
                                            Forecast Pending ...
                                        <?php else: ?>
                                            <?php if (Helpers::strEqual($subscription->forecast->status, 'ERROR')): ?>
                                                <img src="<?php echo asset('/images/icons/not_selected_16px.png'); ?>" alt="" title="" style="vertical-align: middle;" />
                                                <span style="color: #990000;">ERROR: </span>Weather Data Unavailable @ <?php echo date('g:ia', strtotime($subscription->forecast->calculated_at)); ?>
                                            <?php elseif (Helpers::strEqual($subscription->forecast->status, 'LOW')): ?>
                                                <img src="<?php echo asset('/images/icons/ok_16px.png'); ?>" alt="" title="" style="vertical-align: middle;" />
                                                <span style="color: #0011f1;">LOW: </span>Forecast @ <?php echo date('g:ia', strtotime($subscription->forecast->calculated_at)); ?>, Heat Index &le; 93&#176;
                                            <?php elseif (Helpers::strEqual($subscription->forecast->status, 'ALERT')): ?>
                                                <img src="<?php echo asset('/images/icons/alert_16px.png'); ?>" alt="" title="" style="vertical-align: middle;" />
                                                <span style="color: #ff8300;">ALERT: </span>Forecast @ <?php echo date('g:ia', strtotime($subscription->forecast->calculated_at)); ?>, Heat Index &#62; 93&#176;
                                            <?php else: ?>
                                                <img src="<?php echo asset('/images/icons/not_selected_16px.png'); ?>" alt="" title="" style="vertical-align: middle;" />
                                                <span style="color: #990000;">ERROR: </span>Unknown Status @ <?php echo date('g:ia', strtotime($subscription->forecast->calculated_at)); ?>
                                            <?php endif; ?>
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <?php if (!is_null($subscription->forecast)): ?>
                                            <?php if ($subscription->forecast->is_notified): ?>
                                                <img src="<?php echo asset('/images/icons/yellow_flag_16px.png'); ?>" alt="" title="Notifications Sent" style="vertical-align: middle;" />
                                            <?php elseif (Helpers::strEqual($subscription->forecast->status, 'ALERT')): ?>
                                                <img src="<?php echo asset('/images/icons/hollow_flag_16px.png'); ?>" alt="" title="Notifications Pending" style="vertical-align: middle;" /> ...
                                            <?php else: ?>
                                                - -
                                            <?php endif; ?>
                                        <?php endif; ?>
                                    </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; ?>

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

                        <h2>Local Officials Association</h2>
                        <div class="button join_loa_user" style="font-size: 8pt;">Add an Officials Association Role</div>
                        <p style="font-size: 9pt; margin-top: 0.5em;">
                            Click this button to add yourself to a local officials association to manage details, ejection reports, and reimbursement records.
                        </p>

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

                        <h2>OSAAtoday Author</h2>
                        <?php if (!$info['user_access']->today): ?>
                            <div class="button join_osaa_today" style="font-size: 8pt;">Setup OSAAtoday Author Account</div>
                            <p style="font-size: 9pt; margin-top: 0.5em;">
                                Click this button to add yourself as an OSAAtoday author to manage your author profile and create, submit, and publish news articles.
                            </p>
                        <?php else: ?>
                            <p style="font-size: 9pt; margin-top: 0.5em;">
                                Your account is already setup as an OSAAtoday author.  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.
                        </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>

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

                        <h3>Here's What You'll Need</h3>
                        Your Commissioner will need to provide you with your local association's ID number and access code. 

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

                        <h3>You'll need an access code</h3>
                        You will need an access code provided by the OSAA to setup your existing OSAA website user account as an OSAAtoday author. 

                    </div>                   


                </div>

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


        <?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 />            
            
            <?php if (Auth::user()->id != 9338): ?>
                <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>
            <?php endif; ?>

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