home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 March / Chip_2002-03_cd1.bin / bonus / data / scroll.js < prev   
Text File  |  2001-07-03  |  2KB  |  69 lines

  1. function verifyCompatibleBrowser(){ 
  2.     this.ver=navigator.appVersion 
  3.     this.dom=document.getElementById?1:0 
  4.     this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
  5.     this.ie4=(document.all && !this.dom)?1:0; 
  6.     this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
  7.  
  8.     this.ns4=(document.layers && !this.dom)?1:0; 
  9.     this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
  10.     return this 
  11. bw=new verifyCompatibleBrowser() 
  12.  
  13.  
  14. var speed=50 
  15.  
  16. var loop, timer 
  17.  
  18. function ConstructObject(obj,nest){ 
  19.     nest=(!nest) ? '':'document.'+nest+'.' 
  20.     this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
  21.     this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
  22.     this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight 
  23.     this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight 
  24.     this.up=MoveAreaUp;this.down=MoveAreaDown; 
  25.     this.MoveArea=MoveArea; this.x; this.y; 
  26.     this.obj = obj + "Object" 
  27.     eval(this.obj + "=this") 
  28.     return this 
  29. function MoveArea(x,y){ 
  30.     this.x=x;this.y=y 
  31.     this.css.left=this.x 
  32.     this.css.top=this.y 
  33.  
  34. function MoveAreaDown(move){ 
  35.     if(this.y>-this.scrollHeight+objContainer.clipHeight){ 
  36.     this.MoveArea(0,this.y-move) 
  37.     if(loop) setTimeout(this.obj+".down("+move+")",speed) 
  38.     } 
  39. function MoveAreaUp(move){ 
  40.     if(this.y<0){ 
  41.     this.MoveArea(0,this.y-move) 
  42.     if(loop) setTimeout(this.obj+".up("+move+")",speed) 
  43.     } 
  44.  
  45. function PerformScroll(speed){ 
  46.     if(initialised){ 
  47.         loop=true; 
  48.         if(speed>0) objScroller.down(speed) 
  49.         else objScroller.up(speed) 
  50.     } 
  51.  
  52. function CeaseScroll(){ 
  53.     loop=false 
  54.     if(timer) clearTimeout(timer) 
  55. var initialised; 
  56. function InitialiseScrollableArea(){ 
  57.     objContainer=new ConstructObject('divContainer') 
  58.     objScroller=new ConstructObject('divContent','divContainer') 
  59.     objScroller.MoveArea(0,0) 
  60.     objContainer.css.visibility='visible' 
  61.     initialised=true;