home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / Chip_2002-06_cd1.bin / internet / zongl / jongl.js < prev    next >
Text File  |  2002-04-19  |  4KB  |  153 lines

  1. var ua=navigator.userAgent;
  2. var v=navigator.appVersion.substring(0,1); if ((ua.lastIndexOf("MSIE")!=-1) && (v!="1") && (v!="2") && (v!="3"))
  3. {
  4.    document.body.onmouseover=makeCool;
  5.    document.body.onmouseout=makeNormal;
  6.  
  7.  
  8. function makeCool()
  9. {
  10.    src=event.toElement;
  11.    if (src.tagName=="H1")
  12.    {
  13.       src.oldcol=src.style.color;
  14.       src.style.color="F3B14E";
  15.       src.oldback=src.style.background;
  16.       src.style.background="A90000";
  17.    }
  18.    if (src.tagName=="H2")
  19.    {
  20.       src.oldcol=src.style.color;
  21.       src.style.color="A90000";
  22.       src.oldback=src.style.background;
  23.       src.style.background="F3B14E";
  24.    }
  25.    
  26.  
  27. function makeNormal()
  28. {
  29.    src=event.fromElement;
  30.    if (src.tagName=="H1") 
  31.    {
  32.      src.style.color=src.oldcol;
  33.      src.style.background=src.oldback;
  34.    }
  35.  
  36.    if (src.tagName=="H2") 
  37.    {
  38.      src.style.color=src.oldcol;
  39.      src.style.background=src.oldback;
  40.    }
  41. }
  42.  
  43. //Default browsercheck, added to all scripts!
  44. function checkBrowser(){
  45.         this.ver=navigator.appVersion
  46.         this.dom=document.getElementById?1:0
  47.         this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
  48.         this.ie4=(document.all && !this.dom)?1:0;
  49.         this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
  50.         this.ns4=(document.layers && !this.dom)?1:0;
  51.         this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
  52.         return this
  53. }
  54. bw=new checkBrowser()
  55. /*****************
  56. You set the width and height of the divs inside the style tag, you only have to
  57. change the divCont, Remeber to set the clip the same as the width and height.
  58. You can remove the divUp and divDown layers if you want. 
  59. This script should also work if you make the divCont position:relative.
  60. Then you should be able to place this inside a table or something. Just remember
  61. that Netscape crash very easily with relative positioned divs and tables.
  62. Updated with a fix for error if moving over layer before pageload.
  63. ****************/
  64.  
  65. //If you want it to move faster you can set this lower:
  66. var speed=55
  67.  
  68. //Sets variables to keep track of what's happening
  69.  
  70. var loop, timer
  71.  
  72. //Object constructor
  73.  
  74. function makeObj(obj,nest){
  75.     nest=(!nest) ? '':'document.'+nest+'.'
  76.         this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
  77.         this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
  78.  
  79.         this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
  80.  
  81.         this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
  82.  
  83.         this.up=goUp;this.down=goDown;
  84.  
  85.         this.moveIt=moveIt; this.x; this.y;
  86.  
  87.     this.obj = obj + "Object"
  88.  
  89.     eval(this.obj + "=this")
  90.  
  91.     return this
  92.  
  93. }
  94.  
  95. function moveIt(x,y){
  96.  
  97.         this.x=x;this.y=y
  98.  
  99.         this.css.left=this.x
  100.  
  101.         this.css.top=this.y
  102.  
  103. }
  104.  
  105. //Makes the object go up
  106. function goDown(move){
  107.  
  108.         if(this.y>-this.scrollHeight+oCont.clipHeight){
  109.                 this.moveIt(0,this.y-move)
  110.                         if(loop) setTimeout(this.obj+".down("+move+")",speed)
  111.         }
  112. }
  113.  
  114. //Makes the object go down
  115. function goUp(move){
  116.         if(this.y<0){
  117.                 this.moveIt(0,this.y-move)
  118.                 if(loop) setTimeout(this.obj+".up("+move+")",speed)
  119.         }
  120.  
  121. }
  122.  
  123. //Calls the scrolling functions. Also checks whether the page is loaded or not.
  124. function scroll(speed){
  125.  
  126.         if(loaded){
  127.                 loop=true;
  128.                 if(speed>0) oScroll.down(speed)
  129.                 else oScroll.up(speed)
  130.         }
  131.  
  132. }
  133.  
  134. //Stops the scrolling (called on mouseout)
  135. function noScroll(){
  136.         loop=false
  137.         if(timer) clearTimeout(timer)
  138. }
  139.  
  140. //Makes the object
  141. var loaded;
  142. function scrollInit(){
  143.         oCont=new makeObj('divCont')
  144.         oScroll=new makeObj('divText','divCont')
  145.         oScroll.moveIt(0,0)
  146.         oCont.css.visibility='visible'
  147.         loaded=true;
  148. }
  149. //Call the init on page load
  150. onload=scrollInit;
  151.