//
//  This file is part of textscroll
//   clientlogos is free software: you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation, either version 3 of the License, or
//   (at your option) any later version.
//
//   clientlogos is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with clientlogos.  If not, see <http://www.gnu.org/licenses/>.
//  
//  This module was created on March 3rd 2009
//  By Quinten Bril
//  NowIC Webservices
//
// description clientlogos.prototype:
// initclientlogos: initialization, calls clientlogosnextpic then clientlogosshow
// clientlogosshow: shows picture, calls clientlogosnextpic then clientlogostransition
// clientlogosnextpic: goto next picture
// clientlogostransition: transition between logos, calls clientlogostransition or clientlogosshow
// 

var margin = 0;
var scroller;
    
window.onload = begin;

function begin() {
    scroller = document.getElementById("scroller"); 
    if(scroller.hasChildNodes()) {
        for(var i = 0; i < scroller.childNodes.length; i++) {
            if(scroller.childNodes[i].nodeType == 1) {
                scroller.childNodes[i].style.margin = margin + 'px';
            } else if(scroller.childNodes[i].nodeType == 3) {
                scroller.removeChild(scroller.childNodes[i]);
                i--;
            }
        }
        setTimeout("count(" + margin + ")", stopspeed);
    }
}
    
function count(counter) {
    counter--;
    setTimeout("move(" + counter + ")", speed);
}

function move(counter) {
    scroller.firstChild.style.marginTop = counter + 'px';
    if(counter > -(scroller.firstChild.offsetHeight)) {
        count(counter);
    } else {
        setTimeout("stack(" + counter + ")", stopspeed);
    }
}

function stack(counter) {
    var thischild = scroller.firstChild;
    scroller.removeChild(thischild);
    scroller.appendChild(thischild);
    scroller.lastChild.style.margin = margin + 'px';
    count(margin);
}