iScrollBy = 0; scrollTimeout = 0; ppTimeout = 0; interestsBox = null; keepScrolling = false; function start_scroll(dir, one_time) { keepScrolling = true; iScrollBy = dir; scrollSpeed = 1; outerWid = Math.max(0, $('#tScroller').width() - 500); scroll_interests(); } function stop_scroll() { keepScrolling = false; clearTimeout(scrollTimeout); } function scroll_interests() { if ( keepScrolling ) { interestsBox.css('margin-left', Math.max(Math.min(0, parseInt(interestsBox.css('margin-left'))+(iScrollBy*scrollSpeed)), -outerWid)); scrollTimeout = setTimeout('scroll_interests()', 15); scrollSpeed = Math.min(scrollSpeed+0.1, 20); } } function init_scroller() { interestsBox = $('#scrollBox'); interestsBox.css('margin-left', '0px'); } $(document).ready(init_scroller);