var JKowScroller = function(container_id, scroll_content, config) { /* Horiz. scroller Date: 2008-07-22 */ this.scroll_content = null; this.config = { 'default_unit' : 'px', 'increment' : 2.0, 'timer_interval' : 50, 'orientation' : 'h', 'total_content_length' : 0 }; this.id = ''; this.container_id = null; this.scroll_anim = function(sender){ var el = document.getElementById(sender.container_id); var scroll_content = sender.scroll_content; for (var k in scroll_content){ var el2 = document.getElementById('scroll_content_' + k.toString()); if (el2 != null){ var cur_left = parseFloat(el2.style.left); cur_left -= sender.config.increment; if (cur_left < 0 && Math.abs(cur_left) > parseFloat(scroll_content[k].width)){ cur_left = parseFloat(this.config.total_content_length - (parseFloat(scroll_content[k].width))); } el2.style.left = cur_left.toString() + sender.config.default_unit; } } } this.init = function(container_id, scroll_content, config){ var el = document.getElementById(container_id); if (el != null){ this.container_id = container_id; el.style.width = '480' + this.config.default_unit; } if (scroll_content != null && typeof scroll_content == "object"){ this.scroll_content = scroll_content; } if (el != null && scroll_content != null){ var count = 0; var current_left = 0; for (var k in scroll_content){ var el2 = document.createElement('div'); el2.id= 'scroll_content_' + k.toString(); el2.style.position = 'absolute'; el2.style.left = current_left.toString() + this.config.default_unit; el2.style.width = scroll_content[k].width.toString() + this.config.default_unit; if (config['content-style'] != null) { for (var kcs in config['content-style']){ el2.style[kcs.toString()] = config['content-style'][kcs]; } } el2.innerHTML = scroll_content[k].caption; current_left += parseFloat(scroll_content[k].width); el.appendChild(el2); } this.config.total_content_length = current_left; } var self = this; var _t = setInterval( function() { self.scroll_anim(self); }, 50 ); } this.init(container_id,scroll_content, config); }