// JavaScript Document (function($) { $.fn.slide = function() { var $that = $(this); var m, k, x, y = 0; for ( var i = 0; i < $that.children().children().children().length; i++) { if (i == 0) { $that.find('.r_focus a').first().before( $('')); } else { $that.find('.r_focus a').first().before($('')); } } var n = $that.children().eq(1).children().length - 1; $that .children() .eq(1) .children() .click( function() { m = $(this).index(); clearInterval(k); if (m == n && $that.children().eq(0).scrollLeft() < $that .children().eq(0).children() .width() - $that.children().eq(0).width()) { k = setInterval( function() { x = $that.children().eq(0) .scrollLeft(); x += 10; y += 10; $that.children().eq(0) .scrollLeft(x); if (y % $that.children().eq(0) .width() == 0) { stopScroll(); } }, 5); } else if (m == (n - 1) && $that.children().eq(0).scrollLeft() >= 0) { k = setInterval( function() { x = $that.children().eq(0) .scrollLeft(); x -= 10; y -= 10; $that.children().eq(0) .scrollLeft(x); if (y % $that.children().eq(0) .width() == 0) { stopScroll(); } }, 5); } return false; function stopScroll() { $that.children().eq(1).children('a').eq(0) .addClass('r_left'); $that.children().eq(1).children('a').eq(1) .addClass('r_right'); if ($that.children().eq(0).scrollLeft() >= ($that .children().eq(0).width()) * ($that.children().eq(0).children() .children().length - 1)) { $that.children().eq(1).children('a').eq(1) .removeClass('r_right'); } else if ($that.children().eq(0).scrollLeft() <= 0) { $that.children().eq(1).children('a').eq(0) .removeClass('r_left'); } $that.children().eq(1).children( 'span.r_current').removeClass( 'r_current'); switch ($that.children().eq(0).scrollLeft()) { case 0: $that.children().eq(1).children('span').eq( 0).addClass('r_current'); break; case ($that.children().eq(0).width()): $that.children().eq(1).children('span').eq( 1).addClass('r_current'); break; case ($that.children().eq(0).width() * 2): $that.children().eq(1).children('span').eq( 2).addClass('r_current'); break; case ($that.children().eq(0).width() * 3): $that.children().eq(1).children('span').eq( 3).addClass('r_current'); break; } clearInterval(k); } }); } })(jQuery);