﻿$(document).ready(function () {

    //Home Page Slideshow
    $('#slideshow').cycle({
        /*fx: 'fade',*/
        speed: 'fast',
        timeout: 6000,
        pager: '#nav',
        pagerAnchorBuilder: function (idx, slide) {
            // return sel string for existing anchor
            return '#nav li:eq(' + (idx) + ') a';
        },
        before: function (currSlideElement, nextSlideElement, options, forwardFlag) {
            var index = $(this).index();
            var tab = $('#nav li:eq(' + index + ')');
            tab.find('a').addClass('activeSlideCustom');
        },
        after: function (currSlideElement, nextSlideElement, options, forwardFlag) {
            var index = $(this).index();
            var tab = $('#nav li:eq(' + index + ')');

            if (tab.is(':visible')) {
                last_active_slide = tab;
                tab.siblings('li').find('a').removeClass('activeSlideCustom');
            }
            else {
                last_active_slide.find('a').addClass('activeSlideCustom');
            }
        }
    });

    $('#direct').click(function () {
        $('#nav li:eq(2) a').triggerHandler('click');
        return false;
    });

    $('#nav a').click(function () {
        $('#slideshow').cycle('pause');
    });
});
