var VScroller=function(){}
VScroller.prototype={
    id:"SETME",
    speed:8,
    step:2,
    interval:null,
    containerObj:null,
    bodyObj:null,
    containerObjId:null,
    bodyObjId:null,
    cH:0,
    bH:0,
    dir:"+",
    init:function(){
        this.containerObj=document.getElementById(this.containerObjName);
        this.bodyObj=document.getElementById(this.bodyObjName);
        this.cH=this.containerObj.offsetHeight;
        this.bH=this.bodyObj.offsetHeight;
    },
    startScroll:function(_dir){
        this.dir=_dir;
        clearInterval(this.interval);
        this.interval=setInterval('vscrollRegistry["'+this.id+'"].scroll()',this.speed);
    },
    scroll:function(){
        if(this.dir=="+"){
            var newPos=parseFloat(this.bodyObj.style.top)-this.step;
            if(this.bH+ newPos>this.cH){
                this.bodyObj.style.top= newPos+"px";
            }else{
                this.stop();
            }
        }else{
            var newPos=parseFloat(this.bodyObj.style.top)+this.step;
            if(newPos<0){
                this.bodyObj.style.top=newPos+"px";
            }else{
                this.stop();
            }
        }
    },
    stop:function(){
        if(this. interval){
            clearInterval(this.interval);
        }
    }
}
vscrollRegistry=new Array();
function registerVScrollerById(id){
    var scroller=new VScroller();
    scroller.id=id;
    scroller.containerObjName="scrollContainer"+id;
    scroller.bodyObjName="scrollBody"+id;
    registerVScroller(scroller);
}
function registerVScroller(scroller){
    vscrollRegistry[scroller.id]=scroller;
}
function initVScroll(){
    for(var i in vscrollRegistry){
        vscrollRegistry[i].init();
    }
}
function startVScroll(id,dir){
    vscrollRegistry[id].startScroll(dir);
}
function stopVScroll(id){
    vscrollRegistry[id].stop();
}
