﻿//<![CDATA[ 

/*******************JSoul原型扩展方法 [特效类型]******************/
JSoul.fn.extend({
	effectSpread:function(Speed, Delay,cssExp){
	/// <summary>特效：展开内容</summary>
	/// <param name="Speed" type="Number">执行速度</param>
	/// <param name="Delay" type="Number">延时</param>
	/// <param name="cssExp" type="String">CSS表达式</param>
	/// <returns type="JSoul" />
		var _pairs = JSoul.spliteCSSExp(cssExp || "height:1px;visibility:visible;position:relative;display:none;");
		this.each(function(i){
			JSoul.effectSpread(this, Speed, Delay);
			if(!JSoul.isAttr(this.style, "visibility","visible"))
				JSoul.batchSetCss(this, _pairs);
		});
		return this;
	},
	effectGlideShow:function(Args, StartMargin, EndMargin, Speed, Delay){
	/// <summary>特效：滑行显示</summary>
	/// <param name="Args" type="Array">子对象关系表达式[,]</param>
	/// <param name="StartMargin" type="Number">开始距离</param>
	/// <param name="EndMargin" type="Number">结束距离</param>
	/// <param name="Speed" type="Number">执行速度</param>
	/// <param name="Delay" type="Number">延时</param>
	/// <returns type="JSoul" />
		if(this.length == 2){
			this._ef_glide = null;//滑行特效缓存
			this.StartMargin = StartMargin;
			this.EndMargin = EndMargin;
			this.Speed = Speed;
			this.Delay = Delay;
			//this.partnerShip(Args);
			var Menus = JSoul.find(Args[0],this[0]),Boxies = JSoul.find(Args[1],this[1]);
			for(var i=0,j=Menus.length;i<j;i++){
				if(Boxies[i].style.display == "block")this._ef_glide = Boxies[i];
				JSoul.bindEvent(Boxies[i],[["Main", this],["glideShowEvent",JSoul.glideShowEvent],["glideHiddenEvent",JSoul.glideHiddenEvent]]);
				JSoul.bindEvent(Menus[i],[["Main", this],["Relate",Boxies[i]],["onmouseover",JSoul.glideMouseOver]]);
			}
		}
		return this;
	},
	effectTrans:function(maxAlpha,minAlpha, Speed, Delay){
	/// <summary>特效：渐显渐隐藏</summary>
	/// <param name="maxAlpha" type="Number">最大透明度</param>
	/// <param name="minAlpha" type="Number">最小透明度</param>
	/// <param name="Speed" type="Number" option="true">执行速度 [如果配合其他特效方法，可忽略该项]</param>
	/// <param name="Delay" type="Number" option="true">延时 [如果配合其他特效方法，可忽略该项]</param>
	/// <param name="cssExp" type="String">CSS表达式</param>
		this.each(function(i){
			JSoul.effectTrans(this, maxAlpha,minAlpha, Speed, Delay);
		});
		return this;
	}
});
/*******************JSoul静态扩展方法 [特效类型]******************/
JSoul.extend({
	effectSpread:function(elem, Speed, Delay){
	/// <summary>特效：展开内容</summary>
	/// <param name="elem" type="Object">对象</param>
	/// <param name="Speed" type="Number">执行速度</param>
	/// <param name="Delay" type="Number">延时</param>
		elem.maxHeight = elem.offsetHeight;
		elem.Speed = Speed;
		elem.Delay = Delay;
		elem.toMaxHeight = function(){
		/// <summary>特效：扩展高度</summary>
			var elem = this;
			elem.height = 1;
			elem.clearHeightInterval();
			JSoul.attr(elem.style, "display", "block");
			this.runMaxHeight = setInterval(function(){
				elem.height += Math.round((elem.maxHeight - elem.height) * elem.Speed+0.5);
				if(elem.height < elem.maxHeight){
					JSoul.attr(elem.style, "height", elem.height + "px");
				}else{
					elem.clearHeightInterval();
					JSoul.attr(elem.style, "height", elem.maxHeight + "px");
					elem.Status = "runMaxHeight";
				}
			},elem.Delay);
		};
		elem.toMinHeight = function(callback){
		/// <summary>特效：缩小高度</summary>
		/// <param name="callback" type="String">回调方法名称</param>
			this.clearHeightInterval();
			var elem = this;
			elem.height = elem.maxHeight;
			elem.Status = "Start";
			this.runMinHeight = setInterval(function(){
				elem.height -= Math.round(elem.height * elem.Speed+0.5);
				if(elem.height > 1){
					JSoul.attr(elem.style, "height", elem.height + "px");
				}else{
					elem.clearHeightInterval();
					elem.Status = "runMinHeight";
					JSoul.attr(elem.style, "height", "1px");
					if(callback)elem[callback]();
					else JSoul.attr(elem.style, "display", "none");
				}
			},elem.Delay);
		};
		elem.clearHeightInterval = function(){
		/// <summary>停止正在执行的伸展特效</summary>
			if(this.runMaxHeight)clearInterval(this.runMaxHeight);
			if(this.runMinHeight)clearInterval(this.runMinHeight);
		};
	},
	glideMouseOver:function(){
	/// <summary>特效：鼠标经过菜单[滑行显示]</summary>
		if(this.Main._ef_glide && this.Main._ef_glide != this.Relate){
			this.Main._ef_glide.glideHiddenEvent(this.Relate);
			this.Relate.glideShowEvent();
		}
	},
	glideShowEvent:function(){
	/// <summary>特效：显示BOX[滑行显示]</summary>
		JSoul.setAlpha(this,0);
		JSoul.css(this,"margin-left:"+this.Main.StartMargin+"px;display:block;");
		this.marginLeft = this.Main.StartMargin;
		var elem = this;
		this.runStatus = setInterval(function(){
			elem.marginLeft -= Math.round(elem.marginLeft * elem.Main.Speed + 0.5);
			if(elem.marginLeft > elem.Main.EndMargin){
				JSoul.setAlpha(elem,Math.round((1-(elem.marginLeft/elem.Main.StartMargin))*100));
				JSoul.attr(elem.style, "marginLeft", elem.marginLeft+"px");
			}else{
				clearInterval(elem.runStatus);
				JSoul.setAlpha(elem,100);
				JSoul.attr(elem.style, "marginLeft", elem.Main.EndMargin+"px");
				elem.Status = "glideShowEvent";
			}
		},this.Main.Delay);
	},
	glideHiddenEvent:function(elem){
	/// <summary>特效：隐藏BOX[滑行显示]</summary>
	/// <param name="elem" type="Object">对象</param>
		if(this.runStatus)clearInterval(this.runStatus);
		JSoul.attr(this.style, "display", "none");
		this.Main._ef_glide = elem;
	},
	effectTrans:function(elem,maxAlpha,minAlpha,Speed, Delay){
	/// <summary>特效：渐显渐隐</summary>
	/// <param name="elem" type="Object">对象</param>
	/// <param name="maxAlpha" type="Number">最大透明度</param>
	/// <param name="minAlpha" type="Number">最小透明度</param>
	/// <param name="Speed" type="Number" option="true">执行速度 [如果配合其他特效方法，可忽略该项]</param>
	/// <param name="Delay" type="Number" option="true">延时 [如果配合其他特效方法，可忽略该项]</param>
		elem.maxAlpha = maxAlpha;
		elem.minAlpha = minAlpha;
		if(Speed)elem.Speed = Speed;
		if(Delay)elem.Delay = Delay;
		elem.transShow = function(callback){
		/// <summary>特效：渐显</summary>
		/// <param name="callback" type="String">回调方法名称</param>
			this.Alpha = this.minAlpha;
			JSoul.setAlpha(this,this.Alpha);
			JSoul.attr(this.style, "display", "block");
			this.clearTransInterval();
			var elem = this;
			this.runTransShow = setInterval(function(){
				elem.Alpha += Math.round((elem.maxAlpha - elem.Alpha) * elem.Speed + 1);
				if(elem.Alpha < elem.maxAlpha){
					JSoul.setAlpha(elem,elem.Alpha);
				}else{
					elem.clearTransInterval();
					JSoul.setAlpha(elem,elem.maxAlpha);
					elem.Status = "runTransShow";
					if(callback)elem[callback]();
				}
			},this.Delay);
		};
		elem.transHidden = function(){
		/// <summary>特效：渐隐</summary>
			this.Alpha = this.maxAlpha;
			JSoul.setAlpha(this,this.Alpha);
			this.clearTransInterval();
			var elem = this;
			this.runTransShow = setInterval(function(){
				elem.Alpha -= Math.round(elem.maxAlpha * elem.Speed + 1);
				if(elem.Alpha > elem.minAlpha){
					JSoul.setAlpha(elem,elem.Alpha);
				}else{
					elem.clearTransInterval();
					JSoul.setAlpha(elem,elem.minAlpha);
					JSoul.attr(elem.style, "display", "none");
					elem.Status = "transHidden";
				}
			},this.Delay);
		};
		elem.clearTransInterval = function(){
		/// <summary>停止正在执行的伸展特效</summary>
			if(this.runTransShow)clearInterval(this.runTransShow);
			if(this.runTransHidden)clearInterval(this.runTransHidden);
		};
	},
	transShowMouseOver:function(){
	/// <summary>特效：渐显渐隐 鼠标经过事件</summary>
		if(this.Relate.style.display != "block")
			this.Relate.transShow("toMaxHeight");
	},
	transShowClick:function(){
	/// <summary>特效：渐隐 鼠标点击事件</summary>
		if(this.transShow.Status == "runMaxHeight")
			this.transShow.toMinHeight("transHidden");
	}
});
$.$(defaultLoader);
function defaultLoader(){
	$("a").externalLinks();
	$("#Navigation,CategoryInfo").effectGlideShow(["li","li"],100,0,0.05,10);
}
//]]>
