// slideshow events
function slideshowEvents_initCallback(carousel) {
    $('#slideshowEventsNext').bind('click', function() {
        carousel.next();
        return false;
    });

    $('#slideshowEventsPrevious').bind('click', function() {
        carousel.prev();
        return false;
    });
};


function slideshowEvents_itemFirstInCallback(carousel, item, idx, state) {
    if(idx == 1) {
        $('#slideshowEventsPrevious').addClass('disabled');
    }
};

function slideshowEvents_itemFirstOutCallback(carousel, item, idx, state) {
    if(idx == 1) {
        $('#slideshowEventsPrevious').removeClass('disabled');
    }
};

function slideshowEvents_itemLastInCallback(carousel, item, idx, state) {
    if(idx == $('#slideshowEvents li').length) {
        $('#slideshowEventsNext').addClass('disabled');
    }
};

function slideshowEvents_itemLastOutCallback(carousel, item, idx, state) {
    if(idx == $('#slideshowEvents li').length) {
        $('#slideshowEventsNext').removeClass('disabled');
    }
};


// slideshow topics
function slideshowTopics_initCallback(carousel) {
    $('#slideshowTopicsNext').bind('click', function() {
        carousel.next();
        return false;
    });

    $('#slideshowTopicsPrevious').bind('click', function() {
        carousel.prev();
        return false;
    });
};


function slideshowTopics_itemFirstInCallback(carousel, item, idx, state) {
    if(idx == 1) {
        $('#slideshowTopicsPrevious').addClass('disabled');
    }
};

function slideshowTopics_itemFirstOutCallback(carousel, item, idx, state) {
    if(idx == 1) {
        $('#slideshowTopicsPrevious').removeClass('disabled');
    }
};

function slideshowTopics_itemLastInCallback(carousel, item, idx, state) {
    if(idx == $('#slideshowTopics li').length) {
        $('#slideshowTopicsNext').addClass('disabled');
    }
};

function slideshowTopics_itemLastOutCallback(carousel, item, idx, state) {
    if(idx == $('#slideshowTopics li').length) {
        $('#slideshowTopicsNext').removeClass('disabled');
    }
};

$(document).ready (function() {
    $('#slideshow')
    .cycle({
        fx:         'fade',
        speed:      2500,
        timeout:    5000,
        delay:      4000,
        pager:      '#slideshowNavigation',
        slideExpr:  'img'
    });

    // events slideshow
    $('#slideshowEvents')
    .jcarousel({
        next:           '#slideshowEventsNext',
        prev:           '#slideshowEventsPrevious',
        initCallback: slideshowEvents_initCallback,
        scroll: 3,
        itemFirstInCallback:  slideshowEvents_itemFirstInCallback,
        itemFirstOutCallback: slideshowEvents_itemFirstOutCallback,
        itemLastInCallback:   slideshowEvents_itemLastInCallback,
        itemLastOutCallback:  slideshowEvents_itemLastOutCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });

    // topics slideshow
    $('#slideshowTopics')
    .jcarousel({
        next:           '#slideshowTopicsNext',
        prev:           '#slideshowTopicsPrevious',
        initCallback: slideshowTopics_initCallback,
        scroll: 3,
        itemFirstInCallback:  slideshowTopics_itemFirstInCallback,
        itemFirstOutCallback: slideshowTopics_itemFirstOutCallback,
        itemLastInCallback:   slideshowTopics_itemLastInCallback,
        itemLastOutCallback:  slideshowTopics_itemLastOutCallback,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });


});




