<!--

// Copyright 2002 - James Bennett, www.jimbennett.org all rights reserved

var TimerArr = new Array(7);
var Incr = 1000;

var DIVstr = '';
var Indx;
var MaxRows = 5;
var BMax = (8*MaxRows)-1;
var MapTop;
var MapLeft;
var MPath = new Array(BMax);

var NT = NavType();

function XYCoords(StartX,StartY,EndX,EndY) {
var x0, x1, y0, y1
this.StartX = StartX;
this.StartY = StartY;
this.EndX = EndX;
this.EndY = EndY;
if (StartX > EndX) {
  this.src = 'B50-3.gif'
} else {
  this.src = 'B50-1.gif'
}

y0 = (-1 * StartY) - MapTop
y1 = (-1 * EndY) - MapTop
x0 = StartX + MapLeft
x1 = EndX + MapLeft
this.Slope = (y1-y0) / (x1-x0)
this.yint = -1 * ((this.Slope * x1) - y1)

}


function SetButterflies() {
Mexico = new Array(320,474)
California = new Array(40,200)
CA = new Array(585,505,405,302,230,135,120,100,34,82,33,47,59,22,42,20)

SetPos();
 
for (var i = 0; i <= BMax ; i++) {
  Indx = i % 8
  if (Indx <= 4) {
    MPath[i] = new XYCoords(CA[Indx],CA[Indx+8],Mexico[0],Mexico[1])    
  } else {
    MPath[i] = new XYCoords(CA[Indx],CA[Indx+8],California[0],California[1])    
  }
    DIVstr = '<DIV id=bf'  
    DIVstr = DIVstr + String(i) + ' style="WIDTH: 50px; HEIGHT: 53px; POSITION: absolute; left:'
    DIVstr = DIVstr + String(MPath[i].StartX+MapLeft) + 'px; top:' + String(MPath[i].StartY+MapTop)
    DIVstr = DIVstr + 'px; visibility: hidden"><IMG name=bfi' + String(i) + ' src=' + MPath[i].src
    DIVstr = DIVstr + ' height=53 width=50 border=0></DIV>'
    document.write(DIVstr)

}
}

function migrate(Track, ItemNo) {
var Indx = Track + (8*ItemNo)
var oDiv
var dTop, dLeft
var maxVar = 5

if (NT.indexOf("IE1") != -1) {
  oDiv = eval('bf' + (Indx));
  if (oDiv != null) {
    dTop = parseInt(oDiv.style.top);
  }
} else if (NT.indexOf("NS1")!= -1) {
  oDiv = eval('document.bf' + (Indx));
  if (oDiv != null) {
    dTop = parseInt(oDiv.top);
  }
} else if (NT.indexOf("NS2") != -1) {
  oDiv = eval(document.getElementById('bf' + (Indx)));
  if (oDiv != null) {
    dTop = parseInt(oDiv.style.top);
  }

}

if (oDiv != null) {
  if (dTop < (MPath[Indx].EndY + MapTop)) {
    dTop = dTop +7
    dLeft = ( ( (-1*dTop)-MPath[Indx].yint) / MPath[Indx].Slope)

    dTop = dTop + (maxVar+1) - (Math.round(Math.random() * (maxVar*2)) + 1)
    dLeft = dLeft + (maxVar+1) - (Math.round(Math.random() * (maxVar*2)) + 1)

    if (NT.indexOf("NS1") ==-1 ) {
      oDiv.style.top = dTop
      oDiv.style.left = dLeft
      if (oDiv.style.visibility == 'hidden') {
        oDiv.style.visibility = 'visible'
        }
    } else {
      oDiv.top = dTop
      oDiv.left = dLeft
      if (oDiv.visibility == 'hide') {
        oDiv.visibility = 'show'
      }
    }

    if (Track > 4) {
      Incr = Math.round(Math.random() * 1000) + 500
    } else {
      Incr = Math.round(Math.random() * 1000)
    }
    TimerArr[Track]=setTimeout("migrate(" + String(Track) + "," + String(ItemNo) + ")",Incr);
  } else {
    if (ItemNo+1 < MaxRows) {
          TimerArr[Track]=setTimeout("migrate(" + String(Track) + "," + String(ItemNo+1) + ")",Incr);
  }}

}}


function SetPos() {
var OS1
var OS2
var OS3
var OS4

if(NT.indexOf("IE1") != -1) {
   OS1 = (window.document.body.offsetWidth/2)-(parseInt(MMap.style.width)/2)
   OS2 = (window.document.body.offsetWidth/2)-(parseInt(MMap2.style.width)/2)
   OS3 = (window.document.body.offsetWidth/2)-(parseInt(Credits.style.width)/2)
   OS4 = (window.document.body.offsetWidth/2)-(parseInt(Hdr.style.width)/2)

   if (OS1 < 0) {
      OS1 = 0
   }
   if (OS2 < 0) {
      OS2 = 0
   }
   if (OS3 < 0) {
      OS3 = 0
   }
   if (OS4 < 0) {
      OS4 = 0
   }
   MMap.style.left = OS1
   MMap2.style.left = OS2
   Credits.style.left = OS3
   Hdr.style.left = OS4
   MapLeft = parseInt(MMap.style.left)
   MapTop = parseInt(MMap.style.top)

} else if (NT.indexOf("NS1") != -1) {
   OS1 = (window.innerWidth/2)-357;
   OS2 = (window.innerWidth/2)-357;
   OS3 = (window.innerWidth/2)-386;
   OS4 = (window.innerWidth/2)-386;
   if (OS1 < 0) {
      OS1 = 0
   }
   if (OS2 < 0) {
      OS2 = 0
   }
   if (OS3 < 0) {
      OS3 = 0
   }
   if (OS4 < 0) {
      OS4 = 0
   }
   document.MMap.left = OS1;
   document.MMap2.left = OS2;
   document.Credits.left = OS3;
   document.Hdr.left = OS4;
   MapLeft = parseInt(document.MMap.left)
   MapTop = parseInt(document.MMap.top)

} else if(NT.indexOf("NS2") != -1) {

   OS1 = (window.innerWidth/2)-(parseInt(document.getElementById('MMap').style.width)/2)
   OS2 = (window.innerWidth/2)-(parseInt(document.getElementById('MMap2').style.width)/2)
   OS3 = (window.innerWidth/2)-(parseInt(document.getElementById('Credits').style.width)/2)
   OS4 = (window.innerWidth/2)-(parseInt(document.getElementById('Hdr').style.width)/2)

   if (OS1 < 0) {
      OS1 = 0
   }
   if (OS2 < 0) {
      OS2 = 0
   }
   if (OS3 < 0) {
      OS3 = 0
   }
   if (OS4 < 0) {
      OS4 = 0
   }
   document.getElementById('MMap').style.left = OS1
   document.getElementById('MMap2').style.left = OS2
   document.getElementById('Credits').style.left = OS3
   document.getElementById('Hdr').style.left = OS4
   MapLeft = parseInt(document.getElementById('MMap').style.left)
   MapTop = parseInt(document.getElementById('MMap').style.top)

}
}


function ClearTimers() {

  for (var i = 0; i <= 7 ; i++) {
    if (TimerArr[i] != null) {
     clearTimeout(TimerArr[i])
    }
  }

}


function NewYInt(MPNo) {
var x1;
var y1;

x1 = MPath[MPNo].EndX + MapLeft
y1 = -1*MPath[MPNo].EndY - MapTop
MPath[MPNo].yint = -1 * ((MPath[MPNo].Slope * x1) - y1)
}

function ResetAll(){
var oDiv;

if(navigator.appName.indexOf("Netscape") !=-1) {
  ClearTimers();
  location.reload();
} else {

  SetPos();
  for (var i = 0; i <= BMax ; i++) {
    NewYInt(i);
    oDiv = eval('bf' + String(i)) 
    if (parseInt(oDiv.style.top) >= MPath[i].EndY + MapTop) {
      oDiv.style.left = MPath[i].EndX + MapLeft 
    }
  } 
}
}


function StartMigration() {

SetPos();

TimerArr[0]=setTimeout("migrate(0,0)",2000);
TimerArr[1]=setTimeout("migrate(1,0)",16000);
TimerArr[2]=setTimeout("migrate(2,0)",6000);
TimerArr[3]=setTimeout("migrate(3,0)",12000);
TimerArr[4]=setTimeout("migrate(4,0)",10000);

TimerArr[5]=setTimeout("migrate(5,0)",8000);
TimerArr[6]=setTimeout("migrate(6,0)",14000);
TimerArr[7]=setTimeout("migrate(7,0)",4000);

}

function NavType() {
var strPos;
var WinMac;

if(navigator.appVersion.indexOf("Macintosh") != -1) {WinMac = "Mac";}
		else {WinMac = "Win";}


if(navigator.appName.indexOf("Netscape")!=-1) {
      strPos = navigator.userAgent.indexOf("Netscape/");
      if (strPos > 0) {
          if (parseInt(navigator.userAgent.substr(strPos+9,1)) > 6) {
               return ('NS2' + WinMac)
          } else {
             return ('NS1' + WinMac)
          }
      } else if (navigator.userAgent.indexOf("CS") != -1) {
         return ('NS2' + WinMac)
      } else {
         return ('NS1' + WinMac)
      }
} else {
   return ('IE1' + WinMac)
}
}


// -->
