﻿
var currentPage = 0;

jQuery(document).ready(function () {

    jQuery('.page-link').click(function (e) {
        e.preventDefault();

        $('.page-link').removeClass('on');
        $(this).addClass('on');
        var id = $(this).attr('href');
        var newIndex = $('.page-item').index($(id));

        if ($(this).hasClass('slide')) {
            if (newIndex > currentPage) {
                $('.current-page').animate({ left: "-1000px" }, 500);
                $(id).css({ display: 'block', left: '1000px' });
            } else {
                $('.current-page').animate({ left: "1000px" }, 500);
                $(id).css({ display: 'block', left: '-1000px' });
            }
            $(id).animate({ left: "0px" }, 500);
            $('.page-item').removeClass('current-page');
            $(id).addClass('current-page');
        }

        if ($(this).hasClass('vert')) {
            if (newIndex > currentPage) {
                $('.current-page').animate({ top: "-500px" }, 500);
                $(id).css({ display: 'block', top: '500px' });
            } else {
                $('.current-page').animate({ top: "500px" }, 500);
                $(id).css({ display: 'block', top: '-500px' });
            }
            $(id).animate({ top: "0px" }, 500);
            $('.page-item').removeClass('current-page');
            $(id).addClass('current-page');
        }


        if ($(this).hasClass('fade')) {
            $('.page-item:not(#' + id + ')').fadeOut(function () {
                $(id).fadeIn();
            });
        }

        currentPage = newIndex;

    });



    jQuery('.news-link').click(function (e) {

        e.preventDefault();


        var id = jQuery(this).attr('href');

        $.fn.colorbox({ width: 840, html: $(id).html() });

    });


    $("a[rel='lightbox']").colorbox();

    $("a[rel='lightbox-video']").colorbox({ iframe: true, innerWidth: 640, innerHeight: 480, onComplete: function () {
            $('#cboxNext,#cboxPrevious,#cboxCurrent').hide();
        } 
    });

});
