(function ($) {
    $.fn.xyMenu = function (options) {

        var defaults = {
            folderclass: 'wmenu-folder',
			folderclasshover: 'wmenu-folder-hover',
			subfolderclass: 'wmenu-folder',
			folderclasshover: 'wmenu-folder-hover'
		};
        var options = $.extend(defaults, options);

        return this.each(function () {
            var obj = $(this);
            if (obj.length < 1) return false;
            
			// Opera Fix
            $("ul ul", obj).css({
                display: "none"
            });

            $("ul ul", obj).each(function () {
				//loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars)
                $(this).css({
                    visibility: "hidden",
                    display: "none"
                });
            });
			
			//add the folder arrow classes
            $("ul ul", obj).each(function () {
				var li = $(this).parent();
				
				//add the link arrow class
				$(">a", li).addClass(options.folderclass);
				
				//add the link hover arrow classes
				$(">a", li).hover(function () {
					$(this).removeClass(options.folderclass).addClass(options.folderclasshover); //mouse over
				},
					function (){
					$(this).removeClass(options.folderclasshover).addClass(options.folderclass); //mouse out
				});
            });
			
			//add the menu items hover actions
            $("ul li", obj).hover(function () {
                $(this).find('ul:first').css({
                    visibility: "visible",
                    display: "none"
                }).show(options.speed); //'fast'=200, 'slow'=600
            }, function () {
                $(this).find('ul:first').css({
                    visibility: "hidden",
                    display: "none"
                });
            });

        }); //return this.each(function() {
    };//$.fn.xyMenu
})(jQuery);

