var i = 0; var list = new Array(); list[i++] = 'AUDUSD 0.916/10:41:51 '; list[i++] = 'EURCHF 1.462/10:42:06 '; list[i++] = 'EURGBP 0.912/10:42:04 '; list[i++] = 'EURJPY 122.75/10:42:17 '; list[i++] = 'EURPLN 3.871/10:41:35 '; list[i++] = 'EURUSD 1.359/10:42:08 '; list[i++] = 'GBPUSD 1.49/10:42:17 '; list[i++] = 'GOLD 1126/10:41:23 '; list[i++] = 'OIL 79.89/10:41:40 '; list[i++] = 'SILVER 17.38/10:42:06 '; list[i++] = 'USDCAD 1.027/10:40:34 '; list[i++] = 'USDCHF 1.076/10:42:17 '; list[i++] = 'USDJPY 90.33/10:40:06 '; list[i++] = 'USDPLN 2.847/10:41:35 '; 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); }); }