/**
* @author: huwd |  QQ:31916326 | email:java_doc@163.com
* @descript : 通用对话框的编写
* @Version  : 1.0
**/
document.write("<style>#shadowDiv{display:none;width:100%;height:100%;position:absolute;top:0px;left:0px;background-color:#000;filter: alpha(opacity=60);opacity:0.6;z-index:65534}#popDiv{display:none;position:absolute;width:450px;height:300px;z-index:65535;background-color:#fff;}</style>");

var Zd={
 body:function(){//取得各宽大高.
    var F=0,D=0,A=0,J=0,I=0,E=0;
	var B=window,S=document,C=S.documentElement;
	F=C.clientWidth||S.body.clientWidth;
	D=B.innerHeight||C.clientHeight||S.body.clientHeight;
	J=S.body.scrollTop||C.scrollTop;
	A=S.body.scrollLeft||C.scrollLeft;
	I=Math.max(S.body.scrollWidth,C.scrollWidth||0);
	E=Math.max(S.body.scrollHeight,C.scrollHeight||0,D);
	return {scrollTop:J,scrollLeft:A,documentWidth:I,documentHeight:E,viewWidth:F,viewHeight:D};
 }
};
var Pdialog={
  onOk:function(){},
  onclosed:function(){},
  create:function(){
    if(!$("popDiv")){//初始化
      var F = document.createElement("div");
      F.id="shadowDiv";
      var E = document.createElement("div");
      E.id="popDiv";
      var D = document.createElement("iframe");
      D.id="shadowIframe";
      D.style.filter="alpha(opacity=0)";
      D.style.opacity="0";
      D.style.position="absolute";
      E.style.width=E.style.height="500px";
      E.style.border="4px solid #e4e4e4";
      E.innerHTML='<div style="text-align:right;"><input type="button" id="dialogBoxClose" onclick="Pdialog.hide();return false" title="关闭" style="display:block;width:16px;height:16px;float:right;background:url(../pic/popclose.gif) no-repeat 0 0;border:0;margin:0;padding:0;" onmouseover="this.style.backgroundPosition=\'-16px 0\'" onmouseout="this.style.backgroundPosition=\'0 0\'" /><div style="clear:both"></div></div><div id="popBody" style="display:none;text-align:center;padding:20px;font-size:14px;"></div><div id="ifrDiv" style="height:95% !important; height:auto;"><iframe id="popIframe"  name="popIframe" width="100%" frameborder="0" height="95%" style="float:left;" scrolling="no" src="about:blank"></iframe></div>';
      document.body.insertBefore(D,document.body.firstChild);
      document.body.insertBefore(E,document.body.firstChild);
      document.body.insertBefore(F,document.body.firstChild);
    }
  },
  resize:function(R,S,X){
    //调整大小
    Pdialog.create();
    var Q=Zd.body();
    var T=Q.scrollTop;
    var W=Q.documentWidth||500;
    var P=Q.documentHeight||500;
    var U=$("shadowDiv");
    var Z=$("popDiv");
    var a=$("shadowIframe");
    var V=S||parseInt(Z.style.width,10)||500;
    var c=X||parseInt(Z.style.height,10)||500;
    U.style.width=W+"px";
    U.style.height=P+"px";
    a.style.width=(W-20)+"px";
    a.style.height=(P-20)+"px";
    U.style.left=U.style.top="0px";
    a.style.left=a.style.top="5px";
    var Y = (Q.viewWidth-V)/2;
    var b = (Q.viewHeight-c)/2 + T;
    if(Y<1){
      Y = T;
    }
    if( b < 1) b="20";
    Z.style.left=Y+"px";
    Z.style.top=b+"px";
    Z.style.width=V+"px";
    Z.style.height=c+"px";
  },
  config:function(I,H){
    //配置器.
    if(I){};
    $("popBody").innerHTML = "";
    Pdialog.onclosed=Pdialog.onclosed||function(){};
    if(H.url){
       if(H.url != true){
         try{
          $("popIframe").src = H.url;
         }catch(K){
           try{
           document.frames.popIframe.location=H.url;
           }catch(L){
           }
         }
       }
       //用户使用外部iframe来创建内容部分
       $("ifrDiv").style.display="block";
       $("popBody").style.display="none";
    }else{
      //用户只使用普通的Div来创建内容部分
      if(H.info){
        $("ifrDiv").style.display="none";
        $("popBody").style.display="block";
        $("popBody").innerHTML = H.info;
      }
    }
    var M = H.width||500;
    var J=  H.height||400;
    var L = $("popDiv");
    L.style.width=M+"px";
    L.style.height=J+"px";
  },
  show:function(D,C){
    //显示
    Pdialog.create();
    Pdialog.config(D,C);
    Pdialog.resize();
    $("popDiv").style.display="block";
    $("shadowDiv").style.display="block";
    $("shadowIframe").style.display="";
    //当窗口最大后或是最小化后.重设大小
    EV.observe(window,"resize",Pdialog.resize);
  },
  hide:function(){
    Pdialog.onclosed();
    try{
     $("popDiv").style.display="none";
     $("shadowDiv").style.display="none";
     $("shadowIframe").style.display="none";
     $("shadowIframe").style.width="0px";
     $("shadowIframe").style.height="0px";
    }catch(K){}
    try{
     $("popIframe").src="about:blank";
    }catch(G){
     try{document.frames.popIframe.location="about:blank";}catch(C){}
    }
    EV.stopObserving(window,"resize",Pdialog.resize);
  }
};