﻿/*
 * jQuery scroll 1.1
 *
 *
    -------------------------------------------------------------
	Ectrip V5.0
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Design By:		xyb
	Description:	Ectrip V5.0 jquery pic scroll Javascript document
	Filename:		jquery-newscroll-1.1.js
	Version:		1.1
	Create Date:	2009-07-28
	Last Edit:		2009-11-17  增加 反向参数：reverse 上下滚动参数direction
					2009-11-24 修复 maxNum=controlArr.length
					2010-06-01 增加 slow 参数，滚动使之由快变慢slow，或者由慢变快fast，默认为normal
					2010-07-21
					2010-08-03 加入callback
					2010-12-15 加入picZoom方法
					2011-07-29 newScrollLine 横向匀速运动 2011-09-10 加了 左右方向滚动控制按钮
	-------------------------------------------------------------	
 *
 * Depends:
 *	jquery-1.3.2.js
 */

jQuery.fn.newScroll = function(options) {
	var defaults = {
		everyWidth: 75,
		//每一个宽度
		autoShowSpeed: 5000,
		//自动切换速度 ms
		scrollSpeed: 5,
		//优雅速度 ms
		scrollPix: 2,
		//匀速时每次移动像素
		maxNum: 6,
		//可显示的个数
		direction: "x",
		//滚动方向
		reverse: false,
		//反方向
		slow: "normal",
		//变化速度
		callback: null
	};
	//980-120=860/6*140 =840
	var opts = $.extend(defaults, options);

	var scrollWH = "width";
	var marginLF = "marginLeft";

	var control_l_d = 0;
	var control_r_d = -1;

	if (opts.direction == "y") {
		scrollWH = "height";
		marginLF = "marginTop";
	}

	if (opts.reverse) {
		control_l_d = -1;
		control_r_d = 0;
	}
	var callback = opts.callback ||
	function() {};

	this.each(function(time) {
		var self = this;
		var control_l = jQuery('.control_l', this);
		var control_r = jQuery('.control_r', this);
		var scroll_content = jQuery('.scroll_content', this);
		var controlArr = jQuery('li', scroll_content);
		var controlArrLen = controlArr.length;

		var autoShowInter; //自动切换
		var scrollLeftInter; //优雅scrollleft
		var num = 0;

		if (controlArrLen < opts.maxNum) {
			control_l.hide();
			control_r.hide();
		} else {
			if (controlArrLen <= opts.maxNum) { //补齐数量，使之等于2个maxNum
				var bNum = opts.maxNum * 2 - controlArrLen;
				var contentI = 0;
				for (var i = 0; i < bNum; i++) {
					if (i >= controlArrLen && contentI >= controlArrLen) {
						contentI = 0;
					}
					controlArr.eq(0).parent().append(controlArr.eq(contentI).clone(true));
					contentI++;
				}
				controlArrLen = opts.maxNum * 2;
			}
			var contentWidth = (controlArrLen + 1) * opts.everyWidth;
			scroll_content.css(scrollWH, contentWidth + "px");
			$(self).attr("scrollAble", "1");
			controlArr.eq(0).addClass("on");

			function FunScrollLeftInter(type) {
				var scrollLeftInter; //优雅scrollleft
				var x = 0;
				var type = type || 0;
				$(self).removeAttr("scrollAble");
				var liArr = jQuery('li', scroll_content);
				liArr.removeClass("on");
				var fristLi = liArr.eq(0);
				var addPix = opts.slow == "fast" ? Math.ceil(opts.scrollPix / 10) : opts.scrollPix;
				var everyWidth = opts.everyWidth;

				if (type == -1) { //show right
					fristLi.next().addClass("on");
					fristLi.parent().append(fristLi.clone(true));
					scrollLeftInter = setInterval(function() {
						if (opts.slow == "slow") {
							addPix = Math.ceil(everyWidth / 16);
							everyWidth -= addPix;
						} else if (opts.slow == "fast") {
							addPix = Math.ceil(addPix * 1.1);
						}
						x -= addPix;
						if (x > (opts.everyWidth * -1)) {
							scroll_content.css(marginLF, x + "px");
						} else {
							fristLi.remove();
							scroll_content.css(marginLF, "0px");
							$(self).attr("scrollAble", "1");
							clearInterval(scrollLeftInter);
							callback();
						}
					},
					opts.scrollSpeed);
				} else { //show left
					fristLi = liArr.eq(liArr.length - 1);
					//liArr.eq(0).addClass("on");
					fristLi.parent().prepend((fristLi.clone(true)).addClass("on"));
					scroll_content.css(marginLF, "-" + opts.everyWidth + "px");
					scrollLeftInter = setInterval(function() {
						if (opts.slow == "slow") {
							addPix = Math.ceil(everyWidth / 16);
							everyWidth -= addPix;
						} else if (opts.slow == "fast") {
							addPix = Math.ceil(addPix * 1.1);
						}
						x += addPix;
						if (x < opts.everyWidth) {
							scroll_content.css(marginLF, x - opts.everyWidth + "px");
						} else {
							fristLi.remove();
							scroll_content.css(marginLF, "0px");
							$(self).attr("scrollAble", "1");
							clearInterval(scrollLeftInter);
							callback();
						}
					},
					opts.scrollSpeed);
				}
			};
			function autoShowInterFun() {
				$(self).attr("scrollAble", "1");
				autoShowInter = setInterval(function() {
					if ($(self).attr("scrollAble") == "1") {
						FunScrollLeftInter( - 1);
					}
				},
				opts.autoShowSpeed);
			};
			control_l.click(function() {
				clearInterval(autoShowInter);
				if ($(self).attr("scrollAble") == "1") {
					FunScrollLeftInter(control_l_d);
					callback();
				}
				return false;
			});
			control_r.click(function() {
				clearInterval(autoShowInter);
				if ($(self).attr("scrollAble") == "1") {
					FunScrollLeftInter(control_r_d);
				}
				return false;
			});
			$(self).mouseenter(function() {
				clearInterval(autoShowInter);
			}).mouseleave(function() {
				autoShowInterFun();
			});
			autoShowInterFun();
			callback();
		}
	});
	return this;
};

/*
 * jQuery newScrollLine 1.0
 *
 *
    -------------------------------------------------------------
	Ectrip V5.0
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Design By:		xyb
	Description:	Ectrip V5.0 jquery textScroll scroll to top Javascript document
	LastEdit: 2011-07-29
	-------------------------------------------------------------	
 *
 * Depends:
 *	jquery-1.3.2.js
 */

jQuery.fn.newScrollLine = function(options) {
	var defaults = {
		everyHeight: 25,
		//每一个高度
		autoShowSpeed: 5000,
		//自动切换速度 ms
		scrollPix: 2,
		//匀速时每次移动像素
		scrollSpeed: 30,
		//移动速度
		scrollAll: false,
		//是否滚动全部
		maxNum: 1,
		//可显示的个数
		direction: "y",
		//滚动方向
		mousestop: false,
		//鼠标放上去是否停止滚动
		reverse: false
	};
	var opts = $.extend(defaults, options);
	var _this = $(this);
	var scrollText = _this.find('.scrollText');
	var scrollParent = scrollText.parent()[0];
	if (opts.direction == "y" && opts.scrollAll ) {//上下无限滚动对象
		//连续上下对象滚动
		var scrollP = null;
		var scrollTextClone=null;	
		if(scrollText.length == 1) {
			scrollP = scrollText.parent();
			scrollTextClone = scrollText.clone();		
			scrollText.after(scrollTextClone);
			
			var  nMarquee = function(){		
				if(scrollTextClone[0].offsetHeight-scrollP[0].scrollTop<=0) {	
					scrollP[0].scrollTop-=scrollText[0].offsetHeight;
				} else{
					scrollP[0].scrollTop++;
				}
			};
			var nMyMar=setInterval(nMarquee,opts.scrollSpeed);
			if (opts.mousestop) {
				scrollP.mouseenter(function(){clearInterval(nMyMar);}).mouseleave(function(){nMyMar=setInterval(nMarquee,opts.scrollSpeed);});
			}
		}
	} else if (opts.direction == "x") {
		scrollParent = scrollText.parent().parent();
		var pWidth = scrollParent.width();
		var textWidth = scrollText.outerWidth();
		if (textWidth < pWidth) {
			return;
		}
		scrollText.after(scrollText.clone());
		
		var controlObj = _this.find(".control");
		var rev = 1;
		var speedNew = opts.scrollSpeed;
		
		var scrollFun = function() {
			var speed = (rev==1 ?(textWidth - scrollParent.scrollLeft()):scrollParent.scrollLeft()) * speedNew;
			scrollParent.animate({
				scrollLeft: rev==1 ? textWidth : 0
			},
			{
				duration: speed,
				"easing": "linear",
				"complete": function() {
					$(this).scrollLeft(rev==1?0:textWidth);
					scrollFun();
				}
			});
		};
		scrollFun();
		
		controlObj.click(function(){
			speedNew = speedNew/1.5;
			rev = $(this).is(".control_l") ? -1 : 1;
			scrollParent.stop();
			scrollFun();		
			return false;					 
		}).mouseleave(function() {
			speedNew = opts.scrollSpeed;
		});
		if (opts.mousestop) {
			scrollParent.mouseenter(function() {
				scrollParent.stop();
			}).mouseleave(function() {
				scrollFun();
			});
		}
	} else {
		var eHeight = opts.everyHeight * opts.maxNum;
		var newsHeight = scrollText.height();

		if (newsHeight >= eHeight * 2) {
			scrollText.after(scrollText.clone());
		} else {
			return;
		}
		var newsI = 0;
		var setNewsTime;

		function showNew() {
			var i = 0;
			timeS = new Date();
			var _thisTop = parseInt(scrollParent.scrollTop, 10) || 0;
			newsI = _thisTop;
			var topInter = setInterval(function() {
				if (i < eHeight) {
					i += opts.scrollPix;
					scrollParent.scrollTop = newsI + i;
				} else {
					newsI += eHeight;
					scrollParent.scrollTop = newsI;
					clearInterval(topInter);
					//msg.text((new Date()-timeS));
				}
				if (newsI >= newsHeight) {
					newsI = 0;
					scrollParent.scrollTop = 0;
				}
			},
			opts.scrollSpeed);
		}
		if (newsHeight >= eHeight * 2) {
			setNewsTime = setInterval(function() {
				showNew()
			},
			opts.autoShowSpeed);
			if (opts.mousestop) {
				_this.mouseover(function() {
					window.clearInterval(window.setInterval("0") - 1);
					clearInterval(setNewsTime);
				}).mouseout(function() {
					setNewsTime = setInterval(function() {
						showNew();
					},
					opts.autoShowSpeed);
				});
			}
		}
	}
};

/*
 * jQuery picFocus 1.2
 *
 *
    -------------------------------------------------------------
	Ectrip V5.0
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Design By:		xyb
	Description:	Ectrip V5.0 jquery pic focus(1 2 3 4 5 6) Javascript document
	Filename:		jquery-picfocus-1.2.js
	Version:		1.2
	Create Date:	2009-09-19
	Last Edit:		2010.04.26
	-------------------------------------------------------------	
 *
 * Depends:
 *	jquery-1.3.2.js
 */

jQuery.fn.picFocus = function(options) {
	var defaults = {
		autoShowSpeed: 5000,
		maxNum: 6,
		//可显示的个数
		method: 'click'
	};
	//980-120=860/6*140 =840
	var opts = $.extend(defaults, options);

	this.each(function() {
		var self = this;

		var scroll_content = jQuery('.controlContent', this);
		var imgHref = scroll_content.eq(0); //图片链接点击obj
		var controlArr = jQuery('img', scroll_content.eq(1)); //图片
		var controlArrLen = controlArr.length;

		var controlNum = jQuery('.controlNum', this);
		var controlNumArr = jQuery('a', controlNum); //num focus
		var autoShowInter; //自动切换
		var showAble = true;

		$(self).attr("focusnum", 0);
		controlArr.hide();
		controlArr.eq(0).show();
		controlNumArr.eq(0).addClass("on");
		imgHref.html(controlNumArr.eq(0).clone());

		if (controlNumArr.length < 2) {
			return;
		}

		var FunFocusInter = function(curnum) {
			if (showAble) {
				var focusnum = parseInt($(self).attr("focusnum"), 10);
				var nextnum = (focusnum + 1) >= controlArrLen ? 0 : focusnum + 1;
				var curnum = (typeof curnum == "undefined") ? nextnum: curnum;

				showAble = false;
				$(self).attr("focusnum", curnum);

				imgHref.html(controlNumArr.eq(curnum).clone());

				controlNumArr.removeClass('on');
				controlNumArr.eq(curnum).addClass('on');

				controlArr.eq(focusnum).fadeOut(200);
				controlArr.eq(curnum).fadeIn(800,
				function() {
					showAble = true;
				});
			}
		};

		controlNumArr.each(function(i) {
			$(this).attr("focusnum", i);
		});

		if (opts.method == 'mouseover') {
			controlNumArr.mouseenter(function() {
				var _this = $(this);
				clearInterval(autoShowInter);
				if (!_this.hasClass('on')) {
					//alert(parseInt($(self).attr("focusnum"),10)+"__"+showAble);
					FunFocusInter(parseInt(_this.attr("focusnum"), 10));
					return false;
				}
			});
		} else {
			controlNumArr.click(function() {
				var _this = $(this);
				clearInterval(autoShowInter);
				if (!_this.hasClass('on')) {
					FunFocusInter(parseInt(_this.attr("focusnum"), 10));
					return false;
				}
			});
		}

		function autoShowInterFun() {
			showAble = true;
			autoShowInter = setInterval(function() {
				FunFocusInter();
			},
			opts.autoShowSpeed);
		};

		$(self).mouseenter(function() {
			clearInterval(autoShowInter);
		}).mouseleave(function() {
			autoShowInterFun();
		});

		autoShowInterFun();
	});
};

/*
 * jQuery picFocusScroll 1.0
 *
 *
    -------------------------------------------------------------
	Ectrip V5.0
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Design By:		xyb
	Description:	Ectrip V5.0 jquery pic focus scroll(1 2 3 4 5 6) Javascript document
	Filename:		jquery-picfocus-1.0.js
	Version:		1.0
	Create Date:	2011-04-05
	Last Edit:		2011-04-05
	-------------------------------------------------------------	
 *
 * Depends:
 *	jquery-1.3.2.js
 */

jQuery.fn.picFocusScroll = function(options) {
	var defaults = {
		autoShowSpeed: 6000,
		direction: "x",

		//滚动方向
		speed: "normal",
		//变化速度
		callback: null,
		method: 'click'
	};
	//980-120=860/6*140 =840
	var opts = $.extend(defaults, options);
	var autoShowInter = [];
	this.each(function(time) {
		var self = this;

		var scrollContent = jQuery('.contentlist', this);
		var contentArr = scrollContent.find('li'); //图片li
		var infoArr = scrollContent.find('.info'); //内容
		var contentArrLen = contentArr.length;
		var liWH = 100;

		if (opts.direction == "x") {
			liWH = contentArr.eq(0).outerWidth();
			scrollContent.width((contentArrLen + 1) * liWH);
		} else {
			liWH = contentArr.eq(0).outerHeight();
			scrollContent.height((contentArrLen + 1) * liWH);
		}

		var controlList = jQuery('.numlist', this);
		var controlArr = jQuery('a', controlList); //num focus
		var controlNumArr = controlArr.not(".control"); //num focus
		var timeoutObj = jQuery('.timeout', this);

		autoShowInter[time] = null; //自动切换
		var showAble = true;
		var nowindex = 0;
		controlNumArr.eq(0).addClass("on");

		if (controlNumArr.length < 2) {
			return;
		}

		var scrollPic = function() {
			var mRange = "";
			var afterFun = function() {
				infoArr.eq(nowindex).slideDown("normal");
				nextAble = true;
			};
			var mRangeObj = {};
			mRangeObj = opts.direction == "x" ? {
				"marginLeft": ( - nowindex * liWH) + "px"
			}: {
				"marginTop": ( - nowindex * liWH) + "px"
			};
			scrollContent.animate(mRangeObj, opts.speed, afterFun);
			return false;
		};

		var FunFocusInter = function(oldindex, newindex) {
			if (nextAble) {
				nowindex = newindex;
				timeoutObj.stop();
				timeoutObj.animate({
					"width": "0"
				},
				"fast");

				nextAble = false;
				controlNumArr.eq(oldindex).removeClass('on');
				controlNumArr.eq(nowindex).addClass('on');
				infoArr.eq(oldindex).slideUp("slow");
				scrollPic();
			}
		};

		controlNumArr.each(function(i) {
			$(this).attr("focusnum", i);
		});
		var mouseShowFun = function(_this) {
			clearInterval(autoShowInter[time]);
			var oldindex = nowindex;
			var newindex = nowindex;
			if (!_this.hasClass('on') && !_this.hasClass('control')) {
				newindex = parseInt(_this.attr("focusnum"), 10);
			}
			if (_this.hasClass('prev')) {
				newindex = nowindex == 0 ? contentArrLen - 1 : nowindex - 1;
			}
			if (_this.hasClass('next')) {
				newindex = nowindex < contentArrLen - 1 ? nowindex + 1 : 0;
			}
			FunFocusInter(oldindex, newindex);
		}

		if (opts.method == 'mouseenter') {
			controlArr.mouseenter(function() {
				mouseShowFun($(this));
				return false;
			});
		} else {
			controlArr.click(function() {
				mouseShowFun($(this));
				return false;
			});
		}

		var autoShowInterFun = function() {
			nextAble = true;
			timeoutObj.animate({
				"width": "100%"
			},
			opts.autoShowSpeed - 200);
			autoShowInter[time] = setInterval(function() {
				FunFocusInter(nowindex, nowindex < contentArrLen - 1 ? nowindex + 1 : 0);
				timeoutObj.animate({
					"width": "100%"
				},
				opts.autoShowSpeed - 200);
			},
			opts.autoShowSpeed);
		};

		$(self).mouseenter(function() {
			clearInterval(autoShowInter[time]);
			timeoutObj.stop();
			timeoutObj.animate({
				"width": "0"
			},
			"fast");
		});

		$(self).mouseleave(function() {
			autoShowInterFun();
		});

		autoShowInterFun();
		infoArr.eq(nowindex).slideDown("slow");
	});
};

/*
 * jQuery newTabs 1.1
 *
 *
    -------------------------------------------------------------
	Ectrip V5.0
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Design By:		xyb
	Description:	Ectrip V5.0 jquery newtabs Javascript document
	Filename:		jquery-tabs-1.1.js
	Version:		1.1
	Create Date:	2009-07-28
	Last Edit:		2010-07-21
	-------------------------------------------------------------	
 *
 * Depends:
 *	jquery-1.3.2.js
 */

jQuery.fn.newTabs = function(options) {
	var defaults = {
		autoShowSpeed: 5000
	};
	//980-120=860/6*140 =840
	var opts = $.extend(defaults, options);
	function showThisTab(_thisA, _thisTab, _thisTabContent, _thisTabMore, j) {
		if (!_thisA.hasClass('on')) {
			_thisTab.removeClass('on');
			_thisTabContent.hide();
			_thisA.addClass('on');
			if (_thisTabMore.length != 0) {
				var moreLastT = _thisTabMore.attr('lasttitle') || "";
				moreLastT = moreLastT == "" ? '更多' + _thisA.text() : "[" + _thisA.text() + "]的更多" + moreLastT;
				_thisTabMore.attr('href', _thisA.attr('href')).attr('title', moreLastT);
			}
			_thisTabContent.eq(j).show();
		}
	};

	this.each(function(i) {
		var _this = $(this);
		var _thisTab = _this.find(".tabs a");
		var _thistabsmethod = _this.attr("tabsmethod") || "click";
		var _thistabsdefault = parseInt(_this.attr("tabsdefault"), 10) || 0;
		var _thisTabMore = _this.find("a.more");
		var _thisTabContent = _this.find(".tabsContent");
		if (_thistabsmethod == "click") {
			_thisTab.each(function(j) {
				$(this).click(function() {
					showThisTab($(this), _thisTab, _thisTabContent, _thisTabMore, j);
					return false;
				});
			});
		} else if (_thistabsmethod == "mouseover") {
			_thisTab.each(function(j) {
				$(this).mouseenter(function() {
					showThisTab($(this), _thisTab, _thisTabContent, _thisTabMore, j);
				});
			});
		}
		showThisTab(_thisTab.eq(_thistabsdefault), _thisTab, _thisTabContent, _thisTabMore, _thistabsdefault);
	});
};

jQuery.fn.picAutoSize = function(options) {
	var defaults = {
		picMaxW: 640,
		//图片最大宽度
		picMaxH: 480,
		//图片最大高度
		zoom: false,
		//如果zoom=width，按照width来，相反按照height
		afterFun: null
	};
	var opts = $.extend(defaults, options);
	/*/percent=opts.picMaxW/opts.picMaxH =1
	//w/h: 740/240 mw/mh 640/480
	p=740/240;
	740>640{
		w=mw;
		h=h*mw/w
	}
	
	
	// 330*500<percent _thisH = 480 _thisW=480/500*330
	// 320*320=  160*160 320/360<percent  _thisW=160 _thisH=160
	*/
	afterFun = opts.afterFun ||
	function() {};

	function picAutoSizeFun(_this) {
		//setTimeout(function() {
		var _thisW = _this.outerWidth();
		var _thisH = _this.outerHeight();

		var percent = _thisW / _thisH;

		var topNum = 0;

		if (_thisW >= opts.picMaxW && !opts.zoom) {
			_thisH = _thisH * opts.picMaxW / _thisW;
			_thisW = opts.picMaxW;
		}
		if (_thisH > opts.picMaxH && !opts.zoom) {
			_thisW = _thisW * opts.picMaxH / _thisH;
			_thisH = opts.picMaxH;
		}
		if (opts.zoom == "width") {
			percent = _thisW / opts.picMaxW;
			_thisW = opts.picMaxW;
			topNum = _thisH - (_thisH / percent);
			_thisH = _thisH > opts.picMaxH ? opts.picMaxH: _thisH / percent;

		} else if (opts.zoom == "height") {
			percent = _thisH / opts.picMaxH;
			_thisH = opts.picMaxH;
			topNum = _thisW - (_thisW / percent);
			_thisW = _thisW > opts.picMaxW ? opts.picMaxW: _thisW / percent;
		}

		_this.height(_thisH).width(_thisW);

		if (opts.zoom == "width") {
			_this;
		} else if (opts.zoom == "height") {
			_this;
		}
		//},
		//50);
	}

	var picInterval = [];

	function onComplate(_this) {
		picInterval[parseInt(_this.attr("intervalI_B"), 10)] = setInterval(function() {
			if (_this.attr("complete")) {
				clearInterval(picInterval[parseInt(_this.attr("intervalI_B"), 10)]);
				picAutoSizeFun(_this);
			}
			if (picInterval.length == 0) {
				afterFun();
			}
		},
		100);
	};
	this.each(function(i) {
		var _this = $(this);
		_this.attr("intervalI_B", i);
		if (_this.attr("complete")) {
			picAutoSizeFun(_this);
		} else {
			onComplate(_this);
		}
	});
	setTimeout(function() {
		if (picInterval.length == 0) {
			afterFun();
		}
	},
	200);
	return $(this);
};

jQuery.fn.picZoom = function(options) {
	var defaults = {
		picMaxW: 640,
		//图片最大宽度
		picMaxH: 480,
		//图片最大高度
		afterFun: null
	};
	var opts = $.extend(defaults, options);
	afterFun = opts.afterFun ||
	function() {};

	var percent = opts.picMaxW / opts.picMaxH;

	function sizeFun(_this, n) {
		var _thisW = _this.width();
		var _thisH = _this.height();
		var _thisL = _this.position().left;
		var _thisT = _this.position().top;
		//_this.animate({"left": _thisL*n+'px',"top": _thisT*n+'px'}, "slow");
		_this.css({
			"height": _thisH * n,
			"width": _thisW * n,
			"left": _thisL * n + 'px',
			"top": _thisT * n + 'px'
		});

	}

	function sizeFunFit(_this) {
		var _thisW = _this.width();
		var _thisH = _this.height();
		var _newL;
		var _newT;
		var _newW;
		var _newH;
		var _pW = _this.parent().width();
		var _pH = _this.parent().height();
		var _perNumX = _thisW / _pW;
		var _perNumY = _thisH / _pH;
		if (_perNumX > _perNumY) {
			_newW = _pW;
			_newH = _pH * (_perNumY / _perNumX);
			_newL = 0;
			_newT = (_pH - _newH) / 2;
		} else {
			_newH = _pH;
			_newW = _pW * (_perNumX / _perNumY);
			_newT = 0;
			_newL = (_pW - _newW) / 2;
		}

		_this.css({
			"height": _newH,
			"width": _newW,
			"left": _newL,
			"top": _newT
		});
	}

	function picUnit(_this, zoomImg) {
		var zoomArr = _this.find(".w-icon-zoom");
		var zoomLoad = _this.find(".loading");

		var zoomOut = zoomArr.eq(0);
		var zoomIn = zoomArr.eq(1);
		var zoomFit = zoomArr.eq(2);
		var zoomTrue = zoomArr.eq(3);
		zoomOut.click(function() {
			sizeFun(zoomImg, 1.318);
			return false;
		});
		zoomIn.click(function() {
			sizeFun(zoomImg, 0.682);
			return false;
		});
		zoomTrue.click(function() {
			zoomImg.css({
				"height": "auto",
				"width": "auto",
				"left": "0",
				"top": "0"
			});
			return false;
		});
		zoomFit.click(function() {
			sizeFunFit(zoomImg);
			return false;
		});
		setTimeout(function() {
			zoomLoad.fadeOut();

			sizeFunFit(zoomImg);
			zoomImg.fadeIn(800,
			function() {
				$(this).draggable().attr("title", "按住鼠标拖动"); //{ containment: 'parent' }
			});
		},
		1000);

	}

	var picInterval = [];

	function onComplate(_this, zoomImg) {
		picInterval[parseInt(zoomImg.attr("intervalI_B"), 10)] = setInterval(function() {
			if (zoomImg.attr("complete")) {
				clearInterval(picInterval[parseInt(zoomImg.attr("intervalI_B"), 10)]);
				picUnit(_this, zoomImg);
			}
			if (picInterval.length == 0) {
				afterFun();
			}
		},
		100);
	};
	this.each(function(i) {
		var _this = $(this);
		var zoomImg = _this.find(".imgcontent");
		zoomImg.attr("intervalI_B", i);
		if (zoomImg.attr("complete")) {
			picUnit(_this, zoomImg);
		} else {
			onComplate(_this, zoomImg);
		}
	});
};
