window.addEvent('domready', function()
{
  if (window.location.search.indexOf('iso=') != -1 && window.location.hash == '') {
    window.location += '#translations';
  }
  if (Browser.Engine.trident) {
    return;
  }
  $('mainmenu').getElements('ul.level_2').each(function(el) {
    el.set({'opacity':0});
  });
  $('mainmenu').getElements('span.submenu').each(function(el) {
    var ul = el.getParent().getElement('ul.level_2');
    el.addEvent('mouseenter', function() {
      new Fx.Morph(ul, {'duration':300}).start({'opacity':1});
    });
    el.addEvent('mouseout', function() {
      setTimeout(function() {
        if (ul.getStyle('left').toInt() < 0) {
          ul.set({'opacity':0});
        }
      }, 50);
    });
  });
	$('mainmenu').getElements('a.submenu').each(function(el) {
    var ul = el.getParent().getElement('ul.level_2');
    el.addEvent('mouseenter', function() {
      new Fx.Morph(ul, {'duration':300}).start({'opacity':1});
    });
    el.addEvent('mouseout', function() {
      setTimeout(function() {
        if (ul.getStyle('left').toInt() < 0) {
          ul.set({'opacity':0});
        }
      }, 50);
    });
  });
});
window.addEvent('load', function()
{
  var el = $$('p.confirm');
  if ($defined(el[0])) {
    if (el[0].getPosition().y > window.getSize().y) {
      window.scrollTo(0, el[0].getPosition().y - 120);
    }
  }
  if ($defined($('username'))) {
    $('username').focus();
  }
});
window.addEvent('domready', function()
{
  var links = $$('#links>a');
  if($defined(links) && links.length > 1) {
    for (i=1; i<links.length; i++) {
      links[i].setStyle('left', 400);
      links[i].removeClass('hide');
    }
    var slider = {
      index: 0,
      next: function() {
        slider.index++;
        if (slider.index == links.length) {
          slider.index = 0;
        }
        if (slider.index == 0) {
          links[slider.index].tween('left', [400, 0]);
          links[links.length - 1].tween('left', [0, -400]);
        } else {
          links[slider.index].tween('left', [400, 0]);
          links[slider.index - 1].tween('left', [0, -400]);
        }
      }
    };
    slider.next.periodical(5000);
  }
});

