var windCtrls = null;

function doOnLoad()
{
/* td_grad_black_ie
  if (!document.all) {
    document.getElementById('td_grad_left').style.background="url(../img/grad.png) top repeat-x";
    document.getElementById('td_grad_right').style.background="url(../img/grad.png) top repeat-x";
  }
*/
  windCtrls = document.getElementsByClassName("td_button_gray", "main_menu");

  setTimeout('blow();', 3000);
}

var curBlow = -1;
var lastBgColor = "";

function blow()
{
  curBlow = -1;

  _blow_each();

  //setTimeout('blow();', 15000);
}

function _blow_each()
{
  if (curBlow >= 0) {
    var idx = windCtrls.length - curBlow - 1;
    windCtrls[idx].bgColor = lastBgColor;
  }

  if (++curBlow >= windCtrls.length) {
    return;
  }

  var idx = windCtrls.length - curBlow - 1;
  lastBgColor = windCtrls[idx].bgColor;
  windCtrls[idx].bgColor = 'aliceblue';

  setTimeout('_blow_each();', 30);
}

function activateMenu(elem, sw)
{
  var i = 0;
  var textColor = null;
  var fontWeight = null;
  if (sw == true) {
    elem.bgColor = 'chartreuse';
    textColor = '#373737';
    fontWeight = 'bold';
  } else {
    elem.bgColor='dimgray';
    textColor = 'white';
    fontWeight = 'normal';
  }
  for (i=0; i< elem.childNodes.length; i++) {
    try {
      if (textColor != null) {
        elem.childNodes[i].style.color = textColor;
      }
      if (fontWeight != null) {
        elem.childNodes[i].style.fontWeight = fontWeight;
      }
      break;
    } catch (e) {}
  }
}

function showDownloadTree()
{
  var thetisBox=new ThetisBox;
  thetisBox.show("CENTER", "", "TREE", "", "", "");

  thetisBox.folderImg = "../img/thetis/icons/tree_folder_open.gif";

  array = new Array(
          new Array("0", "Download", "", "")
        );
  thetisBox.buildTree("", array);

  array = new Array(
          new Array('1', 'Thetis', '', "ThetisBox.remove("+thetisBox.id+"); window.open('http://sysphonic.com/thetis/frames?default=%2Fthetis%2Fitems%2Fbbs%3Ffolder_id%3D8').focus();"),
          new Array('2', 'ThetisCore', '', "ThetisBox.remove("+thetisBox.id+"); location.href='http://sysphonic.com/en/thetiscore.html';"),
          new Array('3', 'PaintMail', '', "ThetisBox.remove("+thetisBox.id+"); window.open('http://sysphonic.com/thetis/frames?default=%2Fthetis%2Fitems%2Fbbs%3Ffolder_id%3D18').focus();")
        );
  thetisBox.buildTree("0", array);
}

msg = function(m)
{
  var thetisBox = new ThetisBox;
  thetisBox.show('CENTER', '', 'MESSAGE', '', m, '');

  return thetisBox;
}

tips = function(m)
{
  var thetisBox = new ThetisBox;
  thetisBox.show('TOP-RIGHT', '', 'TIPS', '', m, '');

  return thetisBox;
}

prog = function(pos)
{
  var thetisBox = new ThetisBox;
  thetisBox.show(pos, '', 'PROGRESS', '', '', '');

  return thetisBox;
}

confm = function(msg, action)
{
  var thetisBox = new ThetisBox;

  if (arguments.length >= 3) {
    thetisBox.setOnClose(arguments[2]);
  }
  if (arguments.length >= 4) {
    thetisBox.button_ok = arguments[3];
    thetisBox.button_cancel = arguments[4];
  }
  thetisBox.show('CENTER', '', 'CONFIRM', action, msg, '');
}
