window.addEvent('domready', function() {
  SearchBox.init($('search')); /* search box */
  dynamicLinks.init(); /* changes the arrows on mouseover for the necessary links */
  
});

/**
 * Global variables are stored in this object
 */
var globals = {
  imageDir: 'images/'
}


/**
 * Handles the default text in searchbox
 * @param {Object} elem
 */
var SearchBox = {
  init: function(elem){
    this.elem = elem;
    this.value = elem.value;
    this.addEvents();
  },
  addEvents: function(){
    this.elem.addEvent('focus', function(){
      if( this.value == SearchBox.value ){
        this.value = '';
      }
    });
    this.elem.addEvent('blur', function(){
      if( this.value == '' ){
        this.value = SearchBox.value;
      }
    });
  }
};

/**
 * Create further mouseover effects
 */
var dynamicLinks = {
  init: function(){
    this.blueArrows = $$('div.aside-block a');
    this.blueArrowsReplace  = 'url(images/icons/arrow-red.gif)';
    if( this.blueArrows.length > 0 ){
      this.handleBlueArros();
    }
  },
  handleBlueArros: function(){
    this.blueArrowsOriginal = this.blueArrows[0].getStyle('background-image');
    
    this.blueArrows.each(function(e){
      e.addEvent('mouseover', function(){
        this.setStyle('background-image', dynamicLinks.blueArrowsReplace);
      });
      e.addEvent('mouseout', function(){
        this.setStyle('background-image', dynamicLinks.blueArrowsOriginal);
      });
    });
  }
}
