var TurnBoard = function(objname)
{
// setting
	this.itembackcolor = '#dddddd';//µÚÁýÈ÷±â Àü ÄÃ·¯
	this.itemforecolor = '#ffffff';// µÚÁýÈ÷°í ³­ ÄÃ·¯
	this.itemheight = 34;
	this.movepix = 4; // °³´ç µÚÁýÈ÷´Â ¼Óµµ. ºñ·Ê. Å©¸é ¾ÈºÎµå·¯¿ò(ÇÈ¼¿ ¿òÁ÷ÀÓ)
	this.speed = 1; //  °³´ç µÚÁýÈ÷´Â ¼Óµµ. ¹Ýºñ·Ê. Å©¸é ¾ÈºÎµå·¯¿ò (Àç±ÍÈ£Ãâ ½Ã°£ ÅÒ)
	this.term = 110; // ÇØ´ç ¾ÆÀÌÅÛÀÌ µÚÁý Èù ÈÄ ´ÙÀ½ ¾ÆÀÌÅÛÀ» µÚÁý´Â ½Ã°£ ÅÒ
// setting end


	this.objName = objname;
	this.items = [];
	
	this.Add = function(id, height)
	{
		if(!height)
			height = this.height;
		this.items[this.items.length] = new TurnItem(id, this.objName, this.items.length, height);
	}
	this.Run = function()
	{		
		for(var i = 0 ; i < this.items.length ; i++)
		{
			setTimeout(this.objName+'.items['+i+'].BackMotion()', i * this.term);
		}
	}
}
var TurnItem = function(id, parentid, itemindex, height)
{
	this.itemindex = itemindex;
	this.actionObj = document.getElementById(id);
	
	eval('this.parentObj = '+parentid+';');

	

	this.height = this.actionObj.offsetHeight;
	if(!this.height)
		this.height = this.actionObj.style.height.split('px')[0];

	if(height)
		this.height = height;

	if(!this.height)
		this.height = this.parentObj.itemheight;

	this.actionObj.parentNode.style.height = this.height+'px';

	this.html = this.actionObj.innerHTML;
	


	this.actionObj.innerHTML = '';
	this.actionObj.style.height = this.height+'px';
	this.actionObj.style.overflow = 'hidden';
	if(this.parentObj.itembackcolor)
		this.actionObj.style.backgroundColor = this.parentObj.itembackcolor;
	

	this.objName = id;
	this.parentobjName = parentid;

	this.BackMotion = function()
	{
		var h = this.actionObj.style.height.split('px')[0];
		
		if(h - this.parentObj.movepix > 0)
		{
			this.actionObj.style.height = h - this.parentObj.movepix+'px';
			
			
			setTimeout(this.parentobjName+'.items['+this.itemindex+'].BackMotion()', this.parentObj.speed);
		}
		else
		{

			this.actionObj.style.backgroundColor = this.parentObj.itemforecolor;
			this.actionObj.innerHTML = this.html;
			this.actionObj.style.height = '1px';

			
			setTimeout(this.parentobjName+'.items['+this.itemindex+'].ForeMotion()', this.parentObj.speed);
		}
	}
	this.ForeMotion = function()
	{
		var h = this.actionObj.style.height.split('px')[0];

		if(parseInt(h)+parseInt(this.parentObj.movepix) <= this.height)
		{
		    h = parseInt(h)+parseInt(this.parentObj.movepix);

			this.actionObj.style.height = h +'px';
			
			setTimeout(this.parentobjName+'.items['+this.itemindex+'].ForeMotion()', this.parentObj.speed);
		}
		else
		{
			this.actionObj.style.height = this.height+'px';

		}
	}
}
