var KS=[]
var KScounter=0
var over=0
var endscroll = 0
var speed = 60
var layerLength = layerl;

function KScrolling(text,width,height,lineheight){
   if(text.length && text.join){
      text=text.join("<br>")
   }

   this.number=KScounter++
   this.width=width
   this.height=height
   this.lineheight=lineheight
   this.text=text
   this.offset = 0
   KS[this.number]=this
}

KScrolling.prototype.print=function(){
   if(isMSIE || isMozilla || isOpera6){
      document.write("<div id='KSborder"+this.number+"' style='width: "+this.width+"px;height: "+this.height+"px;overflow: hidden'><div id='KStext"+this.number+"' style='position: relative; top: 0px; left: 0px;'>"+this.text+"<br>"+this.text+"</div></div>")
   }else if(isNC4){
      document.write("<style>")
      document.write("#KStext"+this.number+"{")
      document.write("position: absolute;")
      document.write("clip: rect(0px "+this.width+"px "+this.height+"px 0px);")
      document.write("visibility: hidden;")
      document.write("}")
      
      document.write("#KSNN"+this.number+"{")
      document.write("position: relative;")
      document.write("visibility: hidden")
      document.write("}")
      document.write("</style>")
      document.write("<div id='KStext"+this.number+"'>"+this.text+"<br>"+this.text+"</div>")
      document.write("<span id='KSNN"+this.number+"'><spacer type=block width="+this.width+" height="+this.height+"></span>")
   }else{
      document.write(this.text)
      this.badBrowser=true
   }
}
KScrolling.prototype.scroll=function (offset){
      if(this.badBrowser) return
      if(!this.layer) {
         this.layer=layer("KStext"+this.number)
         if(isNC4){
            var l=layer("KSNN"+this.number)
            this.layer.move(this.left=l.getLeft(),this.top=l.getTop())
            this.layer.show()
         }
         this.offset=0
      }else{
//       this.offset=(this.offset+1)%(this.layer.getWidth()/2)
         this.offset = this.offset + offset
   //    alert(this.offset)         
         status=this.layer.getWidth()
         
         if(isNC4){
            this.layer.scroll(this.left,this.top,this.width,this.height,-this.offset, 0)
         }else if(!this.badBrowser){
            this.layer.moveX(-this.offset)
         }
      }
//    setTimeout("KS["+this.number+"].scroll("+this.offset+")",30)
}


function back_scroll(offset) {
//    alert(S.offset)
    if (over == 1 && S.offset > 0 ) {
      S.scroll(offset)
      setTimeout("back_scroll("+offset+")",speed)
    }
}

function forward_scroll(offset) {
//    alert(S.offset)
    if (over == 1 && S.offset < layerLength-725) {
      S.scroll(offset)
      setTimeout("forward_scroll("+offset+")",speed)
    }
}
