﻿$(document).ready(function(){slideLabel();});
var rotateSlide = setInterval ( "displayNext(1000)", 6000 );
var animating;


function displayNext(switchSpeed) {
	var $active = $('.ImageSlideshow IMG.active');
    $active.addClass('last-active');
    animating = true;
	var $next =  $active.next('IMG').length ? $active.next('IMG') : $('.ImageSlideshow IMG:first');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, switchSpeed, function() {
            $active.removeClass('active last-active');
            animating = false;
        });
    var $activeThumb = $('.imgNav img.active');
    animating = true;
    var $nextThumb = $activeThumb.next('img').length ? $activeThumb.next('img') : $('.imgNav img:first');
    $activeThumb.removeClass('active');
    $nextThumb.addClass('active')
        .animate(switchSpeed, function() {
            slideLabel();
            animating = false;
        });
}

function displaySlide1(switchSpeed){
    $('.imgNav img.active').removeClass('active');
    $('.imgNav img:first').addClass('active');
    clearInterval(rotateSlide);
    $('.ImageSlideshow IMG.active').removeClass('active last-active');
    animating = true;    
    $('.ImageSlideshow IMG:first')
        .css({opacity: 0})
        .addClass('active')
        .animate({opacity: 1.0}), switchSpeed, function(){
            this.removeClass('active last-active');
            animating = false;
            };
    slideLabel();
    rotateSlide = setInterval("displayNext(1000)", 6000);
}

function displaySlide2(switchSpeed){
    $('.imgNav img.active').removeClass('active');
    $('.imgNav img:odd').addClass('active');
    clearInterval(rotateSlide);
    $('.ImageSlideshow IMG.active').removeClass('active last-active');
    animating = true;
    $('.ImageSlideshow IMG:odd')
        .css({opacity: 0})
        .addClass('active')
        .animate({opacity: 1.0}), switchSpeed, function(){
            this.removeClass('active last-active');
            animating = false;           
            };
    slideLabel();
    rotateSlide = setInterval("displayNext(1000)", 6000);
}

function displaySlide3(switchSpeed){
    $('.imgNav img.active').removeClass('active');
    $('.imgNav img:last').addClass('active');
    clearInterval(rotateSlide);
    $('.ImageSlideshow IMG.active').removeClass('active last-active');
    animating = true;
    $('.ImageSlideshow IMG:last')
        .css({opacity: 0})
        .addClass('active')
        .animate({opacity: 1.0}), switchSpeed, function(){
            this.removeClass('active last-active');
            animating = false;};
    slideLabel();
    rotateSlide = setInterval("displayNext(1000)", 6000);
}


function slideLabel() {
    $('.showCaseInner span').text($('.imgNav img.active').attr('alt'));
}
