jQuery.fn.scroller = function(options){
return this.each(function(){
	var content = $('.sc-1-content', this);
	var up = $('.sc-1-nav .up', this);
	var down = $('.sc-1-nav .down', this);
	content.css({'position':'relative', 'overflow':'hidden'});
	var scroller = $('<div class="content-scroller"></div>');
	scroller.css({'position':'absolute', 'left':0, 'top':0, 'width':'100%'});
	content.wrapInner(scroller);
	scroller = content.find('.content-scroller');
	/* Events */
	var state = {
		v_height: $(content).height(),
		c_height: $(scroller).height(),
		top: 0
	};	
	var scrollTo = function(delta, size){
		switch( size ){
		case 'wheel':
			var v_size = 20;
		break;
		case 'page':
			var v_size = state.v_height;
		break;
		}
		var move = true;
		if( delta < 0 ){
			var top = state.top - v_size;
			if( top <= state.v_height - state.c_height ){
				if( top != state.v_height - state.c_height ){
					move = false;
				}
				top = state.v_height - state.c_height;
				down.addClass('disabled');
			}else{
				down.removeClass('disabled');
			}
			up.removeClass('disabled');
		}else{
			var top = state.top + v_size;
			if( top >= 0 ){
				if( top != 0 ){
					move = false;
				}
				top = 0;
				up.addClass('disabled');
			}else{
				up.removeClass('disabled');
			}
			down.removeClass('disabled');
		}
		state.top = top;
		if( size == 'page' ){
			scroller.animate({'top': top + 'px'}, {duration:1000, queue:false});
		}else{
			scroller.css({'top': top + 'px'});
		}
		return move;
	}
	var timer = undefined;
	var interval = undefined;
	var timer_scroll = false;
	content.bind('mousewheel', function(e){
		if(e.wheelDelta > 0){
			if( scrollTo(1, 'wheel') ){
				e.preventDefault();
			}
		}else{
			if( scrollTo(-1, 'wheel') ){
				e.preventDefault();
			}
		}
	});
	up.mousedown(function(){		
		clearTimeout(timer);
		clearInterval(interval);
		timer_scroll = false;
		timer = setTimeout(function(){
			timer_scroll = true;
			interval = setInterval(function(){
				scrollTo(1, 'wheel');
			}, 100);
			scrollTo(1, 'wheel');
		}, 500);
		$(document).one('mouseup', function(){
			clearTimeout(timer);
			clearInterval(interval);
			if( !timer_scroll ){
				scrollTo(1, 'page');
			}
		});
	});
	down.mousedown(function(){
		clearTimeout(timer);
		clearInterval(interval);
		timer_scroll = false;
		timer = setTimeout(function(){
			timer_scroll = true;
			interval = setInterval(function(){
				scrollTo(-1, 'wheel');
			}, 100);
			scrollTo(-1, 'wheel');
		}, 500);
		$(document).one('mouseup', function(){
			clearTimeout(timer);
			clearInterval(interval);
			if( !timer_scroll ){
				scrollTo(-1, 'page');
			}
		});
	});
	/* Events */
});
}
