//code by Adam Christensen, adam@spidershopdigital.com


var currentDiv = "";
var timeOut = "1";
var timer = "";
var currentOpacity = 0;
var newOpacity = 0;
var speedIn = ".01";
var speedOut = ".05"
function showDiv(selected){
 if (currentDiv != selected){
  if (currentDiv != "") {
    if (currentDiv != null){
      document.getElementById(currentDiv).style.visibility = "hidden";
      currentOpacity = 0;
      }
    }
  currentDiv = selected;
 if (currentDiv != null){
  if (currentDiv != ""){
    document.getElementById(currentDiv).style.opacity = "0";
    document.getElementById(currentDiv).style.filter = "alpha(opacity=0)";
    document.getElementById(currentDiv).style.visibility = "visible";
    fadeIn();
    }
  }
 }
}
function fadeIn(){
 if (currentOpacity < 100){
 newOpacity = currentOpacity + 5;
 document.getElementById(currentDiv).style.opacity = newOpacity / 100;
 document.getElementById(currentDiv).style.filter = "alpha(opacity=" + newOpacity + ")";
 currentOpacity = newOpacity;
 setTimeout("fadeIn()", speedIn * 1000);
 }
 }
function fadeOut(){
 if (currentOpacity > 100){
 currentOpacity = 100;
 }
 if (currentOpacity > 0){
 newOpacity = currentOpacity - 5;
 document.getElementById(currentDiv).style.opacity = newOpacity / 100;
 document.getElementById(currentDiv).style.filter = "alpha(opacity=" + newOpacity + ")";
 currentOpacity = newOpacity;
 setTimeout("fadeOut()", speedOut * 1000);
 }
 else{
 showDiv('');
 }
 }
function stopTimer(){
  clearTimeout(timer);
 }
function startTimer(){
 timer = setTimeout("fadeOut('')", timeOut * 1000);
 } 

