
// ¿©·¯°³ÀÇ ¸®½ºÆ®¸¦ ÇÏ³ª¾¿ ·Ñ¸µ
// ÀÛ¼ºÀÚ : ÀÌÃ¢¿ë (v 0.9)

// ¿©·¯°³ÀÇ ÀÌ¹ÌÁö¸¦ ÇÑÄ­¾¿ ÁÂÃøÀ¸·Î ·Ñ¸µ
// _frameID 	: ÀüÃ¼ ·Ñ¸µ ÀÌ¹ÌÁö°¡ ´ã±æ ·¹ÀÌ¾î 
// _objID 		: ·Ñ¸µ ÀÌ¹ÌÁö ÇÏ³ª¾¿ ´ã±ä ·¹ÀÌ¾î
// _count 		: È­¸é¿¡ ÇÑ¹ø¿¡ º¸¿©Áö´Â ÀÌ¹ÌÁö ¼ö
// _time  		: ·Ñ¸µµÉ ½Ã°£
// _direction 	: ·Ñ¸µ ¹æÇâ(»óÇÏ,ÁÂ¿ì)
// _rollFlag    : ·Ñ¸µ ¿©ºÎ
// _rollNum	: ÇÑ¹ø¿¡ ·Ñ¸µµÉ ¾ÆÀÌÅÛ 
	rollByOne=function rollVar(className,_frameID,_objID,_count,_time,_direction,_startIndex,_rollFlag,_alignFlag,_rollNum)	{
		this.className=className;
		if(typeof(_startIndex)!="undefined"&&!isNaN(_startIndex))		this.rollCnt=_startIndex;
		else															this.rollCnt=0;
		this.r_cid;
		//º¯¼ö ÃÊ±âÈ­
		if(typeof(_rollNum)!="undefined"&&!isNaN(_rollNum))	{	
			this.r_rollNum=_rollNum; 
		}	else	{
			this.r_rollNum=1;
		}
		this.r_frameID=_frameID;;
		this.r_objID=_objID;;
		this.r_count=_count;
		this.r_time=_time;
		this.r_direction;
		this.r_rollflag=true;
		this.r_validate=true;
		if(_rollFlag==false)	{
			this.r_rollflag=false;
		}
		if(_alignFlag==false)	{
			this.r_tablealign="";
		}	else	{
			this.r_tablealign="align='center'";
		}
		//¾ÆÀÌÅÛÀÌ 2°³ ÀÌÇÏÀÏ°æ¿ì ¿¡·¯ ¹æÁö
		document.write("<div id='"+this.r_objID+"' style='display:none'></div>");		
		document.write("<div id='"+this.r_objID+"' style='display:none'></div>");		
		this.r_start=1;
		if(_direction)	{
			this.r_direction=_direction;
		}	else	{	this.r_direction="left";	}
		this.innerOBJ = eval("document.all."+this.r_objID);

		//¾ÆÀÌÅÛÀÌ À¯È¿ÇÑÁö Ã¼Å© & ¾ÆÀÌÅÛ ½ºÅ¸ÀÏ Ã¼Å©
		if(typeof(this.innerOBJ)!="object")	{
			this.r_validate=false;
		}	else	{
			this.frameOBJ=eval("document.all."+this.r_frameID);
			this.length=this.innerOBJ.length-2;	
			if(this.length==1)	{
				this.r_rollflag=false;
			}
			if(this.rollCnt>=this.length)	
				this.rollCnt=0;
			if(this.length>0)	
				if(this.innerOBJ[0].style.display!='none')	
					for(i=0;i<this.length;i++)	
						this.innerOBJ[i].style.display='none';
		}
	// ·Ñ¸µ ½ÃÀÛ
	rollByOne.prototype.rollingStart=function ()	{
		if(this.r_validate==false) return;
		if(this.r_start!=1)	{		 
			this.setRollCnt(this.r_rollNum);		 				
		} else { 
			this.r_start=0;	
		}
 		this.printLayer();	
 		if(this.r_rollflag==true)	{
			this.r_cid=setTimeout(this.className +".rollingStart()", this.r_time * 1000);
		}
	}
	// ÁßÁö
	rollByOne.prototype.rollingStop = function() {
		if( this.r_cid != null ) {
			clearTimeout( this.r_cid );
		}
	}
	
	//rollCnt ¼ÂÆÃ
	rollByOne.prototype.setRollCnt=function(movecnt,target)	{
		if(target==null||target=="")	{
			target=this.r_direction;
		}
		if(target=='left'||target=='up')	{
			if(this.rollCnt>=this.length-movecnt)	this.rollCnt=this.rollCnt-(this.length-movecnt);
			else										this.rollCnt+=movecnt;	
		} else 	{
			if(this.rollCnt<=(movecnt-1))	this.rollCnt=this.length-(movecnt-this.rollCnt);
			else							this.rollCnt-=movecnt;			
		}	
	}
	// ÀÌ¹ÌÁö¸¦ ÁÂÃø ¶Ç´Â ¿ìÃøÀ¸·Î ÇÑÄ­¾¿ »ç¿ëÀÚ°¡ ¿òÁ÷ÀÏ ¼ö ÀÖ°Ô ÇÔ
	// target : ¹æÇâ right left up down
	rollByOne.prototype.moveImg=function(target,cnt)	{
		if(this.r_validate==false) return;
		if(isNaN(cnt)||cnt==null)	{
			cnt=1;
		}	
		if(this.r_cid)					clearTimeout(this.r_cid);
		if(this.r_time==null)			this.r_time=5;	
 		this.setRollCnt(cnt,target);
		this.printLayer();		
		if(this.r_rollflag==true)	{	
			this.r_cid=setTimeout(this.className +".rollingStart()", this.r_time * 1000);	
		}
	}
	rollByOne.prototype.printLayer=function()	{
		var html="";
		if(this.r_direction=="up"||this.r_direction=="down") 	html+="<table cellpadding='0' cellspacing='0' width='100%'>";		
		else						html+="<table cellpadding='0' cellspacing='0' width='100%'><tr>";
		for(i=this.rollCnt;i<eval(this.r_count+this.rollCnt);i++)	{ 
			if(i>this.length-1)	{imgcnt=i-this.length;  	}
			else				{imgcnt=i; 	}
			if(this.r_direction=="up"||this.r_direction=="down") 	html += "<tr><td " + this.r_tablealign + ">" + this.innerOBJ[imgcnt].innerHTML + "</td></td>";
			else 						html += "<td " + this.r_tablealign + ">" + this.innerOBJ[imgcnt].innerHTML + "</td>";		 
		}
		if(this.r_direction=="up"||this.r_direction=="down")		html+="</table>";
		else							html+="</tr></table>"
		this.frameOBJ.innerHTML=html;
	}
}
