var bodyScrollWidth = 0;
var bodyScrollHeight = 0;
var screenAvailWidth = window.screen.availWidth;
var screenAvailHeight = window.screen.availHeight;

if (navigator.appName.indexOf("Explorer") > -1) {//ie
	var exp = 1;
} else {//for ff
	var exp = 2;
}

reCalBodySize();

function reCalBodySize() {
	//bodyScrollWidth=document.documentElement.scrollWidth;
	// bodyScrollHeight=document.documentElement.scrollHeight;
	bodyScrollWidth = document.body.scrollWidth;
	bodyScrollHeight = document.body.scrollHeight;
}

function set_div_style(obj, id, top, left, width, height, position, border,
		cursor, background) {
	var obj = obj;
	obj.id = id ? id : null;
	obj.style.top = top ? top : '0px';
	obj.style.left = left ? left : '0px';
	obj.style.width = width ? width : '0px';
	obj.style.height = height ? height : '0px';
	obj.style.position = position ? position : "static";
	obj.style.border = border ? border : "1px #000 solid";
	obj.style.cursor = cursor ? cursor : "default";
	obj.style.background = background ? background : "";
	return obj
}

//*********************
// 隐藏元素
var hiddenObjs = [];
function HideElement(strElementTagName) {
	try {
		for (i = 0; i < window.document.all.tags(strElementTagName).length; i++) {
			var objTemp = window.document.all.tags(strElementTagName)[i];
			if ('visible' == objTemp.style.visibility) {
				objTemp.style.visibility = "hidden";
				hiddenObjs.push(objTemp);
			}
		}
	} catch (e) {
		alert(e.message);
	}
}

function hideElementAll() {
	hiddenObjs = [];
	HideElement("SELECT");
	HideElement("OBJECT");
	HideElement("IFRAME");
}

function showElementAll() {
	var len = hiddenObjs.length;
	for ( var i = 0; i < len; i++) {
		hiddenObjs[i].style.visibility = "visible";
	}
}

function synSizeByBody() {
	reCalBodySize();
	var argArr = synSizeByBody.arguments;
	for ( var i = 0; i < argArr.length; i++) {
		if (document.getElementById(argArr[i]) != null) {
			document.getElementById(argArr[i]).style.width = (bodyScrollWidth) + 'px';
			document.getElementById(argArr[i]).style.height = (bodyScrollHeight) + 'px';

		}
	}
}
//滤镜效果
function hideBody() {
	synSizeByBody("globalDiv");
	document.getElementById("globalDiv").style.display = "block";
	if (1 == exp) {
		hideElementAll();
	}
}

//取消隐藏
function cancelHide() {
	document.getElementById("globalDiv").style.display = "none";
	if (1 == exp) {
		showElementAll();
	}
}

function buildGlobalDiv_1() {
	var globalDiv = document.getElementById("globalDiv");
	globalDiv.style.zIndex = '98';
	// globalDiv =
	// set_div_style(globalDiv,'globalDiv','0px','0px',bodyScrollWidth+'px',bodyScrollHeight+'px',"absolute","
	// #333333 0px solid","default","#000000");
	globalDiv = set_div_style(globalDiv, 'globalDiv', '0px', '0px', '100%','100%', "absolute", " #333333 0px solid", "default", "#000000");

	if (1 == exp) {
		globalDiv.style.filter = "alpha(opacity=30)";
	} else {
		globalDiv.style.opacity = 30 / 100;
	}
}

function buildGlobalDiv() {
	var globalDiv = document.createElement('div');
	globalDiv.id = 'globalDiv';
	globalDiv.style.display = 'none';
	globalDiv.style.zIndex = '98';
	globalDiv = set_div_style(globalDiv, 'globalDiv', '0px', '0px',bodyScrollWidth + 'px', bodyScrollHeight + 'px', "absolute"," #333333 0px solid", "default", "#000000");

	if (1 == exp) {
		globalDiv.style.filter = "alpha(opacity=30)";
	} else {
		globalDiv.style.opacity = 30 / 100;
	}
	//document.body.appendChild(globalDiv);
	document.body.insertBefore(globalDiv, document.body.childNodes[0])
}

//
buildGlobalDiv();
