function rolling(parent, id, method, width, height, cols, rows, moveunit) { this.isIE = (navigator.userAgent.toLowerCase().indexOf("msie") != -1); this.timer = null; this.objWrap = null; this.arrData = new Array(); // ·Ñ¸µ Ç׸ñ ¹è¿­ this.parent = parent; this.id = id; // ·Ñ¸µ °´Ã¼ID this.method = method; // ·Ñ¸µ ¹æ¹ý(v : »óÇÏ, h : Á¿ì) this.width = width; // Ç׸ñ Æø(px) this.height = height; // Ç׸ñ ³ôÀÌ(px) this.cols = (cols)?cols:1; // ³ëÃâ °¡·Î °³¼ö this.rows = (rows)?rows:1; // ³ëÃâ ¼¼·Î °³¼ö this.moveunit = (moveunit)?moveunit:0; // À̵¿´ÜÀ§(0 : ·Ñ¸µÇ׸ñº°, 1 : ·Ñ¸µ±×·ìº°) this.direction = 1; // ¹æÇâ(1 : Á¤¹æÇâ, -1 : ¿ª¹æÇâ) this.idle = 3000; // Á¤Áö ŸÀÌ¸Ó this.time = 3; // ½ÇÇà ŸÀÌ¸Ó : ÀÛÀ»¼ö·Ï ºÎµå·¯¿ò this.speed = 7; // ¿òÁ÷ÀÓ ¼Óµµ : ÀÛÀ»¼ö·Ï ºü¸§ this.align = 'left'; // Ç׸ñ ¼öÆò Á¤·Ä(left °íÁ¤) this.valign = 'top'; // Ç׸ñ ¼öÁ÷ Á¤·Ä(top °íÁ¤) this.overstop = true; // ¸¶¿ì½º ¿À¹ö½Ã Á¤Áö ¿©ºÎ this.direct_time = 1; // Áï½ÃÀ̵¿ ½ÇÇà ŸÀ̸Ó(ÀÛÀ»¼ö·Ï ºÎµå·¯¿ò) this.direct_speed = 3; // Áï½ÃÀ̵¿ ¿òÁ÷ÀÓ ¼Óµµ(ÀÛÀ»¼ö·Ï ºü¸§) this.cells = 0; // ³ëÃâ Ç׸ñ °³¼ö this.target = 0; // À̵¿ ¸ñÀûÁö À§Ä¡°ª this.basis = 0; // ±âÁØ »çÀÌÁî°ª(»óÇÏ ·Ñ¸µ °æ¿ì : Ç׸ñ ³ôÀÌ, ÁÂ¿ì ·Ñ¸µ °æ¿ì : Ç׸ñ Æø) this.end = 0; this.isdirect = false; this.add = function(data) { this.arrData[this.arrData.length] = data; } this.init = function() { var self = this; var objTable = objTbody = objTr = objTd = objDiv = null; var i, len, no; var html = ''; if (this.direction != 1 && this.direction != -1) this.direction = 1; if (this.moveunit != 1) this.moveunit = 0; this.cells = this.cols * this.rows; this.basis = ((this.method == 'h')?this.width:this.height); if (this.moveunit) { this.basis *= ((this.method=='h')?this.cols:this.rows); this.end = this.basis * Math.ceil(this.arrData.length / (this.cols * this.rows)); } else { this.end = this.basis * Math.ceil(this.arrData.length / ((this.method=='h')?this.rows:this.cols)); } var wrapWidth = this.width * this.cols; var wrapHeight = this.height * this.rows; this.objWrap = document.createElement('div'); this.objWrap.id = this.id; this.objWrap.style.width = wrapWidth+'px'; this.objWrap.style.height = wrapHeight+'px'; this.objWrap.style.overflow = 'hidden'; this.objWrap.style.display = 'none'; if (this.overstop) { this.objWrap.onmouseover = function() { self.pause(); } this.objWrap.onmouseout = function() { if (self.cells < self.arrData.length) { if (((self.method=='h') ? self.objWrap.scrollLeft : self.objWrap.scrollTop) % self.basis > 0) self.play(); else self.timer = setTimeout(function() { self.play() }, self.idle); } } } objTable = this.objWrap.appendChild(document.createElement('table')); objTable.cellPadding = 0; objTable.cellSpacing = 0; objTable.border = 0; objTable.style.tableLayout = 'fixed'; objTbody = objTable.appendChild(document.createElement('tbody')); if (this.method == 'h') objTr = objTbody.appendChild(document.createElement('tr')); for (s=0; s<2; s++) { if (s == 0) len = this.arrData.length; else { if (this.cells >= this.arrData.length) break; len = this.cells; } for (i=0; i'+this.arrData[i]+''; if (this.moveunit) { if (no % this.cols == 0 || i == (len-1)) { if (!objTd) { objTr = objTbody.appendChild(document.createElement('tr')); objTd = objTr.appendChild(document.createElement('td')); objTd.noWrap = true; objTd.width = (this.width * this.cols); objTd.height = (this.height * this.rows); objTd.align = this.align; objTd.vAlign = this.valign; } objDiv = objTd.appendChild(document.createElement('div')); objDiv.style.clear = 'both'; objDiv.innerHTML = html; html = ''; if (no % (this.cols * this.rows) == 0) objTd = null; } } else { if (no % this.cols == 0 || i == (len-1)) { objTr = objTbody.appendChild(document.createElement('tr')); objTd = objTr.appendChild(document.createElement('td')); objTd.noWrap = true; objTd.width = (this.width * this.cols); objTd.height = this.height; objTd.align = this.align; objTd.vAlign = this.valign; objTd.innerHTML = html; html = ''; } } } else { html += '
'+this.arrData[i]+'
'; if (this.moveunit) { if (no % this.rows == 0 || i == (len-1)) { if (!objTd) { objTd = objTr.appendChild(document.createElement('td')); objTd.noWrap = true; objTd.width = (this.width * this.cols); objTd.height = (this.height * this.rows); objTd.align = this.align; objTd.vAlign = this.valign; } objDiv = objTd.appendChild(document.createElement('div')); if (this.isIE) objDiv.style.styleFloat = 'left'; else objDiv.style.cssFloat = 'left'; objDiv.innerHTML = html; html = ''; if (no % (this.cols * this.rows) == 0) objTd = null; } } else { if (no % this.rows == 0 || i == (len-1)) { objTd = objTr.appendChild(document.createElement('td')); objTd.noWrap = true; objTd.width = this.width; objTd.height = (this.height * this.rows); objTd.align = this.align; objTd.vAlign = this.valign; objTd.innerHTML = html; html = ''; } } } } objTd = null; } } this.run = function() { var self = this; window.clearTimeout(this.timer); if (this.arrData.length > 0 && this.objWrap) { this.parent.appendChild(this.objWrap); this.objWrap.style.display = ''; } if (this.cells < this.arrData.length) { this.target = this.basis * this.direction; this.timer = setTimeout(function() { self.play() }, this.idle); } } this.play = function() { var self = this; window.clearTimeout(this.timer); if (!this.idle) this.idle = 1; if (!this.time) this.time = 1; if (!this.speed) this.speed = 1; var scroll = (this.method=='h') ? this.objWrap.scrollLeft : this.objWrap.scrollTop; if (scroll == this.target) this.target = scroll + (this.basis * this.direction); if (this.target < 0) { scroll = this.end; this.target = scroll - this.basis; } else if (this.target > this.end) { scroll = 0; this.target = this.basis; } var dist = Math.ceil((this.target - scroll) / ((this.isdirect)?this.direct_speed:this.speed)); var next = scroll + ((dist)?dist:this.direction); if (this.method=='h') this.objWrap.scrollLeft = next; else this.objWrap.scrollTop = next; if (next % this.basis > 0) { this.timer = setTimeout(function() { self.play() }, ((this.isdirect)?this.direct_time:this.time)); } else { this.isdirect = false; this.timer = setTimeout(function() { self.play() }, this.idle); } } this.pause = function() { window.clearTimeout(this.timer); } this.direct = function(direction) { if (typeof document.getElementById(this.id) != 'undefined' && this.cells < this.arrData.length) { window.clearTimeout(this.timer); if (!this.direct_time) this.direct_time = 1; if (!this.direct_speed) this.direct_speed = 1; this.direction = direction; this.target = this.target + (this.basis * this.direction); this.isdirect = true; this.play(); } } this.direct_right = function() { this.direct(1); } this.direct_reverse = function() { this.direct(-1); } }