// otten-flim intro dynamics
// (c) 2007 Loco (Loohuis Consulting), http://www.loohuis-consulting.nl/
// This work is licensed under a 
// Creative Commons Attribution-Share Alike 3.0 Netherlands License
// see http://www.loohuis-consulting.nl/development/cc-by-sa.php

function hover(e)
{
    var elm = Event.element(e);
    if (elm.nodeName == 'A') {
        var counter = elm.getAttribute('count');
        Element.addClassName(elm, 'block' + counter);
    }
    else if (elm.nodeName == 'H1') {
        var counter = elm.parentNode.getAttribute('count');
        Element.addClassName(elm.parentNode, 'block' + counter);
    }
}

function unhover(e)
{
    var elm = Event.element(e);
    var counter = elm.getAttribute('count');
    if (elm.nodeName == 'A') {
        var counter = elm.getAttribute('count');
        Element.removeClassName(elm, 'block' + counter);
    }
    else if (elm.parentNode.nodeName == 'H1') {
        var counter = elm.parentNode.getAttribute('count');
        Element.removeClassName(elm.parentNode, 'block' + counter);
    }
}

// initialise page
function init()
{
    var intro = $('index');
    if (intro) {
        // link hover events
        var counter = 0;
        var links = document.getElementsByClassName('index');
        links.each(function(a)
        {
            a.setAttribute('count', ++counter);
            Event.observe(a, 'mouseout', unhover);
            Event.observe(a, 'mouseover', hover);
        });
        var heads = document.getElementsByClassName('indexhead');
        heads.each(function(h)
        {
            Event.observe(h, 'mouseout', unhover);
            Event.observe(h, 'mouseover', hover);
        });
    }
}

Event.observe(window, 'load', init);
