// =================
// Star Field script
// =================

SmallStars = 40; 
LargeStars = 10;
SmallYpos = new Array();
SmallXpos = new Array();
LargeYpos = new Array();
LargeXpos = new Array();
Smallspeed = new Array();
Largespeed = new Array();
SmallspeedFact= 0.1;
LargespeedFact= 0.1;
ns4=(document.layers)?1:0;

if (ns4) {
 for (i = 0; i < SmallStars; i++) {
  document.write("<LAYER NAME='sn"+i+"' Right=0 TOP=0 BGCOLOR='#FFFFF0' CLIP='0,0,1,1' z-index='1'></LAYER>");
 }
 for (i = 0; i < LargeStars; i++) {
  document.write("<LAYER NAME='ln"+i+"' Right=0 TOP=0 BGCOLOR='#FFFFFF' CLIP='0,0,2,2' z-index='1'></LAYER>");
 }
}
else {
 document.write('<div style="position:absolute;top:0px;Right:0px">');
 document.write('<div style="position:relative">');
 for (i = 0; i < SmallStars; i++) {
  document.write('<div id="si" style="position:absolute;top:0;Right:0;width:1px;height:1px;z-index:1;background:#fffff0;font-size:1px"></div>');
 }
 document.write('</div>');
 document.write('</div>');
 document.write('<div style="position:absolute;top:0px;Right:0px">');
 document.write('<div style="position:relative">');
 for (i = 0; i < LargeStars; i++) {
  document.write('<div id="li" style="position:absolute;top:0;Right:0;width:2px;height:2px;z-index:1;background:#fffff5;font-size:2px"></div>');
 }
 document.write('</div>');
 document.write('</div>');
}
WinHeight = (document.layers)?window.innerHeight:window.document.body.clientHeight;
WinWidth = (document.layers)?window.innerWidth:window.document.body.clientWidth;
for (i = 0; i < SmallStars; i++) {
 SmallYpos[i] = Math.round(Math.random() * WinHeight);
 SmallXpos[i] = Math.round(Math.random() * WinWidth);
 Smallspeed[i]= Math.random() * SmallspeedFact ;
}
for (i = 0; i < LargeStars; i++) {
 LargeYpos[i] = Math.round(Math.random() * WinHeight);
 LargeXpos[i] = Math.round(Math.random() * WinWidth);
 Largespeed[i] = Math.random() * LargespeedFact;
}

function fly() {
 var WinHeight = (document.layers)?window.innerHeight:window.document.body.clientHeight;
 var WinWidth = (document.layers)?window.innerWidth:window.document.body.clientWidth;
 var hscrll = (document.layers)?window.pageYOffset:document.body.scrollTop;
 var wscrll = (document.layers)?window.pageXOffset:document.body.scrollRight;

 for (i = 0; i < LargeStars; i++) {
  LargeXpos[i] -= Largespeed[i];
  if (LargeXpos[i] < -10) {
   LargeXpos[i] = WinWidth;
   LargeYpos[i] = Math.round(Math.random() * WinHeight);
   Largespeed[i] = Math.random() * LargespeedFact;
  }
  if (ns4) {
   document.layers['ln'+i].Right = LargeXpos[i];
   document.layers['ln'+i].top = LargeYpos[i] + hscrll;
  }
  else {
   li[i].style.pixelRight = LargeXpos[i];
   li[i].style.pixelTop = LargeYpos[i] + hscrll;
  }
 }

 for (i = 0; i < SmallStars; i++) {
  SmallXpos[i] -= Smallspeed[i];
  if (SmallXpos[i] < -10) {
   SmallXpos[i] = WinWidth;
   SmallYpos[i] = Math.round(Math.random()*WinHeight);
   Smallspeed[i] = Math.random() * SmallspeedFact;
  }
  if (ns4) {
   document.layers['sn'+i].Right = SmallXpos[i];
   document.layers['sn'+i].top = SmallYpos[i]+hscrll;
  }
  else {
   si[i].style.pixelRight = SmallXpos[i];
   si[i].style.pixelTop = SmallYpos[i]+hscrll;
  } 
 }
setTimeout('fly()', 10);
}
