var waitElement;
function AJAX_LOADING(){
	function CreateWaitElement() {
		var elem = document.getElementById('__AjaxCall_Wait');
		if (!elem) {
			elem = document.createElement("div");
			elem.id = '__AjaxCall_Wait';
			elem.style.position = 'absolute';
			elem.style.height = 17;
			elem.style.marginTop = "200px"; // 外部上间距
			elem.style.marginRight = "500px"; // 外部右间距
			elem.style.paddingLeft = "3px"; // 内部左间距
			elem.style.paddingRight = "3px"; // 内部右间距
			elem.style.fontSize = "11px";
			elem.style.fontFamily = 'Arial, Verdana, Tahoma';
			elem.style.fontWeight = 'bold';
			elem.style.border = "#ec0000 1px solid";
			elem.style.backgroundColor = "#ec0000";
			elem.style.color = "#ffffff";
			elem.innerHTML = 'Loading ...';
			elem.style.visibility = 'hidden'; // 隐藏 loading
			document.body.insertBefore(elem, document.body.firstChild);
		}
		waitElement = elem;
	}

	var scrollX = -1, scrollY = -1;
	function MoveWaitElement() {
		var scrollYT, scrollXT;
		if (!waitElement)
			CreateWaitElement();
		if (typeof(window.pageYOffset) == "number") { 
			scrollYT = window.pageYOffset; 
			scrollXT = window.pageXOffset; 
		}
		else if (document.body && document.documentElement && document.documentElement.scrollTop) { 
			scrollYT = document.documentElement.scrollTop; 
			scrollXT = document.body.scrollLeft;
		}
		else if (document.body && typeof(document.body.scrollTop) == "number") { 
			scrollYT = document.body.scrollTop; 
			scrollXT = document.body.scrollLeft; 
		} 
		if (scrollX != scrollXT || scrollY != scrollYT) {
			scrollX = scrollXT;
			scrollY = scrollYT;
			var width = document.body.clientWidth;
			waitElement.style.top = scrollYT + "px";
			waitElement.style.right = -scrollXT +  "px";
		}
	}
	if (window.addEventListener) {
		window.addEventListener('scroll', MoveWaitElement, false);
		window.addEventListener('resize', MoveWaitElement, false);
	}
	else if (window.attachEvent) {
		window.attachEvent('onscroll', MoveWaitElement);
		window.attachEvent('onresize', MoveWaitElement);
	}
	this.Show = function(){
		CreateWaitElement();
		MoveWaitElement();
		waitElement.style.visibility = '';
	};
	this.Hide = function(){
		CreateWaitElement();
		waitElement.style.visibility = 'hidden';
	}
}
var AjaxLoading = new AJAX_LOADING();