﻿function ShowMessage(text){
        // 判断是否为Opear浏览器
         var isOpear=(navigator.userAgent.indexOf('Opera')>-1);
         var winhide=document.createElement("iframe")
         winhide.id="hideiframe"   
         winhide.style.background="#000"
         winhide.style.position="absolute"
         winhide.style.filter='alpha(opacity=30)'
         //winhide.style.border="#06C solid 1px"
         winhide.style.border="#06C solid 0px"
         winhide.zIndex=10000
         winhide.style.left=0
         winhide.style.top=0;
         winhide.style.width="99.8%";
         winhide.style.height="99.8%";
         winhide.style.height=document.body.clientHeight+20+"px"
         winhide.style.left=0
         winhide.style.top=0;
         winhide.style.width=document.body.clientWidth-2
         winhide.style.height=document.body.clientHeight+document.body.scrollTop 
         document.body.appendChild(winhide)
         
         // 创建透明阴影遮照效果层
        var shadow = document.createElement("div");
        // 给新创建的节点设置各个属性
        shadow.setAttribute("id","sewa_hidden"); 
        shadow.style.position="absolute";　  　　
        shadow.style.left="0";
        shadow.style.top="0";
        shadow.style.width="99.8%";
        shadow.style.height=document.body.clientHeight+30+"px"
        shadow.style.zIndex=10001;
        // 如果是Opera浏览器则给shadow设置背景色和透明效果
        if(!isOpear){
            shadow.style.backgroundColor="#000";
        
            if(document.all){
              shadow.style.filter = "alpha(opacity=10)";
           }
           else{
              shadow.style.opacity = 0.1;
           }
       }
       
       
        //显示层
        var obj=document.createElement("div");
        obj.setAttribute("id","sewa_showmessagebox");
        obj.style.zIndex=10002; 

//        //获取隐藏滚动条的高度
//        var w3c=(document.getElementById)? true: false;//是否3W标准
//        var agt=navigator.userAgent.toLowerCase();
//        var ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1) && (agt.indexOf("omniweb") == -1));//是否IE
//        var currerbody=(document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
//        var scrolltop=ie ? currerbody.scrollTop : window.pageYOffset;//隐藏滚动条的高度 
//        obj.style.top=document.body.clientHeight/2-150+scrolltop +"px"//顶部

        //标题
        var divTitle = document.createElement("div");
        divTitle.setAttribute("id","sewa_showmessagebox_head");
        //关闭按钮
        var head_A = document.createElement("a");
        head_A.setAttribute("href","#1");
        head_A.setAttribute("id","sewa_showmessagebox_btnClose");
        head_A.setAttribute("title","关闭");
        //关闭按钮图片
        var close_img=document.createElement("img");
        close_img.setAttribute("src","../App_Themes/admin/images/msg_head_x1.gif");
        //标题文本
        var H4 = document.createElement("h4"); 
        var txtTitle=document.createTextNode("系统提示");
        H4.appendChild(txtTitle);
        head_A.appendChild(close_img);
        divTitle.appendChild(head_A);
        divTitle.appendChild(H4);
        
         //中间部分
        var div_center = document.createElement("div");
        div_center.setAttribute("id","sewa_showmessagebox_center");
        
        //填写文本
        var div_text = document.createElement("div");
        div_text.setAttribute("id","sewa_showmessagebox_text");
        div_text.innerHTML=text;
        div_center.appendChild(div_text); 
        
        //底部
        var divFoot = document.createElement("div");
        divFoot.setAttribute("id","sewa_showmessagebox_foot");
        //确定按钮
        var foot_A = document.createElement("a");
        foot_A.setAttribute("href","#1");
        foot_A.setAttribute("id","sewa_showmessagebox_btnOK");
        foot_A.setAttribute("title","确定");
        //确定按钮图片
        var ok_img=document.createElement("img");
        ok_img.setAttribute("src","../App_Themes/admin/images/button_ok.jpg");
     
        foot_A.appendChild(ok_img);
        divFoot.appendChild(foot_A); 
    
        
        
        obj.appendChild(divTitle); 
        obj.appendChild(div_center); 
        obj.appendChild(divFoot); 
        document.body.appendChild(shadow);  
        document.body.appendChild(obj);
       // document.body.style.overflow="hidden";
        hiddenDiv();   
        foot_A.focus();
}
function hiddenDiv(){
     //var hideiframe = document.getElementById("hideiframe");
     var objId = document.getElementById("sewa_showmessagebox");
     var shadow = document.getElementById("sewa_hidden");
     var aClose = document.getElementById("sewa_showmessagebox_btnClose");
     var btnEnter = document.getElementById("sewa_showmessagebox_btnOK");
     var div_hidden = document.getElementById("sewa_hidden");
      var hideiframe = document.getElementById("hideiframe");
     /***
      如果节点阴影、提示框、关闭按钮或确定按钮，
      有一个节点不存在，则退出此程序（避免报错）
    ***/ 
    if(!shadow || !objId || !aClose || !btnEnter ) { 
         return false; 
    }
    else{
             // 设置关闭和确定按钮的功能--关闭(移除)提示框       
              btnEnter.onclick=aClose.onclick=function(){
              document.body.removeChild(objId); 
              document.body.removeChild(shadow);   
              document.body.removeChild(hideiframe);  
              try
              {
                if(typeof(eval("ShowMessageBack")=="function")) 
                   ShowMessageBack();
              }
              catch(e) {}
              //document.body.removeChild(hideiframe);                           
         }
     } 
} 
