function addOverHandlers(root) {
  if (!root) return;
  for (var i = 0; i < root.childNodes.length; i++) {
    var node = root.childNodes[i];
    if (node.nodeName == "LI") {
      node.onmouseover = function() {
        this.className += " over";
      }
      node.onmouseout = function() {
        this.className = this.className.replace(" over", "");
      }
      node = node.getElementsByTagName("UL")[0];      
      if (node) {
        addOverHandlers(node);
      }
    }
  }
}

window.onload = function() {
  if (document.all && document.getElementById) {
  	var menu = document.getElementById("menu").getElementsByTagName("UL")[0];
  	addOverHandlers(menu);
  }
}


function showForm(id) {
	document.getElementById(id).style.display = 'block';
	return false;
}

function hideForm(id) {
	document.getElementById(id).style.display = 'none';
	return false;
}


// slideshow

/**** MooTools v1.2 ****/
/*

var slideshowDelay = 5000;
var slideshowImage = 0;

function changeSlide() {
	images = $('sl_pictures').getElements('img');
	images[slideshowImage].set('tween', {duration: 1500}).fade('out');
	slideshowImage = (slideshowImage+1) % images.length;
	images[slideshowImage].set('tween', {duration: 1500}).fade('in');
	setTimeout(changeSlide, slideshowDelay);
}

window.addEvent('domready', function() {
	images = $('sl_pictures').getElements('img');
	images.map(function(el){
		el.fade('hide');
	});
	images[0].fade('show');
	setTimeout(changeSlide, slideshowDelay);
});

*/

/**** MooTools v1.1 ****/

var slideshowDelay = 5000;
var slideshowImage = 0;

function changeSlide() {
	images = $('sl_pictures').getElements('img');
	images[slideshowImage].effect('opacity', {duration: 1500, transition: Fx.Transitions.linear}).start(0);
	slideshowImage = (slideshowImage+1) % images.length;
	images[slideshowImage].effect('opacity', {duration: 1500, transition: Fx.Transitions.linear}).start(1);
	setTimeout(changeSlide, slideshowDelay);
}

window.addEvent('domready', function() {
	images = $('sl_pictures').getElements('img');
	images.map(function(el){
		el.effect('opacity', {duration: 0, transition: Fx.Transitions.linear}).start(0);
	});
	images[0].effect('opacity', {duration: 0, transition: Fx.Transitions.linear}).start(1);
	setTimeout(changeSlide, slideshowDelay);
});
