
var isPause = 'N'
var directions = '>'    // ½ºÅ©·Ñ ¹æÇâ < , >
var nums = 10        // ÀÌ¹ÌÁö °¹¼ö
var speed = 1        // ÇÑ¹ø¿¡ ¿òÁ÷ÀÌ´Â px
var imgWidth = 120    // ÀÌ¹ÌÁö °¡·Î px
var tableWidth = 740    // ÀÌ¹ÌÁö°¡ µé¾îÀÖ´Â DIV °¡·Îpx


// * ·¹ÀÌ¾î À§Ä¡ÁöÁ¤
function setPosition(str,str2,str3){ // ÀÌ¸§, À§Ä¡, Á¾·ù(left,top):l,t
    if(str3 == 'l')document.getElementById(str).style.left = str2
    else if(str3 == 't')document.getElementById(str).style.top = str2
}

// * ·¹ÀÌ¾î À§Ä¡Á¤º¸
function getPosition(str,str2){ // ÀÌ¸§, Á¾·ù(left,top):l,t
    if(str2 == 'l')return parseInt(document.getElementById(str).style.left.replace('px',''))
    else if(str2 == 't')return parseInt(document.getElementById(str).style.top.replace('px',''))
}

// * ½ºÅ©·Ñ·¯
function moves(){
    var cutRightPosi = imgWidth * (nums-1)
    var tmp = tableWidth - imgWidth

    if(isPause == 'N'){
        for(var i=1; i<=nums ; i++){
            if(directions == '>'){
                if(getPosition('img'+i, 'l') >= cutRightPosi)setPosition('img'+i, -imgWidth, 'l')
                setPosition('img'+i, getPosition('img'+i, 'l')+speed, 'l')
            }else if(directions == '<'){
                if(getPosition('img'+i, 'l') <= -(cutRightPosi)+tmp)setPosition('img'+i, tableWidth, 'l')
                setPosition('img'+i, getPosition('img'+i, 'l')-speed, 'l')
            }
        }
    }
}

// * ÀÌ¹ÌÁö À§Ä¡ ¼³Á¤
function initPosition(){
    for(var i=1 ; i<=nums ;i++){
        setPosition('img'+i, (i-1)*imgWidth , 'l')
    }
}

// * ½ºÅ©·Ñ ¹æÇâ ¹Ù²Ù±â
function dirChange1(){
    if(directions == '>')directions = '<'
}
function dirChange2(){
    if(directions == '<')directions = '>'
}

initPosition()
setInterval("moves()", 30)


