/* Scripter : jaejunyi version:1.0 Date : 2012.08.14 */ jQuery.noConflict(); var jQ = jQuery; jQ(function () { /* init set */ var myCount, // setInterval function name _posX, // position _left, // postion left reclick = 1, // prevenr from double click! _wrapper = jQ("#secondary"), _mover = jQ('.viewer ol'), btn_prev = jQ('.prev'), btn_next = jQ('.next'), //_easing = 'easeOutBounce' moveUnit = 133, // move gap _timer = 3000; // duration /*check position*/ function pos () { _posX = _mover.position(); _left = _posX.left; } /* Event Prev */ btn_prev.click(function () { if(reclick) { pos(); if (_left > -340) { btn_next.css({'cursor' : 'pointer'}); _mover.stop().animate({'left' : '-=133'}, 500, function () { reclick = 1; }); } else { _mover.stop().animate({left : 0}); btn_prev.css({'cursor' : 'default'}); return false; } reclick = 0; } }); /* Event Next */ btn_next.click(function () { if(reclick) { pos(); if (_left < -133) { btn_prev.css({'cursor' : 'pointer'}); _mover.stop().animate({'left' : '+=133'}, 500, function () { reclick = 1; }); } else { _mover.stop().animate({left : -400}); btn_next.css({'cursor' : 'default'}); return false; } reclick = 0; } }); /* Auto Move Call */ function moveTo() { myCount = setInterval(function () { pos(); if(_left < -1729) { clearInterval(myCount); _mover.stop().animate({left : 0}, 500, function () { moveTo(); }); } else { btn_prev.trigger('click'); } }, _timer); return myCount; } _wrapper.mouseenter(function () { clearInterval(myCount); }); _wrapper.mouseleave(function () { btn_next.css({'cursor' : 'pointer'}); btn_prev.css({'cursor' : 'pointer'}); moveTo(); }); window.onload = function () { moveTo(); } });