function ScrollArea(instName, areaName, totalCnt, perCnt, dispSize, speed, wait) { this.instName = instName; // ÀνºÅϽº¸í this.areaName = areaName; // À̵¿ÇÒ ¿µ¿ª div id this.totalCnt = parseInt(totalCnt); //ºí·° cnt °¡ ¾Æ´Ñ ÃÑ ³ëÃâ µ¥ÀÌÅÍÀÇ °¹¼ö; this.perCnt = parseInt(perCnt); //ºí·°´ç µ¥ÀÌÅÍÀÇ °¹¼ö; this.curIndex = 0; this.destIndex = 0; this.blockCnt = 0; // ´õ¹Ì¸¦ Á¦¿ÜÇÑ ¼ø¼ö ºí·°ÀÇ ¼ö this.dispSize = parseInt(dispSize); // ºí·°ÀÇ ³ôÀÌ/³ÐÀÌ this.speed = parseInt(speed); // À̵¿¼Óµµ : Ŭ¼ö·Ï »¡¶óÁü if(this.speed > this.dispSize) { this.speed = this.dispSize; } this.autospeed = this.speed; this.wait = parseInt(wait); // ºí·° À̵¿ ÈÄ ´ë±â ½Ã°£ milsec, 0 ÀÏ °æ¿ì ÀÚµ¿ ½ºÅ©·Ñ ÇÏÁö ¾Ê´Â´Ù. this.interval = 50; // ½½¶óÀ̵åÀ̵¿½Ã setTime ŸÀÓ interval/1000 ÃÊ this.funcName = "scrollInit"; this.objTimeout = 0; this.firstCall = true; this.scroll = true; /* Set blockCnt */ if(this.totalCnt == 0 || this.perCnt == 0 ) { this.blockCnt = 0; } else { this.blockCnt = this.totalCnt/this.perCnt; if(("" + this.blockCnt).indexOf(".") > -1) { this.blockCnt = parseInt(("" + this.blockCnt).substring(0, ("" + this.blockCnt).indexOf(".")) ) + 1; } } this.setBlockCnt = function(blockCnt) { this.blockCnt = blockCnt; } this.getPosition = function(index) { return - (index * this.dispSize); } /* ÃʱâÈ­ */ this.scrollInit = function() {} /* ½ºÅ©·Ñ ÁßÁö */ this.scrollStop = function() { //this.firstCall = true; try { clearTimeout(this.objTimeout); } catch(e) {} this.scroll = false; } /* ½ºÅ©·Ñ Àç°³ */ this.scrollContinue = function() { this.objTimeout = setTimeout(this.instName + "." + this.funcName + "()", this.interval); this.scroll = true; } /* ¾Æ·¡·Î ½ºÅ©·Ñ */ this.scrollDown = function() { this.funcName = "scrollDown"; clearTimeout(this.objTimeout); if(this.blockCnt == 0) return; if(this.firstCall) { if(this.curIndex == this.blockCnt) { this.curIndex = 0; document.getElementById(this.areaName).style.top = this.getPosition(this.curIndex); } this.destIndex = this.curIndex + 1; this.firstCall = false; } if(this.scroll) { document.getElementById(this.areaName).style.top = parseInt(document.getElementById(this.areaName).style.top) - this.speed; } if(parseInt( document.getElementById(this.areaName).style.top) < this.getPosition(this.destIndex)) { document.getElementById(this.areaName).style.top = this.getPosition(this.destIndex); this.curIndex = this.destIndex; this.firstCall = true; if(parseInt(this.wait) > 0) { this.speed = this.autospeed; this.objTimeout = setTimeout(this.instName + "." + this.funcName + "()", this.wait); } } else { this.objTimeout = setTimeout(this.instName + "." + this.funcName + "()", this.interval); } } /* À§·Î ½ºÅ©·Ñ */ this.scrollUp = function() { this.funcName = "scrollUp"; clearTimeout(this.objTimeout); if(this.blockCnt == 0) return; if(this.firstCall) { if(this.curIndex == 0) { this.curIndex = this.blockCnt; document.getElementById(this.areaName).style.top = this.getPosition(this.curIndex) ; } this.destIndex = this.curIndex - 1; this.firstCall = false; } if(this.scroll) { document.getElementById(this.areaName).style.top = parseInt(document.getElementById(this.areaName).style.top) + this.speed; } if(parseInt(document.getElementById(this.areaName).style.top) > this.getPosition(this.destIndex)) { document.getElementById(this.areaName).style.top = this.getPosition(this.destIndex); this.curIndex = this.destIndex; this.firstCall = true; if(parseInt(this.wait) > 0) { this.speed = this.autospeed; this.objTimeout = setTimeout(this.instName + "." + this.funcName + "()", this.wait); } } else { this.objTimeout = setTimeout(this.instName + "." + this.funcName + "()", this.interval); } } /* ¿ìÃøÀ¸·Î ½ºÅ©·Ñ */ this.scrollRight = function() { this.funcName = "scrollRight"; clearTimeout(this.objTimeout); if(this.blockCnt == 0) return; if(this.firstCall) { if(this.curIndex == this.blockCnt) { this.curIndex = 0; document.getElementById(this.areaName).style.left = this.getPosition(this.curIndex); } this.destIndex = this.curIndex + 1; this.firstCall = false; } if(this.scroll) { document.getElementById(this.areaName).style.left = parseInt(document.getElementById(this.areaName).style.left) - this.speed; } if(parseInt(document.getElementById(this.areaName).style.left) < this.getPosition(this.destIndex)) { document.getElementById(this.areaName).style.left = this.getPosition(this.destIndex); this.curIndex = this.destIndex; this.firstCall = true; if(parseInt(this.wait) > 0) { this.speed = this.autospeed; this.objTimeout = setTimeout(this.instName + "." + this.funcName + "()", this.wait); } } else { this.objTimeout = setTimeout(this.instName + "." + this.funcName + "()", this.interval); } } /* ÁÂÃøÀ¸·Î ½ºÅ©·Ñ */ this.scrollLeft = function() { this.funcName = "scrollLeft"; clearTimeout(this.objTimeout); if(this.blockCnt == 0) return; if(this.firstCall) { if(this.curIndex == 0) { this.curIndex = this.blockCnt; document.getElementById(this.areaName).style.left = this.getPosition(this.curIndex); } this.destIndex = this.curIndex - 1; this.firstCall = false; } if(this.scroll) { document.getElementById(this.areaName).style.left = parseInt(document.getElementById(this.areaName).style.left) + this.speed; } if(parseInt(document.getElementById(this.areaName).style.left) > this.getPosition(this.destIndex)) { document.getElementById(this.areaName).style.left = this.getPosition(this.destIndex); this.curIndex = this.destIndex; this.firstCall = true; if(parseInt(this.wait) > 0) { this.speed = this.autospeed; this.objTimeout = setTimeout(this.instName + "." + this.funcName + "()", this.wait); } } else { this.objTimeout = setTimeout(this.instName + "." + this.funcName + "()", this.interval); } } /* ¹öư Ŭ¸¯½Ã ¿ÀÅä ½ºÅ©·Ñ°ú ´Ù¸¥ ¼Óµµ·Î À̵¿ ½Ãų °æ¿ì */ this.clickDown = function(clickspeed) { this.speed = parseInt(clickspeed); this.scrollDown(); } this.clickUp = function(clickspeed) { this.speed = parseInt(clickspeed); this.scrollUp(); } this.clickLeft = function(clickspeed) { this.speed = parseInt(clickspeed); this.scrollLeft(); } this.clickRight = function(clickspeed) { this.speed = parseInt(clickspeed); this.scrollRight(); } }