﻿// JScript File
function scroll(id, speed, step) {
    //default speed
    var speed = speed || 10; // delay ms
    var step  = step  || 1;  // shift px
 
    //scroll content
    var element = document.getElementById(id);
 
    //all childs they'll move
    var children = element.childNodes;
 
    // push all children to array without spaces (nodeType = 3)
    var childrenArray = [];
    for (var i = 0, l = children.length; i < l; i++) {
        if (children[i].nodeType != 3) {
            // they are shifted
            children[i].style.left = element.offsetWidth;
            childrenArray.push(children[i]);
        }
    }
 
    // Determine  local circular for range
    var moveText = function() {
        var steps        = step,
            container    = element,
            scrolling    = childrenArray,
            current      = 0,
            currentWidth = element.offsetWidth;
 
        // Initial first element
        scrolling[current].style.left = currentWidth;
        scrolling[current].style.visibility = "visible";
 
        return function() {
            // if size of container was changed
            if (container.offsetWidth != currentWidth) {
                // calculate difference
                var delta = parseInt(currentWidth) - parseInt(container.offsetWidth);
                currentWidth = container.offsetWidth;
                // shift this element for difference value
                scrolling[current].style.left = parseInt(scrolling[current].style.left) - delta;
            }
 
            // if current element was hided for left border
            if ((Math.abs(scrolling[current].offsetLeft) >=  scrolling[current].offsetWidth) &&
                scrolling[current].offsetLeft < 0) {
                // Take next element and hide this
                scrolling[current].style.visibility = "hidden";
 
                // Take next element
                current++;
 
                // if all elements were hided begin again
                if (current >= scrolling.length) current = 0;
 
                // show element
                scrolling[current].style.left = parseInt(currentWidth);
                scrolling[current].style.visibility = "visible";
            } else {
                // just  shift element
                scrolling[current].style.left = parseInt(scrolling[current].style.left) - steps;
            }
        }
    }();
 
    var interval = setInterval(moveText, speed);
}

function blinkAllRows(id_ids, id_colors, id_background_color) {
    try {        
        var string_ids = document.getElementById(id_ids).value;
        var string_colors = document.getElementById(id_colors).value;
        var background_color = document.getElementById(id_background_color).value;        
        var ids = string_ids.split(';');
        var colors = string_colors.split(';');
        //alert(colors);
        for (var i = 0; i < ids.length; i++) {
            var obj = document.getElementById(ids[i]);
            if (obj) {
                if (obj.style.color.toLowerCase() == colors[i].toLowerCase()) {
                    obj.style.color = background_color;                    
                }
                else {
                    obj.style.color = colors[i];                    
                }
            }
        }
    }
    catch (e) {alert(e.message); }
}
