$(function(){
$('.slides-wrap').each(function(){
var $container = $(this).find('.slides'),
$item = $container.find('span'),
$indicator = $(this).find('.indicator'),
indicatorHTML = '',
slideCount = $item.length,
currentIndex = 0,
duration = 0,
easing = 'linear',
interval = 7000,
timer = null;
$item.each(function (i){
var src = $(this).find('img').attr('src');
indicatorHTML += '
';
});
$indicator.html(indicatorHTML);
function mainGoToSlide (idx){
$item.removeClass('show');
$item.stop(true).animate({'opacity':0}, duration);
$item.eq(idx).addClass('show');
$('.show').stop(true).animate({'opacity':1}, duration);
currentIndex = idx;
updateNav();
}
function updateNav (){
$indicator.find('div').removeClass('active').eq(currentIndex).addClass('active');
}
function mainStartTimer (){
timer = setInterval(function (){
var nextIndex = (currentIndex + 1) %slideCount;
mainGoToSlide(nextIndex);
}, interval);
}
$indicator.find('div').on('click touchstart', function (){
if(!$(this).hasClass('active')){
mainGoToSlide($(this).index());
}
});
mainGoToSlide(currentIndex);
mainStartTimer();
});
$pagetop = $('#pagetop');
$pagetop.on('click', function(){
$('body, html').animate({ scrollTop: 0 }, 1000, 'easeOutExpo');
return false;
});
$(window).on('scroll', function(){
if($(window).scrollTop() > 200){
$pagetop.fadeIn();
}else{
$pagetop.fadeOut();
}
});
$(window).trigger('scroll');
$(window).on('load', function(){
});
});