﻿//动态创建遮照层类
function CreateDiv(){
    var bgObj;
        this.Index=1;
        //遮照层
        this.sWidth=document.documentElement.offsetWidth;
        //this.sHeight=screen.Height+document.documentElement.scrollTop;
        this.sHeight=document.documentElement.clientHeight;
        this.color="#777";
        
        //图层
        this.id="div1";
        this.w=300;
        this.h=-1;
        this.left=200;
        this.top=100;
        this.bottom=-1;
        this.border="1px solid #09387E";
        this.position="absolute";
        //this.background="#5E97DE";
        this.background="#DFE9F5";      
}
        
    
CreateDiv.prototype.AlphaBgDiv=function(){//创建透明遮照层
        if(!document.getElementById("bgDIV")){
            bgObj=document.createElement("div");
            bgObj.setAttribute('id','bgDiv');
            bgObj.style.position="absolute";
            bgObj.style.top=0;
            bgObj.style.background=this.color;
            bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75)";
            bgObj.style.opacity="0.6";
            bgObj.style.left=0;
            bgObj.style.width=this.sWidth + "px";
            bgObj.style.height=this.sHeight + "px";
            bgObj.style.zIndex = parseInt(this.Index);
            document.body.appendChild(bgObj);
        }
}
CreateDiv.prototype.ImgBgDiv=function(){ //创建纯色遮照层
    if(!document.getElementById("bgDIV")){
        bgObj=document.createElement("div");
        bgObj.setAttribute('id','bgDiv');
        bgObj.style.position="absolute";
        bgObj.style.top=0;
        bgObj.style.background=this.color;
        bgObj.style.left=0;
        bgObj.style.width=this.sWidth + "px";
        bgObj.style.height=this.sHeight + "px";
        bgObj.style.zIndex = parseInt(this.Index);
        document.body.appendChild(bgObj);
    }
}
    
CreateDiv.prototype.getDiv=function(){
        bgObj=document.createElement("div");
        bgObj.setAttribute("id",this.id);
        bgObj.setAttribute("align","center");
        bgObj.style.background=this.background;
        bgObj.style.cursor="hand";
        bgObj.style.border=this.border;
        bgObj.style.position = this.position;
        bgObj.style.left = parseInt(this.left);
        if(this.bottom<0){
            bgObj.style.top = parseInt(this.top);
        }else{
            bgObj.style.bottom=parseInt(this.bottom);
        }
        bgObj.style.width = parseInt(this.w) + "px";
        if(this.h>0){
            bgObj.style.height=parseInt(this.h)+"px";
        }
        bgObj.style.textAlign = "center";
        bgObj.style.lineHeight ="25px";
        bgObj.style.zIndex = parseInt(this.Index)+1;
        bgObj.style.display="none";		
        document.body.appendChild(bgObj);
}
