/*
// Purpose:     Adds mouseover/mouseout effect to display submenu
// Requires:    jQuery library
// Author:      Eelco Weijmans, 31 may 2009
// Edited by:   Willem Mulder, june 3 2009
*/


// wait for document to finish loading
$(document).ready(function(){
    
    // select menu, loop through items
    $("#menu").find("li").each(function() {
        
        // does current item have children?
        if($(this).children().find("li").length > 0) {
            var submenu = $(this).find("ul");
            
            // attach mouseover event
            $(this).hover( function() {
                    var submenuTop = $(this).position().top+$(this).height();
                    var submenuLeft = $(this).position().left;
                    
                    // position submenu
                    submenu.css({'top' : submenuTop, 'left' : submenuLeft});
                    submenu.show();
                }, function() {
                    submenu.hide();
                });
            
        } else {
            // no children, so no action required
        }
    });
});

