

function pageWidth() {
var x;
if (self.innerHeight) // all except Explorer
{
	x = self.innerWidth;
}
else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
{
	x = document.documentElement.clientWidth;
}
else if (document.body) // other Explorers
{
	x = document.body.clientWidth;
}
  return x;
}

function pageHeight() {
var y;
if (self.innerHeight) // all except Explorer
{
	y = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
{
	y = document.documentElement.clientHeight;
}
else if (document.body) // other Explorers
{
	y = document.body.clientHeight;
}
  return y;
}

function getHexAlpha (n) {

  switch(n){
    case 10: return "A";
    case 11: return "B";
    case 12: return "C";
    case 13: return "D";
    case 14: return "E";
    case 15: return "F";
  }
  return ""+n;
}


function intToHex(n) {

   l = Math.floor(n/16);
   r = n-l*16;

   return getHexAlpha(l)+getHexAlpha(r);
}

   function SetElement(n) {
     i = document.getElementById('p'+n);
     i.style.z_index=n;
	  w=pageWidth()/2;
	  h=pageHeight()*0.9;
     i.style.left=Math.round(w*Math.random())+'px';
     i.style.top=Math.round(h*Math.random())+'px';
     i.style.color='#'+intToHex(Math.round(0xff*Math.random()))+intToHex(Math.round(0xff*Math.random()))+intToHex(Math.round(0xff*Math.random()));
     i.style.fontSize=9+Math.round(25*Math.random())+'pt';

     if ( Math.random() < 0.5) {
	i.style.visibility='hidden';
     } else {
	i.style.visibility='visible';
     }
																							
   }

   var sat;

   function SetAll() {
     for (var i=1; i < 17; ++i ) {
       SetElement(i);
     }

     i = document.getElementById('ibox');
     i.style.left= pageWidth()-200 +'px';
     i.style.top=  pageHeight()-300 +'px';

     document.getElementById('cr').style.top=pageHeight()-24 +'px';

     clearTimeout(sat);
     sat = setTimeout("SetAll()",10000);
   }



var SBStep=1;
var Interval=40;
var crossobj=0;
var contentheight=0;
var ScrollBoxDownVar=0;
var ScrollBoxUpVar=0;
var run = 0;
var bs6 = document.all || document.getElementById;
var ns4 = document.layers;

function StartScrollBox() {
  if (bs6) {
    document.write('<div id="container" style="position:relative;width:175px;height:260px;border:1px solid gray;overflow:hidden;">')
    document.write('<div id="content" style="position:absolute;width:170px;left:0;top:0;margin:3px">')
  } else {
    document.write('<ILAYER NAME="nscontainer" WIDTH="175" HEIGHT="260" CLIP="0,0,175,260">');
    document.write('<LAYER NAME="nscontent" WIDTH="175" HEIGHT="260" VISIBILITY="hidden">');
  }
  
}  

  
function EndScrollBox() {  
  if (bs6){
    crossobj=document.getElementById ? document.getElementById("content") : document.all.content;
    contentheight=crossobj.offsetHeight;
  } else if (ns4){
    crossobj=document.nscontainer.document.nscontent;
    contentheight=crossobj.clip.height;
  }
}

function ScrollBoxDown(){


  if (bs6 && parseInt(crossobj.style.top) >= (contentheight*(-1)+100)) {
    crossobj.style.top=parseInt(crossobj.style.top)-SBStep+"px";
  } else if (ns4 && crossobj.top >= (contentheight*(-1)+100)) {
    crossobj.top-=SBStep;
  }
  ScrollBoxDownVar=setTimeout("ScrollBoxDown()",Interval)

}

function ScrollBoxUp(){

  if (bs6 && parseInt(crossobj.style.top) <= 0) {
    crossobj.style.top=parseInt(crossobj.style.top)+SBStep+"px";
  } else if (ns4 && crossobj.top <= 0) {
    crossobj.top+=SBStep;
  }
  ScrollBoxUpVar=setTimeout("ScrollBoxUp()",Interval)
}

function ScrollBoxInit(){
  if (bs6) {
    contentheight=crossobj.offsetHeight;
  } else if (ns4) {
    document.nscontainer.document.nscontent.visibility="show"
  }
  
  run = run +1;
  if(run == 1) ScrollBoxDownVar=setTimeout("ScrollBoxDown()",3000)
}

function EndScrollBoxContent() {  
if (bs6) {
  document.write('</div></div>')
} else {
  document.write('</LAYER></ILAYER>');
}
}
