<script type="text/javascript" src="wp-content/themes/cvp-irontec/events/custom/js/scripts.js"></script>
<?php
do_action( 'bp_before_events_loop' );

$showevent  = 1;
$jes_adata  = get_site_option('jes_events' );
$eshowevent = $jes_adata['jes_events_addnavicatalog_disable'];
$sortby     = $jes_adata['jes_events_sort_by']; ?>

<?php if ( bp_jes_has_events( bp_ajax_querystring( 'events' )) ) : ?>

    <div class="pagination">
        <div class="pag-count" id="group-dir-count">
            <?php jes_bp_events_pagination_count(); ?>
        </div>
        <div class="pagination-links" id="group-dir-pag">
            <?php jes_bp_events_pagination_links(); ?>
        </div>
    </div>

<!-- <?php _e('Style:', 'buddypress'); ?> <?php _e($jes_adata['jes_events_style'],'jet-event-system'); ?> -->

    <?php 
    if ( !is_user_logged_in() and !$eshowevent ) {
    ?>
        <div id="message" class="info">
            <p><?php _e('Private events are not shown, register to view', 'buddypress'); ?></p>
        </div>
    <?php
    }
    
    if ($jes_adata['jes_events_style'] == 'Calendar') {
    ?>
    <script type="text/javascript" src="<?php echo WP_PLUGIN_URL . '/jet-event-system-for-buddypress/js/fullcalendar.min.js'; ?>"></script>
    <?php
    require_once ( WP_PLUGIN_DIR . '/jet-event-system-for-buddypress/main/jet-events-themetemplate.php' );
    ?>
    
    <script type="text/javascript">
        var jqr = jQuery;
        jqr(document).ready(function($) {
        $(document).ready(function() {
        var date = new Date();
        $("#icalendar").fullCalendar({
            editable: true,
            buttonText: {
                today: '<?php _e('today', 'buddypress'); ?>',
                month: '<?php _e('month', 'buddypress'); ?>',
                week:  '<?php _e('week', 'buddypress'); ?>',
                day:   '<?php _e('day', 'buddypress'); ?>'
            },
            dayNamesShort: ['<?php _e('Sun'); ?>','<?php _e('Mon'); ?>','<?php _e('Tue'); ?>','<?php _e('Wed'); ?>','<?php _e('Thu'); ?>','<?php _e('Fri'); ?>','<?php _e('Sat'); ?>'],
            monthNames: ['<?php _e('January'); ?>','<?php _e('February'); ?>','<?php _e('March'); ?>','<?php _e('April'); ?>','<?php _e('May'); ?>','<?php _e('June'); ?>','<?php _e('July'); ?>','<?php _e('August'); ?>','<?php _e('September'); ?>','<?php _e('October'); ?>','<?php _e('November'); ?>','<?php _e('December'); ?>',],
            monthNamesShort: ['<?php _e('Jan', 'buddypress'); ?>','<?php _e('Feb', 'buddypress'); ?>','<?php _e('Mar', 'buddypress'); ?>','<?php _e('Apr', 'buddypress'); ?>','<?php _e('May', 'buddypress'); ?>','<?php _e('Jun', 'buddypress'); ?>','<?php _e('Jul', 'buddypress'); ?>','<?php _e('Aug', 'buddypress'); ?>','<?php _e('Sep', 'buddypress'); ?>','<?php _e('Oct', 'buddypress'); ?>','<?php _e('Nov', 'buddypress'); ?>','<?php _e('Dec', 'buddypress'); ?>',],
            header: {
                left: 'title',
                center: '',
                right: 'basicWeek,month,today,prev,next' },
                events: [
    
    <?php while ( jes_bp_events() ) : bp_jes_the_event();
    
        $er = jes_bp_get_event_type();
    
    // Admin Approve
        $shiftcan = 0;
        $showeventnona = $jes_adata[ 'jes_events_adminapprove_enable' ];
    
    // Not Private Event?
        if ( !is_user_logged_in() and !$eshowevent and $er == 'Private Event' )
            {
                $showevent = 0;
            }
                else
            {
                $showevent = 1;
            }
    // Check Approved Event?
            if ( !jes_bp_get_event_eventapproved() and $showeventnona )
                {
                    if ( current_user_can('manage_options') )
                        { 
                            $showevent = 1;
                            $shiftcan = 1;
                        }
                            else
                        {
                            $showevent = 0;
                            $shiftcan = 0;
                        } 
                }
    if ( $showevent )
        {
    // Loop Templates
    
                    jes_theme_template_calendar();
        }
    endwhile; ?>
         {
            title:"end event",
            start: new Date(2009,11,1),
            end: new Date(2009,11,1)
        }
        ]
        });
        });
    });
    </script>
    
    <ul id="group-list" class="item-list">
        <div id="loading" style="display:none">loading...</div>
        <div id="icalendar"></div>
    </ul>
    
    <?php // endif;
    } else {
    ?>
    
    <style>
    #group-list li {
        margin: 10px 1px 10px 1px;
        padding: 0;
    }
    
    ul.item-list li div.meta {
        margin-top: 40px;
    }
    </style>
    
    <ul id="group-list" class="item-list" style=" width: 505px; ">
        <?php while ( jes_bp_events() ) : bp_jes_the_event();
        
            $er = jes_bp_get_event_type();
        
        // Admin Approve
            $shiftcan = 0;
            $showeventnona = $jes_adata[ 'jes_events_adminapprove_enable' ];
        
        // Not Private Event?
            if ( !is_user_logged_in() and !$eshowevent and $er == 'Private Event' )
                {
                    $showevent = 0;
                }
                    else
                {
                    $showevent = 1;
                }
        // Check Approved Event?
                if ( !jes_bp_get_event_eventapproved() and $showeventnona )
                    {
                        if ( current_user_can('manage_options') )
                            { 
                                $showevent = 1;
                                $shiftcan = 1;
                            }
                                else
                            {
                                $showevent = 0;
                                $shiftcan = 0;
                            } 
                    }
                
        if ( $showevent )
            {
        // Loop Templates
                if ($jes_adata['jes_events_style'] != 'Custom' )
                    {
                        require_once ( WP_PLUGIN_DIR . '/jet-event-system-for-buddypress/main/jet-events-themetemplate.php' );
                    }
            // Standart style Event Catalog 
                if ($jes_adata['jes_events_style'] == 'Standart') 
                    {
                        jes_theme_template_standart();
                }
        
            // Standard will full description
                if ($jes_adata['jes_events_style'] == 'Standard will full description') 
                    {
                        jes_theme_template_standartfull();
                }
        
            // Twitter style Event Catalog
                if ($jes_adata['jes_events_style'] == 'Twitter' )
                    {
                        jes_theme_template_twitter();
                }
        
            // Custom style Event Catalog
                if ($jes_adata['jes_events_style'] == 'Custom' ) 
                    {
                        if (file_exists(STYLESHEETPATH . '/events/looptemplates/custom.php'))
                            {
                                include('looptemplates/custom.php');
                            }
                                else
                            {
                                jes_theme_template_standart();
                            }
                }
            }
        endwhile;
        ?>
    </ul>
    <?php
    }
    
    do_action( 'bp_after_events_loop' );
    
    else:
    ?>
    
    <div id="message" class="info">
        <p><?php _e( 'There were no events found.', 'buddypress' ) ?></p>
    </div>
    
<?php
endif;
?>