function $(id){return document.getElementById(id);}
//var isIE = (document.all) ? true : false;
function Box(objID,W,H,inner,alerturl){
	var objHead,objBody,objFooter,inner,footerInner,alerturl;
	
	if(!$(objID)){
	//创建html结构并赋id以及class		
		var obj = document.createElement("div");		
		var objHead = document.createElement("div");
		var objBody = document.createElement("div");
		var objFooter = document.createElement("div");
		obj.id=objID;
		obj.className="lightBox";		
		objHead.id=objID+"_head";
		objBody.id=objID+"_body";
		objFooter.id=objID+"_footer";
		objHead.className="Boxheader";
		objBody.className="Boxbody";
		objFooter.className="Boxfooter";		
		obj.appendChild(objHead);
		obj.appendChild(objBody);
		obj.appendChild(objFooter);
		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="参数错误"}
		if(footerInner==undefined || footerInner=="" ){footerInner="www.ouccs.com &copy; 2012"}//页脚没有内容时默认值
		var BodyLid = objID+"BodyL",BodyRid = objID+"BodyR",headerLid = objID+"headerL",FooterLid= objID+"FooterL",closeBtn= objID+"closeBtn",cancelBtn =objID+"cancel";
			
			objBody.innerHTML='<div class="BodyL" id='+BodyLid+' style="line-height:60PX;height:'+H+'px;">'+inner+'</div><span class="BodyR" id='+closeBtn+'>确定</span>';	
		
		objHead.innerHTML='';
		//js样式设置
		$(BodyLid).style.height=H+"px";
		$(BodyLid).style.width=W+"px";	
		obj.style.cssText+=";position:fixed!important;position:absolute;left:50%;top:50%;z-index:901;_top:expression(eval(document.compatMode && document.compatMode=='CSS1Compat') ? documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 : document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2);";		
		obj.style.marginLeft=-obj.scrollWidth/2+"px";
		obj.style.marginTop=-obj.scrollHeight/2+"px";	
		
		document.body.style.cssText+="height: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)}
		}
		
		if(alerturl!=""){
			$(closeBtn).onclick = function(){location.href=alerturl};//function(){JumpURL(alerturl)};//跳转链接	
		}else{
		    $(closeBtn).onclick = function(){Close(objID)};//关闭按钮
			}
		if($(cancelBtn)){$(cancelBtn).onclick = function(){Close(objID)}}//取消按钮
		
		//拖动功能			
	//if(evt.keycode==27){alert("esc")};
	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;
		objHead.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("请先确认"));
	
}//box();End
