function init()
{
    var divs = document.getElementsByTagName('DIV');
    
    AttachMouseEventsToImages(divs, 'navigation_item');
}

function AttachMouseEventsToImages(divs, sClassName )
{
    for( i = 0; i < divs.length; i++ )
    {
        
        if( divs[i].className == sClassName )
        {
                        
            if(divs[i].addEventListener)
            {
                divs[i].addEventListener('mouseover',swapImage,false);
                divs[i].addEventListener('mouseout',swapImage,false);
            }
            
            if(divs[i].attachEvent) 
            {
                divs[i].attachEvent('onmouseover',swapImage);   
                divs[i].attachEvent('onmouseout',swapImage);
            }
        }
    }
}

function swapImage(e)
{
    if (!e) var e = window.event;
    
    var targ = null;
    
    if (e.target)
    {
        targ = e.target;
    }
    else if (e.srcElement)
    {
         targ = e.srcElement;   
    }
    
    if (targ.nodeType == 3)
    {
        // opvangen Safari bug
        targ = targ.parentNode;
    }

    while( targ.className != "navigation_item" )
    {
        targ = targ.parentNode;
    }
    
    for( k = 0; k < targ.childNodes.length; k++)
    {
        if( targ.childNodes[k].nodeName == 'A' )
        {
            for( j = 0; j < targ.childNodes[k].childNodes.length; j++ )
            {
                if(targ.childNodes[k].childNodes[j].nodeName == 'IMG' )
                {
                    filename = targ.childNodes[k].childNodes[j].src;
                    if( filename.indexOf('_selected') != -1 )
                    {
                        return false;
                    }
                    else if( filename.indexOf('_hover') == -1 )
                    {
                        targ.childNodes[k].childNodes[j].src = filename.substring(0,filename.length-4) + "_hover.gif";
                    }
                    else
                    {
                        targ.childNodes[k].childNodes[j].src = filename.substring(0,filename.length-10) + ".gif";
                    }
                }
            }
        }
    }
}

window.onload=init;

