window.onload = init

function init()
{ setRollovers()
  setWindows()
  
  if (document.getElementById("home"))
  { startAnimation()
  }
  if (document.getElementById("work"))
  { setInterval("startMonitoring()",50)
  }
}




/*

after the html page loads, setRollovers() scans the HTML page for any img tag 
that has the class "rollOver". When it finds one, it attaches the mouseover events.

*/

function setRollovers()
{ imgs = document.getElementsByTagName("img")
  for (i=0;i<imgs.length;i++)
  { if (/rollOver/.test(imgs[i].className))
    { imgs[i].parentNode.onmouseover=function(){roll(this,true);}
      imgs[i].parentNode.onmouseout=function(){roll(this,false);}
      imgs[i].parentNode.onfocus=function(){roll(this,true);}
      imgs[i].parentNode.onblur=function(){roll(this,false);}
    }
  }
}

function setWindows()
{ var anchors = document.getElementsByTagName("a")
  for (var i=0; i<anchors.length; i++)
  { var anchor = anchors[i]
    if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "newWindow")
    { anchor.target = "_blank";
    }
  }
} 




/*

roll() handles the image rollovers.

*/

function roll(node,status)
{ nodeImg = node.firstChild
  srcImg = nodeImg.getAttribute("src")
  fileName = srcImg.substring(0,srcImg.length - 7)
  navState = srcImg.substring(srcImg.length - 7,srcImg.length - 4)
  fileType = srcImg.substring(srcImg.length - 3,srcImg.length - 0)
  
  if (status)
  { if (navState == "off")
    { fileName = fileName + "ovr." + fileType
      nodeImg.setAttribute("src",fileName)
    }
  }
  else
  { if ((navState != "sel") && (navState != "off"))
    { fileName = fileName + "off." + fileType
      nodeImg.setAttribute("src",fileName)
    }
  }
}




workCurrent = 0
workShowing = 0
workPics = new Array(100,0,0,0,0)

function startMonitoring()
{ for (i=0;i<=4;i++)
  { if (workShowing == i)
    { workPics[i] = workPics[i] + 20
      if (workPics[i] >= 100)
      { workPics[i] = 100
      }
    }
    else
    { workPics[i] = workPics[i] - 20
      if (workPics[i] < 0)
      { workPics[i] = 0
      }
    }
  }
   updateDisplay()
}

function updateDisplay()
{ for (i=0;i<=4;i++)
  { setOpacity("bigImg" + i, workPics[i])
  }
}






function workRoll(which)
{ workShowing = which
}

function workOff()
{ workShowing = workCurrent
}

function workClick(which)
{ for (i=0; i<=4; i++)
  { if (i != which)
    { document.getElementById("copy" + i).style.display = "none"
    }
    else
    { document.getElementById("copy" + i).style.display = "block"
      workCurrent = which
    }
  }
  workSetTab(workCurrent)
  workOff()
}

function workSetTab(which)
{ liList = document.getElementById("sideNav").getElementsByTagName("LI")
  for (i=0; i<=4; i++)
  { if (i != which)
    { liList[i].className = ""
      if ((i == 1) || (i == 4))
      { liList[i].className = "twoLine"
      }
    }
    else
    { liList[i].className = "selected"
      if ((i == 1) || (i == 4))
      { liList[i].className = "twoLine selected"
      }
    }
  }
}










function setOpacity(obj,num)
{ obj = document.getElementById(obj)
  obj.style.MozOpacity = (num / 100)
  obj.style.opacity = (num / 100)
  obj.style.filter = "alpha(opacity=" + num + ")"
}






currentMain = 0
nextMain = 1
opacMain = 100

function startAnimation()
{ setInterval("fadeMain()",3250)
}

function fadeMain()
{ setOpacity("main" + currentMain, opacMain)
  setOpacity("main" + nextMain, (100 - opacMain))
  
  opacMain = opacMain - 10
  
  if (opacMain >= 0 )
  { setTimeout("fadeMain()", 50)
  }
  else
  { currentMain++
    if (currentMain == 6)
    { currentMain = 0
    }
    nextMain++
    if (nextMain == 6)
    { nextMain = 0
    }
    opacMain = 100
  }
}





/*

play video in pop-up window.

*/

function popVid()
{ url = "webcast.htm"
  win = window.open(url,'video','toolbar=no,location=no,directories=no,width=640,height=520');
  win.focus();
} 