﻿$(document).ready(function () {


    $("#events-total").text($('.UpCommingEvent').size());
    $("#news-total").text(Math.ceil(parseInt($('.SCCIPNews').size()) / 2));

    // UP COMMING EVENTS PAGING

    $('#ctl00_cphBody_hypUpCommingEventNext').click(function () {

        //get total count
        var total
        total = $('.UpCommingEvent').size();

        //get the rel of the currently displayed item
        var current
        current = $('.UpCommingEvent:visible').attr("rel");
        $("#events-current").text(current);

        if (current < total) {

            current = parseInt(current) + 1;
            $('.UpCommingEvent').hide();
            $('.UpCommingEvent[rel="' + current + '"]').show();

        }

        $("#events-current").text(current);

        return false;

    });

    $('#ctl00_cphBody_hypUpCommingEventPrevious').click(function () {

        //get total count
        var total;
        total = $('.UpCommingEvent').size();

        //get the rel of the currently displayed item
        var current;
        current = $('.UpCommingEvent:visible').attr("rel");

        if (current > 1) {

            current = parseInt(current) - 1;
            $('.UpCommingEvent').hide();
            $('.UpCommingEvent[rel="' + current + '"]').show();
        }

        $("#events-current").text(current);

        return false;

    });


    // SCCIP NEWS PAGING

    $('#ctl00_cphBody_hypSCCIPNewsNext').click(function () {

        //get total count - but dont forget to divide by the page count
        var total;
        total = parseInt($('.SCCIPNews').size()) / 2;


        //get the rel of the currently displayed item
        var current;
        current = $('.SCCIPNews:visible').attr("rel");

        // alert(current);
        if (current < total) {

            current = parseInt(current) + 1;
            $('.SCCIPNews').hide();
            $('.SCCIPNews[rel="' + current + '"]').show();

        }

        $("#news-current").text(current);

        return false;

    });

    $('#ctl00_cphBody_hypSCCIPNewsPrev').click(function () {

        //get total count - but dont forget to divide by the page count
        var total
        total = parseInt($('.SCCIPNews').size()) / 2;

        //get the rel of the currently displayed item
        var current
        current = $('.SCCIPNews:visible').attr("rel");

        // alert(current);
        if (current > 1) {

            current = parseInt(current) - 1;
            $('.SCCIPNews').hide();
            $('.SCCIPNews[rel="' + current + '"]').show();

        }

        $("#news-current").text(current);

        return false;

    });

});
