home *** CD-ROM | disk | FTP | other *** search
/ Chip Hitware 7 A / CHIP_HITWARE_7A.iso / internet / Webmaster / _SETUP.4 / Group3 / bgf.jav < prev    next >
Text File  |  1998-12-30  |  1KB  |  65 lines

  1. <!---BeginTitle--->Background Fade Black to White<!---BeginJAVHead---><SCRIPT LANGUAGE="JavaScript">
  2. <!-- JavaScript by Jacob Friis Larsen ---
  3.  
  4.  window.defaultStatus = "Jacobs Java enhanced HomePage";
  5.  
  6. // FadeScript begin
  7.  
  8. function MakeArray(N) 
  9.  {
  10.   this.length = N;
  11.   for (I = 1; I <= N; I++)
  12.    this[I] = 0;
  13.   return this;
  14.  }
  15.  
  16. Hexa = new MakeArray(16);
  17.  
  18. for (I = 0; I < 10; I++)
  19.  Hexa[I] = I;
  20.  
  21. Hexa[10]="A"; Hexa[11]="B"; Hexa[12]="C";
  22. Hexa[13]="D"; Hexa[14]="E"; Hexa[15]="F";
  23.  
  24. function Hex(I) 
  25.  {
  26.   if (I < 0)
  27.     return "00";
  28.    else 
  29.     if (I > 255)
  30.       return "FF";
  31.      else
  32.       return "" + Hexa[Math.floor(I/16)] + Hexa[I%16];
  33.  }
  34.  
  35. function SetbgColor(R, G, B) 
  36.  {
  37.   HexRed = Hex(R); HexGreen = Hex(G); HexBlue = Hex(B);
  38.   document.bgColor = "#" + HexRed + HexGreen + HexBlue;
  39.  }
  40.  
  41. function Fade(StartRed, StartGreen, StartBlue, EndRed, EndGreen, EndBlue, 
  42. Step) 
  43.  {
  44.   for(I = 0; I <= Step; I++) 
  45.    {
  46.     Rtmp = Math.floor(StartRed   * ((Step-I)/Step) + EndRed   * (I/Step));
  47.     Gtmp = Math.floor(StartGreen * ((Step-I)/Step) + EndGreen * (I/Step));
  48.     Btmp = Math.floor(StartBlue  * ((Step-I)/Step) + EndBlue  * (I/Step));
  49.  
  50.     SetbgColor (Rtmp,Gtmp,Btmp);
  51.    }
  52.  }
  53.  
  54. function FadeIn() 
  55.  {
  56.   Fade(0,0,0, 255,255,255, 64);
  57.  }
  58.  
  59. FadeIn();
  60.  
  61. // End of FadeScript
  62.  
  63. // --- End hiding from JavaScript challenged browsers -->
  64. </SCRIPT><!---BeginJAVBody---><!--EndJAVBody-->
  65.