var $ =  document.getElementById;
var _POPWinObj = null;
function ShowPopWin(sObj)
{
	_POPWinObj = sObj;
	document.documentElement.scroll = true;
	_POPWinObj.style.display="inline";
	_POPWinObj.style.top = (document.body.clientHeight - _POPWinObj.offsetHeight)/2+"px";
	_POPWinObj.style.left = (document.body.clientWidth - _POPWinObj.offsetWidth)/2+"px";
	_POPWinObj.onmousedown=Function("Drag(this)"); //ÍÏ¶¯²ã
	//±³¾°²ã
	var sTopDIV=document.createElement("div");
	sTopDIV.id="__sTopDIV";
	sTopDIV.style.cssText="position:absolute;z-index:1;background:#000;filter:alpha(opacity=30);opacity:0.3;top:0;left:0;";
	sTopDIV.style.width=document.body.scrollWidth+"px";
	var AH=document.body.scrollHeight;
	var BH=document.body.clientHeight;
	if(AH<BH){sTopDIV.style.height=BH+"px";}else{sTopDIV.style.height=AH+"px";}
	document.body.appendChild(sTopDIV);

	onresize=function(){
		if(document.body.scrollHeight==document.body.clientHeight){
			if(document.body.scrollHeight>document.body.clientHeight){
				$("__sTopDIV").style.height=document.body.clientHeight+"px";
			}else{
				$("__sTopDIV").style.height=document.body.scrollHeight+"px";
			}
		}else{
			$("__sTopDIV").style.height=document.body.scrollHeight+"px";
		}
		$("__sTopDIV").style.width=document.body.clientWidth+"px";
		_POPWinObj.style.left= document.body.scrollLeft+(document.body.clientWidth-_POPWinObj.offsetWidth)/2+"px";
		_POPWinObj.style.top= document.body.scrollTop+(document.body.clientHeight-_POPWinObj.offsetHeight)/2+"px";
	}
	onscroll=function(){_POPWinObj.style.top= document.body.scrollTop+(document.body.clientHeight-_POPWinObj.offsetHeight)/2+"px";}
}

function HiddenPopWin()
{
	if(_POPWinObj){_POPWinObj.style.display="none";}
	if($("__sTopDIV")){document.body.removeChild($("__sTopDIV"));}
}

function Drag(str)
{
	var e=window.event || arguments.callee.caller.arguments[0];
	var deltaX=e.clientX-str.offsetLeft;
	var deltaY=e.clientY-str.offsetTop;
	var deltaH=document.body.scrollHeight;
	var deltaW=document.body.scrollWidth;
	var drag=true;
	str.onmousemove=function(ev)
	{
		ev=ev?ev:window.event;
		if(drag)
		{
		   var Y=ev.clientY-deltaY;
		   var X=ev.clientX-deltaX;
		   var H=deltaH-str.offsetHeight;
		   var W=deltaW-str.offsetWidth;
		    if(Y>0 || X>0){
		     if(Y>=H){str.style.top=H+"px";}else{str.style.top=Y+"px";}
		     if(X>=W){str.style.left=W+"px";}else{str.style.left=X+"px";}
		    }
		    if(Y<=0){str.style.top=0;}
		    if(X<=0){str.style.left=0;}
		   str.setCapture();
		}
	}
	str.onmouseup=function()
	{
		drag=false;str.releaseCapture();
	}
}