function columnHeights() {
  var cm = $('c-m');
  var ca = $('c-a');
  var nav = $('nav');
  if (cm && ca && cm.offsetHeight < ca.offsetHeight) {
    cm.setAttribute('style', 'height: '+(ca.offsetHeight+125)+'px');
    cm.style.height = (ca.offsetHeight+125)+'px'
  }if (cm && nav && cm.offsetHeight < nav.offsetHeight) {
    cm.setAttribute('style', 'height: '+(nav.offsetHeight+125)+'px');
    cm.style.height = (nav.offsetHeight+125)+'px';
  }
  if (cm && cm.offsetHeight < 657) {
    cm.setAttribute('style', 'height: '+657+'px');
    cm.style.height = '657px';
  }
}
Event.observe(window,'load', columnHeights, false);

/*
  Simple slideshow using prototype and scriptaculous.
  
  Usage:
  
    <script src="prototype.js"></script>
    <script src="effects.js"></script>
    <script src="slideshow.js"></script>
    <style type="text/css">
      #slideshow { position: relative; width: 100px; height: 100px; }
      #slideshow div { position: absolute; left: 0; top: 0; }
    </style>
    <div class="slideshow" id="slideshow">
      <div class="slide"><img src="slide1.jpg"></div>
      <div class="slide"><img src="slide2.jpg"></div>
      <div class="slide"><img src="slide3.jpg"></div>
    </div>
    <script type="text/javascript">new Slideshow('slideshow', 3000);</script>
  
  See also: http://blog.remvee.net/post/17
  
  Copyright (c) 2006 - R.W. van 't Veer
*/

function setup_slideshow(){
  var slideshow_images = $A(['1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg','8.jpg']);

  if($('slideshow')) {
    slideshow_images.each(function(image) {
      var div = document.createElement('div');
      div.className = 'slide';
      div.innerHTML = '<img src="/images/slideshow/'+image+'">'
      $('slideshow').appendChild(div);
    });
    new Slideshow('slideshow', 3000);
  }
}

Event.observe(window, 'load', setup_slideshow, false);

function Slideshow(slideshow, timeout) {
  this.slides = [];
  var nl = $(slideshow).getElementsByTagName('div');
  for (var i = 0; i < nl.length; i++) {
    if (Element.hasClassName(nl[i], 'slide')) {
      this.slides.push(nl[i]);
    }
  }
  this.timeout = timeout;
  this.current = 0;

  for (var i = 0; i < this.slides.length; i++) {
    this.slides[i].style.zIndex = this.slides.length - i;
  }

  Element.show(slideshow);
  setTimeout((function(){this.next();}).bind(this), this.timeout + 2850);
}
Slideshow.prototype = {
  next: function() {
    for (var i = 0; i < this.slides.length; i++) {
      var slide = this.slides[(this.current + i) % this.slides.length];
      slide.style.zIndex = this.slides.length - i;
    }

    Effect.Fade(this.slides[this.current], {
      duration: 2, 
      fps: 50,
      afterFinish: function(effect) {
        effect.element.style.zIndex = 0;
        Element.show(effect.element);
        Element.setOpacity(effect.element, 1);
      }
    });
    
    this.current = (this.current + 1) % this.slides.length;
    setTimeout((function(){this.next();}).bind(this), this.timeout + 2850);
  }
}
