//获取ID值
function $(a){return document.getElementById(a);}

//关闭层
function hidden_div(obj){$(obj).style.display='none';}

//自定义层
function showdiv(obj,content,width,height,mode)
{
	//检测ID是否存在
	if($("Bcms-"+obj))
	{
		//存在直接调用
		var oDiv=$("Bcms-"+obj);
	}
	else 
	{
		//不存在生成一个并设置默认属性
		var oDiv=document.createElement("DIV");
			oDiv.id="Bcms-"+obj;
			oDiv.className="js-"+obj;
		document.body.appendChild(oDiv);
	}

		//填充内容
		oDiv.innerHTML=content;

		//定义默认样式
		oDiv.style.width=width+"px";
		oDiv.style.display="block";
		
		//该模式完全自定义方式
		if(mode==1){
			//设置高度
			oDiv.style.height=height+"px";
		}else{

			//获取高度
			if (height==0){height=$("Bcms-"+obj).offsetHeight;}

			//获取可视宽高
			var bt = document.documentElement.clientHeight-height;
			var bl = document.documentElement.clientWidth-width;

			//初始化
			var top,left;

			//非IE6及以下
			if (window.XMLHttpRequest){

				//计算位置
				top=(bt/2)-10;
				left=(bl/2);

				//使用决对定位
				oDiv.style.position='fixed';
			}else{
			
				//获取浏览器上卷和左卷
				var st = window.pageYOffset || document.documentElement.scrollTop;
				var sl = window.pageXOffset || document.documentElement.scrollLeft;

					//计算位置
					top=(bt/2)+st-10;
					left=(bl/2)+sl;

					//使用相对定位
					oDiv.style.position='absolute';
			}
			//设置位置
			oDiv.style.top=top+"px";
			oDiv.style.left=left+"px";
		}
}
// 随机数
function randnum(Min,Max) {
	var Range = Max - Min; 
	var Rand = Math.random(); 
	return(Min + Math.round(Rand * Range)); 
} 

var k="";
function konami(e){
	var e = e || event;
	k+=e.keyCode + ",";
	if(k.indexOf("66,65")>=0) {
		//显示彩蛋
		var randswf=randnum(1,16)
		showdiv("konami","<object codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"500\" height=\"350\"><param name=\"movie\" value=\"plugins/konami/"+randswf+".swf\"><param name=\"menu\" value=\"false\"><param name=\"quality\" value=\"high\"><param name=\"play\" value=\false\"><param name=\"wmode\" value=\"transparent\"><embed src=\"plugins/konami/"+randswf+".swf\" wmode=\"transparent\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"500\" height=\"350\"></embed></object>",500,350)
		//退出
		setTimeout("hidden_div('Bcms-konami');",5000);
		k="";
	}
}
document.onkeydown=konami;