/*
    Simple Scroller by K. Bogac Bokeer
    2008-04-30, info [at] webasis [dot] com
*/
    var newstimer   = null;
    var interval    = 30;

    var bbScroller = null;

    ScrollerItem = function(idx, ncontainer, nscroller) {

        this.ncontainer   = ncontainer;
        this.nscroller    = nscroller;
        this.divcontainer = document.getElementById( ncontainer );
        this.divscroller  = document.getElementById( nscroller );
        this.cHeight      = this.divcontainer.clientHeight || this.divcontainer.offsetHeight;
        this.sHeight      = this.divscroller.clientHeight || this.divscroller.offsetHeight;

        this.newstimer    = null;
        this.paused       = false;

        this.divcontainer.onmouseover = function() {
            bbScroller.stop(idx);
        }
        this.divcontainer.onmouseout = function() {
            bbScroller.start(idx);
        }

        this.divscroller.style.top = this.cHeight+'px';
    }

    bbScroller = function() {

        var _items = new Array();

        this.AddScrollerItem = function(ncontainer, nscroller) {
            idx = _items.length;
            _items[idx] = new ScrollerItem(idx, ncontainer, nscroller);
        }

        this.getCount = function() {
            return _items.length;
        }

        this.getItem = function(idx) {
            return _items[idx];
        }

        this.move = function() {

            for (idx=0; idx<this.getCount(); idx++) {
                var item = this.getItem(idx);
                if ( !item.paused ) {
                    var top = parseInt(item.divscroller.style.top);
                    if ( item.sHeight + top < 0 ) {
                        top = item.cHeight;
                    }
                    item.divscroller.style.top = (top - 1) + 'px';
                }
            }
        }

        this.stop = function(idx) {
            _items[idx].paused = true;
        }
        this.start = function(idx) {
            _items[idx].paused = false;
        }

        this.init = function() {

            this.AddScrollerItem('news-container', 'news-scroller');

            newstimer = setInterval("bbScroller.move()", interval);
        }

        this.init();
    }

    window.onload = function() {
        bbScroller = new bbScroller();
    };

