function $(id){return document.getElementById(id);}
//var isIE = (document.all) ? true : false;
function Box(objID,W,H,inner,footerInner){
	var objHead,objBody,objFooter,inner,footerInner;
	if(!$(objID)){
	//创建html结构并赋id以及class		
		var obj     = document.createElement("div");
		var objBody = document.createElement("div");
		obj.id=objID;
		obj.className="lightBox";		
		objBody.id=objID+"_body";
		objBody.className="Boxbody";	
		obj.appendChild(objBody);
		document.body.appendChild(obj);
		//如果参数为空时的处理
		if(W==undefined||W<200||W==""){W=200}//最小宽度
		if(H==undefined||H<60||H==""){H=60}
		if(inner==undefined || inner=="" ){inner=""}
		var BodyLid = objID+"BodyL",BodyRid = objID+"BodyR";		
		objBody.innerHTML='<div class="BodyL" id='+BodyLid+'>'+inner+'</div>';
		//js样式设置
		$(BodyLid).style.height=H+"px";
		$(BodyLid).style.width=W+"px";
		obj.style.cssText+=";position:fixed;left:50%;top:50%;z-index:901;";		
		obj.style.marginLeft=-obj.scrollWidth/2+"px";
		obj.style.marginTop=-obj.scrollHeight/2+"px";	
		
		//document.body.style.cssText+="hight:100%;overflow:hidden;";		
		var mask=1;//是否创建遮罩层
		if(mask){
			var objMask = document.createElement("div");
				objMask.id="Mask";objMask.className="BoxMask";
				document.body.appendChild(objMask);objMask.style.cssText+=";position:absolute;z-index:900;";
				objMask.style.height=document.documentElement.scrollHeight+document.documentElement.scrollTop+"px";
			}
		function Close(objID){
			document.body.removeChild($(objID));document.body.style.cssText+="width:100%;overflow:auto;"; if(objMask){document.body.removeChild(objMask)}
		}
		$(BodyLid).onclick = function(){Close(objID)};//关闭按钮
		$("Mask").onclick = function(){Close(objID)};
		
		//拖动功能
		/*
		var w = obj.scrollWidth,h = obj.scrollHeight;
		var iWidth = document.documentElement.clientWidth; 
		var iHeight = document.documentElement.clientHeight; 	
		var moveX = 0,moveY = 0,moveTop = 0,moveLeft = 0,moveable = false;
		objBody.onmousedown = function(e) {	
		moveable = true; 	
		e = window.event?window.event:e;
		moveX = e.clientX-obj.offsetLeft;		
		moveY = e.clientY-obj.offsetTop;
		obj.style.zIndex++;
		document.onmousemove = function(e) {
				if (moveable) {
				e = window.event?window.event:e;		
				var x = e.clientX - moveX;
				var y = e.clientY - moveY;
					if ( x > 0 &&( x + w < iWidth) && y > 0 && (y + h < iHeight) ) {
						obj.style.left = x + "px";
						obj.style.top = y + "px";
						obj.style.margin = "auto";
						}
					}
				}
				document.onmouseup = function () {moveable = false;};
		}
		*/
	}else(alert("has been opened!"));
	
}//box();End

