/**
 * @author Bastian Jansen
 *
 * (C) Bastian Jansen, scaleweb.de
 */
SCROLL = function(obj, inattr){
    var t = 0;
    var h = 0;
    var attr = inattr;
    if (obj) {
        if (obj.offsetTop != null) 
            t = obj.offsetTop;
        if (obj.offsetHeight != null) 
            h = obj.offsetHeight;
    }
    
    var offset = {
        top: t,
        height: h
    };
    
    this.start = function(in_amount){
        /* Default setzen */
        amount = in_amount;
        var at = 0;
        var aw = "auto";
        var ah = "auto";
        var ati = 60;
        if (attr != null) {
            if (attr.top != null) 
                at = attr.top;
            if (attr.width != null) 
                aw = attr.width;
            if (attr.height != null) 
                ah = attr.height;
            if (attr.time != null) 
                ati = attr.time;
        }
        attr.top = at;
        attr.width = aw;
        attr.height = ah;
        /* Intervall starten */
        interval = setInterval(move, ati);
    };
    
    this.stop = function(){
        if (interval) {
            clearInterval(interval);
        }
    };
    
    var move = function(){
        /* Werte refreshen */
        attr.top += amount;
        attr.height += amount;
        offset.top -= amount;
        /* Grenze überschritten? */
        if (attr.top < 0 || attr.height > offset.height) {
            attr.top -= amount;
            attr.height -= amount;
            offset.top += amount;
            return;
        }
        
        /* Object bewegen */
        obj.style.clip = "rect(" + attr.top + "px, " + attr.width + "px, " + attr.height + "px, 0px)";
        obj.style.top = offset.top + "px";
    };
};
var scrollBar = null;
var scrollBar_one = null;
var scrollBar_one_g = null;

function initScroll(){
    if (document.getElementById('content_panel') != null) {
        var ele = document.getElementById('content_panel');
        scrollBar = new SCROLL(ele, {
            time: 60,
            width: 550,
            height: 587
        });
        return;
    }
    if (document.getElementById('content_panel_one') != null) {
        var ele = document.getElementById('content_panel_one');
        scrollBar_one = new SCROLL(ele, {
            time: 60,
            width: 216,
            height: 462
        });
        return;
    }
    if (document.getElementById('content_panel_one_g') != null) {
        var ele = document.getElementById('content_panel_one_g');
        scrollBar_one_g = new SCROLL(ele, {
            time: 60,
            width: 216,
            height: 428
        });
        return;
    }
    
    window.setTimeout("initScroll()", 10);
};

function startScroll_one(sind){
    scrollBar_one.start(sind);
};

function stopScroll_one(){
    scrollBar_one.stop();
};

function startScroll_one_g(sind){
    scrollBar_one_g.start(sind);
};

function stopScroll_one_g(){
    scrollBar_one_g.stop();
};

function startScroll(sind){
    scrollBar.start(sind);
};

function stopScroll(){
    scrollBar.stop();
};



