﻿//You need an anonymous function to wrap around your function to avoid conflict
(function($ektron) {

    //Attach this new method to ektron jQuery
    $ektron.fn.extend({

        //This is where you write your plugin's name
        listMenu: function() {

            function showMenu() {
                // Get the item being hovered on.
                var item = $ektron('span.menuItem:first',this);
                // Get the menu to show.
                var menu = $ektron('ul:first', this);
                // Add "hover" class to list item
                item.addClass("hover");
                // Show sub menu
                menu.show();
            }

            function hideMenu() {
                // Get the item being hovered on.
                var item = $ektron('span.menuItem:first', this);
                // Get the menu to show.
                var menu = $ektron('ul:first', this);
                // Remove "hover" class to list item
                item.removeClass("hover");
                // Hide sub menu
                menu.hide();
            }

            //Iterate over the current set of matched elements
            return this.each(function() {
                var object = $ektron(this);
                var items = $ektron("li", object).hover(showMenu, hideMenu);
            });
        }
    });
    // Pass $ektron to the function	so we know it is defined properly	
})($ektron);
