var _scroll_step = 0;
var _scroll_th = null;

var _scroll = function(elm) {
	if (_scroll_th != null)
		document.getElementById(elm).scrollLeft += _scroll_step;
}
var _scroll_stop = function() {
	if (_scroll_th != null) {
		window.clearInterval(_scroll_th);
		_scroll_th = null;
	}
}

$(function() {
	$(".scrollpane").find(".scroller a:last").css("border-right", "1px solid #fff").end().mousemove(function(e) {
		var x = e.pageX - $(this).offset().left;
		var max = $(this).width();

		if (x <= 300) {
			_scroll_step = (300-x)/30 * -5;
			if (_scroll_th == null)
				_scroll_th = window.setInterval("_scroll('" + this.id + "')", 100);
		}
		else if (x >= (max - 300)) {
			_scroll_step = ((max-300)-x)/30 * -5;
			if (_scroll_th == null)
				_scroll_th = window.setInterval("_scroll('" + this.id + "')", 100);
		}
		else _scroll_stop();

	}).mouseleave(function() { _scroll_stop() });

	$("a").focus(function() { this.blur() });
});
