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

<?php $__env->startSection('page_sub_title'); ?>    
	<?php echo $info['online_form']->name; ?>
<?php $__env->stopSection(); ?>

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

    <style type="text/css">
    	
        h2 {
            color: #1C43A6 !important;
        }

        h2.line {
            border-bottom: 1px solid #1C43A6;
            padding-bottom: 0.25em;
            margin-bottom: 0.25em;
        }

        h3 {
            color: #990000 !important;
        }

        .no-close .ui-dialog-titlebar-close {
            display: none;
        }

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

        .page_functions {
            width: auto !important;
        }  

        .odd {
            background-color: #dedede;
        }

        .ap_table {
            border-collapse: collapse;
            width: 100%;
            
        }

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

        .ap_table thead th {            
            padding: 4px 2px;
            text-align: left;
            vertical-align: bottom;
        }

        .ap_table tbody tr {
            line-height: 3em;
        }

        .required {
            color: #990000;
            font-weight: bold;
            font-size: 14pt;
            position: relative;
            top: 4px;
            margin-left: 5px;
        }

        /* 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;
            text-decoration: underline;
        }

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

        .ui-autocomplete {
            font-size: 9pt !important;
            max-height: 200px;
            overflow-y: auto;
        }        

        label, .label {            
            font-weight: bold;            
            float: left;
            margin-right: 10px;
        }        
       

        
        /* Form Action Area */
        .action_area {
            padding: 1.5em 1em 0.5em 1em;
            background-color: #f2f2f2;
            border: 1px solid black;
            margin: -9px -10px 1em 0;
            position: relative;
            height: 2em;            
        }

        .action_area .title {
            position: absolute;
            font-size: 8pt;
            top: 0;
            left: 4px;
            color: #005fa9;
            width: 100%;
        }

        .action_area .title .title_right {
            position: absolute;
            top: 0;
            right: 10px;
        }

        .action_area .status_path {
            float: right;
        }

        .action_area .status_path .state,
        .help_dialog .status_path .state {
            display: inline-block;
            color: #999999;
        }

        .action_area .status_path img,
        .help_dialog .status_path img {
            position: relative;
            top: 2px;
        }

        .action_area .status_path .state.current,
        .help_dialog .status_path .state.current {
            font-weight: bold;
            color: #000000;
        }

        .action_area .status_path .state.complete,
        .help_dialog .status_path .state.complete {
            color: #77aa77;
        }

        .progress_alert {
            padding: 0.25em 0.5em;
            margin-bottom: 1em; 
            line-height: 32px; 
            font-size: 12pt; 
            font-weight: bold;
        }

        

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

<?php $__env->startSection('jquery_init'); ?>
	
    if(!window.console)
    {
        window.console = { log: $.noop, group: $.noop, groupEnd: $.noop };            
    }

    // Success bar
    $('.success_bar').animate({ 'top' : 32, 'background-color' : 'rgba(176, 255, 190, 1.0)'}, 1600, 'easeOutQuad', function ()
    {       
        $(this).delay(6000).fadeOut(4000);  

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


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

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


    /*
     * Submit Button
     */
    $('.submit_button')
        .css({'font-size' : '9pt'})
        .button({'icons':{'primary':'ui-icon-check'}})        
        .click(function(event)
        {
            event.preventDefault();

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

            var ok_to_submit = true;

            // Check for no offerings
            var offer_count = 0;
            $('input[type="checkbox"].preselect_option').each(function(index, item)
            {
                var obj = $(item);

                if (obj.is(':checked'))
                {
                    offer_count++;
                }
            });

            if (offer_count == 0)
            {
                // Confirm no offerings for next year
                $('<div></div>')
                    .appendTo('body')
                    .dialog(
                    {                       
                        modal : true,
                        draggable : true,
                        resizable : false,
                        height : 300,
                        width : 500,                    
                        title : 'Attention',
                        buttons: [
                            {
                                text : "Continue",
                                'class' : "float_left",
                                icons : { primary : 'ui-icon-check'},
                                click : function()
                                        {                                                       
                                            // Continue on to submitting the form                                            
                                            var dialog_object = $(this);
                                            $(dialog_object).remove();

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

                                var html = '<div style="font-size: 10pt; margin: 1em 0;">';                                
                                html += '<img src="<?php echo asset('images/icons/danger_icon_72px.png'); ?>" alt="" title="" style="float: left; width: 24px; height: 24px; margin: 0.5em 1em 1em 0;" />';
                                html += '<b>You indicated your school will not be offering any <?php echo $info['season']; ?> sports or activities for the next school year.</b><br /><br /><div class="ui-state-error">Are you sure you want to submit this form?</div>';
                                html += '<br />';
                                html += '<div class="small gray">You didn\'t preselect any sports or activities.  Click "Cancel" to return to your form or click "Continue" to proceed with the form submission.</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%');
                                $('.ui-dialog-titlebar').addClass('ui-state-highlight');

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

            return;                                       
        }); 
    

    // Submit the form
    function submitForm()
    {
        // Confirm
        $('<div></div>')
            .appendTo('body')
            .dialog(
            {                       
                modal : true,
                draggable : true,
                resizable : false,
                height : 250,
                width : 400,                    
                title : 'Confirm Form Submission',
                buttons: [
                    {
                        text : "Submit",
                        'class' : "float_left",
                        icons : { primary : 'ui-icon-check'},
                        click : function()
                                {                                                       
                                    // Submit the form
                                    $('<div><div>')
                                        .attr('data-check', 1)
                                        .addClass('ui-widget-overlay ui-front')
                                        .appendTo('body');
                                      
                                    $('<div><div>').appendTo('body')
                                        .attr('data-check', 1)
                                        .css('width', '225px')
                                        .css('height', '170px')
                                        .css('text-align', 'center')
                                        .css('padding', '0.5em')
                                        .position({my : "center center", at : "center center", of : window})
                                        .addClass('ui-dialog ui-widget ui-widget-content ui-corner-all ui-front')
                                        .html('<br />Submitting Form...<br /><br /><img src="http://www.osaa.org/images/icons/ajax_loader3.gif" /><div style="font-size: 8pt; line-height: 105%; margin-top: 2em;">Form check passed, now please wait while your form is submitted, this may take a while to process...</div>');

                                    // Submit the form
                                    window.location.href= "<?php echo url('/forms/seasonal/' . $info['season'] . '/' . $info['school']->id . '/submit'); ?>";
                                }
                    },                        
                    {
                        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>';
                        <?php if (!$info['school_form']->data->is_submitted): ?>
                            html += '<b>Are you sure you want to submit this form?</b>';
                            html += '<br /><br />';
                            html += '<div class="small gray">You will be able to make changes and re-submit this form up until the form\'s deadline.  Your school will be notified by e-mail confirming receipt.</div>';
                        <?php else: ?>
                            html += '<b>Are you sure you want to re-submit this form?</b>';
                            html += '<br /><br />';
                            html += '<div class="small gray">You will be able to make changes and re-submit this form up until the form\'s deadline.  Your school will be notified by e-mail confirming receipt.</div>';
                        <?php endif; ?>                                    
                        
                        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();
                    }                
            }); 
    }


    // Required field marker
    $('[data-required]:not([data-required-indicator])').after('<span class="required">*</span>'); 
    
    // Table row highlighter
    function colorRows ()
    {       
        $('table').each(function ()
        {
            var i = 0;

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


    /* alertRequiredField
     *
     * Shows an alert box when attempting to save a blank value to a required field.
     */
    function alertRequiredField()
    {
        $('<div></div>')
            .appendTo('body')
            .dialog(
            {                       
                modal : true,
                draggable : false,
                resizable : false,                    
                height : 275,                    
                width : 415,                    
                title : 'Required Field',                    
                buttons: [
                    {
                        text : "OK",
                        'class' : "float_right",
                        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\'ve entered in a blank value for a required field.  Required fields cannot be empty.<div style="font-size: 9pt; margin-top: 1em;" class="small gray note">The original value has been restored.</div>');
                        
                        $('.ui-dialog-buttonpane').css('padding', '0 0.5em').css('font-size', '9pt');
                        $('.ui-dialog-buttonpane .ui-dialog-buttonset').css('width', '100%');
                        $('.ui-dialog-buttonpane .ui-dialog-buttonset').append('<div style="font-size: 8pt; line-height: 1.25em; margin-top: 0.5em;">Still having trouble?<br />(503) 682-6722 x228</div>');
                    },                    
                close : function ()
                    {
                        var dialog_object = $(this);
                        $(dialog_object).remove();
                    }                
            });
    }


    /* saveFormData
     *
     * 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 saveFormData(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 form_id = <?php echo $info['school_form']->id; ?>;

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

        var jqxhr = $.ajax(
        {
            type : 'POST',                      
            url : '<?php echo url('/forms/seasonal/'); ?>/' + form_id + '/update',
            data : { 'field' : field,
                     'value' : value,
                     'type'  : type },
            dataType : 'html'
        })
        .done(function(returned_data)
        {                               
            // Success
            //console.log("Successfully saved {'" + form_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 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 original_value = input_field.attr('data-original');
            var field = input_field.attr('data-field');
            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;
            }

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

            if (required && value == '' && !(original_value == '' || typeof original_value === typeof undefined || original_value === false))
            {
                input_field.val(original_value);

                input_field.focus();

                alertRequiredField();          

                return;
            }

            if (value != original_value && ((required && value != '') || !required))
            {
                saveFormData(field, value, type, reload);
                input_field.attr('data-original', value);
            }
        }, 50);
    }

    // Autosave text fields and textareas
    $('input[type="text"][data-autosave]').on('change blur autocompletechange autocompleteselect', function (event)
    {            
        autoSaveTextField ($(this));
    });
    $('textarea[data-autosave]').on('change blur autocompletechange autocompleteselect', function (event)
    {            
        autoSaveTextField ($(this));
    });   

    // 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)
        {
            saveFormData(field, value, type, reload);
            select_field.attr('data-original', value);
        }                
    });

    // Autosave check-box fields    
    $('input[type="checkbox"][data-autosave]').on('change', function(event)
    {
        var checkbox_field = $(this);        
        var value = checkbox_field.is(':checked');
        var original_value = checkbox_field.attr('data-original'); 
        var field = checkbox_field.attr('data-field');
        var type = checkbox_field.attr('data-type');                        
        
        var readonly_attr = checkbox_field.attr('readonly');            
        if (typeof readonly_attr !== typeof undefined && readonly_attr !== false)
        {
            return false;
        }

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

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


    <?php if (Session::has('new_form') or Input::has('new-form')): ?>
        showHelp('new-form', 'New Seasonal School Form');
    <?php endif; ?>


    /* ShowHelp
     *
     * Shows a help topic.
     */
    function showHelp(help_topic, special)
    {
        if (typeof special === 'undefined' || special == '')
        {
            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    draggable : true,
                    resizable : true,
                    height : 725,
                    minHeight : 400,
                    width : 615,
                    minWidth : 330,
                    modal : false,                    
                    title : 'Form Help',
                    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('forms/seasonal/' . $info['school_form']->id . '/help'); ?>?topic=' + help_topic,
                                          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);
                                          alert ("There was an error looking up help information.\n\nThis page will be reloaded.");
                                          location.reload();
                                      })
                                      .complete(function ()
                                      {
                                           
                                      });                            
                            
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);

                            $(dialog_object).remove();
                        }                
                });
        }
        else
        {
            $('<div></div>')
                .appendTo('body')
                .css({'z-index':'2000 !important'})
                .dialog(
                {                       
                    draggable : false,
                    resizable : false,
                    height : 725,
                    minHeight : 725,
                    width : 615,                    
                    modal : true,
                    dialogClass : 'no-close',
                    title : special,
                    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('forms/seasonal/' . $info['school_form']->id . '/help'); ?>?topic=' + help_topic,
                                          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);
                                          alert ("There was an error looking up help information.\n\nThis page will be reloaded.");
                                          location.reload();
                                      })
                                      .complete(function ()
                                      {
                                           $('.close_first_view_button', dialog_object)
                                               .button()
                                               .click(function ()
                                               {
                                                   dialog_object.dialog("close");
                                               });

                                           // Shake action items
                                          function shakeTheseActionImages (object)
                                          {
                                              var direction;
                                              if ($(object).has('[data-direction]'))
                                              {
                                                  var direction = $(object).attr('data-direction');
                                              }                                              
                                              if (typeof direction == 'undefined')        
                                              {
                                                  var direction = 'left';
                                              }          
                                              $(object).effect("shake", {direction : direction, distance : 5, times : 1}, 600, function ()
                                              {
                                                  $(this).delay(Math.floor(Math.random() * 4000) + 2000);
                                                  shakeTheseActionImages($(this));
                                              });        
                                          }  
                                          
                                          var img = $('img.action_item', dialog_object);
                                          img.position({my:"center center", at : "right+30 center", of : ".close_first_view_button"});

                                          shakeTheseActionImages(img);  
                                      });                            
                            
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);

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


    /* 
     * Help button    
     */
    $('.help_button')
        .button({'icons':{'primary':'ui-icon-help'}})
        .css({'font-size':'9pt'})
        .click(function(event)
        {
            var object = $(this);
            object.blur();

            event.preventDefault();

            var topic = object.attr('data-topic');            

            showHelp(topic);            

        });


    /*
     * Close button
     */
    $('.close_button')
        .button({'icons':{'primary':'ui-icon-circle-close'}})
        .css({'font-size':'9pt', 'margin-left':'10px'});     


    /* Status Log
     *
     * Shows the status log when link is clicked.
     */
    $('[name="status_log"]')
        .click(function(event)
        {
            event.preventDefault();

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

            var data = {
                created_at : "<?php echo date('D n/j/y g:ia', strtotime($info['school_form']->created_at)); ?>",
                updated_at : "<?php echo date('D n/j/y g:ia', strtotime($info['school_form']->updated_at)); ?>",                
                is_submitted : "<?php echo ($info['school_form']->data->is_submitted) ? ('<img src=\'' . asset('/images/icons/check_16px.png') . '\' alt=\'\' title=\'\' style=\'vertical-align: middle;\' /> Yes - Complete') : ('<img src=\'' . asset('/images/icons/missing_16px.png') . '\' alt=\'\' title=\'\' style=\'vertical-align: middle;\' /> No - Never Submitted'); ?>"
            };                        

            var html = '<div style="font-size: 9pt;">';
            html += '<div style="display: inline-block; width: 150px;">Last Updated:</div>' + data.updated_at + '<br />';
            html += '<div style="display: inline-block; width: 150px;">Form Created:</div>' + data.created_at + '<br />';
            html += '<div style="display: inline-block; width: 150px;">Submitted:</div>' + data.is_submitted + '<br />';            
            
            html += '<table style="width: 100%; border-collapse: collapse; margin-top: 1em;"><tbody>';

            <?php foreach ($info['school_form']->data->status_history as $i => $log): ?>

                <?php if (($i % 2) == 0): ?>
                    html += '<tr style="background-color: #dedede;">';
                <?php else: ?>
                    html += '<tr>';
                <?php endif; ?>
                html += '<td style="padding-right: 15px;vertical-align: top;"><?php echo date('n/j/y g:ia', strtotime($log->timestamp)); ?></td>';
                html += '<td style="padding-right: 15px;vertical-align: top;"><?php echo $log->action; ?></td>';
                html += '<td style="vertical-align: top;"><?php echo str_replace('\'', '\\\'', $log->user); ?><br /><i><?php echo str_replace("\n", '<br />', str_replace('\'', '&quot;', $log->notes)); ?></i></td></tr>';

            <?php endforeach; ?> 

            html += '</tbody></table></div>';

            $('<div></div>')
                .appendTo('body')
                .dialog(
                {                       
                    resizable: false,
                    height: 'auto',
                    width: 550,
                    modal: false,                    
                    title: 'Status Log',
                    open : function ()
                        {  
                            var dialog_object = $(this);                            

                            dialog_object.html(html);
                        },
                    close : function ()
                        {
                            var dialog_object = $(this);

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

        })
        .hover(function()
        {
            $(this).css({'cursor':'pointer'});
        },
        function()
        {
            $(this).css({'cursor':''});
        });        


    /*
     * Form Behavior
     */

    $('[data-format="integer"]')
        .bind('input', function()
        {
              $(this).val($(this).val().replace(/[^0-9]/gi, ''));
        }); 
    
   
<?php $__env->stopSection(); ?>

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

	<a href="#" class="submit_button" style="margin-right: 10px;">Submit</a>

    <a href="#" class="help_button" data-topic="general-help">Help</a>

    <?php if (Auth::check() and Auth::user()->isOsaaUser()): ?>
        <a href="<?php echo url('/forms/seasonal'); ?>" class="close_button">Close</a>
    <?php else: ?>
        <a href="<?php echo url('/account'); ?>" class="close_button">Close</a>
    <?php endif; ?>

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


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

	<?php /*  Past Due Notification  */ ?>
    <?php if (false): ?>
		<?php /*  NEED TO REDO  */ ?>
        <div class="online_form_late ui-state-error ui-corner-all">
			<span class="ui-icon ui-icon-alert" style="display:inline-block; position:relative; top:2px;"></span>
			This form was due by <?php echo date('g:i A l, F j, Y', strtotime($info['seasonal_school_form']->due_at)); ?> and is now past the deadline.  Please submit your entries now before the form closes and becomes unavailable.
		</div>
	<?php endif; ?>

    <?php /*  Status Log  */ ?>
    <div name="status_log" data-tooltip='Click to view detailed status history.' style="float: right; font-size: 9pt; color: #005fa9;">
        <img src="<?php echo asset('/images/icons/history_log_24px.png'); ?>" alt="" title="" style="width: 16px; vertical-align: middle;" /> <u>Status</u>
    </div>

    <?php /*  Form Icon & Heading  */ ?>
	<img src="<?php echo asset('images/icons/participation_teams.png'); ?>" alt="" title="" style="float: left; width: 88px; height: 64px; margin-right: 1em;" />
	<h1 style="padding-top: 1em;"><?php echo $info['school_year']->slug; ?> <?php echo ucfirst($info['season']); ?> Activity Programs for <?php echo $info['school']->short_name; ?></h1>
	
    <br /><br />

    <?php /*  Instructions  */ ?>
    <div class="online_form_instructions ui-corner-all">
        <span class="ui-icon ui-icon-info" style="display:inline-block; position:relative; top:2px;"></span>
        <b>Instructions</b>
        
        <p>
            This new Seasonal form replaces the old Participation and Preselection forms.  On this form, you need to provide the number of students that represented your school for each of the sports and/or activities offered this <?php echo $info['season']; ?>.  You must also indicate which <?php echo $info['season']; ?> sports or activities your school will be offering next year.
        </p>

        <a href="#" class="help_button float_right" data-topic="general-help">Help</a>

        <p>            
            For additional assistance regarding the use of this form or what information to provide, click the <b>Help</b> button.
        </p>        

    </div> 

    <br />             

    <?php /*  Not Submitted Note  */ ?>
    <?php if (!$info['school_form']->data->is_submitted): ?>
        <div class="ui-state-highlight progress_alert">
            <img src="<?php echo asset('/images/icons/construction_32px.png'); ?>" alt="" title="" style="float: left; width: 32px; display: inline-block; margin-right: 10px;" />
            
            <a href="#" class="submit_button float_right" style="margin-top: 0.25em;">Submit</a>

            This form has not been submitted.
            <br class="clear" />
        </div>    
    <?php endif; ?>

    <?php /*  Errors  */ ?>
    <?php if (Session::has('errors')): ?>                
        <div class="ui-state-error" style="padding: 2px 4px;">
            <span class="ui-icon ui-icon-alert" style="display:inline-block; position:relative; top:2px;"></span>
            <?php foreach ($errors->all() as $error): ?><?php echo $error; ?> <?php endforeach; ?>
        </div>
        <br />
    <?php endif; ?>

    <?php /*  Required Note  */ ?>
    <div class="clear float_right small gray">
        Required fields are indicated with a red asterisk, <span style="color: #990000; font-weight: bold; font-size: 14pt !important; position: relative; top: 6px;">*</span>.
    </div>

    

    <h2 class="line">Activity Programs</h2>

    <table class="ap_table">
        <thead>
            <tr>
                <th>Sport / Activity</th>
                <th>Offered This<br />Year (<?php echo $info['school_year']->slug; ?>)</th>
                <th>Offering Next<br />Year (<?php echo $info['next_school_year']->slug; ?>)<span class="required">*</span></th>
                <th># Boys</th>
                <th># Girls</th>
            </tr>
        </thead>

        <tbody>

            <?php foreach ($info['school_form']->data->activities as $index => $activity_object): ?>

                <tr>
                    <td>
                        <b><?php echo Helpers::getActivityName($activity_object->slug); ?></b>
                    </td>

                    <td>
                        <?php echo ($activity_object->offered) ? ('<img src=\'' . asset('/images/icons/check_16px.png') . '\' alt=\'\' title=\'\' style=\'vertical-align: middle;\' /> Yes') : ('<img src=\'' . asset('/images/icons/missing_16px.png') . '\' alt=\'\' title=\'\' style=\'vertical-align: middle;\' /> No'); ?>                        
                    </td>

                    <td>
                        <?php echo Form::label($activity_object->slug . '_preselect', 'Preselect'); ?>
                        <?php echo Form::checkbox($activity_object->slug . '_preselect',
                                          true,
                                          $info['school_form']->data->activities[$index]->preselect,
                                          array('data-autosave' => true,
                                                'data-field'    => 'data->activities[' . $index . ']->preselect',
                                                'data-type'     => 'BOOL',
                                                'style'         => 'vertical-align: middle;',
                                                'class'         => 'preselect_option')); ?>
                    </td>

                    <td>
                        <?php if ($activity_object->offered): ?>
                            <?php echo Form::label($activity_object->slug . '_boys', 'Boys: '); ?>
                            <?php echo Form::text($activity_object->slug . '_boys',
                                          $info['school_form']->data->activities[$index]->boys,
                                          array('data-autosave' => true,
                                                'data-field'    => 'data->activities[' . $index . ']->boys',
                                                'data-type'     => 'INT',
                                                'data-required' => true,
                                                'data-format'   => 'integer',
                                                'data-original' => $info['school_form']->data->activities[$index]->boys,
                                                'style'         => 'width: 40px;')); ?>
                        <?php else: ?>
                            N/A
                        <?php endif; ?>
                    </td>

                    <td>
                        <?php if ($activity_object->offered): ?>
                            <?php echo Form::label($activity_object->slug . '_girls', 'Girls: '); ?>
                            <?php echo Form::text($activity_object->slug . '_girls',
                                          $info['school_form']->data->activities[$index]->girls,
                                          array('data-autosave' => true,
                                                'data-field'    => 'data->activities[' . $index . ']->girls',
                                                'data-type'     => 'INT',
                                                'data-required' => true,
                                                'data-format'   => 'integer',
                                                'data-original' => $info['school_form']->data->activities[$index]->girls,
                                                'style'         => 'width: 40px;')); ?>
                        <?php else: ?>
                            N/A
                        <?php endif; ?>
                    </td>

                </tr>

            <?php endforeach; ?>

        </tbody>


    </table>

    






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

