﻿/**///slideshow

var context = $('#tabSlideshow');

function onBefore() {
    $('.slideshow-nav li').removeClass('active');
    var navId = $(this).attr('rel');
    $('#' + navId).addClass('active');
}

$(document).ready(function () {
    var step = 1;
    var current = 0;
    var maximum = $('.slideshow-nav ul li').size();
    var visible = 4;
    var speed = 200;
    var liSize = 159;
    var carousel_height = 35;


    // handle / add attributes needed for navigation
    $('.slideshow-nav ul li').each(function (i) {
        $(this).attr('id', 'navigation-title-' + i);
    });

    $('#slideshow li').each(function (i) {
        $(this).attr('rel', 'navigation-title-' + i);
    });

        $('.slideshow-nav ul li a').each(function (i) {
            $(this).click(function () {
                $('#slideshow').cycle(i);
            });
        });

    var ulSize = liSize * maximum;
    var divSize = liSize * visible;
    $('#tabSlideshow .slideshow-nav ul').css("width", ulSize + "px").css("left", -(current * liSize)).css("position", "absolute");

    // generate 'more' tab
    if (maximum > visible) {
        $('.slideshow-nav.header').after('<div class="more"><a href="javascript:void(0);">more &raquo;</a></div>');
        $('.section.tabSLideshowBox .more a').click(function () {
            if (current + step < 0 || current + step > maximum - visible) { current = 0; }
            else
                current = current + step;

            $('#tabSlideshow .slideshow-nav ul').animate({ left: -(liSize * current) }, speed, null);

            return false;
        });
    }

    $('#slideshow').cycle({
        fx: 'fade',
        speed: 4000,
        timeout: 4000,
        pause: 1,
        before: onBefore
    });
});
