var HScroller=function(){}
HScroller.prototype={
    id:"SETME",
    speed:8,
    step:2,
    interval:null,
    containerObj:null,
    bodyObj:null,
    containerObjId:null,
    bodyObjId:null,
    cW:0,
    bW:0,
    dir:"+",
    init:function(){
        this.containerObj=$(this.containerObjName);
        this.bodyObj=$(this.bodyObjName);
        this.cW=this.containerObj.offsetWidth;
        this.bW=this.bodyObj.offsetWidth;
    },
    startScroll:function(_dir){
        this.dir=_dir;
        clearInterval(this.interval);
	this.interval=setInterval('hscrollRegistry["'+this.id+'"].scroll()',this.speed);
    },
    scroll:function(){
        if(this.dir=="+"){
            var newPos=parseFloat(this.bodyObj.style.left)-this.step;
            if(this.bW+ newPos>this.cW){
                this.bodyObj.style.left= newPos+"px";
            }else{
                this.stop();
            }
        }else{
            var newPos=parseFloat(this.bodyObj.style.left)+this.step;
            if(newPos<0){
                this.bodyObj.style.left=newPos+"px";
            }else{
                this.stop();
            }
        }
    },
    stop:function(){
        if(this. interval){
            clearInterval(this.interval);
        }
    }
}
hscrollRegistry=new Array();
function registerHScrollerById(id){
    var scroller=new HScroller();
    scroller.id=id;
    scroller.containerObjName="scrollContainer"+id;
    scroller.bodyObjName="scrollBody"+id;
    registerHScroller(scroller);
}
function registerHScroller(scroller){
    hscrollRegistry[scroller.id]=scroller;
}
function initHScroll(){
    for(var i in hscrollRegistry){
        hscrollRegistry[i].init();
    }
}
function startHScroll(id,dir){
    hscrollRegistry[id].startScroll(dir);
}
function stopHScroll(id){
    hscrollRegistry[id].stop();
}
