document.observe('dom:loaded', function(event) {
  var pageContainer = $('container_1');
  if (pageContainer && pageContainer.hasClassName('splash')) {
    new Rotator('slideshow_1', [ 'images/slide01.jpg', 'images/slide02.jpg', 'images/slide03.jpg' ], { duration: 2.0, delay: 2 });

    var splash = $('content_1').select('.splash_background').first();
    if (splash) splash.setOpacity(0.85);
    // Fix for Safari <= 2 and IE for the CSS content :before thing
    if (Prototype.Browser.IE || (Prototype.Browser.WebKit && navigator.userAgent.match(/Version\/(1|2)\./))) {
      var titles = $('footer_1').select('h2.title span');
      if (titles.any()) {
        titles.each(function(title) {
          title.insert({ before: '> ' });
        });
      }
    }
    var navMenu = $('navigator_1');
    if (navMenu && Prototype.Browser.IE) {
      var buttons = navMenu.select('ul.menu > li.menu_button.drop');
      buttons.each(function(button) {
        button.observe('mouseover', function(event) {
          buttons.each(function(button) {
            if (button.hasClassName('active') && button.identify() != this.identify())
              button.removeClassName('active');
          }.bind(this));
          this.addClassName('active');
        });
        button.observe('mouseout', function(event) {
          var element = this;
          element.removeClassName('active');
        });
      });
    }
  }

  if (pageContainer && pageContainer.hasClassName('standard')) {
    // Monitor the viewport height to resize the scrollbar on standard pages.
    var scaleStageHeight = function(event) {
      var currentHeight = document.viewport.getHeight();
      if (currentHeight >= 550) {
        $('page_1').setStyle({ 'height': (currentHeight - 36)+'px' });
      }
    };
    scaleStageHeight();
    Event.observe(window, 'resize', scaleStageHeight);

    // Fix for IE, it doesn't like the mouseovers for the menus
    var navMenu = $('navigator_1');
    if (navMenu && Prototype.Browser.IE) {
      var buttons = navMenu.select('ul.menu > li.menu_button.drop');
      buttons.each(function(button) {
        button.observe('mouseover', function(event) {
          buttons.each(function(button) {
            if (button.hasClassName('active') && button.identify() != this.identify())
              button.removeClassName('active');
          }.bind(this));
          this.addClassName('active');
          this.__delay = true;
        });
        button.observe('mouseout', function(event) {
          var element = this;
          element.__delay = false;
          setTimeout(function() {
            if (!element.__delay)
              element.removeClassName('active');
          }, 2000);
        });
      });
    }
  }
});
