﻿function $_(str) {
	if (typeof str == 'string' && document.getElementById(str) != null ) {
		return document.getElementById(str);
	}
	return false;
}

//*********************浏览器信息********************

var Sys = {};
var ua = navigator.userAgent.toLowerCase();
if (window.ActiveXObject)
  Sys.ie = ua.match(/msie ([\d.]+)/)[1]
else if (document.getBoxObjectFor)
  Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1]
else if (window.MessageEvent && !document.getBoxObjectFor)
  Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1]
else if (window.opera)
  Sys.opera = ua.match(/opera.([\d.]+)/)[1]
else if (window.openDatabase)
  Sys.safari = ua.match(/version\/([\d.]+)/)[1];
  
var browser= {};

if(Sys.ie)
{
 browser.msie=true;
 browser.version=Sys.ie;
}
//*********************滤镜效果*********************

//创建滤镜层
function buildGlobalLayer() {
	//定义记住BODY滚动高度的全局变量
	window.bdscrollHeight = document.body.scrollHeight || document.documentElement.scrollHeight;
	if ( browser.msie && browser.version != '7.0' ) {//IE 7.0以下版本需加iframe
		var gIfr			= document.createElement( 'iframe' );
		gIfr.id				='globalIfr';
		gIfr.style.display	= 'none';
		gIfr.style.position	= 'absolute';
		gIfr.style.clear	= 'both';
		gIfr.style.zIndex	= '90';
		gIfr.style.left		= '0px';
		gIfr.style.top		= '0px';
		gIfr.style.width	= '0px';
		gIfr.style.height	= '0px';
		gIfr.style.border	= '0px #ffffff solid';
		gIfr.onselectstart	= function() { return false;};
		gIfr.style.filter	= 'alpha(opacity=0)';
		document.body.appendChild( gIfr );
	}
	var gDiv				= document.createElement( 'div' );
	gDiv.id					= 'globalDiv';
	gDiv.style.display		= 'none';
	gDiv.style.position		= 'absolute';
	gDiv.style.clear		= 'both';
	gDiv.style.zIndex		= '91';
	gDiv.style.left			= '0px';
	gDiv.style.top			= '0px';
	gDiv.style.width		= '0px';
	gDiv.style.height		= '0px';
	gDiv.style.border		= '0px #ffffff solid';
	gDiv.style.background	= 'darkgray';
	gDiv.onselectstart		= function() { return false;};
	if ( browser.msie ) {
		gDiv.style.filter	= 'alpha(opacity=30)';
	}
	else {
		gDiv.style.opacity	= 30/100;
	}
	
	
	document.body.appendChild( gDiv );
}

//打开滤镜层
function openGlobalLayer() {
    buildGlobalLayer();
	window.bdscrollHeight = document.body.scrollHeight || document.documentElement.scrollHeight;
	var bw = ( document.body.scrollWidth || document.documentElement.scrollWidth ) + 'px';
	var bh = ( document.body.clientHeight || document.documentElement.clientHeight ) + 'px';
	if ( $_( 'globalIfr' ) ) {
		$_( 'globalIfr' ).style.width	= bw;
		$_( 'globalIfr' ).style.height	= bh;
		$_( 'globalIfr' ).style.display = 'block';
	}
	$_( 'globalDiv' ).style.width		= bw;
	$_( 'globalDiv' ).style.height		= bh;
	$_( 'globalDiv' ).style.display		= 'block';
}

//关闭滤镜层
function closeGlobalLayer() {
	if ( $_("globalIfr") ) {
		$_( 'globalIfr' ).style.width	= '0px';
		$_( 'globalIfr' ).style.height	= '0px';
		$_("globalIfr").style.display	= 'none';
	}
	$_( 'globalDiv' ).style.width		= '0px';
	$_( 'globalDiv' ).style.height		= '0px';
	$_( 'globalDiv' ).style.display		= 'none';
}
//*********************滤镜效果 end*********************