$(document).ready(function() { var g = true; var m = 8000; var e = 2000; $('#scroller ul li:first').css('left', '0px'); var f = $('#scroller ul li').length; var c = $('#scroller ul').width(); var a = 1; var d = false; var i = true; function j() { if (g) { setTimeout(j, m) } if (!i && g) { k() } else { i = false } } if (f > 1) { j() } $('#scroll_next').click(function(b) { b.preventDefault(); g = false; if (!d && f > 1) { k() } }); function k() { var b = a + 1; l(b) } $('#scroll_previous').click(function(b) { b.preventDefault(); g = false; if (!d && f > 1) { d = true; $('#scroller ul li:nth-child(' + a + ')').stop(true, true).animate({ left: '+=' + c }, e, "easeInOutQuart"); a--; if (a < 1) { a = f } $('#scroller ul li:nth-child(' + a + ')').css('left', '-' + c + 'px'); $('#scroller ul li:nth-child(' + a + ')').stop(true, true).animate({ left: '+=' + c }, e, "easeInOutQuart", function() { d = false }) } }); $('#nav_list > li').click(function(b) { b.preventDefault(); g = false; if (!d && f > 1) { var h = $(this).index() + 1; l(h) } }); function l(b) { if (b != a) { var h = b > a; if (h) { $('#scroller ul li:nth-child(' + a + ')').stop(false, true).animate({ left: '-=' + c }, e, "easeInOutQuart") } else { $('#scroller ul li:nth-child(' + a + ')').stop(true, true).animate({ left: '+=' + c }, e, "easeInOutQuart") } $('#scroller_nav ul li:nth-child(' + a + ') a').attr('class', ''); a = b; if (a > f) { a = 1 } if (h) { $('#scroller ul li:nth-child(' + a + ')').css('left', c + 'px'); $('#scroller ul li:nth-child(' + a + ')').stop(false, true).animate({ left: '-=' + c }, e, "easeInOutQuart", function() { d = false }) } else { $('#scroller ul li:nth-child(' + a + ')').css('left', '-' + c + 'px'); $('#scroller ul li:nth-child(' + a + ')').stop(true, true).animate({ left: '+=' + c }, e, "easeInOutQuart", function() { d = false }) } $('#scroller_nav ul li:nth-child(' + a + ') a').attr('class', 'active') } } }); 
