﻿

/***

Author David Schweickhard

Purpose
    Makes a div which contains properly structured div tags into a popup menu

***/


(function($) {


    $.fn.hovermenu = function(options) {
        
        var defaults = {
            hoveron: "",
            hoveroff: "",
            fadetime: 1
        };
        
        
        var options = $.extend(defaults, options);
    
        return this.each(function() {   
            $(this)
                .hover(
                    function () {
                        $(this).children(":first").fadeIn(options.fadetime);
                        $(this).removeClass(options.hoveroff);
                        $(this).addClass(options.hoveron);
                        
                    },
                    function () {
                    
                        //determine if there are submenu objects
                        var children = $(this).children();
                        
                        if (children.length > 1){
                            //if there is more than 1 child fadeout the first one
                            $(this).children(":first").fadeOut(options.fadetime/4); 
                        };
                        
                        $(this).removeClass(options.hoveron);
                        $(this).addClass(options.hoveroff);
                                                                    
                    }
                );
        });
    };


})(jQuery);