home *** CD-ROM | disk | FTP | other *** search
/ PCMania 13 / Pcmania_Ep2_13_CD-01.iso / ARTICULOS / CDROM / Demos / SCRIPT.JS < prev   
Encoding:
Text File  |  2000-10-10  |  3.0 KB  |  76 lines

  1. /*Browsercheck:*/
  2. ie=document.all?1:0
  3. n=document.layers?1:0
  4.  
  5. /*********************************************************************************
  6. These are the variables you have to set:
  7. *********************************************************************************/
  8.  
  9. //The speed of the timeout between each scroll.
  10. timSpeed=50
  11.  
  12. //The height of the container (change this when it scrolls to much or to little)
  13. contHeight=100
  14.  
  15. /*********************************************************************************
  16. This is the object constructor function, which applies 
  17. methods and properties to the Cross-browser layer object
  18. *********************************************************************************/
  19. function makeScrollObj(obj,nest){
  20.     nest=(!nest) ? '':'document.'+nest+'.'                                        
  21.     this.css=(n) ? eval(nest+'document.'+obj):eval('document.all.'+obj+'.style')                            
  22.     this.scrollHeight=n?this.css.document.height:eval('document.all.'+obj+'.offsetHeight')                            
  23.     this.top=b_gettop                                        
  24.     return this
  25. }
  26. //Getting the top for the top method
  27. function b_gettop(){
  28.     var gleft=(n) ? eval(this.css.top):eval(this.css.pixelTop);
  29.     return gleft;
  30. }
  31. //Variables
  32. var scrollTim;
  33. var active=0;
  34. /*********************************************************************************
  35. The scroll function. Checks what way to scroll and checks if the
  36. layer is not already on top or bottom.
  37. *********************************************************************************/
  38. function scroll(speed){
  39.     clearTimeout(scrollTim)
  40.     way=speed>0?1:0
  41.     if((!way && oScroll[active].top()>-oScroll[active].scrollHeight+contHeight) || (oScroll[active].top()<0 && way)){
  42.         oScroll[active].css.top=oScroll[active].top()+speed
  43.         scrollTim=setTimeout("scroll("+speed+")",timSpeed)
  44.     }
  45. }
  46. //Clears the timeout so the scroll stops, this is called onmouseout.
  47. function noScroll(){
  48.     clearTimeout(scrollTim)
  49. }
  50. /*********************************************************************************
  51. Changes the active layer. Hides the one that's visible and
  52. shows the "new" one. Also set's the new layers top to
  53. 0 so it starts at top.
  54. *********************************************************************************/
  55. function changeActive(num){
  56.     oScroll[active].css.visibility='hidden'
  57.     active=num
  58.     oScroll[active].css.top=0
  59.     oScroll[active].css.visibility='visible'
  60. }
  61. /*********************************************************************************
  62. Initilizes the page, makes a oScroll Array and calls the object constructor.
  63. Here you can add as many scrollObjects as you want
  64. *********************************************************************************/
  65. function scrollInit(){
  66.     oScroll=new Array()
  67.     oScroll[0]=new    makeScrollObj('divScroll1','divCont')
  68.     oScroll[0].css.visibility='visible'
  69. }
  70. /*********************************************************************************
  71. Executes the scrollInit function on pageload.
  72. *********************************************************************************/
  73. onload=scrollInit;
  74.  
  75. //-->
  76.