/*
 * Copyright 2006, Peter Rowntree. All Rights Reserved.
 * http://www.hdyn.com/wr/common/contact.php?addr=pr
 * needs: timers.js
 */
preloadImages(["/images/"],["arch.jpg","slx.gif"]);
var g_wo=null;
function doLoad()
{
   PNGInit(true);
   var boxes=initBoxes(document.getElementById("holder"));
   boxes.setRepeatAt(80);
   boxes.setWHOpts([70,49,1.7,1.9]);
   boxes.setWiggleProc(boxesWiggleProc);
   var stars=initStars(document.getElementById("holder2"));
   stars.setDensity(200);
/***
   if(Math.random() > 0.5)
      stars.start();
   else
      doOrbit();
***/
   g_wo=new Array(new Wiggler("head1",0,108),new Wiggler("xfcHolder",1,100),new Wiggler("btNotes",2,80));
}

function randPM(lt)
{
   var m=Math.random() > 0.5 ? 0.99999 : -0.99999;
   return Math.floor(Math.random()*m*lt);
}

function startAll()
{
   if(g_wo == null)
      return;
   for(var i=0; i<g_wo.length; ++i) 
      g_wo[i].start(130);
}

function dwi(i)
{
   if(g_wo != null)
      g_wo[i].dw(1.11);
}

function Wiggler(obName,i,delay)
{
   this.i_ob=document.getElementById(obName);
   this.i_i=i;
   this.i_delay=delay;
   this.i_gpt=new GPTimer();
   this.i_startLeft=this.i_ob.offsetLeft;
   this.i_startTop=this.i_ob.offsetTop;
   this.start=function(delta)
   {
      this.i_ob.style.left=(this.i_startLeft+randPM(delta))+"px";
      this.i_ob.style.top=(this.i_startTop+randPM(delta))+"px";
      this.i_gpt.doAfter("dwi("+i+")",delay);
   }
   //this.start(90);
   this.dw=function(f)
   {
      var delta=(this.i_ob.offsetLeft-this.i_startLeft)*f;
      if(Math.abs(delta) > 0)
         this.i_ob.style.left=(this.i_startLeft+randPM(delta))+"px";
      delta=(this.i_ob.offsetTop-this.i_startTop)*f;
      if(Math.abs(delta) > 0)
         this.i_ob.style.top=(this.i_startTop+randPM(delta))+"px";
      if(this.i_ob.offsetLeft != this.i_startLeft || this.i_ob.offsetTop != this.i_startTop)
         this.i_gpt.doAfter("dwi("+this.i_i+")",this.i_delay);
   }
}

function boxesWiggleProc(node,style)
{
   style.left=(node.offsetLeft+randPM(40))+"px";
   style.top=(node.offsetTop+randPM(40))+"px";
}

function doCombined()
{
   if(g_boxes != null)
      g_boxes.doBoxes();
}

function clrCombined()
{
   if(g_boxes != null)
      g_boxes.clrBoxes(true);
   if(typeof clrFloatSet != "undefined")
      clrFloatSet();
   if(typeof clrStars != "undefined")
      clrStars();
   if(typeof clrFloatSet != "undefined")
      clrFloatSet();
}

function oBeads(how)
{
	document.getElementById("rtOb").style.backgroundColor = how ? "#fe4" : "transparent"; 
}