(function(){
		var minyoo = jQuery.noConflict();//防止冲突
		var GESMenu = {
			buildMemu : function(navUl){
				//所有的一级菜单的hover样式：
				var firstMenu = minyoo(navUl).children("li");
				firstMenu.each(function(){
					var _this = minyoo(this);
					var _thisHasUl = false;
					_thisHasUl = _this.children("ul").length > 0;
					_this.hover(function(e){
						_thisHasUl ? _this.children("span").addClass("selected") : 0;						
					},function(e){
						_thisHasUl ? _this.children("span").removeClass("selected") : 0;
					});
				});
				//二级等菜单的hover样式
				var _menuUl = minyoo(navUl);
				var _headers = _menuUl.find("ul").parent();
				var _allLayerArray = _menuUl.parents();
				//alert();
				var _wraper = minyoo(_allLayerArray[_allLayerArray.length-3]);
				_headers.each(function(i){
					var _this = minyoo(this);
					var _currObj = _this.css({zIndex: 100+i});
						_currObj.hover(function(e){
							var _aWidth = 0;
							_this.find("ul:eq(0)").append("<span class='secNavL'></span><span class='secNavR'></span>");
							var _liN = _this.find("ul:eq(0)").children("li");								
							var _childUl = _this.find("ul:eq(0)").css({display:"block",left:"-2px",top:_this.height()+"px"});
							for(var j =0; j < _liN.length; j++){_aWidth += parseInt(minyoo(_liN[j]).outerWidth(true));}			
							var _childUl = _this.find("ul:eq(0)").css({width:_aWidth+"px"});
							var _sumLength = _aWidth + _this.offset().left;
							var _wrapLength = _wraper.width() + _wraper.offset().left;
							//alert(_wrapLength);
							if( _sumLength > _wrapLength){
								var _leftChaochu = _sumLength - _wrapLength;								
								_this.find("ul:eq(0)").css({left: (-2 - _leftChaochu) +"px"});
							}
						},function(e){
							_this.find("ul:eq(0)").css({display:"none"});
						});
				});
				_menuUl.find("ul").find("li").each(function(){
					var _this = minyoo(this);
					var aColor = _this.children("a").css("color");
					_this.hover(function(){
						_this.children("a").css({color:"#FFF",backgroundColor:"#EFA235"});
					},function(){
						_this.children("a").css({color:aColor,backgroundColor:"transparent"});
					})
				});
				//各级点击事件：
			},
			init : function(navUl){
				GESMenu.buildMemu(navUl);
			}
		}
		minyoo("document").ready(function(){
			GESMenu.init(".navUl");
		});
	})();
