(function($) {
	$.extend({
		/**
		 * 取得页面的长宽
		 */
		getPageSize: function() {
			var xScroll, yScroll;
			
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight) {
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else {
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			
			var windowWidth, windowHeight;
			
			if (self.innerHeight) {
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) {
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) {
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}
			
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else { 
				pageHeight = yScroll;
			}
			
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
		
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
			return arrayPageSize;
		},
		
		/**
		 * 取得页面的偏移量
		 */
		getPageScroll: function() {
			
			var xScroll, yScroll;
		
			if (self.pageYOffset) {
				yScroll = self.pageYOffset;
				xScroll = self.pageXOffset;
			} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
				yScroll = document.documentElement.scrollTop;
				xScroll = document.documentElement.scrollLeft;
			} else if (document.body) {// all other Explorers
				yScroll = document.body.scrollTop;
				xScroll = document.body.scrollLeft;	
			}
		
			arrayPageScroll = new Array(xScroll,yScroll) 
			return arrayPageScroll;
		},
		
		/**
		 * 数据加载中
		 */
		dataLoading: function(o) {
			o = $.extend({
				mask: false,
				message: "数据处理中..."
			}, o);
			
			var scrollArray = $.getPageScroll();
			$("<div class=\"loading\">" + o.message + "</div>").appendTo("body")
			.css({
				position: "absolute",
				left: scrollArray[0] + 5,
				top: scrollArray[1] + 5,
				zIndex: 10001
			});
			
			if (o.mask) {
				var arrayPageSize = $.getPageSize();
				$("<div class=\"mask\"></div>").appendTo("body")
				.css({
					position: "absolute",
					left: 0,
					top: 0,
					opacity: 0,
					background: "#000000",
					width: arrayPageSize[0],
					height: arrayPageSize[1],
					zIndex: 10001
				});
			}
		},
		
		/**
		 * 数据加载完成
		 */
		dataLoaded: function(funcCallback) {
			$(".mask").remove();
			$(".loading").fadeOut("fast", function() {
				if (funcCallback != "undefined" && $.isFunction(funcCallback)) {
					funcCallback.call(this);
				}
				$(this).remove();
			});
		}
	});
})(jQuery);