/**
 * 2011-01-23
 * By Gerry
 * 重新调整相关的弹出层的一些效果
 */

var DsrEliDivPro = function(){
	function LoadingCoverDiv(flag){
		var tempObj,rootDoc, docH, docW,browser;
		browser=navigator.userAgent.indexOf("MSIE 6.0");
		tempObj = document.getElementById('BGCOVERDIV');
		//存在层但是被隐藏
		if (tempObj) {
			//已存在但是隐藏时  打开div层
			if (tempObj.style.display == 'none') {
				tempObj.style.display = 'block';
				//ie6的时候还要打开iframe层
				if (browser>0) {
					tempObj = document.getElementById('BGCOVERIFR');
					if (tempObj) {
						tempObj.style.display = 'block';
					}
				}
			}
			//已存在但是隐藏时  打开图片和文字层
			tempObj = document.getElementById('TOP_BGCOVERDIV');
			if(tempObj){
				if (tempObj.style.display == 'none') {
					tempObj.style.display = 'block';
				}
			}
		//重新创建层
		}else {
			rootDoc = document.body || document.documentElement;
			docH = ((rootDoc.clientHeight > rootDoc.scrollHeight) ? rootDoc.clientHeight : rootDoc.scrollHeight);
			docW = ((rootDoc.clientWidth > rootDoc.scrollWidth) ? rootDoc.clientWidth : rootDoc.scrollWidth);
			//蒙版层
			tempObj = document.createElement('div');
			tempObj.setAttribute('id', 'BGCOVERDIV');
			tempObj.style.left = '0px';
			tempObj.style.top = '0px';
			tempObj.style.width = '100%';//docW;
			tempObj.style.height = '100%';//docH;
			tempObj.style.position = 'absolute';
			tempObj.style.zIndex = 11300;
			tempObj.style.filter = 'alpha(opacity=15)';
			tempObj.style.opacity = 0.15;
			tempObj.style.display = 'block';
			tempObj.style.backgroundColor = '#d2d0d0';
			document.body.appendChild(tempObj);
			//ie6下增加iframe遮盖下拉框
			if (browser>0) {
				var ifrObj = document.createElement('iframe');
				ifrObj.id = 'BGCOVERIFR';
				ifrObj.setAttribute('scrolling', 'auto');
				ifrObj.setAttribute('width', '100%');
				ifrObj.setAttribute('height', '100%');
				ifrObj.setAttribute('frameborder', 0);
				ifrObj.setAttribute('framespacing', 0);
				ifrObj.style.filter = 'alpha(opacity:0)';
				ifrObj.style.opacity = 0;
				ifrObj.style.position = 'absolute';
				ifrObj.style.zIndex = 299;
				document.body.appendChild(ifrObj);
			}
			
			//加入loading图标
			var objDivCover = document.createElement('div');
			objDivCover.id = "TOP_BGCOVERDIV";
			var temp;
			if(flag && flag==1){
				temp = '<div style="width:98px;height:50px;background:url(../../dsrtool/popUpDiv/skin/default/images/loading_bgImg.png) no-repeat;">'
					 + '<div style="width:31px;height:31px;margin :9px 3px 8px 8px;float:left;display:inline;"><img src="../../dsrtool/popUpDiv/skin/default/images/loading.gif"/></div>'
					 + '<div style="width:50px;height:31px;text-align:center;float:left;padding-top:18px;color:#0157ae;font:Arial, Helvetica, sans-serif;font-size:12px;display:inline;">Loading</div>'
					 + '</div>';
			}else{
				temp = '<div style="width:98px;height:50px;background:url(dsrtool/popUpDiv/skin/default/images/loading_bgImg.png) no-repeat;">'
						 + '<div style="width:31px;height:31px;margin :9px 3px 8px 8px;float:left;display:inline;"><img src="dsrtool/popUpDiv/skin/default/images/loading.gif"/></div>'
						 + '<div style="width:50px;height:31px;text-align:center;float:left;padding-top:18px;color:#0157ae;font:Arial, Helvetica, sans-serif;font-size:12px;display:inline;">Loading</div>'
						 + '</div>';
			}
			objDivCover.innerHTML = temp;
			objDivCover.style.position = 'absolute';
			objDivCover.style.zIndex = tempObj.style.zIndex + 300;
			document.body.appendChild(objDivCover);
			objDivCover.style.left = (docW - objDivCover.offsetWidth) / 2 + 'px';
			objDivCover.style.top = (docH - objDivCover.offsetHeight) / 2 + 'px';
		}
		tempObj = null;
		rootDoc = null;
	}
	/**
	*	隐藏层
	*/
	function LoadingCoverClose(){
		var tempObj;
		//关闭ie6下的iframe层
		tempObj = document.getElementById('BGCOVERIFR');
		if(tempObj){
			tempObj.style.display = 'none';
		}
		//关闭div层
		tempObj = document.getElementById('BGCOVERDIV');
		if(tempObj){
			tempObj.style.display = 'none';
		}
		//关闭加载的动画和文字层
		tempObj = document.getElementById('TOP_BGCOVERDIV');
		if(tempObj){
			tempObj.style.display = 'none';
		}
	}
	return {
		LoadingCoverDiv: function(flag){
			LoadingCoverDiv(flag);
		},
		LoadingCoverClose: function(){
			LoadingCoverClose()
		}
	}
}();
