var OPEN_WIDTH = 680;
var CLOSE_WIDTH = 135;
var INTERVAL = 20;

var openedfold = 1;
var trayopen = false;
var traysize = 0;
var traypos = 350;

var traystyles = new Array();
traystyles[1] = 'frcdescrip';
traystyles[2] = 'ftcdescrip';
traystyles[3] = 'flldescrip';

var widths = new Array();
widths[1] = OPEN_WIDTH;
widths[2] = CLOSE_WIDTH;
widths[3] = CLOSE_WIDTH;

var tray1 = new Image();
tray1.src = '/themes/tutorial/images/frc_descrip.png';
var tray2 = new Image();
tray2.src = '/themes/tutorial/images/ftc_descrip.png';
var tray3 = new Image();
tray3.src = '/themes/tutorial/images/fll_descrip.png';

function openFold(elem)
{
/*for(i=1; i<=3; i++)
{
   document.getElementById('fold'+i).className = 'folded';
}
elem.className = 'folded foldedopen';*/

openedfold = elem;

document.getElementById('tray').className = 'progdescrip ' + traystyles[elem];
}

function rcappopLinks()
{
var els = document.getElementsByTagName('a');
for(var i in els)
{
if (els[i].className=='rcappop')
{
els[i].href = "javascript: void(window.open('"+els[i].href+"', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'));";
els[i].target = '';
}
}
}

function tick()
{
   delta = 0;
   for(i=1; i<=3; ++i)
   {
      if (i!=openedfold)
      {
         width = widths[i];
         if (width > CLOSE_WIDTH)
         {
            el = document.getElementById('fold'+i);
            d = Math.min(width-CLOSE_WIDTH, INTERVAL);
            delta += d;
			widths[i] = (width-d);
            el.style.width = widths[i]+"px";
            break;
         }
      }
   }
   if (delta > 0)
   {
      el = document.getElementById('fold'+openedfold);
      widths[openedfold] += delta;
      el.style.width = widths[openedfold]+"px";
   }

   if (trayopen && (traysize < 70))
   {
      el = document.getElementById('tray');
      traysize += 5;
      el.style.height = traysize + "px";
      traypos -= 5;
      el.style.marginTop = traypos + "px";
   }
   else if ((!trayopen) && (traysize > 0))
   {
      el = document.getElementById('tray');
      traysize -= 5;
      el.style.height = traysize + "px";
      traypos += 5;
      el.style.marginTop = traypos + "px";
   }
}

function openMenu(m)
{
if (m=='') m = '2';
document.getElementById('menu0').className = 'menubar';
for(i=1; ; i++)
{
   var el = document.getElementById('menu'+i)
   if (el==null) break;
   el.className = 'menubar';
   document.getElementById('button'+i).className = 'button';
}
document.getElementById('menu'+m).className = 'menubar menubaropen';
document.getElementById('button'+m).className = 'button buttonopen';
}

function opentray()
{
trayopen = true;
}
function closetray()
{
trayopen = false;
}
