/* ¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à
	ÇÁ·Î±×·¥ : A2ScrollLoop Ver 1.0.1
	°³ ¹ß ÀÚ : ¹Ú¹Î±Ç
	¼³    ¸í : ¹è³Ê ¹× ¸Þ´º·Î »ç¿ëÇÒ ¿©·¯ °´Ã¼¸¦ Æ÷ÇÔÇÏ°í ÀÖ´Â ·¹ÀÌ¾îµîÀÇ °´Ã¼¸¦ º¯È¯ÇÏ¿©
			   Æ÷ÇÔµÈ ÄÁÅÙÃ÷¸¦ ¹Ýº¹½ºÅ©·ÑÀÌ °¡´ÉÇÏ°Ô º¯È¯½ÃÅ²´Ù.
			   W3C ±ÔÁ¤À» ÁØ¼öÇÏ°í IEÀÇ ºñ±ÔÁ¤µµ Áö¿øÇÏ¿© Å©·Î½º ºê¶ó¿ìÂ¡ ±¸Çö
	ex)	<div id="Banner" style="border:1px solid red; width:320px; height:150px;">
			<img src="b1.jpg" /><img src="b2.jpg" /><img src="b3.jpg" />
			<img src="b4.jpg" /><img src="b5.jpg" /><img src="b6.jpg" />
		</div>
		<button type="button" onclick="document.getElementById('Banner').fastMove(false)">ÁÂ</button>
		<button type="button" onclick="document.getElementById('Banner').fastMove(true)">¿ì</button>
		<script type="text/javascript">
			A2ScrollLoop('Banner',600,100,100,5,300,100,100,1,false,false);
		</ script>
	
	A2ScrollLoop(Àû¿ëÇÒ °´Ã¼¸ístr, ³»ºÎÄÁÅÙÃ÷ ³ÐÀÌint,³ôÀÌint, ¸¶µðÅ©±âint, ÀÌµ¿°Å¸®int, ºü¸¥ÀÌµ¿°Å¸®int, Å¸ÀÌ¸Ó¼Óµµint, ºü¸¥Å¸ÀÌ¸Ó¼Óµµint, X|YÀÌµ¿bool, ÀÌµ¿¹æÇâbool)
	-> X|YÀÌµ¿ = (false) ? x : y
	-> ÀÌµ¿¹æÇâ  = (false) ? - : +
	
	¡ØÁÖ ÀÇ : ºñÇ¥ÁØÀ¸·Î À¥À» °³¹ßÇÏ½Ã´Â ºÐÀº »ç¿ëÀ» ±ÝÇÕ´Ï´Ù.
			  xhtml1-transitional.dtd ¼±¾ðµÈ ¹®¼­¿¡ Å×½ºÆ®ÇÏ¿´½À´Ï´Ù.
¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à¡á¡à */

//ºê¶ó¿ìÀúº° °Ë»ç
var op = /opera/i.test(navigator.userAgent);
var ie = !op && /msie/i.test(navigator.userAgent);
var mz = !op && /mozilla\/5/i.test(navigator.userAgent);
var pA2ScrollLoop_StopObj; //ÇöÀç Á¤ÁöµÈ ½ºÅ©·Ñ¹è³Ê °´Ã¼¸¦ ´ã¾ÆµÎ´Â Àü¿ªº¯¼ö

function A2ScrollLoop(id,width,height,word,move,fmove,sec,fsec,fcount,xy,course){
	//¹è³Ê¸¦ Æ÷ÇÔÇÑ °´Ã¼¿¡ ´ëÇÑ ±âº» ½ºÅ¸ÀÏ ¼³Á¤
	var objBorder = document.getElementById(id);
	objBorder.style.overflow = 'hidden';
	
	if(ie) var objBanner = document.createElement('<div onmouseover>'); //¹è³ÊÀÇ ³»ºÎÀÇ Èê·¯°¡´Â div»ý¼º
	else var objBanner = document.createElement('div');
	
	var sObj = "document.getElementById('"+id+"')";
	objBanner.setAttribute('onmouseover',sObj+'.Stop(event)'); //¸¶¿ì½º¿À¹ö½Ã ¸ØÃá´Ù.
	
	//¹è³ÊÀÇ ±âº» ½ºÅ¸ÀÏ ¼³Á¤
	with(objBanner){
		style.overflow = 'hidden';
		style.marginLeft = '0';
		style.marginTop = '0';
		style.width = width + 'px';
		style.height = height + 'px';
	}

	while(objBorder.childNodes.length){ //objBorderÀÇ ÀÚ½Ä³ëµå¸¦ objBanner·Î ÀÌµ¿ÇÑ´Ù.
		//ÅÂ±×°¡ ¾Æ´Ñ(text) °ÍÀº »èÁ¦ÇÏ°í ÅÂ±×¸¸ ÀÌµ¿.
		if(!objBorder.firstChild.tagName) objBorder.removeChild(objBorder.firstChild);
		else objBanner.appendChild(objBorder.firstChild);
	}
	
	objBorder.appendChild(objBanner);
	
	/* private ¸Þ¼Òµå */
	objBorder.Timer = A2ScrollLoop_Timer; //Å¸ÀÌ¸Ó
	objBorder.Move = A2ScrollLoop_Move; //ÀÌµ¿
	objBorder.overCheck = A2ScrollLoop_OverCheck; //ÀÌµ¿¿À¹ö Ã¼Å©
	
	objBorder.Stop = A2ScrollLoop_Stop; //¿òÁ÷ÀÓ ¿©ºÎ
	objBorder.Action = A2ScrollLoop_Action; //Timer¿Í Move¸¦ Á¦¾î
	
	/* public ¸Þ¼Òµå */
	objBorder.fastMove = A2ScrollLoop_FastMove; //ºü¸¥ÀÌµ¿
	
	/* private ¼Ó¼º */
	objBorder.nWord = word; //¸¶µð°ª
	objBorder.nMove = move; //ÀÌµ¿°ª
	objBorder.nFMove = fmove; //ºü¸¥ÀÌµ¿°ª
	objBorder.nSec = sec; //Å¸ÀÌ¸Ó¼Óµµ
	objBorder.nFSec = fsec; //ºü¸¥ Å¸ÀÌ¸Ó¼Óµµ
	objBorder.nFCount = fcount; //ºü¸¥ÀÌµ¿ À¯ÁöÈ½¼ö
	objBorder.bXY = xy; //X|YÀÌµ¿
	objBorder.bCourse = course; //ÀÌµ¿¹æÇâ

	objBorder.pFastCount = 0; //ºü¸¥¼Óµµ À¯ÁöÄ«¿îÆ®
	objBorder.bEnable = true; //¿òÁ÷ÀÓ °¡´É¿©ºÎ
	
	/* public ¼Ó¼º */
	
	//Å¸ÀÌ¸Ó ½ÇÇà
	objBorder.Timer();
}


/*¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬private ¸Þ¼Òµå ÇÔ¼ö ¼±¾ðºÎ¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬*/
function A2ScrollLoop_OverCheck(){
	var objBanner = this.firstChild; //¹è³ÊÃ¢
	
	var value = parseInt((!this.bXY)?objBanner.style.marginLeft:objBanner.style.marginTop);

	if(!this.bCourse){ //ÁÂ|»ó ÀÌµ¿ÀÌ¸é
		while(value <= -this.nWord){ //ÇÑ¸¶µð ÀÌ»ó ¾ÈÂÊÀ¸·Î ³Ñ¾î°¬´Ù¸é ÇÑ¸¶µð ÀÌ»ó ¹Ù±ùÂÊÀ¸·Î ³ª¿Ã¶§±îÁö ·çÇÁ
			//¸ÇÃ³À½ ³ëµå¸¦ ¸¶Áö¸·À¸·Î ¿Å±ä´Ù.
			objBanner.appendChild(objBanner.firstChild);
			//ÇÑ¸¶µð ¹Ù±ùÂÊÀ¸·Î »«´Ù.
			value += this.nWord;
			if(!this.bXY) objBanner.style.marginLeft = value + 'px';
			else objBanner.style.marginTop = value + 'px';
		}
	}
	else{
		while(value >= 0){ //0ÀÌ»óÀ¸·Î ºüÁ®³ª¿Ô´Ù¸é 0ÀÌÇÏ·Î µé¾î°¥¶§±îÁö ·çÇÁ
			//¸¶Áö¸· ³ëµå¸¦ Ã³À½À¸·Î ¿Å±ä´Ù.(Ã³À½³ëµå ¾Õ¿¡ ¸¶Áö¸· ³ëµå¸¦ ³õ´Â´Ù.)
			objBanner.insertBefore(objBanner.lastChild,objBanner.firstChild);
			//ÇÑ¸¶µð ¾ÈÂÊÀ¸·Î ³Ö´Â´Ù.
			value -= this.nWord;
			if(!this.bXY) objBanner.style.marginLeft = value + 'px';
			else objBanner.style.marginTop = value + 'px';
		}
	}
}

function A2ScrollLoop_Move(){
	var objBanner = this.firstChild; //¹è³ÊÃ¢

	var moveValue = (this.pFastCount > 0) ? this.nFMove : this.nMove; //ºü¸¥ÀÌµ¿ Ä«¿îÆ®°¡ ÀÖ´Ù¸é nFMove, ¾Æ´Ï¸é nMove

	var value = parseInt((!this.bXY)?objBanner.style.marginLeft:objBanner.style.marginTop);
	value = value + ((!this.bCourse) ? -moveValue : moveValue) + 'px';
	
	if(!this.bXY) objBanner.style.marginLeft = value;
	else objBanner.style.marginTop = value;
	
	this.overCheck(); //¿À¹öÃ¼Å©
}

function A2ScrollLoop_Action(){
	if(this.bEnable) this.Move();
	if(this.pFastCount > 0) --this.pFastCount; //ºü¸¥ ÀÌµ¿ Ä«¿îÆ®°¡ ÀÖ´Ù¸é Ä«¿îÆ® °¨¼Ò
	this.Timer();
}

function A2ScrollLoop_Timer(){
	var func = "document.getElementById('"+this.id+"').Action()";
	setTimeout(func,(this.pFastCount > 0)?this.nFSec:this.nSec); //ºü¸¥ÀÌµ¿ Ä«¿îÆ®°¡ ÀÖ´Ù¸é nFSec, ¾Æ´Ï¸é nSec
}

function A2ScrollLoop_Stop(e){
	//ÀÌº¥Æ® ÁøÇàÀ» ¸·´Â´Ù.
	if(window.event) window.event.cancelBubble = true; //IE
	else e.stopPropagation();

	if(!this.bEnable) return; //ÀÌ¹Ì ¸ØÃá»óÅÂ¶ó¸é ¸®ÅÏ, °è¼Ó ÁøÇà½Ã ÀÌº¥Æ® Ä¸ÃÄ°¡ ¿©·¯°³ »ý¼ºµÈ´Ù.
	
	//ÀÌº¥Æ®Ä¸ÃÄ ¡Ø¾Æ½±°Ôµµ Ä¸ÃÄµÈ ÀÌº¥Æ®¿¡ ´ëÇÑ ½ÇÇàÀ» °´Ã¼¸Þ¼Òµå·Î ÇÒ ¼ö ¾ø´Ù. this.Play Ã³·³ ¾µ ¼ö ¾ø´Ù.
	if(document.addEventListener) document.addEventListener('mouseover', A2ScrollLoop_Play, false); //	W3C DOM
	else document.attachEvent('onmouseover', A2ScrollLoop_Play); //IE
	
	this.bEnable = false;
	pA2ScrollLoop_StopObj = this; //ÀÚ½ÅÀ» ¸ØÃá°´Ã¼·Î ¡ØÀ§¿Í °°Àº ÀÌÀ¯·Î ÀÎÇØ Àü¿ªº¯¼ö¸¦ ÅÃÇÏ¿´´Ù.
}

function A2ScrollLoop_Play(){
	//ÀÌº¥Æ®ÇØÁ¦
	if(document.removeEventListener) document.removeEventListener('mouseover', A2ScrollLoop_Play, false); //	W3C DOM
	else document.detachEvent('onmouseover', A2ScrollLoop_Play); //IE

	pA2ScrollLoop_StopObj.bEnable = true;
	pA2ScrollLoop_StopObj = null;
}

/*¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬public ¸Þ¼Òµå ÇÔ¼ö ¼±¾ðºÎ¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬¦¬*/
function A2ScrollLoop_FastMove(course){
	this.bCourse = course;
	this.pFastCount = this.nFCount; //ºü¸¥ÀÌµ¿ Ä«¿îÆ® Áõ°¡
}