<?php /* 
<div class="ui-corner-all ui-state-highlight" style="margin: -10px -10px 10px 0; padding: 0.25em;">
    This page is currently under revision.  Please check back later for OSAA Rankings.
</div>
 */ ?>

<div class="tabs" style="width:100%; min-height:620px;">

    <ul style="padding-left:5px; font-size:10pt;">
        <?php foreach ($information['divisions'] as $div): ?>           
            <li><a href="#tabs-<?php echo $div; ?>"><?php echo $div; ?></a></li>            
        <?php endforeach; ?>   
    </ul>

    <?php foreach ($information['divisions'] as $div): ?>
        
        <div id="tabs-<?php echo $div; ?>" class="" style="padding-left:.25em; padding-right:.25em; /*overflow-x: hidden; overflow-y:auto; height:552px;*/">                        
            <?php if (count($information['rankings'][$div]) > 0): ?>

                <table class="all_rankings">
                    <thead class="head">
                        <th class="team">Team Name &amp; Logo<br />League</th>
                        <?php if ($information['has_apr'][$div]): ?>
                            <th class="apr">APR</th>
                        <?php endif; ?>
                        <th class="rank ranking_highlight" style="border-top: 2px solid #1C43A6; font-size: 100% !important;">OSAA<br />Ranking</th>
                        <th class="record">Overall<br />Record</th>
                        <th class="rank">RPI<br />Rank</th>
                        <th class="rpi">RPI<br />Rating</th>
                        <th class="rank">Colley<br />Rank</th>
                        <th class="rpi">Colley<br />Rating</th>
                    </thead>

                    <tbody>
                        <?php $i = 1; ?>
                        <?php foreach ($information['rankings'][$div] as $item): ?>
                            
                            <?php                               

                                $class = "rankings_entry";
                                if ($i++ % 2 == 0)
                                {
                                    $class .= ' odd';
                                }                                

                            ?>

                            <tr class="<?php echo $class; ?>" data-team="<?php echo $item->team->id; ?>">                               

                                <td class="team">
                                    <div class="logo">
                                        <?php                                                                                
                                            $image_url = ImagesController::getImageURLFromTeamID($item->team->id, 'logo', '32x32');
                                        ?>
                                        <?php if (!is_null($image_url)): ?>
                                            <img src="<?php echo $image_url; ?>" alt="" title="" style="width: 32px; height: 32px;" />
                                        <?php else: ?>       
                                            <img src="<?php echo asset('images/no_logo.png'); ?>" alt="" title="" style="width: 32px; height: 32px;" />
                                        <?php endif; ?>
                                    </div>

                                    <div class="team_name"><a href="<?php echo url('/teams/' . $item->activity_program->id); ?>" style="color: #005fa9;"><?php echo $item->activity_program->name; ?></a></div>
                                    <div class="league">
                                        <?php if (!is_null($item->league)): ?>
                                            <a href="<?php echo url('/activities/' . strtolower($item->activity_program->activity) . '/teams-leagues?div=' . $item->activity_program->division . '#' . preg_replace('/\(.*\)/', '', $item->league->slug)); ?>">
                                                <?php echo $item->display_league; ?>
                                            </a>
                                        <?php else: ?>
                                            <?php echo $item->display_league; ?>
                                        <?php endif; ?>                                        
                                    </div>
                                </td>
                                
                                <?php if ($information['has_apr'][$div]): ?>
                                    <td class="apr">
                                        <?php echo $item->ranking->apr; ?>
                                    </th>
                                <?php endif; ?>

                                <td class="rank ranking_highlight">
                                    <b><?php echo $item->ranking->rank; ?></b>
                                </td>
                                <td class="record">
                                    <?php echo $item->display_record; ?>
                                </td> 
                                <td class="rank">
                                    <?php echo $item->ranking->rpi_rank; ?>
                                </td>  
                                <td class="rpi">                                    
                                    <a href="<?php echo url('/teams/' . $item->activity_program->id . '#sub-tabs-ranking'); ?>" style="color: #005fa9;">
                                        <?php echo number_format($item->ranking->rpi * 1000, 3, '.', ''); ?>
                                    </a>
                                </td>
                                <td class="rank">
                                    <?php echo $item->ranking->colley_rank; ?>
                                </td> 
                                <td class="rpi">                                    
                                    <a href="<?php echo url('/teams/' . $item->activity_program->id . '#sub-tabs-ranking'); ?>" style="color: #005fa9;">
                                        <?php echo number_format($item->ranking->colley * 1000, 3, '.', ''); ?>
                                    </a>
                                </td>                                
                            </tr>

                        <?php endforeach; ?>
                    </tbody>

                </table>

                <br />

                <div class="rankings_definitions">
                    <div style="color: #990000; font-weight: bold;">Legend</div>

                    <?php if ($information['has_apr'][$div]): ?>
                        <b>APR</b>: The Adjusted Playoff Ranking (APR) is the bracket seed adjusted from final frozen ranking to remove first round same league matchup conflicts and to accommodate league champion guarantees.<br />
                    <?php endif; ?>
                    <b>OSAA Ranking</b>: Official OSAA ranking, composed of the averaged RPI rank and Colley rank for all teams within the same classification.<br />
                    <b>Overall Record</b>: The team's overall play record is displayed in W-L or W-L-T format.<br />
                    <b>RPI Rank</b>: A numerical order of teams, ranked by RPI Rating.<br />
                    <b>RPI Rating</b>: A team's Rating Percentage Index (RPI) Rating = 35% &#215; WWP + 65% &#215; OWP.<br />
                    <b>Colley Rank</b>: A numerical order of teams, ranked by Colley Rating.<br />
                    <b>Colley Rating</b>: Rating calculated by Colley's bias free ranking method (only includes contests in classification.)<br />

                    <?php if ($information['incomplete_list']): ?>
                        <br />
                        <div style="color: #990000; font-weight: bold;">Where's My Team?</div>
                        Only teams that have played at least one rankable contest will be included on this page.  Some contests, like jamborees, are not rankable.  Some contests may have been finished, but the system is still waiting for a score to be submitted.

                    <?php endif; ?>

                    <?php if (!is_null($information['impacts'][$div])): ?>
                        <br /><br />

                        <h4>Effective Impact on RPI</h4>
                        The RPI formula uses a 1:1.86 ratio of WWP:OWP, the effective impact on a team's RPI for <?php echo $div; ?> <?php echo $activity_name; ?> was:
                        <div style="float: right; padding-top: 2.25em;">                            
                            <a href="<?php echo url('/help/rankings'); ?>"><u>Frequently Asked Questions</u></a>
                        </div>

                        <table style="margin: 0.5em 0 0 5em; width: 60%; border-collapse: collapse;">
                            <tr style="text-align: center; font-weight: bold;">
                                <td></td>
                                <td>Max</td>
                                <td>Min</td>
                                <td>Range</td>                                
                                <td>Effect</td>
                                <td>Weight</td>
                                <td>Impact</td>
                            </tr>
                            <tr style="text-align: center;">
                                <td style="text-align: right; font-weight: bold; border-bottom: 1px solid #d9e1e0;">WWP</td>
                                <td style="border-bottom: 1px solid #d9e1e0;"><?php echo number_format((float)$information['impacts'][$div]['wwp']['max'], 3); ?></td>
                                <td style="border-bottom: 1px solid #d9e1e0;"><?php echo number_format((float)$information['impacts'][$div]['wwp']['min'], 3); ?></td>
                                <td style="border-bottom: 1px solid #d9e1e0;"><?php echo number_format((float)$information['impacts'][$div]['wwp']['range'], 3); ?></td>
                                <td style="border-bottom: 1px solid #d9e1e0;"><?php echo number_format((float)$information['impacts'][$div]['wwp']['weight'], 3); ?></td>
                                <td  style="border-bottom: 1px solid #d9e1e0; border-top: 1px solid #d9e1e0; background-color: #f2f2f2;" rowspan="2"><?php echo number_format((float)$information['impacts'][$div]['wwp']['effect'], 3); ?></td>
                                <td style="border-bottom: 1px solid #d9e1e0; font-weight: bold;"><?php echo number_format((float)$information['impacts'][$div]['wwp']['percentage'], 0); ?>%</td>
                            </tr>
                            <tr style="text-align: center;">
                                <td style="text-align: right; font-weight: bold;">OWP</td>
                                <td><?php echo number_format((float)$information['impacts'][$div]['owp']['max'], 3); ?></td>
                                <td><?php echo number_format((float)$information['impacts'][$div]['owp']['min'], 3); ?></td>
                                <td><?php echo number_format((float)$information['impacts'][$div]['owp']['range'], 3); ?></td>
                                <td><?php echo number_format((float)$information['impacts'][$div]['owp']['weight'], 3); ?></td>
                                <td style="font-weight: bold;"><?php echo number_format((float)$information['impacts'][$div]['owp']['percentage'], 0); ?>%</td>
                            </tr>
                            
                        </table>

                    <?php endif; ?>

                </div>

            <?php else: ?>
               
                <h2>Unavailable</h2>
                <p>
                    Rankings are unavailable at this time.
                </p>

                <h3 style="color: #990000;">How soon at the start of the season will rankings appear on the website?</h3>
                <p>
                    Rankings will be available on the website beginning with the first contest date of each sports season.
                </p>

                <h3 style="color: #990000;">Why do the rankings look weird early in the season?</h3>
                <p>
                    The OSAA rankings system is a combination of two rankings systems.  The RPI rating is primarily a measurement of strength of schedule and how a team does against that schedule. The Colley rating is a measurement of teams' success rates marked against opponents within the same classification.
                </p>
                <p>
                    There are no pre-season expectations or polls included. Every team starts from scratch each season. Consequently, the numbers can be skewed early in the season because teams have played so few contests or completed against opponents outside their classification. The data begins to take shape as more contests are played. The more contests played, the better the data gets.
                </p>

                <p>
                    Learn more about OSAA Rankings by reading our <a href="<?php echo url('/help/rankings'); ?>"><u>Frequently Asked Questions</u></a>.
                </p>

            <?php endif; ?>           

        </div>

    <?php endforeach; ?>      

</div> 
