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

<?php $__env->startSection('page_sub_title'); ?>    
    <div class="today-navigation">
        <form name="search-article-form" method="GET" action="<?php echo url('/today/search'); ?>" accept-charset="UTF-8">
            <input type="text" name="title" title="Search articles by title" style="width: 125px;" />
            <img src="<?php echo asset('images/icons/magnifier_16px.png'); ?>" alt="" title="Search articles by title" style="cursor: pointer;" data-search="title" /><br />
        </form>
        
        <select name="search-author" title="Filter articles by author" style="width: 129px;">
            <option value=""></option>
            <?php foreach ($info['authors'] as $id => $author_item): ?>
                <option
                    value="<?php echo $id; ?>"
                    <?php if (!is_null($info['author']) and $id == $info['author']->id): ?>
                        selected="selected"
                    <?php endif; ?>
                    data-link="<?php echo $author_item->link; ?>"><?php echo $author_item->name; ?></option>
            <?php endforeach; ?>
        </select>
        <img src="<?php echo asset('images/icons/author_16px.png'); ?>" alt="" title="Filter articles by author" style="" /><br />
        
        <select name="search-tag" title="Filter articles by tag" style="width: 129px;">
            <option value=""></option>
            <?php foreach ($info['tags'] as $url => $tag_item): ?>
                <option
                    value="<?php echo $url; ?>"
                    <?php if (!is_null($info['tag']) and Helpers::strEqual($tag_item->name, $info['tag'])): ?>
                        selected="selected"
                    <?php endif; ?>
                    data-link="<?php echo $tag_item->link; ?>"><?php echo $tag_item->name; ?></option>
            <?php endforeach; ?>
        </select>
        <img src="<?php echo asset('images/icons/tag_16px.png'); ?>" alt="" title="Filter articles by tag" style="" /><br />
    </div>

    <a href="<?php echo url('/today'); ?>"><img src="<?php echo asset('/images/logos/OSAAtoday-Tagline.png'); ?>" data-hover-src="<?php echo asset('/images/logos/OSAAtoday-Tagline-Hover.png'); ?>" data-original-src="<?php echo asset('/images/logos/OSAAtoday-Tagline.png'); ?>" alt="" title="" style="" /></a>  

    <div class="specific">
        <?php if (!Helpers::strIsEmpty($info['specific'])): ?>
            <?php echo $info['specific']; ?> <a href="<?php echo url('/today'); ?>"><img src="<?php echo asset('/images/icons/not_selected_16px.png'); ?>" alt="" title="Remove filter and view all articles" /></a>
        <?php endif; ?>
    </div>
<?php $__env->stopSection(); ?>

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

    <style type="text/css">
        .page_functions {
            display: none;
        }

        h1 a {
            color: #990000;
        }

        h3 {
            color: #000000 !important;
        }

        .today-navigation {            
            float: right;
            font-family: Arial, Helvetica, sans-serif;
            font-size: 11pt;
            line-height: 1.5em;
        }

        .today-navigation img {
            vertical-align: middle;
            margin-left: 4px;
        }

        .specific {
            float: right;
            font-size: 12pt;
            line-height: 64px;
            margin-right: 40px;
        }

        .specific img {
            vertical-align: middle;
        }

        .horizontal_divider-2 {
            border-bottom-color: #dedede;
            border-bottom-width: 1px;
        }

        .article-list {

        }

        .article {
            height: 95px;
        }

        .article .thumbnail {
            float: left;
            margin-right: 20px;
            margin-bottom: 10px;
            width: 150px;
            height: 94px;
            text-align: center;
        }

        .article .thumbnail a {            
        }

        .article .thumbnail img {
            max-width: 150px;
            max-height: 94px;
            text-align: center;
            margin: 0 auto;
        }

        .article .sub_title {
            line-height: 1.25em;
        }

        .article .footer {
            color: #777777;
        }

        .article-footer {
            background-image: url('/images/logos/OSAAtoday-BG.png');
            background-repeat: no-repeat;
            background-position: right center;
            border-top: 2px solid #d9e1e0;
            border-bottom: 2px solid #d9e1e0;
            background-color: #f2f2f2;
            width: 1030px;
            height: 84px;
            padding: 0.5em 0;
            margin: 0.25em 0 2.5em 0;
        }
        .article-footer .author-photo-holder {
            width: 64px;
            height: 80px;
            margin: 0 1em 0 0.5em;
            background-color: #7d7b7d;
            border: 1px solid #ffffff;
            float: left;
        }
        .article-footer .author-photo img {
            width: 64px;
            height: 80px;
            margin: 0 1em 0 0.5em;  
            border: 1px solid #222222;
            float: left;
        }
        .article-footer .author-name {
            font-size: 13pt;
            font-weight: bold;
        }
        .article-footer .author-role {
            color: #000c67;
            font-size: 10pt;
            padding-top: 30px;
        }
        .article-footer .author-contact {
            font-size: 10pt;
            padding-top: 1.5em;
        }
        .article-footer .author-social-media {
            margin-top: 0.5em;
        }
        .article-footer .author-social-media a {
            margin-right: 12px;
        }

        .pagination {
            height: 3em;
            font-size: 10pt;
            padding-top: 1em;
        }

        .pagination .page_button {
            padding: 1em;
            background-color: #0d2458;
            color: #ffffff;
            margin: 1em 0.25em 1em 0;
            font-weight: bold;
        }

        .pagination .page_button:hover {
            background-color: #005fa9;
            text-decoration: none;
        }

        .pagination .page_button.current_page {
            background-color: #990000;
        }

        .pagination .page_button.direct_jump {
            padding-left: 1.5em;
            padding-right: 1.5em;
        }


    </style>    

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

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

    $('.page_functions').remove();
    $('#championships').remove();
    $('.specific img').tooltip();

    $('.thumbnail a img').each(function(index, item)
    {
        var height = item.clientHeight;
        var full_height = $(item).parents('.thumbnail').height();                        

        if (height < full_height && height > 10)
        {
            var top_margin = (full_height - height) / 2;
            $(item).css({'margin-top' : top_margin + 'px'});
        }
    });

    var space = '<div style="height: 1em;">&nbsp;</div>';
    var more = '<?php echo AdsController::getAd('160x600'); ?>';    
    var more_2 = '<?php echo AdsController::getAd('160x600'); ?>';
    <?php /*  var more_3 = '<?php echo AdsController::getAd('160x600'); ?>';
    var more_4 = '<?php echo AdsController::getAd('160x600'); ?>';
    var more_5 = '<?php echo AdsController::getAd('160x600'); ?>';
    var more_6 = '<?php echo AdsController::getAd('160x600'); ?>';  */ ?>

    $('#wide_scraper_ad')
        .css({'height' : 'auto'})
        .append(space, more, space, more_2);

    function searchTitle()
    {
        var field = $('input[type="text"][name="title"]');
        var value = field.val();

        var form = field.parent('form');

        console.log('searching for ' + value);

        form.submit();
    }

    $('.today-navigation img').tooltip();
    $('[name="title"]')
        .on('change', searchTitle)
        .tooltip();
    $('img[data-search="title"]').on('click', searchTitle);
    $('[name="search-author"]')
        .on('change', function(event)
        {
            var option = $('option:selected', $(this));
            var value = option.val();
            var link = option.attr('data-link');

            if (value == "")
            {
                window.location = "<?php echo url('/today'); ?>";
            }
            else
            {
                window.location = link;
            }
        })
        .tooltip();
    $('[name="search-tag"]')
        .on('change', function(event)
        {
            var option = $('option:selected', $(this));
            var value = option.val();
            var link = option.attr('data-link');

            if (value == "")
            {
                window.location = "<?php echo url('/today'); ?>";
            }
            else
            {
                window.location = link;
            }
        })
        .tooltip();

    $('a img[data-hover-src]').hover(function()
    {
        $(this).attr('src', $(this).attr('data-hover-src'));
    },
    function()
    {
        $(this).attr('src', $(this).attr('data-original-src'));
    });

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

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


<?php $__env->startSection('main_content'); ?>    
    
    <?php /*  Errors  */ ?>
    <?php if (Session::has('errors')): ?>        
        <div class="error ui-state-error" style="padding: 0.5em; font-size: 12pt;">
            <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 /*  Author, if specified  */ ?>
    <?php if (!is_null($info['author'])): ?>
        <div class="article-footer">        
            <div class="columns">
                <div class="half">
                    <?php if (is_null($info['author']->photo_path)): ?>
                        <div class="author-photo-holder">       
                        </div>
                    <?php else: ?>
                        <div class="author-photo">      
                            <img src="<?php echo asset($info['author']->photo_path); ?>" alt="" title="" />
                        </div>
                    <?php endif; ?>          
                    <div class="author-name"><?php echo $info['author']->getName(); ?></div>         
                    <div class="author-role">
                        <?php echo $info['author']->title; ?><br />  
                        <?php echo $info['author']->outlet; ?><br />
                    </div>
                </div>
                <div class="half">
                    <div class="author-contact">
                        <a href="mailto:<?php echo Helpers::obfuscateEmailAddress($info['author']->getEmail(false)); ?>"><img src="<?php echo asset('/images/icons/email_icon_16px.png'); ?>" alt="" title="" style="vertical-align: middle; margin-right: 1em;" /><?php echo Helpers::obfuscateEmailAddress($info['author']->getEmail(false)); ?></a>
                    </div>
                    <div class="author-social-media">                   
                        <?php foreach ($info['author']->getSocialMediaHandles() as $handle): ?>                      
                            <a href="<?php echo $handle->link; ?>" target="_blank"><img src="<?php echo $handle->icon; ?>" alt="" title="<?php echo $handle->handle; ?>" /></a>
                        <?php endforeach; ?>
                    </div>              
                </div>
            </div>
        </div>
    <?php endif; ?>

    <?php /*  List of Articles  */ ?>
    <div class="article-list">
        
        <?php            
            $index = -1;            

            // Debug pagination
            if (Helpers::isGibby())
            {
                echo "\n<!--\n\nPagination Data:\n";             
                print_r($info['pagination']);                
                echo "\n-->";
            }
        ?>

        <?php for($i = $info['pagination']['start_index']; $i < $info['pagination']['end_index']; $i++): ?>        

            <?php
                $index++;                
                if ($i + 1 > $info['pagination']['article_count'])
                {
                    continue;
                }
            
                // Get the articles at the specified index
                $article = $info['articles'][$i];
            ?>

            <?php /*  Ad  */ ?>
            <?php if ($index % 4 == 3): ?>
                <!-- Large Leaderboard Ad (970x90) -->                
                <div id="leaderboard_ad" class="ad" style="margin-left: 146px;">
                    <?php echo AdsController::getAd('728x90'); ?>
                </div>

                <br class="clear" />
                <div class="horizontal_divider horizontal_divider-2" style="width: 100%; margin-top: 1em;"></div>                    
            <?php endif; ?>

            <?php /*  Article  */ ?>
            <div class="article">
                <div class="thumbnail">
                    <a href="<?php echo url('/today/article/' . $article->id . '/view?title=' . urlencode($article->title)); ?>"><img src="<?php echo asset($article->photo_path); ?>" alt="" title="" /></a>
                </div>                
                <div class="title">
                    <h1><a href="<?php echo url('/today/article/' . $article->id . '/view?title=' . urlencode($article->title)); ?>"><?php echo $article->title; ?></a></h1>
                </div>
                <div class="sub_title">
                    <h2><?php echo $article->sub_title; ?></h2>
                </div>
                <div class="footer">
                    <?php echo date('l F j, Y', strtotime($article->published_at)); ?> by <a href="<?php echo url('/today/author/' . $article->getAuthor()->id . '/' . str_replace(' ', '_', $article->getAuthor()->getName())); ?>"><?php echo $article->getAuthor()->getName(); ?></a> | <?php echo $article->getAuthor()->getRole(); ?><br />
                    <?php if (!Helpers::strIsEmpty($article->tags)): ?>
                        <?php foreach(explode(',', $article->tags) as $tag_index => $tag): ?>
                            <a href="<?php echo url('/today/tag/' . urlencode(str_replace('/', '-', trim($tag)))); ?>"><?php echo trim($tag); ?></a>
                            <?php if (($tag_index + 1) < count(explode(',', $article->tags))): ?> | <?php endif; ?>
                        <?php endforeach; ?>
                    <?php endif; ?>
                    
                </div>
            </div>                        
            
            <?php /*  Divider  */ ?>
            <div class="horizontal_divider horizontal_divider-2" style="width: 100%;"></div>                

        <?php endfor; ?>
    </div>

    <div class="pagination">

        <?php
            $add_on = null;
            if (Input::has('title'))
            {
                $add_on = '&title=' . Input::get('title');
            }
        ?>


        <?php if ($info['pagination']['page'] - 1 >= 1): ?>            
            <a href="?page=1<?php echo $add_on; ?>" class="page_button relative_jump">First</a>
            <a href="?page=<?php echo ($info['pagination']['page'] - 1) . $add_on; ?>" class="page_button relative_jump">Back</a>
        <?php endif; ?>        

        <?php if ($info['pagination']['page'] < $info['pagination']['page_count']): ?>
            <a href="?page=<?php echo ($info['pagination']['page'] + 1) . $add_on; ?>" class="page_button relative_jump">Next</a>
            <a href="?page=<?php echo $info['pagination']['page_count'] . $add_on; ?>" class="page_button relative_jump">Last</a>
        <?php endif; ?>

        <div style="display: inline-block; width: 50px;"></div>

        <?php for ($i = $info['pagination']['page_range_start']; $i <= $info['pagination']['page_range_end']; $i++): ?>

            <a href="?page=<?php echo $i . $add_on; ?>" class="page_button direct_jump <?php echo ($i == $info['pagination']['page']) ? 'current_page' : null; ?>"><?php echo $i; ?></a>

        <?php endfor; ?>

    </div>


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