﻿ (function($) {
     $.fn.buidMenu = function(options) {
         var defaults = {
                 length: 300,
                 minTrail: 20,
                 moreText: "more",
                 lessText: "less",
                 ellipsisText: "..."
         };
         var mergeoptions = $.extend(defaults, options);
         return this.each(function() {
             var root = $(this);
             var objMenu = new DDMenu(root, mergeoptions);
             objMenu.Render();
         });
     };
 })(jQuery);

 function DDMenu(target,options) {
     this.Options = options;
     this.Target = target;
     this.Root = null;
     this.Parents = null;
     this.Timer = null;
     this.TimerTarget = null;
     this.Render = function() {	
		 var obj = this;
         var root = this.Root = this.Target.find('ul').eq(0);
         var timer = this.Timer;
         var timerTarget = this.TimerTarget = null;
         var allChilds = this.Target.children().find('.hug_SS_OW');
		 allChilds.hover(function(){ $(this).parent().select('.hug_SS_OW').css('background-color','#77bdf6'); },function(){ $(this).parent().select('.hug_SS_OW').css('background-color',''); });
         var header = this.Headers = allChilds.parent();
         this.Headers.hover(function() {
			 //$('a',root).removeClass('hug_SS_ParentHover');
             $(this).find('.hug_SS_OW').eq(0).show(0);
         }, function() {
            var timerTargetx = $(this).find('.hug_SS_OW').eq(0);
			timerTargetx.hide(0);
			return;
         }).append($('<div class="hug_SS_More"></div>'));

         this.Headers.children('a').addClass('hug_SS_Parent');
     }
 }

