﻿//popup({title:"title",content:str,callbackkey:true,callbackfun:fun,callbackfunpar:[1,2],popWidth:width,popHeight:height})
function popup(){
try{
    var arg=popup.arguments[0];
    var str=arg.content;
    var title=arg.title;
    var callbackkey=arg.callbackkey;
    var callbackfun=arg.callbackfun;
    var callbackfunpar=arg.callbackfunpar;
    var popWidth=arg.popWidth;
    var popHeight=arg.popHeight;    
    var headerDivHeight=5;
    var bodyDivHeight=popHeight-28;
    var maskDivWidth=document.body.offsetWidth;
    var maskDivHeight=document.body.scrollHeight==0?screen.height:document.body.scrollHeight+document.body.offsetHeight;    
    var maskDiv=document.createElement("div");
    maskDiv.setAttribute('id','maskDiv');
    maskDiv.style.position="absolute";
    if(navigator.appName=="Microsoft Internet Explorer")
    {
        maskDiv.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,src=/style/images/ico/pass.png, sizingMethod=scale)";
    }else{
        maskDiv.style.backgroundImage="url(/style/images/ico/pass.png)";
    }
    maskDiv.style.top="0";
    maskDiv.style.opacity="60%";
    maskDiv.style.left="0";
    maskDiv.style.width="100%";
    maskDiv.style.height=maskDivHeight + "px";
    maskDiv.style.zIndex = "10000";
    document.body.appendChild(maskDiv);
    var containerDiv=document.createElement("div");
    containerDiv.setAttribute("id","containerDiv");
    containerDiv.setAttribute("align","center");
    containerDiv.style.background="white";
    containerDiv.style.position = "absolute";
    containerDiv.style.border="1px solid #6699cc";
    containerDiv.style.left = parseInt((document.body.offsetWidth-popWidth)/2)+"px";
    containerDiv.style.top = parseInt((document.body.offsetHeight-popHeight)/2)-100+"px";
    containerDiv.style.font="12px Verdana, Geneva, Arial";
    containerDiv.style.width = popWidth + "px";
    containerDiv.style.height =popHeight + "px";
    containerDiv.style.zIndex = "10000";
    document.body.appendChild(containerDiv);
    var headerDiv=document.createElement("div");
    headerDiv.setAttribute("id","headerDiv");
    if(navigator.appName=="Microsoft Internet Explorer")
    {
        headerDiv.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
        headerDiv.style.opacity="65%";
    }
    var beginMoving=false;
    headerDiv.onmousedown=function(e){
        beginMoving=true;
        var e=e||window.event;
        var Parent=headerDiv.offsetParent;
        var X=e.clientX||e.pageX;
        var Y=e.clientY||e.pageY;
        headerDiv.mouseDownX=Parent.offsetLeft-X;
        headerDiv.mouseDownY=Parent.offsetTop-Y;
        if(headerDiv.mouseDownY==Parent.offsetTop)
            
        if(headerDiv.setCapture){headerDiv.setCapture();}
        else{e.preventDefault();}
    };
    document.onmousemove=function(e){
        if(!beginMoving)return;
        var e=e||window.event;
        var Parent=headerDiv.offsetParent;
        var X=e.clientX||e.pageX;
        var Y=e.clientY||e.pageY;
        if(X>1){Parent.style.left=headerDiv.mouseDownX+X+"px";}
        if(Y>1){Parent.style.top=headerDiv.mouseDownY+Y+"px";}
    };
    document.onmouseup=function(){
        if(!beginMoving)return;
        if(headerDiv.releaseCapture){headerDiv.releaseCapture();}
        beginMoving=false;
    };
    containerDiv.appendChild(headerDiv);
    var closeBtn=document.createElement("img");
    closeBtn.setAttribute("id","closeBtn");
    closeBtn.setAttribute("src","/style/images/ico/dialogclose.gif");
    closeBtn.setAttribute("title","关闭");
    closeBtn.onclick=function(){
        headerDiv.removeChild(closeBtn);
        containerDiv.removeChild(headerDiv);
        containerDiv.removeChild(bodyDiv);
        document.body.removeChild(containerDiv);
        document.body.removeChild(maskDiv);
        if(callbackkey){
            var par="";
            for(var i=0;i<callbackfunpar.length;i++)
            {
                par+=callbackfunpar[i]+",";
            }
            callbackfun(par.substring(0,par.length-1));
        }
    };
    headerDiv.appendChild(closeBtn);
    var titleDiv=document.createElement("div");
    titleDiv.setAttribute("id","titleDiv");
    titleDiv.innerHTML="<img src='/style/images/ico/popup_title.png' class='clear'/>"+title;
    headerDiv.appendChild(titleDiv);
    var bodyDiv=document.createElement("div");
    bodyDiv.setAttribute("id","bodyDiv");
    bodyDiv.style.height=bodyDivHeight+"px";
    bodyDiv.innerHTML=str;
    containerDiv.appendChild(bodyDiv);
}catch(e){alert(e);}
}
function closeWin()
{
	document.body.removeChild($("containerDiv"));
	document.body.removeChild($("maskDiv"));
}