/*
 * zCool.UI 1.0 - Javascript
 *
 * Copyright (c) 2009 - 2010  周柏民 (http://jscaler.appspot.com/)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * $Date: 2010-06-28 19:28:00 BeiJing $
 * $Revision: 33 $
 */
 
// @imports zCool.js

/*$.imports('0.800', ['zCool'], function($, undefined){
	
});*/


(function(window, $, undefined){
	
	var DOC = window.document,
	
	oe = $.ONLY_ELEMENT,
	
	AP = Array.prototype,
	some = AP.some,
	forEach = AP.forEach,
	slice = AP.slice,
	
	//DISABLED_TAG = { LINK:1, STYLE:1, BUTTON:1, FIELDSET:1, INPUT:1, SELECT:1, OPTGROUP:1, OPTION:1, TEXTAREA:1 },
	DISABLED_TAG = { BUTTON:1, INPUT:1, SELECT:1, TEXTAREA:1 },
	
	// 存储遮罩对象，运行时创建
	CacheMask = {},
	
	// 面板各部件的命名 string array
	panelPartNames = ' Tl Tr Tc Ml Mr Mc Body Bl Br Bc'.
		replace(/ /g, ' panel').slice(1).split(' '),
	
	// $UI类的构造器	
	$UI = $.UI = function(root, settings){
			
		return this.initialize(root, settings);
			
   	};
		
	
	// 静态方法集
	$.extend($UI, {
		
		instances : {},
		
		// 定义一个子类
		// @name string 子类名，通常也是$UI控件的基础样式类名
		// @subClass function 子类的构造器
		defined: function( name, subClass ){
			
			$.override(subClass, this);
			
			// 构造函数类的原型继承
			$.inherits(subClass, this);
			
			this[ name ] = subClass;
			
			subClass.className = name;
			
			subClass.instances = {};
			
			return subClass;
			
		},
		
		// 获取一个空闲的组件实例
		getFreeInstance: function(){
			
			var instances = this.instances, instance, id;
			
			for( id in instances ){
				
				if( instances[ id ].free ){
					return instances[ id ];
				}
			}
			return null;
		},
		
		// 根据元素获取所在的实例
		getWhereInstance: function(el){
			
			var instances = this.instances, id;
			
			while( el ){
				if( (id = el[$.CSS_INDEX]) && instances[ id ] ){
					return instances[ id ];
				}
				el = el.parentNode;
			}
			return null;
		}
		
	});
	
	// 原型方法集提供$UI组件原型继承
	$.extend($UI.prototype, {
		
		extend: $.extend,
		
		bind: $.bindEventHandle,
		
		// $UI子类的初始化函数
		// @settings json对象（键/值）格式设置
		initialize : function(root, settings){
			
			this.initPrototypeSettings();
			
			this.extend(true, settings || {});
			
			// @root 创建$UI控件实例所对应的DOM模块的根节点	
			if( !(root && root.nodeType) ){
				root = this.createRoot(root);
			}
			else{
				this.DOC = root.ownerDocument;
			}
			this.root = root;
						
			var id = root[$.CSS_INDEX] || (root[$.CSS_INDEX] = ++$.CSS_ID);
			
			// 将实例存储在实例集中
			$UI.instances[ id ] = this.constructor.instances[ id ] = this;
			
		},
		
		defaultSettings: {
		},
		
		clearTimeout: function(){
			
			if( this.timeoutId ){
				window.clearTimeout( this.timeoutId );
				this.timeoutId = null;
			}
		},
		
		// 追溯原型链上的所有原型，
		// 初始化每个原型的缺省设置（如果有的话），
		// 并将这些缺省设置的转换为一个key的数组
		initPrototypeSettings: function(){
			
			var ps = [], i = 0, a, j, k,
				p = this.constructor.prototype,
				d = p.defaultSettings;
			
			while( d && !$.isArray(d) ){
				
				ps[ i++ ] = p;
				if( !(p = p.constructor.superclass) ){
					break;
				}
				d = p.defaultSettings;
			}
			
			for( ; --i > -1; ){
				
				p = ps[i];
				d = p.defaultSettings;
				a = [];
				j = 0;
				
				for( k in d ){
					p[k] = d[k];
					a[ j++ ] = k;
				}
				p.defaultSettings = a;
			}
		},
		
		// 恢复实例的缺省设置
		resetSettings: function(){
			
			this.initPrototypeSettings();
			
			var a = [], 
				p = this.constructor.prototype,
				d = p.defaultSettings;
			
			while( d && $.isArray(d) ){
				
				a = a.concat(d);
				if( !(p = p.constructor.superclass) ){
					break;
				}
				d = p.defaultSettings;
			}
			
			a.uniq().each(function( k ){
				
				delete this[k];
				
			}, this);
		},
		
		// 创建实例的根元素
		createRoot : function(root){
			
			if( typeof root === 'string' ){
				root = $( root )[0];
				this.DOC = DOC;
				
			}
			else{
				root = this.createPanel(root && root.classPrefix);
				this.DOC || (this.DOC = DOC);
			}
			
			$( this.root = root ).addClass( this.constructor.className );
			
			this.DOC.body.appendChild( this.root );
			
			return this.root;
		},
	
		// 创建面板元素
		createPanel : function(classPrefix){
			
			var html = '<div class="w-panel">' +
					  '<div class="w-panel-tl"><div class="w-panel-tr"><div class="w-panel-tc"></div></div></div>' +
					  '<div class="w-panel-ml"><div class="w-panel-mr"><div class="w-panel-mc">' + 
					  	'<div class="w-panel-body"></div>' + 
					  '</div></div></div>' +
					  '<div class="w-panel-bl"><div class="w-panel-br"><div class="w-panel-bc"></div></div></div>' +
					'</div>';
					
			if( classPrefix ){
				html = html.replace(/w/g, classPrefix);
			}
			
			this.panel = $( html )[0];
			
			$('*', this.panel).
				each( function(el, i){
					this[ panelPartNames[i] ] = el;
				}, this);
			
			return this.panel;
		},
		
		// 加载页面
		// 为实例添加一个页面对象，并插入该对象的根元素
		loadPage: function( page ){
			
			if( page ){
				this.page = page;
			}
			else{
				page = this.page || this.createPage();
			}
			
			var root = page && page.root;
			
			if( root ){
				
				var firstChild = this.panelBody.fisrtChild;
				
				if( firstChild ){
					this.panelBody.replaceChild( root, firstChild );
				}
				else{
					this.panelBody.appendChild( root );
				}
			}
			
			return this;
		},
		
		// 删除实例的页面对象，并删除该对象的根元素
		// 返回页面对象的引用
		unloadPage: function(){
			
			var page = this.page;
			
			if( page ){
				if( page.root && page.root.parentNode === this.panelBody ){
					this.panelBody.removeChild( page.root );
				}
				delete this.page;
			}
			
			return page;
		},
		
		createPage: $.noop,
		
		render: $.noop,
		
		// 设置DOM成员（根据元素的样式类）
		// 返回成员名数组
		setDOMMemberByClass : function(root, prefix){
			
			prefix || ( prefix = this.constructor.className );
			prefix = new RegExp('(?:^|\\s)\\s*' + prefix + '-(\\S+)');
			
			var names = [], l = 0;
			
			$('*', root).each(function( el ){
				
				var className = el.className;
				if( className && prefix.test(className) ){
					this[ names[ l++ ] = RegExp.$1.camelCase() ] = el;
				}
			}, this);
			
			return names;
		},
		
		// 设置DOM成员是否可用（显示或隐藏）
		// @names string array 成员名
		// @type string 样式类名
		setDOMMemberEnable: function(names, className){
			
			names.each(function(name){
				
				$( this[name] )
					[ this[name + 'Enable'] ? 'removeClass' : 'addClass' ]
						(className || 'none');
				
			}, this);
		},
		
		// 为DOM成员注册事件
		// @names string array 成员名数组
		// @type string DOM 事件类型
		setDOMMemberOn: function(names, types){
			
			names.each(function(name){
				
				types.each(function(type){
					
					var handle = this[name + type.capitalize()];
					if( handle ){
						$( this[name] )[ type ]
							( this.bind( handle ) );
					}
				}, this);
						
			}, this);
		},
		
		// 事件监听器
		// ！！！注意：只能注册为实例（而非原型）的属性
		// EventListeners : {
		//	  resize : [ fn, fn1 ...]
		//	  ...
		// }
		
		// 注册侦听器
		// @type string
		// @fn function
		on : function(type, fn){
			
			if( typeof fn === 'function' ){
				
				var EL = this.EventListeners || (this.EventListeners = {}),
					fns = EL[type];
				
				if( !fns ){
					EL[type] = fn;
					return this;
				}
				else if( fns !== fn ){
					
					if( typeof fns === 'function'){
						EL[type] = [fns, fn];
						return this;
					}
					else{
						var l = fns.length;
						for( ; --l > -1; ){
							if( fns[l] === fn ){
								return this;
							}
						}
						return this;
					}
				}
			}
			return this;
		},
		
		// 注销侦听器
		// @type string 事件队列类型
		// @fn function 事件函数
		no : function(type, fn){
			
			var EL = this.EventListeners, fns;
			
			// 若实例存在事件侦听器
			if( EL ){
				// 当未指定事件类型，注销全部事件侦听器
				if( typeof type !== 'string' ){
					delete this.EventListeners;
					return this;
				}
				// 否则，当存在指定类型事件队列时
				else if( fns = EL[type] ){
					
					// 当未指定事件函数时，删除该队列
					if( fns === fn || typeof fn !== 'function' ){
						delete EL[type];
						
						// 若侦听器已还存在事件队列，直接返回
						for(type in EL){
							return this;
						}
						
						// 否则删除整个事件侦听器
						delete this.EventListeners;
						return this;
					}
					else if( typeof fns !== 'function' ){
						
						var l = fns.length;
						for( ; --l > -1; ){
							if( fns[l] === fn ){
								fns.splice( l, 1 );
								if( fns.length < 2 ){
									EL[type] = fns[0];
								}
								return this;
							}
						}
						return this;
					}
					return this;
				}
				
			}
			return this;
		},
		
		// 触发$UI组件事件
		// @type 事件名称
		emit : function(type){
			
			var EL = this.EventListeners, fns;
			
			// 若已注册事件队列
			if( EL && (fns = EL[type])){
				
				if( typeof fns == 'function' ){
					
    				switch (arguments.length) {
      					// fast cases
      					case 1:
        				fns.call(this);
        				break;
      					case 2:
        				fns.call(this, arguments[1]);
        				break;
      					case 3:
        				fns.call(this, arguments[1], arguments[2]);
       					break;
      					// slower
      					default:
        				fns.apply(this, slice.call(arguments, 1));
    				}
					return this;
				}
				
				// 执行事件队列		
				var i = -1; l = fns.length, args = slice.call(arguments, 1);
				for( ; ++i < l; ){
					if( fns[i].apply(this, args) === false ){
						return false;
					};
				}
				return this;
			}
			return this;
		},
		
		// 销毁实例
		// @deep boolean 深度销毁，包含的所有$UI子类的实例
		destroy : function( deep ){
			
			var root = this.root;
			
			deep && 
				$('*', root).each(function( el ){
					var id = el[ $.CSS_INDEX ];
					if( id ){
						if( this[ id ] ){
							this[ id ].destroy();
						}
					}
				}, $UI.instances);
			
			var parent = root.parentNode,
				id = root[ $.CSS_INDEX ];
			
			if( parent ){
				parent.removeChild( this.root );
			}
			delete $UI.instances[ id ];
			delete this.constructor.instances[ id ];
		}
		
	});
	
	
	$.extend({
		
		// 禁用选择文本
		userSelect : (function(){
			
			var s = 'var m=b?"removeEvent":"addEvent",p=$.preventDefault;$[m](e,"mousedown",p);';
			
			['userSelect', 'MozUserSelect', 'WebkitUserSelect', 'KhtmlUserSelect'].
				some(function(p){
					return (p in this) && (s += '(e.style||e.body.style).' + p + '=b?"":"none";');
				}, oe.html.style);
			
			// firefox && opera 不支持
			if( 'onselectstart' in DOC ){
				s += '$[m](e,"selectstart",p);';
			}
			
			return new Function('$', 'return function(e,b){' + s + '}')($);
			
		})(),
		
		// 设置遮罩指定的页面或元素
		// @target 被遮罩元素
		mask : function(target, settings){
				
			var nodeType, id, masks, mask, doc;
			
			if( !target ){
				return;
			}
				
			switch( nodeType = target.nodeType ){
				
				case 9:
				doc = target;
				break;
				
				case 1:
				doc = target.ownerDocument;
				if( oe[target.nodeName] ){
					target = doc;
					nodeType = 9;
				}
				break;
				
				default:
				if( target === window ){
					doc = target = DOC;
				}
				else if( $.isNative('setTimeout', target) ){
					doc = target = target.document;
				}
				else{
					settings = target;
					doc = target = DOC;
				}
				nodeType = 9;
			}
			
			id = target[$.CSS_INDEX] || (target[$.CSS_INDEX] = ++$.CSS_ID);
			
			if( !settings ){
				if( (mask = CacheMask[id]) ){
					if( mask.nodeType ){
						delete CacheMask[id];
					}
					else{
						mask = ( masks = mask ).pop();
						if( masks.length < 2 ){
							CacheMask[id] = masks[0];
						}
						
					}
					$(mask).remove();
				}
				return mask;
			}
			
			var html, body, width, height, coord, top = 0, left = 0, cssText, $mask;
				
			if(nodeType === 1){
				// 若设置从目标元素内部插入遮罩层
				if( settings && settings.internal ){
					body = target;
					width = body.scrollWidth;
					height = body.scrollHeight;
				}
				else{
					body = (doc === DOC) ? oe.body: doc.body;
					coord = $.coord(target);
					left = coord.left;
					top = coord.top;
					width = coord.right - left;
					height = coord.bottom - top;
				}
			}
			else{
				if( doc === DOC ){
					html = oe.html;
					body = oe.body;
				}
				else{
					html = doc.documentElement;
					body = doc.body;
				}
				width = Math.max(html.scrollWidth, body.scrollWidth);
				height = Math.max(html.scrollHeight, body.scrollHeight);
			}
			
			cssText =
					'position:absolute;left:' + left + 
					'px;top:' + top +  
					'px;width:' + width + 
					'px;height:' + height +  
					'px;';
					
			$mask = $('<div style="' +  cssText + '"/>');
			
			if( masks = CacheMask[id] ){
				if( masks.nodeType ){
					CacheMask[id] = [masks, $mask[0]];
				}
				else{
					masks.push( $mask[0] );
				}
			}
			else{
				CacheMask[id] = $mask[0];
			}
					
			$(mask).css(cssText);
			
			if( typeof settings === 'object' ){
				if( settings.css ){
					$mask.css(settings.css);
				}
				if( settings.className ){
					$mask.addClass(settings.className);
				}
				if( settings.html){
					$mask.html(settings.html);
				}
			}
			return body.appendChild( $mask[0] );
		},
		
		// 依赖样式：w-ui.css
		// 依赖脚本：zCool.finalStyle
		// 定义：限制元素的宽高在一个规定尺寸的容器内
		// @img DOM Element 通常为图片
		// @minWidth UInt 限定元素的最大宽度
		// @minWidth UInt 限定元素的最大高度
		// @fill Boolean 在宽高都不足规定的尺寸时，true就等比放大至规定的尺寸，否则保持原样
		limitImgSize: function(img, maxWidth, maxHeight, fill){
			
			var style = img.style, ow, oh, wRatio, hRatio, width, height;
			
			var toLocate = $.finalStyle(img, 'position') === 'absolute';
			
			style.top = style.left = '-32767px';
			style.width = style.height = 'auto';
				
			if( (ow = img.offsetWidth) && (oh = img.offsetHeight) && 
			((ow > maxWidth || oh > maxHeight) || (fill && ow < maxWidth && oh < maxHeight)) ){
				
				if((wRatio = ow/maxWidth) >= (hRatio = oh/maxHeight)){
					style.width = maxWidth + 'px';
					style.left = '';
					style.height = (height = oh/wRatio) + 'px';
					style.top = toLocate ? (maxHeight - height)/2 + 'px' : '';
				}
				else{
					style.height = maxHeight + 'px';
					style.top = '';
					style.width = (width = ow/hRatio) + 'px';
					style.left = toLocate ? (maxWidth - width)/2 + 'px' : '';
				}
			}
			else{
				if( toLocate ){
					style.top = (maxHeight - oh)/2 + 'px';
					style.left = (maxWidth - ow)/2 + 'px';
				}
				else{
					style.top = style.left = '';
				}
			}
			
			return img;
		},
		
		isParentFixed: function(el){
			var parent = el.parentNode;
			while( parent ){
				if( oe[parent.nodeName] ) return false;
				if( $.finalStyle(parent, 'position') === 'fixed' ) return true;
				parent = parent.parentNode;
			}
			return false;
		},
		
		// 
		setPosition: function(target, top, left, limit){
			
			var doc, html, body,
				offsetParent = $(target).offsetParent()[0],
				isFixed = $.finalStyle(target, 'position') === 'fixed',
				isRelativeRoot = isFixed || !!oe[offsetParent.nodeName],
				sLeft = 0, sTop = 0,
				width, height, cWidth, cHeight;
			
			if( isRelativeRoot ){	
				doc = target.ownerDocument;
				if( doc === DOC ){
					html = oe.html;
					body = oe.body;
				}
				else{
					html = doc.documentElement;
					body = doc.body;
				}
			}
			
			if(  typeof left !== 'number' ){
				
				width = target.offsetWidth;
				
				if( isRelativeRoot ){
					cWidth = html.clientWidth || body.clientWidth;
					isFixed || (sLeft = html.scrollLeft || body.scrollLeft);
				}
				else{
					cWidth = offsetParent.clientWidth;
					isFixed || (sLeft = offsetParent.scrollLeft);
				}
				left = sLeft + (cWidth - width)/2;
			}
			
			if( typeof top !== 'number' ){
				
				height = target.offsetHeight;
				
				if( isRelativeRoot ){
					cHeight = html.clientHeight || body.clientHeight;
					isFixed || (sTop = html.scrollTop || body.scrollTop);
				}
				else{
					cHeight = offsetParent.clientHeight;
					isFixed || (sTop = offsetParent.scrollTop);
				}
				
				top = sTop + (cHeight - height)/2;
			}
			
			$(target).css({
				top: limit && top < 0 ? 0 : top + 'px'
				,left: limit && left < 0 ? 0 : left + 'px'
			});
			
			return target;
		},
		
		disabled: function(el, boolean, className, callback){
			
			boolean = !!boolean;
			className || (className = 'disabled');
			
			var nodeName = el.nodeName,
				classMethod = boolean ? 'addClass' : 'removeClass';
			
			// BUTTON, INPUT, SELECT, TEXTAREA element
			if( DISABLED_TAG[ nodeName ] ){
				toggleDisabled(el, boolean, classMethod, className, callback);
				return el;
			}
			else {
				var els = el.getElementsByTagName('*');
				
				// LABEL element
				if( nodeName === 'LABEL'){
			
					$(el)[ classMethod ](className);
				
					some.call(els, function(el){
				
						if( DISABLED_TAG[ el.nodeName ] ){
							el.disabled = boolean;
							callback && callback(el);
							return true;
						}
					});
					return el;
				}
				// other element
				else{
					forEach.call(els, function(el){
				
						if( DISABLED_TAG[ el.nodeName ] ){
							toggleDisabled(el, boolean, classMethod, className, callback);
						}
					});
					return el;
				}
			}
			
			function toggleDisabled(el, boolean, classMethod, className, callback){
				$(el).ancestor('label')[ classMethod ](className);
				el.disabled = boolean;
				callback && callback(el);
			};
		}
		
	});
	
	// 提示框组件，构造器
	var $UITooltips = $UI.defined('Tooltips', function(root, settings){
			
			$.UI.call(this, root, settings);
			
			// 打开提示框，设置（坐标/大小等参数）
			this.open();
		
	});
	
	$.override($UITooltips.prototype, {
		
		defaultSettings: {
			free: true,
			target: null,
			type: 'get',
			url: '',
			xhr: null,
			timeoutId: null
		},
		
		createRoot: function(){
			
			this.root = $(
				'<div class="Tooltips">' + 
					'<div class="Tooltips-body">' +
						'<h1 class="Tooltips-h1"><i class="icons icons-user"></i>回执理由</h1>' +
						'<div class="Tooltips-page-root"></div>' +
					'</div>' +
					'<span class="Tooltips-arrow-points"></span>' +
				'</div>'
			).
				addClass( this.constructor.className )[0];
				
			this.setDOMMemberByClass(this.root);
			
			$( this.root ).mouseenter( this.bind( this.rootMouseenter ) );
			
			this.DOC = this.target.ownerDocument;
			this.DOC.body.appendChild( this.root );
			
			return this.root;
		},
		
		rootMouseenter: function(e){
			
			this.clearTimeout();
			$( this.root ).mouseleave( this.bind( this.rootMouseleave ) );
		},
		
		rootMouseleave: function(e){
			
			var self = this;
			
			this.timeoutId = window.setTimeout(function(){
				self.close();
			}, 200);
			$( this.root ).noMouseleave( this.rootMouseleave );
		},
		
		open: function( settings ){
			
			var self = this;
			
			this.clearTimeout();
			
			this.timeoutId = window.setTimeout(function(){
				
				self.render( settings );
				self.root.style.visibility = 'visible';
				
			}, 200);
			
			return this;
		},
		
		close: function(e){
			
			this.clearTimeout();
			
			$( this.root ).css('');
			
			// 删除页面
			this.unloadPage();
			
			// 删除实例注册的事件
			this.no();
			
			// 重置选项
			this.resetSettings();
		},
		
        // 设置窗口实例
        render: function( settings ){
			
			if( settings ){
				this.extend(true, settings);
			}
			
			// 已被调用
			//this.free = false;
			
			// 若需插页（插入一个DOM根元素）
			this.loadPage();
			
			// 设置窗口位置
			this.setPosition();
			
			return this;
        },
		
		loadPage: function(){
			
			$( this.pageRoot ).
				addClass('Tooltips-loading').
					appendTo( this.body );
			
			this.xhr = $.ajax({
				url: this.url,
				type: this.type,
				cache: false,
				context: this,
				success: this.ajaxSuccess
			});
			
			return this.page;
		},
		
		ajaxSuccess: function( data ){
			
			$( this.pageRoot ).removeClass('Tooltips-loading');
			$( this.pageRoot ).html( data );
		},
		
		unloadPage: function(){
			
			if( this.xhr ){
				this.xhr.abort();
				delete this.xhr;
			}
		},
		
		setPosition: function(){
			
			var coord = $.coord( this.target ),
				top = coord.top,
				left = coord.left,
				width = coord.right - coord.left,
				rootWidth = this.root.clientWidth,
				rootHeight = this.root.clientHeight;
			
			$( this.root ).css({
				top: top - rootHeight + 'px',
				left: left + width/2 - rootWidth/2 + 'px'
			});
		}
		
	});
	
	$.override($UITooltips, {
		
		init: function( root, selector ){
			
			selector || (selector = 'a.Tooltips-trigger');
			
			$.match(root, selector) && (selector = root);
			
			return $(selector, root).mouseenter( $UITooltips.mouseenter );
		},
		
		mouseenter: function(e){
			
			var target = e.currentTarget,
				type = $(target).attr('data-request-type'),
				url = target.href;
				
			if( type && url ){
				
				var instance = $UITooltips.open({
					target: target,
					type: type,
					url: url
				});
				
				$( target ).mouseleave( instance.bind( $UITooltips.mouseleave ) );
			}
		},
		
		mouseleave:function(e){
			
			if( this.root.style.visibility ){
				
				var instance = this;
				this.timeoutId = window.setTimeout(function(){
					
					instance.close();
					
				}, 200);
			}
			else{
				this.clearTimeout();
			}
			
			$( e.currentTarget ).noMouseleave( $UITooltips.mouseleave );
		},
		
		open: function( settings ){
			
			var instance = this.getFreeInstance();
				
			return instance ? instance.open( settings ) : new this(null, settings);
		}
		
	});
	
	/*---------------------------------------- 指定浏览器及其版本的bug修正方法 ----------------------------------------*/
	
	$.msieVersion < 7 && $.extend({
		
		// ie6- 相对父容器奇数尺寸时，子元素以百分比（或右/下）定位偏移 -1px bug
		msie6_fixOddPosition : function(el, width, height, xClass, yClass, xCall, yCall){
			
			var curStyle;
			
			width || (width = parseInt((curStyle = el.currentStyle).width));
			height || (height = parseInt((curStyle || el.currentStyle).height));
			
			xClass && $[width % 2 ? 'addClass' : 'removeClass'](el, xClass);
			yClass && $[height % 2 ? 'addClass' : 'removeClass'](el, yClass);
			
			xCall && xCall(el, width);
			yCall && yCall(el, height);
			
			return el;
		}
		
	});
	
	// 原型扩展
	$.fn.extend({
		
		userSelect: function(settings){
			return this.each(function(el){
				$.userSelect(el, settings);
			});
		},
		
		mask: function(settings){
			return this.each(function(el){
				$.mask(el, settings);
			});
		},
		
		disabled: function(boolean, className, callback){
			return this.each(function(el){
				this(el, boolean, className, callback);
			}, $.disabled);
		}
		
	});
	
})(this, zCool);




