/*******************************************************************************
 * Common scripts
 */



/*******************************************************************************
 * All pages
 */
var all = {
  start: function() {
    // Do nothing special yet
  }
};



/*******************************************************************************
 * Home page
 */
var home = {
  start: function() {
    // Retrieves the label for the leitmotiv
    var label = $E("P STRONG");
    
    if (label) {
      // Initializes visual effect
      var opacityEffect = new Fx.Style(label, "opacity", {duration: 250, wait: false});
      
      // Setups a chain of effects
      var chain = function() { 
        opacityEffect.start(0.3).chain(function() {
          opacityEffect.start(1).chain(function() {
            opacityEffect.start(0.3).chain(function() {
              opacityEffect.start(1).chain(function() {
                opacityEffect.start(0.3).chain(function() {
                  opacityEffect.start(1);
                });
              });
            });
          });
        });
      };
      
      // Starts the chain of effects every 7 seconds
      chain.periodical(7000);
    }
  }
};



/*******************************************************************************
 * Initialization (when document object model is available)
 */
window.addEvent("domready", function() {
  // Handles behaviors common to all pages
  all.start();
  
  // Retrieves BODY element
  var body = $E("body");
  
  // Extracts id attribute for this element
  var pageId = body.getProperty("id");
  
  // Handles specific behaviors
  if (pageId === "homepage") {
    home.start();
  }
});
