﻿// JScript File

// array used to hold state of each button
// 0 = inactive state (no hover)
// 1 = active state (hover)
var currState = new Array(1, 0, 0, 0, 0, 0);

getCurrState = function(id, alertID) {
   var idNum = id.replace(/text/, '').replace(/bg/, '');
   if (-1 < idNum < 7)
      return currState[idNum];
   else
      return null;
}

swap = function(activeID) {
   inactivateAllIcons();
   
   for (num=0; num<7; num++) {
      // if state is active, deactivate
      if (currState[num] == 1) {
         currState[num] = 0;
         fadeOut('text' + num, 300);
         if (num > 0) setTimeout("fadeOut(document.getElementById('bg" + num + "').id, 300)", 200);
      }
   }

   currState[activeID] = 1; 
   setTimeout("fadeIn('text" + activeID + "', 1000)", 400);
   if (activeID > 0) {
      activateIcon(activeID);
      fadeIn('bg' + activeID, 500);
   }

}

inactivateAllIcons = function() {
   for (j=1; j<7; j++) {
      document.getElementById('button' + j).src = 'graphics/site/home/buttons/button_' + j + '_off.png';
   }
}

activateIcon = function(activeID) {
      document.getElementById('button' + activeID).src = 'graphics/site/home/buttons/button_' + activeID + '_on.png';
}

clickIcon = function(iconNum) {
   document.getElementById('button' + iconNum).src = 'graphics/site/home/buttons/button_' + iconNum + '_click.png';
}

releaseIcon = function(iconNum) {
   document.getElementById('button' + iconNum).src = 'graphics/site/home/buttons/button_' + iconNum + '_on.png';
}

initSwapPanel = function() {
   document.getElementById('text0').style.opacity = 0;
   document.getElementById('text0').style.visibility = 'visible';
   for (i=1; i<7; i++) {
      document.getElementById('text' + i).style.opacity = 0;
      document.getElementById('bg' + i).style.opacity = 0;
   }
   fadeIn('text0', 1);
}