var i = 0; var list = new Array(); list[i++] = 'AUDUSD 0.91/17:45:47 '; list[i++] = 'EURCHF 1.297/17:45:49 '; list[i++] = 'EURGBP 0.832/17:45:59 '; list[i++] = 'EURJPY 107.87/17:46:02 '; list[i++] = 'EURPLN 3.964/17:43:28 '; list[i++] = 'EURUSD 1.282/17:45:21 '; list[i++] = 'GBPUSD 1.539/17:45:42 '; list[i++] = 'GOLD 1250.38/17:45:36 '; list[i++] = 'OIL 75.75/17:45:16 '; list[i++] = 'SILVER 19.54/17:45:26 '; list[i++] = 'USDCAD 1.052/17:46:00 '; list[i++] = 'USDCHF 1.012/17:45:49 '; list[i++] = 'USDJPY 84.15/17:46:02 '; list[i++] = 'USDPLN 3.091/17:45:27 '; var speedWalut = 60; var scrollId = 'pasek'; // prepare node structure // function loadStructure() { // div 4 frame - user defined // var scroll = document.getElementById(scrollId); if (scroll == null) return; // add cliping outside frame // scroll.style.cssText = scroll.style.cssText + '; overflow: hidden;'; var children = scroll.childNodes; while (children.length > 0) scroll.removeChild(children[0]); // add sliding div inside frame // var innerScroll = document.createElement('div'); innerScroll.style.width = '10000px'; innerScroll.style.marginLeft = (scroll.clientWidth+10)+'px'; scroll.appendChild(innerScroll); // add floating div-containers 4 list elements // for (var j in list) { var newDiv = document.createElement('div'); newDiv.style.cssText = 'float: left; padding-right: 5px;'; newDiv.innerHTML = list[j]; innerScroll.appendChild(newDiv); } } // move first container to the end // function shiftLeft() { // static frame // var scroll = document.getElementById(scrollId); if (scroll == null) return; // slider // var children = scroll.childNodes; if (children.length == 0) return; var innerScroll = children[0]; // list of containers // var floaters = innerScroll.childNodes; if (floaters.length == 0) return; // move container to the end // innerScroll.appendChild(floaters[0]); } var timerWalut; // make the world spin :) // function animateScroll() { // frame // var scroll = document.getElementById(scrollId); if (scroll == null) return; // slider // var children = scroll.childNodes; if (children.length == 0) return; var innerScroll = children[0]; // the hiding container // var floaters = innerScroll.childNodes; if (floaters.length == 0) return; var runner = floaters[0]; // left margin of the slider // var marginLeft = innerScroll.style.marginLeft; if (marginLeft.length) marginLeft = marginLeft.substr(0, marginLeft.length-2); marginLeft = marginLeft - 2; // do we shift ? // if (marginLeft < -runner.clientWidth) { marginLeft = marginLeft + runner.clientWidth; shiftLeft(); } // step left // innerScroll.style.marginLeft = marginLeft+'px'; timerWalut= setTimeout(animateScroll, speedWalut); } // make it happen // function initScroll() { loadStructure(); timerWalut= setTimeout(animateScroll, speedWalut); } // pause // scrollW = document.getElementById(scrollId); if (scrollW.addEventListener) { scrollW.addEventListener("mouseover", function() { clearTimeout(timerWalut); }, false); } else if (scrollW.attachEvent) { scrollW.attachEvent("onmouseover", function() { clearTimeout(timerWalut); }); } if (scrollW.addEventListener) { scrollW.addEventListener("mouseout", function() { timerWalut = setTimeout(animateScroll, speedWalut); }, false); } else if (scrollW.attachEvent) { scrollW.attachEvent("onmouseout", function() { timerWalut = setTimeout(animateScroll, speedWalut); }); }