(function ($) {
	var playlist = mm.playlist = mm.extend({
		//初回時スクロール開始までのライムラグ
		initScrollTimeout: 500,
		//初回時スクロールの移動スピード(ミリ秒)
		initScrollSpeed: 800,
		//スクロールする移動スピード(ミリ秒)
		scrollSpead: 250,
		//スクロールする時間間隔(ミリ秒)
		interval: 5000,
		//liの高さ(px)
		itemHeight: 56,
		//移動個数(個)
		itemSet: 5,
		
//=========================================================================================//
		
		lock:  false,
		intTimer: null,
		outTimer: null,
		
		init: function () {
			var ul = $('div.frm-playlist-content ul');
			ul.css({top: this.itemHeight * ul.find('li').length * -1});
			setTimeout(this.bind(function () {
				ul.animate({top: 0}, this.initScrollSpeed);
				playlist.ctrl();
			}), this.initScrollTimeout);
		},
		
		ctrl: function () {
			var ul   = $('div.frm-playlist-content ul');
			var up   = $('li.frm-playlist-ctrl-up a');
			var down = $('li.frm-playlist-ctrl-down a');
			var max  = (ul.find('li').length - this.itemSet) * this.itemHeight * -1;
			var now  = 0;
			var min  = 0;
			var move;
			
			this.lock = false;
			
			up.click(this.bind(function () {
				if (this.lock || now >= min)
					return false;
				this.lock = true;
				
				move = this.itemHeight * this.itemSet;
				
				if ((now + move) > min)
					move = (this.itemSet - ((now + move) / this.itemHeight)) * this.itemHeight;
				
				ul.animate({top: '+=' + move}, this.scrollSpeed, this.bind(function () {
					now = parseInt(ul.css('top'));
					this.lock = false;
				}));
				
				return false;
			}));
			
			down.click(this.bind(function () {
				if (this.lock || now <= max)
					return false;
				this.lock = true;
				
				move = this.itemHeight * this.itemSet;
				
				if ((now - move) < max)
					move = (this.itemSet - (((now - move) - max) / this.itemHeight * -1)) * this.itemHeight;
				
				ul.animate({top: '-=' + move}, this.scrollSpeed, this.bind(function () {
					now = parseInt(ul.css('top'));
					this.lock = false;
				}));
				
				return false;
			}));
		}
	});
	
	$(playlist.bind(playlist.init));
})(jQuery);