var fadeTime = 300;

$(document).ready(function()
{
  initTopMenu();
  $('#topMenu').pngFix();
});

function initTopMenu()
{
  $('#topMenu a').hover(function()
                  {
                    showRed($(this));
                  }, function()
                  {
                    showWhite($(this));
                  })
                 .click(function()
                  {
                    if (loaderBusy) {
                      return;
                    }

                    $('#topMenu a.active').removeClass('active');
                    $(this).addClass('active');
                    activeOnly();
                  });
  activeOnly();
}

function showRed(links, time)
{
  time = time || 0;
  $(links).each(function(i, a)
  {
    $(a).children('.red'  ).fadeTo(time, 1);
    $(a).children('.white').fadeTo(time, 0);
  });
}

function showWhite(links, time)
{
  time = time || 0;
  $(links).each(function(i, a)
  {
    if (!$(a).hasClass('active')) {
      $(a).children('.red'  ).fadeTo(time, 0);
      $(a).children('.white').fadeTo(time, 1);
    }
  });
}

function activeOnly()
{
  showWhite($('#topMenu a'));
  showRed($('#topMenu a.active'));
}


