//zwp
(function(a){
	a.fn.menu=function(option){
	var style={
		type:0,//0--无滑块；1--有滑块
		defaultIndex:0,//子级索引值
		height:5,//滑块高度
		background:"red",//滑块背景色
		bottom:0,//滑块距离导航底部距离
		animateEase:"linear",//滑块的运动轨迹
		time:500,//滑块的运动时间
		zIndex:-1,//滑块的层级
		margin:0,//滑块左右间距
		antComplete:true,//默认滑块动画完成后调函数
		startFun:null,//滑块进入方法
		endFun:null//滑块离开方法
	},
	b=$.extend({},style,option),
	fun=b.type,
	h=b.height,
	bg=b.background,
	btm=b.bottom,
	e=b.animateEase,
	t=b.time,
	i=b.zIndex,
	m=b.margin,
	muIconW=0,
	pt=0,
	muIconWH=0,
	ptH=0,
	$this=this,
	d=a(this),
	p=parseInt(b.defaultIndex),
	cl=b.antComplete,
	f=function(){
		a.isFunction(b.startFun) && b.startFun(p);
	},
	r=function(){
		a.isFunction(b.endFun) && b.endFun(p);
	},
	$children=$this.children(),
	lg=$this.children().length,
	ddHv=null,
	ddAt=null;
	if(lg>0){
		ddHv=$children[0].tagName+".hover";
		ddAt=$children[0].tagName+".active";	
	}
	switch(fun)
	{
		case 1:
			$this.parent().css({"position":"relative","z-index":9});
			$this.parent().append('<div class="menuIcon" style="position:absolute"><div></div></div>');
			$this.siblings(".menuIcon").css({
				"height":h,
				"bottom":btm,
				"z-index":i
			});
			$this.siblings(".menuIcon").find("div").css({
				"height":h,
				"background":bg,
				"marginLeft":m,
				"marginRight":m
			});
			$children.each(function(index){
				if($(this).hasClass("hover")){
					muIconWH=$(this).outerWidth();
					ptH=$(this).position().left;
					$this.siblings(".menuIcon").stop(true,false).animate({
						"width":muIconWH,
						"left":ptH,
					},{"duration":t,"easing":e});   
				}
				$(this).hover(function(){
					p=$(this).index();
					muIconW=$(this).outerWidth();
					pt=$(this).position().left;
					switch(cl)
					{
						case true:
							$this.siblings(".menuIcon").stop(true,false).animate({
								"width":muIconW,
								"left":pt,
							},t,e,f);
							break;
						case false:
							$this.siblings(".menuIcon").stop(true,false).animate({
								"width":muIconW,
								"left":pt,
							},{"duration":t,"easing":e});
							f();
							break;
					};
					$this.find(ddHv).addClass("active").removeClass("hover");
					$(this).addClass("hover");
				},function(){
					r();
					$(this).removeClass("hover");
					$this.find(ddAt).addClass("hover").removeClass("active");
				});
			});	
			$children.hover(function(){},function(){
				$this.siblings(".menuIcon").stop(true,false).animate({
					"width":muIconWH,
					"left":ptH,
				},{"duration":t,"easing":e});
			});
			break;
		case 0:
			$children.each(function(index){
				$(this).hover(function(){
					p=$(this).index();
					f();
					$this.find(ddHv).addClass("active").removeClass("hover");
					$(this).addClass("hover");
					
				},function(){
					r();
					$(this).removeClass("hover");
					$this.find(ddAt).addClass("hover").removeClass("active");
				});
			});	
			break;
	}
}})(jQuery),
jQuery.easing.jswing = jQuery.easing.swing,
jQuery.extend(jQuery.easing, {
	def: "easeOutQuad",
	swing: function(a, b, c, d, e) {
		return jQuery.easing[jQuery.easing.def](a, b, c, d, e)
	},
	easeInQuad: function(a, b, c, d, e) {
		return d * (b /= e) * b + c
	},
	easeOutQuad: function(a, b, c, d, e) {
		return - d * (b /= e) * (b - 2) + c
	},
	easeInOutQuad: function(a, b, c, d, e) {
		return 1 > (b /= e / 2) ? d / 2 * b * b + c: -d / 2 * (--b * (b - 2) - 1) + c
	},
	easeInCubic: function(a, b, c, d, e) {
		return d * (b /= e) * b * b + c
	},
	easeOutCubic: function(a, b, c, d, e) {
		return d * ((b = b / e - 1) * b * b + 1) + c
	},
	easeInOutCubic: function(a, b, c, d, e) {
		return 1 > (b /= e / 2) ? d / 2 * b * b * b + c: d / 2 * ((b -= 2) * b * b + 2) + c
	},
	easeInQuart: function(a, b, c, d, e) {
		return d * (b /= e) * b * b * b + c
	},
	easeOutQuart: function(a, b, c, d, e) {
		return - d * ((b = b / e - 1) * b * b * b - 1) + c
	},
	easeInOutQuart: function(a, b, c, d, e) {
		return 1 > (b /= e / 2) ? d / 2 * b * b * b * b + c: -d / 2 * ((b -= 2) * b * b * b - 2) + c
	},
	easeInQuint: function(a, b, c, d, e) {
		return d * (b /= e) * b * b * b * b + c
	},
	easeOutQuint: function(a, b, c, d, e) {
		return d * ((b = b / e - 1) * b * b * b * b + 1) + c
	},
	easeInOutQuint: function(a, b, c, d, e) {
		return 1 > (b /= e / 2) ? d / 2 * b * b * b * b * b + c: d / 2 * ((b -= 2) * b * b * b * b + 2) + c
	},
	easeInSine: function(a, b, c, d, e) {
		return - d * Math.cos(b / e * (Math.PI / 2)) + d + c
	},
	easeOutSine: function(a, b, c, d, e) {
		return d * Math.sin(b / e * (Math.PI / 2)) + c
	},
	easeInOutSine: function(a, b, c, d, e) {
		return - d / 2 * (Math.cos(Math.PI * b / e) - 1) + c
	},
	easeInExpo: function(a, b, c, d, e) {
		return 0 == b ? c: d * Math.pow(2, 10 * (b / e - 1)) + c
	},
	easeOutExpo: function(a, b, c, d, e) {
		return b == e ? c + d: d * ( - Math.pow(2, -10 * b / e) + 1) + c
	},
	easeInOutExpo: function(a, b, c, d, e) {
		return 0 == b ? c: b == e ? c + d: 1 > (b /= e / 2) ? d / 2 * Math.pow(2, 10 * (b - 1)) + c: d / 2 * ( - Math.pow(2, -10 * --b) + 2) + c
	},
	easeInCirc: function(a, b, c, d, e) {
		return - d * (Math.sqrt(1 - (b /= e) * b) - 1) + c
	},
	easeOutCirc: function(a, b, c, d, e) {
		return d * Math.sqrt(1 - (b = b / e - 1) * b) + c
	},
	easeInOutCirc: function(a, b, c, d, e) {
		return 1 > (b /= e / 2) ? -d / 2 * (Math.sqrt(1 - b * b) - 1) + c: d / 2 * (Math.sqrt(1 - (b -= 2) * b) + 1) + c
	},
	easeInElastic: function(a, b, c, d, e) {
		var f = 1.70158,
		g = 0,
		h = d;
		if (0 == b) return c;
		if (1 == (b /= e)) return c + d;
		if (g || (g = .3 * e), Math.abs(d) > h) {
			h = d;
			var f = g / 4
		} else var f = g / (2 * Math.PI) * Math.asin(d / h);
		return - (h * Math.pow(2, 10 * (b -= 1)) * Math.sin((b * e - f) * 2 * Math.PI / g)) + c
	},
	easeOutElastic: function(a, b, c, d, e) {
		var f = 1.70158,
		g = 0,
		h = d;
		if (0 == b) return c;
		if (1 == (b /= e)) return c + d;
		if (g || (g = .3 * e), Math.abs(d) > h) {
			h = d;
			var f = g / 4
		} else var f = g / (2 * Math.PI) * Math.asin(d / h);
		return h * Math.pow(2, -10 * b) * Math.sin((b * e - f) * 2 * Math.PI / g) + d + c
	},
	easeInOutElastic: function(a, b, c, d, e) {
		var f = 1.70158,
		g = 0,
		h = d;
		if (0 == b) return c;
		if (2 == (b /= e / 2)) return c + d;
		if (g || (g = e * .3 * 1.5), Math.abs(d) > h) {
			h = d;
			var f = g / 4
		} else var f = g / (2 * Math.PI) * Math.asin(d / h);
		return 1 > b ? -.5 * h * Math.pow(2, 10 * (b -= 1)) * Math.sin((b * e - f) * 2 * Math.PI / g) + c: .5 * h * Math.pow(2, -10 * (b -= 1)) * Math.sin((b * e - f) * 2 * Math.PI / g) + d + c
	},
	easeInBack: function(a, b, c, d, e, f) {
		return void 0 == f && (f = 1.70158),
		d * (b /= e) * b * ((f + 1) * b - f) + c
	},
	easeOutBack: function(a, b, c, d, e, f) {
		return void 0 == f && (f = 1.70158),
		d * ((b = b / e - 1) * b * ((f + 1) * b + f) + 1) + c
	},
	easeInOutBack: function(a, b, c, d, e, f) {
		return void 0 == f && (f = 1.70158),
		1 > (b /= e / 2) ? d / 2 * b * b * (((f *= 1.525) + 1) * b - f) + c: d / 2 * ((b -= 2) * b * (((f *= 1.525) + 1) * b + f) + 2) + c
	},
	easeInBounce: function(a, b, c, d, e) {
		return d - jQuery.easing.easeOutBounce(a, e - b, 0, d, e) + c
	},
	easeOutBounce: function(a, b, c, d, e) {
		return 1 / 2.75 > (b /= e) ? d * 7.5625 * b * b + c: 2 / 2.75 > b ? d * (7.5625 * (b -= 1.5 / 2.75) * b + .75) + c: 2.5 / 2.75 > b ? d * (7.5625 * (b -= 2.25 / 2.75) * b + .9375) + c: d * (7.5625 * (b -= 2.625 / 2.75) * b + .984375) + c
	},
	easeInOutBounce: function(a, b, c, d, e) {
		return e / 2 > b ? .5 * jQuery.easing.easeInBounce(a, 2 * b, 0, d, e) + c: .5 * jQuery.easing.easeOutBounce(a, 2 * b - e, 0, d, e) + .5 * d + c
	}
});

/******************/
/*
$(".menuDl").menu({
	type:1,//0--无滑块(默认)；1--有滑块
	height:5,//滑块高度
	background:"#152d79",//滑块背景色
	bottom:0,//滑块距离导航底部距离
	animateEase:"easeOutBounce",//滑块的运动轨迹
	time:1000,//滑块的运动时间
	zIndex:-1,//滑块的层级
	margin:0,//滑块左右间距
	antComplete:true,//滑块动画完成后调函数（默认）
	startFun:function(i){//滑块进入后回调方法
		$(".menuDl dd").eq(i).find(".div_a").stop(true,true).slideDown();
	},
	endFun:function(i){//滑块离开后回调方法
		$(".menuDl dd").find(".div_a").stop(true,true).slideUp()
	}
});
*/