//·Ñ ÀÌ¹ÌÁö ¿òÁ÷ÀÌ´Â Å¬·¡½º Á¤ÀÇ
//ÇöÀç ÁÂ¿ì´Â ±¸ÇöÀÌ ´Ù ¾ÈµÊ

function class_MoveScroll()
{
	//private º¯¼ö
	var m_nowpage = 0; //³»ºÎ¿¡¼­¸¸ ¾²´Â ÇöÀç ÆäÀÌÁö
	var m_position = 0; //¿òÁ÷ÀÌ´Â °´Ã¼ÀÇ À§Ä¡
	var m_Timerid = null; //½Ã°£ °´Ã¼
	var m_moveobj = null;
	var m_movepixel = 1; //ÀÌµ¿ÇÈ¼¿
	
	//public º¯¼ö
	this.MoveID = null; //ÀÌµ¿ÇÏ´Â °´Ã¼ÀÇ ID ÅÂ±×°ª
	this.Direction = "top"; //ÀÌµ¿¹æÇâ - top or left
	this.ObjSize = 0; //°³Ã¼ÀÇ ³Êºñ (¶Ç´Â ³ôÀÌ)
	this.TotalCount = 0; //ÀüÃ¼ »óÇ°¼ö
	this.TotalPage = 0; //ÀüÃ¼ ÆäÀÌÂ¡ °¹¼ö
	this.ViewSize = 0; //ÆäÀÌÁö´ç º¸±â¼ö
	this.SlideSpeed = 1; //ÀÌµ¿ÀÇ ½ÇÇà ÁÖ±â (¸¶ÀÌÅ©·Î ÃÊ)
	this.Movepixel = 8; //slidespeed¸¶´Ù ¿òÁ÷ÀÏ ÇÈ¼¿»çÀÌÁî
	
	//public ÇÔ¼ö Á¤ÀÇ
	//°´Ã¼¾ÆÀÌµð, ÀÌµ¿¹æ½Ä, °´Ã¼±âº»»çÀÌÁî, ÀüÃ¼°¹¼ö, ÆäÀÌÁö´çº¸±â¼ö, ÀÌµ¿¼Óµµ, ¼Óµµ´ç ÀÌµ¿ÇÈ¼¿
	this.makeRoll = function (p_moveid, p_dir, p_size, p_total, p_view, p_speed, p_pixel) {
		m_moveobj = document.getElementById(p_moveid);
		this.Direction = p_dir;
		this.ObjSize = p_size;
		this.TotalCount = p_total;
		this.ViewSize = p_view;
		this.SlideSpeed = p_speed;
		m_movepixel = p_pixel;
		this.Movepixel = m_movepixel;
		this.TotalPage = Math.ceil(p_total / p_view) - 1;
		if (p_size % p_pixel != 0){
			alert("°´Ã¼ÀÇ »çÀÌÁî´Â ÀÌµ¿ÇÈ¼¿ ´ÜÀ§ÀÇ ¹è¼öÀÌ¾î¾ß ÇÕ´Ï´Ù.");
		}
	};
	
	this.move = function (p_dir){
		switch (p_dir){
			case "up":
				this.moveup(); break;
			case "down":
				this.movedown(); break;
			case "left":
				this.moveprev(); break;
			case "right":
				this.movenext(); break;
		}		
	};
		
	this.moveup = function (){
		if (m_nowpage <= 1) {m_nowpage = 0;}
		else {m_nowpage -= 1;}
		m_position = -(this.ViewSize * this.ObjSize * m_nowpage);
		clearInterval(m_Timerid);
		m_Timerid = setInterval(this.moveslidedown, this.SlideSpeed);
	};
	
	this.movedown = function (){
		if (m_nowpage >= this.TotalPage) {m_nowpage = this.TotalPage;}
		else {m_nowpage += 1;}
		m_position = -(this.ViewSize * this.ObjSize * m_nowpage);
		clearInterval(m_Timerid);
		m_Timerid = setInterval(this.moveslideup, this.SlideSpeed);
	};
	
	this.moveslideup = function(){
		if (m_position != parseInt(m_moveobj.style.top)){
			m_moveobj.style.top = parseInt(m_moveobj.style.top) - m_movepixel;
		} else {
			clearInterval(m_Timerid);
		}
	};
	
	this.moveslidedown = function(){
		if (m_position != parseInt(m_moveobj.style.top)){
			m_moveobj.style.top = parseInt(m_moveobj.style.top) + m_movepixel;
		} else {
			clearInterval(m_Timerid);
		}
	};
	
	this.moveprev = function(){
		if (m_nowpage <= 1) {m_nowpage = 0;}
		else {m_nowpage -= 1;}
		moveleft = -(this.ViewSize * this.ObjSize * m_nowpage);
		clearInterval(m_Timerid);
		m_Timerid = setInterval(this.moveslideright, this.SlideSpeed);
	};
	
	this.movenext = function(){
		if (m_nowpage >= this.TotalPage) {m_nowpage = this.TotalPage;}
		else {m_nowpage += 1;}
		moveleft = -(this.ViewSize * this.ObjSize * m_nowpage);
		clearInterval(m_Timerid);
		m_Timerid = setInterval(this.moveslideleft, this.SlideSpeed);	
	};
	
	this.moveslideleft = function(){
		if (m_position != parseInt(m_moveobj.style.left)){
			m_moveobj.style.left = parseInt(m_moveobjD.style.left) - m_movepixel;
		} else {
			clearInterval(m_Timerid);
		}
	};
	
	this.moveslideright = function(){
		if (m_position != parseInt(m_moveobj.style.left)){
			m_moveobj.style.left = parseInt(m_moveobj.style.left) + m_movepixel;
		} else {
			clearInterval(m_Timerid);
		}
	};
};