// ------------------------------------------------------------------
// HD.rolling
// ------------------------------------------------------------------
// update : 2011.6.22
// ------------------------------------------------------------------
HD.object({rolling:{
	dir:["left", "right", "up", "down"],
	// ------------------------------------------
	// create
	// ------------------------------------------
	create:function(){
		return {
			id:null,		// ·Ñ¸µ°³Ã¼ id					(¿ÜºÎÀÔ·Â)
			list:[],		// list
			action:"push",	// push | fade | slide | zigzag | drop | tetris (¿ÜºÎÀÔ·Â ¿µ¹®°ª)
			flow:"repeat",	// repeat | reverse
			display:"in",	// in | out
			direction:3,	// 0 left, 1 right 2 up 3 down  (¿ÜºÎÀÔ·Â ¿µ¹®°ª)
			speed:1,		// speed (px)					(¿ÜºÎÀÔ·Â ÃÖ¼Ò°ª 1)
			delay:50,		// anim delay (ms)				(¿ÜºÎÀÔ·Â ÃÖ¼Ò°ª 10)
			waiting:2000,	// waiting time (ms)			(¿ÜºÎÀÔ·Â ÃÖ¼Ò°ª 0)
			slide_bk:"white",// ½½¶óÀÌµå¿ë ¹è°æ»ö			(¿ÜºÎÀÔ·Â ÄÃ·¯¸íorÄÃ·¯ÄÚµå)
			pause:false,	// ÁßÁö
			lock:false		// ¶ô
		};
	},
	// ------------------------------------------
	// init
	// ------------------------------------------
	init:function(params)
	{
		D.ready(function(){
			this.id = params.id;
			this.view = D.byId(this.id);
			if(!this.view) return alert("·Ñ¸µ°³Ã¼¸¦ Ã£À» ¼ö ¾ø½À´Ï´Ù");
			
			// -- ¿ÜºÎ ÀÔ·Â -- //
			if(params.action) this.action = params.action;
			if(params.speed) this.speed = params.speed;
			if(params.delay) this.delay = params.delay;
			if(params.slide_bk) this.slide_bk = params.slide_bk;
			if(params.waiting || params.waiting===0) this.waiting = params.waiting;
			this.set_direction(params.direction);
			
			// -- ¾ÆÀÌÅÛ ¼öÁý -- //
			for(var node=this.view.firstChild; node; node=node.nextSibling){
				if(node.nodeType==1)
					this.list.push(node.cloneNode(true));
			}
		
			this.draw_base();
			if(this.display=="out")
				this.play();
			else if(this.display=="in"){
				window.setTimeout(J.func(function(){
					this.play();
				}, this), this.waiting);
			}
		}, this);
		return this;
	},
	// ------------------------------------------
	// set_direction
	// ------------------------------------------
	set_direction:function(dir)
	{
		if(!dir) return;
		dir = dir.toLowerCase();
		for(var i=0; i<this.dir.length; i++)
		{
			if(dir==this.dir[i]){
				this.direction = i;
				break;
			}
		}
	},
	// ------------------------------------------
	// draw base
	// ------------------------------------------
	draw_base:function()
	{
		// -- ¹Ø¿¡ 3°³ ¼ø¼­ ¹Ù²Ù¸é ¾ÈµÊ -- //
		this.view.css({dis:0,p:[0,0,0,0]});
		this.view.innerHTML = "";
		var view_height = this.view.offsetHeight-4;

		// -- ÄÁÅ×ÀÌ³Ê »ý¼º -- //
		var box = D.table(D.tbody(D.tr()), {ps:2,pos:[0,0],z:2, ov:2, op:1.0, h:view_height}, {cs:0,cp:0});
		box.op = 1.0;
		box.pos = 0;
		box.pos_end = 0;
		box.pos_start = 0;
		var box2 = D.table(D.tbody(D.tr()), {ps:2,pos:[0,0],z:1,ov:2, op:0.0, h:view_height}, {cs:0,cp:0});
		var container = D.div([box,box2], {ws:1, ov:2, z:5, h:view_height, ps:1,pos:[0,0],m:[0,0,1,0]});

		if(this.direction>1){
			box.vnode(0).empty();
			box2.vnode(0).empty();
		}
		this.box = box;
		this.box2 = box2;
		this.container = container;
		this.view.appendChild(container);

		// -- ¾ÆÀÌÅÛ Ã¤¿ì±â -- //
		for(var i=0; i<this.list.length; i++)
			this.push_item(i);

		if(this.display=="out"){
			if(this.direction==0){
				this.box.style.left = this.container.offsetWidth +"px";
			}
			else if(this.direction==1){
				this.box.style.left = -this.box.offsetWidth +"px";
			}
		}
		
		// -- ÄÁÅ×ÀÌ³Ê ¸¶¿ì½º ¿À¹ö -- //
		this.container.ev_mouseover(function(e){
			this.pause = true;
			this.stop();
		}, this);
		
		// -- ÄÁÅ×ÀÌ³Ê ¸¶¿ì½º ¾Æ¿ô -- //
		this.container.ev_mouseout(function(e){
			this.pause = false;
			this.play();
		}, this);
	},
	// ------------------------------------------
	// ¾ÆÀÌÅÛÀ» Ã¤¿ö³ÖÀ½
	// ------------------------------------------
	push_item:function(i)
	{
		if(this.direction<2)
			this.box.vnode(0,0).appendChild(D.td(this.list[i].cloneNode(true), {va:0}));
		else
			this.box.vnode(0).appendChild(D.tr(D.td(this.list[i].cloneNode(true), {va:0})));
	},
	// ------------------------------------------
	// ¿ÞÂÊ ¶Ç´Â À§·Î ¹æÇâ ÀüÈ¯ (»ç¿ëÀÚ ¹öÆ°)
	// ------------------------------------------
	turn_left:function()
	{
		if(this.direction<2) this.move_play(0, true);
		else this.move_play(2, true);
	},
	// ------------------------------------------
	// ¿À¸¥ÂÊ ¶Ç´Â ¾Æ·¡·Î ¹æÇâ ÀüÈ¯ (»ç¿ëÀÚ ¹öÆ°)
	// ------------------------------------------
	turn_right:function()
	{
		if(this.direction<2) this.move_play(1, true);
		else this.move_play(3, true);
	},
	// ------------------------------------------
	// ¿ÞÂÊ ¶Ç´Â À§·Î ¹æÇâ ÀüÈ¯ (»ç¿ëÀÚ ¹öÆ°)
	// ------------------------------------------
	turn_up:function()
	{
		this.turn_left();
	},
	// ------------------------------------------
	// ¿À¸¥ÂÊ ¶Ç´Â ¾Æ·¡·Î ¹æÇâ ÀüÈ¯ (»ç¿ëÀÚ ¹öÆ°)
	// ------------------------------------------
	turn_down:function()
	{
		this.turn_right();
	},
	// ------------------------------------------
	// play (»ç¿ëÀÚ ¹öÆ°)
	// ------------------------------------------
	play:function(instant)
	{
		if(instant){
			this.pause = false;
			this.move_play(this.direction);
		}
		else{
			if(this.waiting)
				window.setTimeout(J.func(function(){ this._start(true); }, this), this.waiting);
			else{
				this._start(true);
			}
		}
	},
	// ------------------------------------------
	// ÇÃ·¹ÀÌ
	// ------------------------------------------
	_play:function()
	{
		if(!this.pause){
			if(this.waiting)
				window.setTimeout(J.func(function(){ this._start(); }, this), this.waiting);
			else
				this._start();
		}
	},
	// ------------------------------------------
	// ½ÃÀÛ
	// ------------------------------------------
	_start:function(always)
	{
		if(this.pause && !always) return;
		this.pause = false;
		this.move_play(this.direction);
	},
	// ------------------------------------------
	// stop (»ç¿ëÀÚ ¹öÆ°)
	// ------------------------------------------
	stop:function()
	{
		this.pause = true;
		this.move_stop();
	},
	// ------------------------------------------
	// ¿òÁ÷ÀÎ´Ù
	// ------------------------------------------
	move_play:function(dir, instant)
	{
		if(this.action=="push")
		{
			window.clearInterval(this.tid);
			instant = (instant && this.direction==dir);
			this.direction = dir;
			if(dir==0) this.push_left(instant);
			else if(dir==1) this.push_right(instant);
			else if(dir==2) this.push_up(instant);
			else if(dir==3) this.push_down(instant);
		}
		else if(this.action=="fade")
		{
			if(instant) return this.instant(dir);
			if(this.lock) return;	// ¶ôÀÌ °É¸° °æ¿ì Ã³¸® ¾ÈÇÔ
			this.lock = true;		// ¶ôÀ» °Ç´Ù
			this.direction = dir;
			if(dir==0) this.fade_left();
			else if(dir==1) this.fade_right();
			else if(dir==2) this.fade_up();
			else if(dir==3) this.fade_down();
		}
		else if(this.action=="slide")
		{
			if(this.lock && !instant) return;
			this.lock = true;		// ¶ôÀ» °Ç´Ù
			this.direction = dir;
			if(dir==0) this.slide_left(instant);
			else if(dir==1) this.slide_right(instant);
			else if(dir==2) this.slide_up(instant);
			else if(dir==3) this.slide_down(instant);
		}
	},
	// ------------------------------------------
	// ¸ØÃá´Ù
	// ------------------------------------------
	move_stop:function()
	{
		if(this.action=="push")
		{
			window.clearInterval(this.tid);
			this._play();
		}
		else if(this.action=="fade")
		{
			if(!this.lock) return; // ¶ôÀÌ °É·Á ÀÖÁö ¾ÊÀ¸¸é
			window.clearInterval(this.tid);

			if(this.box.op>0.2){
				this.box2.empty();
				this.box2.css({op:0.0,z:1});
				this.box.css({op:1.0});
				this.box.op = 1;
			}
			else{
				this.box.empty();
				this.box.appendChild(this.box2.vnode(0).cloneNode(true));
				this.box.op = 1;
				this.box2.empty();
				this.box2.css({op:0.0,z:1});
				this.box.css({op:1.0});
			}
			this.lock = false;
			this._play();
		}
		else if(this.action=="slide")
		{
			if(!this.lock) return; // ¶ôÀÌ °É·Á ÀÖÁö ¾ÊÀ¸¸é
			window.clearInterval(this.tid);
			this.lock = false;
			this._play();
		}
	},
	// ------------------------------------------
	// Çª½Ã ÁØºñ (ºí·° À§Ä¡ ÀçÁ¶Á¤)
	// ------------------------------------------
	push_begin:function(direction)
	{
		if(!this.display=="in" || !this.flow=="repeat") return;

		var pivot_left = -this.box.offsetLeft;						// containerÀÇ ½ÃÀÛÀ§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)
		var pivot_right = pivot_left + this.container.offsetWidth;	// containerÀÇ ³¡ À§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)

		var pivot_top = -this.box.offsetTop;						// containerÀÇ ½ÃÀÛÀ§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)
		var pivot_bottom = pivot_top + this.container.offsetHeight;	// containerÀÇ ³¡ À§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)

		if(direction==0){
			var tr = this.box.vnode(0,0);
			var node = tr.firstChild;
			var left = node.offsetLeft;
			var offset = node.offsetWidth;
			var right = left + offset;
			if(right <= pivot_left){
				tr.removeChild(node);
				tr.appendChild(node);
				this.box.style.left = parseInt(this.box.style.left)+offset+"px";
			}
		}
		else if(direction==1){
			var tr = this.box.vnode(0,0);
			var node = tr.lastChild;
			var left = node.offsetLeft;
			var offset = node.offsetWidth;
			if(pivot_right<=left){
				tr.removeChild(node);
				tr.insertat(0, node);
				this.box.style.left = parseInt(this.box.style.left)-offset+"px";
			}
		}
		else if(direction==2){
			var tbody = this.box.vnode(0);
			var tr = tbody.firstChild;
			var node = tr.firstChild;
			var top = node.offsetTop;
			var offset = node.offsetHeight;
			var bottom = top+offset;
			if(bottom <= pivot_top){
				tbody.removeChild(tr);
				tbody.appendChild(tr);
				this.box.style.top = parseInt(this.box.style.top)+offset+"px";
			}
		}
		else if(direction==3){
			var tbody = this.box.vnode(0);
			var tr = tbody.lastChild;
			var node = tr.firstChild;
			var top = node.offsetTop;
			var offset = node.offsetHeight;
			if(pivot_bottom<=top){
				tbody.removeChild(tr);
				tbody.insertat(0, tr);
				this.box.style.top = parseInt(this.box.style.top)-offset+"px";
			}
		}
	},
	// ------------------------------------------
	// Çª½Ã ¿ÞÂÊ
	// ------------------------------------------
	push_left:function(instant)
	{
		this.push_begin(0);
		var pivot_left = -this.box.offsetLeft;						// containerÀÇ ½ÃÀÛÀ§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)
		var pivot_right = pivot_left + this.container.offsetWidth;	// containerÀÇ ³¡ À§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)

		var to = null;
		for(var node=this.box.vnode(0,0).firstChild; node; node=node.nextSibling)
		{
			var left = node.offsetLeft;				// nodeÀÇ ½ÃÀÛÀ§Ä¡
			var right = left + node.offsetWidth;	// nodeÀÇ ³¡ À§Ä¡
			if(left<= pivot_left && pivot_left < right){
				to = -right;
				break;
			}
		}
		if(to===null){
			var box_left = 0;						// boxÀÇ ½ÃÀÛÀ§Ä¡
			var box_right = this.box.offsetWidth;	// boxÀÇ ³¡ À§Ä¡
			if(box_right<=pivot_left){		// ´õÀÌ»ó ÀÌµ¿ÇÒ °ÍÀÌ ¾ø´Â °æ¿ì
				if(this.flow=="repeat"){	// ÀüÃ¼¸¦ ¿À¸¥ÂÊ ±¸¼®À¸·Î ¹Î´Ù
					this.box.style.left = this.container.offsetWidth+"px";
					return this.move_left(on);
				}
				else if(this.flow=="reverse"){ // ¹æÇâÀ» ¹Ù²Û´Ù
					this.direction = 1;
					return this.move_right(on);
				}
				else{
				//	window.status = "no flow";
					return;
				}
			}
			if(box_left>pivot_left){	// ¿ÞÂÊ¼±¿¡ °É·Á ÀÖÁö ¾ÊÀº °æ¿ì
				to = box_left;
			}
		}
		window.clearInterval(this.tid);
		if(instant){
			this.box.style.left = to+"px";
			this.pause = true;
			return this.move_stop();
		}
		this.tid = window.setInterval(J.func(function(){
			var pos = parseInt(this.box.style.left) - this.speed;
			if(pos<=to){
				this.box.style.left = to+"px";
				return this.move_stop();
			}
			this.box.style.left = pos+"px";
		}, this), this.delay);
	},
	// ------------------------------------------
	// Çª½¬ ¿À¸¥ÂÊ
	// ------------------------------------------
	push_right:function(instant)
	{
		this.push_begin(1);
		var pivot_left = -this.box.offsetLeft;								// containerÀÇ ½ÃÀÛÀ§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)
		var pivot_right = -this.box.offsetLeft+this.container.offsetWidth;	// containerÀÇ ³¡ À§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)

		var to = null;
		for(var node=this.box.vnode(0,0).firstChild; node; node=node.nextSibling)
		{
			var left = node.offsetLeft;				// nodeÀÇ ½ÃÀÛÀ§Ä¡
			var right = left + node.offsetWidth;	// nodeÀÇ ³¡ À§Ä¡
			if(left< pivot_right && pivot_right <= right){
				to = this.container.offsetWidth - left;
				break;
			}
		}
		if(to===null){
			var box_left = 0;						// boxÀÇ ½ÃÀÛÀ§Ä¡
			var box_right = this.box.offsetWidth;	// boxÀÇ ³¡ À§Ä¡
			if(box_left>=pivot_right){
				if(this.flow=="repeat"){
					this.box.style.left = -box_right+"px";
					this.move_right(on);
					return;
				}
				else if(this.flow=="reverse"){
					this.direction = 0;
					this.move_left(on);
					return;
				}
				else{
					window.status = "no flow";
					return;
				}
			}
			if(box_right < pivot_right){
				var node = this.box.vnode(0,0).lastChild;
				var left = node.offsetLeft;
				var right = left + node.offsetWidth;
				to = this.container.offsetWidth-right;
			}
		}

		window.clearInterval(this.tid);
		if(instant){
			this.box.style.left = (to+1)+"px";
			this.pause = true;
			return this.move_stop();
		}
		this.tid = window.setInterval(J.func(function(){
			var pos = parseInt(this.box.style.left) + this.speed;
			if(pos>=to){
				this.box.style.left = (to+1)+"px";
				return this.move_stop();
			}
			this.box.style.left = pos+"px";
		}, this), this.delay);
	},
	// ------------------------------------------
	// Çª½Ã À§
	// ------------------------------------------
	push_up:function(instant)
	{
		this.push_begin(2);
		var pivot_top = -this.box.offsetTop;						// containerÀÇ ½ÃÀÛÀ§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)
		var pivot_bottom = pivot_top + this.container.offsetHeight;	// containerÀÇ ³¡ À§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)

		var to = null;
		for(var tr=this.box.vnode(0).firstChild; tr; tr=tr.nextSibling)
		{
			var node = tr.firstChild;
			var top = node.offsetTop;				// nodeÀÇ ½ÃÀÛÀ§Ä¡
			var bottom = top + node.offsetHeight;	// nodeÀÇ ³¡ À§Ä¡
			if(top<= pivot_top && pivot_top < bottom){
				to = -bottom;
				break;
			}
		}
		if(to===null){
			var box_top = 0;						// boxÀÇ ½ÃÀÛÀ§Ä¡
			var box_bottom = this.box.offsetHeight;	// boxÀÇ ³¡ À§Ä¡
			if(box_bottom<=pivot_top){		// ´õÀÌ»ó ÀÌµ¿ÇÒ °ÍÀÌ ¾ø´Â °æ¿ì
				if(this.flow=="repeat"){	// ÀüÃ¼¸¦ ¿À¸¥ÂÊ ±¸¼®À¸·Î ¹Î´Ù
					this.box.style.top = this.container.offsetHeight+"px";
					return this.move_up(on);
				}
				else if(this.flow=="reverse"){ // ¹æÇâÀ» ¹Ù²Û´Ù
					this.direction = 3;
					return this.move_down(on);
				}
				else{
				//	window.status = "no flow";
					return;
				}
			}
			if(box_top>pivot_top){	// ¿ÞÂÊ¼±¿¡ °É·Á ÀÖÁö ¾ÊÀº °æ¿ì
				to = box_top;
			}
		}

		window.clearInterval(this.tid);
		if(instant){
			this.box.style.top = to+"px";
			this.pause = true;
			return this.move_stop();
		}
		this.tid = window.setInterval(J.func(function(){
			var pos = parseInt(this.box.style.top) - this.speed;
			if(pos<to){
				this.box.style.top = to+"px";
				return this.move_stop();
			}
			this.box.style.top = pos+"px";
		}, this), this.delay);
	},
	// ------------------------------------------
	// Çª½Ã ¾Æ·¡
	// ------------------------------------------
	push_down:function(instant)
	{
		this.push_begin(3);
		var pivot_top = -this.box.offsetTop;								// containerÀÇ ½ÃÀÛÀ§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)
		var pivot_bottom = -this.box.offsetTop+this.container.offsetHeight;	// containerÀÇ ³¡ À§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)

		var to = null;
		for(var node=this.box.vnode(0).firstChild; node; node=node.nextSibling)
		{
			var top = node.offsetTop;				// nodeÀÇ ½ÃÀÛÀ§Ä¡
			var bottom = top + node.offsetHeight;	// nodeÀÇ ³¡ À§Ä¡
			if(top< pivot_bottom && pivot_bottom <= bottom){
				to = this.container.offsetHeight - top;
				break;
			}
		}
		if(to===null){
			var box_top = 0;						// boxÀÇ ½ÃÀÛÀ§Ä¡
			var box_bottom = this.box.offsetHeight;	// boxÀÇ ³¡ À§Ä¡
			if(box_top>=pivot_bottom){
				if(this.flow=="repeat"){
					this.box.style.top = -box_bottom+"px";
					this.move_down(on);
					return;
				}
				else if(this.flow=="reverse"){
					this.direction = 0;
					this.move_up(on);
					return;
				}
				else{
					window.status = "no flow";
					return;
				}
			}
			if(box_bottom < pivot_bottom){
				var node = this.box.vnode(0,0).lastChild;
				var top = node.offsetTop;
				var bottom = top + node.offsetHeight;
				to = this.container.offsetHeight-bottom;
			}
		}

		window.clearInterval(this.tid);
		if(instant){
			this.box.style.top = (to+1)+"px";
			this.pause = true;
			return this.move_stop();
		}
		this.tid = window.setInterval(J.func(function(){
			var pos = parseInt(this.box.style.top) + this.speed;
			if(pos>=to){
				this.box.style.top = (to+1)+"px";
				return this.move_stop();
			}
			this.box.style.top = pos+"px";
		}, this), this.delay);
	},
	// ------------------------------------------
	// ÆäÀÌµå ÁØºñ
	// ------------------------------------------
	fade_begin:function(direction)
	{
		this.box2.empty();
		this.box2.appendChild(this.box.vnode(0).cloneNode(true));
	
		var tr = this.box.vnode(0,0);
		var tbody = this.box.vnode(0);
		
		if(direction==0){
			var node = tr.firstChild;
			tr.removeChild(node);
			tr.appendChild(node);
		}
		else if(direction==1){
			var node = tr.lastChild;
			tr.removeChild(node);
			tr.insertat(0, node);
		}
		else if(direction==2){
			var node = tbody.firstChild;
			tbody.removeChild(node);
			tbody.appendChild(node);
		}
		else if(direction==3){
			var node = tbody.lastChild;
			tbody.removeChild(node);
			tbody.insertat(0, node);
		}

		this.box.css({op:0.0});
		this.box.op = 0;
		this.box2.css({op:1.0,z:3});
	},
	// ------------------------------------------
	// ÆäÀÌµå
	// ------------------------------------------
	fade:function()
	{
		var v = 0;
		window.clearInterval(this.tid);
		this.tid = window.setInterval(J.func(function(){
			v += 0.01;
			var op2 = 1-v;
			if(op2<0) op2 = 0;
			var op1 = -0.5+v;
			if(op1<0) op1 = 0;

			this.box2.css({op:op2});
			this.box.css({op:op1});
			this.box.op = op1;

			if(v>=1.5)
				this.move_stop();
		}, this), this.delay);
	},
	// ------------------------------------------
	// ÆäÀÌµå ¿ÞÂÊ
	// ------------------------------------------
	fade_left:function()
	{
		this.fade_begin(0);
		this.fade();
	},
	// ------------------------------------------
	// ÆäÀÌµå ¿À¸¥ÂÊ
	// ------------------------------------------
	fade_right:function()
	{
		this.fade_begin(1);
		this.fade();
	},
	// ------------------------------------------
	// ÆäÀÌµå À§
	// ------------------------------------------
	fade_up:function()
	{
		this.fade_begin(2);
		this.fade();
	},
	// ------------------------------------------
	// ÆäÀÌµå ¾Æ·¡
	// ------------------------------------------
	fade_down:function()
	{
		this.fade_begin(3);
		this.fade();
	},
	// ------------------------------------------
	// Áï½Ã ±³Ã¼ÇÑ´Ù
	// ------------------------------------------
	instant:function(dir)
	{
		if(this.action=="fade"){
			this.stop();
			this.direction = dir;
			if(dir==0) this.instant_left();
			else if(dir==1) this.instant_right();
			else if(dir==2) this.instant_up();
			else if(dir==3) this.instant_down();
			this.pause = true;
		}
	},
	// ------------------------------------------
	// Áï½Ã ±³Ã¼ ¿ÞÂÊ
	// ------------------------------------------
	instant_left:function()
	{
		var tr = this.box.vnode(0,0);
		var node = tr.firstChild;
		tr.removeChild(node);
		tr.appendChild(node);
	},
	// ------------------------------------------
	// Áï½Ã ±³Ã¼ ¿À¸¥ÂÊ
	// ------------------------------------------
	instant_right:function()
	{
		var tr = this.box.vnode(0,0);
		var node = tr.lastChild;
		tr.removeChild(node);
		tr.insertat(0, node);
	},
	// ------------------------------------------
	// Áï½Ã ±³Ã¼ À§
	// ------------------------------------------
	instant_up:function()
	{
		var tbody = this.box.vnode(0);
		var node = tbody.firstChild;
		tbody.removeChild(node);
		tbody.appendChild(node);
	},
	// ------------------------------------------
	// Áï½Ã ±³Ã¼ ¾Æ·¡
	// ------------------------------------------
	instant_down:function()
	{
		var tbody = this.box.vnode(0);
		var node = tbody.lastChild;
		tbody.removeChild(node);
		tbody.insertat(0, node);
	},
	// ------------------------------------------
	// ½½¶óÀÌµå ÁØºñ
	// ------------------------------------------
	slide_begin:function(direction)
	{
		if(this.box.pos !=this.box.pos_end) return;
		
		this.box2.empty();
		this.box2.appendChild(this.box.vnode(0).cloneNode(true));
		this.box2.style.left = this.box.style.left;
		this.box2.style.top = this.box.style.top;
		
		var tr = this.box.vnode(0,0);
		var tbody = this.box.vnode(0);
		if(direction==0){
			for(var i=0; i<100; i++){
				var pivot_left = -this.box.offsetLeft;						// containerÀÇ ½ÃÀÛÀ§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)
				var pivot_right = pivot_left + this.container.offsetWidth;	// containerÀÇ ³¡ À§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)
				var node = tr.firstChild;
				var left = node.offsetLeft;
				var offset = node.offsetWidth;
				var right = left + offset;
				if(pivot_left >= left){
					tr.removeChild(node);
					tr.appendChild(node);
					this.box.style.left = parseInt(this.box.style.left)+offset+"px";
				}
				else{
					this.box.pos = parseInt(this.box.style.left);
					this.box.pos_start = this.box.pos;
					this.box.pos_end = this.box.pos + pivot_left - left;
					break;
				}
			}
		}
		else if(direction==1){
			for(var i=0; i<100; i++){
				var pivot_left = -this.box.offsetLeft;						// containerÀÇ ½ÃÀÛÀ§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)
				var pivot_right = pivot_left + this.container.offsetWidth;	// containerÀÇ ³¡ À§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)
				var node = tr.lastChild;
				var left = node.offsetLeft;
				var offset = node.offsetWidth;
				var right = left + offset;
				if(pivot_right <= right){
					tr.removeChild(node);
					tr.insertat(0, node);
					this.box.style.left = parseInt(this.box.style.left)-offset+"px";
				}
				else{
					this.box.pos = parseInt(this.box.style.left);
					this.box.pos_start = this.box.pos;
					this.box.pos_end = this.box.pos + pivot_right -right;
					break;
				}
			}
		}
		else if(direction==2){
			for(var i=0; i<100; i++){
				var pivot_top = -this.box.offsetTop;						// containerÀÇ ½ÃÀÛÀ§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)
				var pivot_bottom = pivot_top + this.container.offsetHeight;	// containerÀÇ ³¡ À§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)
				var node = tbody.firstChild;
				var top = node.offsetTop;
				var offset = node.offsetHeight;
				var bottom = top + offset;
				if(pivot_top >= top){
					tbody.removeChild(node);
					tbody.appendChild(node);
					this.box.style.top = parseInt(this.box.style.top)+offset+"px";
				}
				else{
					this.box.pos = parseInt(this.box.style.top);
					this.box.pos_start = this.box.pos;
					this.box.pos_end = this.box.pos + pivot_top - top;
					break;
				}
			}
		}
		else if(direction==3){
			for(var i=0; i<100; i++){
				var pivot_top = -this.box.offsetTop;						// containerÀÇ ½ÃÀÛÀ§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)
				var pivot_bottom = pivot_top + this.container.offsetHeight;	// containerÀÇ ³¡ À§Ä¡ (box±âÁØ »ó´ëÀ§Ä¡)
				var node = tbody.lastChild;
				var top = node.offsetTop;
				var offset = node.offsetHeight;
				var bottom = top + offset;
				if(pivot_bottom <= bottom){
					tbody.removeChild(node);
					tbody.insertat(0, node);
					this.box.style.top = parseInt(this.box.style.top)-offset+"px";
				}
				else{
					this.box.pos = parseInt(this.box.style.top);
					this.box.pos_start = this.box.pos;
					this.box.pos_end = this.box.pos + pivot_bottom - bottom;
					break;
				}
			}
		}
		this.box2.css({op:1.0});
		this.box.css({bk:this.slide_bk});
	},
	// ------------------------------------------
	// ½½¶óÀÌµå ¿ÞÂÊ
	// ------------------------------------------
	slide_left:function(instant)
	{
		this.slide_begin(0);
		window.clearInterval(this.tid);
		if(instant){
			this.box.pos = this.box.pos_end;
			this.box.style.left = this.box.pos+"px";
			this.pause = true;
			return this.move_stop();
		}
		this.tid = window.setInterval(J.func(function(){
			var pos = this.box.pos;
			pos -= this.speed;
			this.box.pos = pos;
			this.box.style.left = pos+"px";
			if(pos<=this.box.pos_end){
				this.box.pos = this.box.pos_end;
				this.move_stop();
			}
		}, this), this.delay);
	},
	// ------------------------------------------
	// ½½¶óÀÌµå ¿À¸¥ÂÊ
	// ------------------------------------------
	slide_right:function(instant)
	{
		this.slide_begin(1);
		window.clearInterval(this.tid);	
		if(instant){
			this.box.pos = this.box.pos_end;
			this.box.style.left = (this.box.pos+1)+"px";
			this.pause = true;
			return this.move_stop();
		}
		this.tid = window.setInterval(J.func(function(){
			var pos = this.box.pos;
			pos += this.speed;
			this.box.pos = pos;
			this.box.style.left = pos+"px";
			if(pos>this.box.pos_end){
				this.box.pos = this.box.pos_end;
				this.move_stop();
			}
		}, this), this.delay);
	},
	// ------------------------------------------
	// ½½¶óÀÌµå À§·Î
	// ------------------------------------------
	slide_up:function(instant)
	{
		this.slide_begin(2);
		window.clearInterval(this.tid);	
		if(instant){
			this.box.pos = this.box.pos_end;
			this.box.style.top = this.box.pos+"px";
			this.pause = true;
			return this.move_stop();
		}
		this.tid = window.setInterval(J.func(function(){
			var pos = this.box.pos;
			pos -= this.speed;
			this.box.pos = pos;
			this.box.style.top = pos+"px";
			if(pos<=this.box.pos_end){
				this.box.pos = this.box.pos_end;
				this.move_stop();
			}
		}, this), this.delay);
	},
	// ------------------------------------------
	// ½½¶óÀÌµå ¾Æ·¡
	// ------------------------------------------
	slide_down:function(instant)
	{
		this.slide_begin(3);
		window.clearInterval(this.tid);	
		if(instant){
			this.box.pos = this.box.pos_end;
			this.box.style.top = this.box.pos+"px";
			this.pause = true;
			return this.move_stop();
		}
		this.tid = window.setInterval(J.func(function(){
			var pos = this.box.pos;
			pos += this.speed;
			this.box.pos = pos;
			this.box.style.top = pos+"px";
			if(pos>this.box.pos_end){
				this.box.pos = this.box.pos_end;
				this.move_stop();
			}
		}, this), this.delay);
	},
	// ------------------------------------------
	// easing (unused)
	// ------------------------------------------
	easing:function(pos)
	{
		return (-Math.cos(pos*Math.PI)/2) + 0.5;
	}
}});
// ------------------------------------------------------------------
