/**
 ** 显示一个最顶层 网页全部阴影透明的对话框
 ** bzmsg.showiframe('url',600,300); //显示iframe 宽600 高300 ; 也通过对象属性设置
 ** bzmsg.showhtml('<div ....>.....</div>');  //显示HTML代码 
**/
var bzmsg={
  $:function(v){return document.getElementById(v)},
  timer:'',
  cssbg : "position:absolute;filter:alpha(opacity=50);opacity: 0.5;-moz-opacity:0.5;top:0px; left:0px;z-index:9998; background:#000;width:100%;height:100%", //最底部的样式
  cssmsgbox : "position:absolute;top:0px;left:0px;z-index:9999;width:100%;overflow:hidden",//最顶层对话框的样式
  cssiframe : "background:#fff; border:1px #000 solid",
  url:"about:blank",
  bgclassName:'msgbg',
  msgclassName:'bz_msg',
  iframeclassName : 'bz_iframe',
  bgid : 'bz_msgbg',
  scrolling:'no',
  msgid : 'bz_msg',
  iframeid:'bz_msgiframe',
  width:600,
  height:300,
  esc : true,
  mt : 100, //于顶部间距
  settop:true,  //默认显示对话框后便网页显示最顶部
  IsNull:function(v){if (v==undefined||v==''||v==null){return true;}else{return false;}},
  showiframe:function(url,w,h,mt){
	 this.url = url;
	 if (!this.IsNull(mt)) this.mt=mt;
	 if (!this.IsNull(w)) this.width=w;
	 if (!this.IsNull(h)) this.height=h;
	 this.display('url');
  },
  showhtml:function(content){
	 this.content = content;
	 this.display('content');
  },
  top:function(){
	 if (this.settop==true){window.location.hash='#';window.location.hash='#top';}
  },

  display : function(t){
	    if (!this.IsNull(this.$(this.bgid))){
		  this.resize();
		  this.$(bzmsg.bgid).style.display='';this.$(bzmsg.msgid).style.display='';
		  this.writehtml(t);
		  return;
		}
	    var ele = document.createElement('div'); 
  		ele.className = bzmsg.bgclassName;
  		ele.id = bzmsg.bgid;
  		ele.style.cssText = bzmsg.cssbg;
  		document.body.appendChild(ele);
  		var ele2 = document.createElement('div');
  		ele2.id=bzmsg.msgid;
		ele2.className = bzmsg.msgclassName;
  		ele2.style.cssText = bzmsg.cssmsgbox;
  		document.body.appendChild(ele2);
		this.writehtml(t);
  		this.resize();
  		//this.$(bzmsg.msgid).style.width = w ;
  		//this.$(bzmsg.msgid).style.height = h;
  },
  resize : function(){
	    var w = document.body.scrollWidth;
  		var h = document.body.scrollHeight;
  		if (h<window.screen.availHeight) h = window.screen.availHeight;
		this.$(bzmsg.bgid).style.width = w;
  		this.$(bzmsg.bgid).style.height = h; 
  },
  writehtml : function(t){
	      this.getxy();
		  document.body.onkeydown = function(){
			  if (event.keyCode == 27)bzmsg.closewin();
		  }
		  if (t=='content'){
		      this.$(bzmsg.msgid).innerHTML = "<div>"+this.content+"</div>";
		  }else if (t=='url'){
		      this.$(bzmsg.msgid).innerHTML = "<div><center><iframe frameborder=\"0\" width="+this.width+" height="+this.height+" scrolling=\""+this.scrolling+"\" id="+this.iframeid+" src="+this.url+" style='"+this.cssiframe+"'></iframe></center></div>";
		  }
		  this.timer=setInterval(function(){bzmsg.position()},10);
  },
  position : function (){
	   this.getxy();
	   this.$(bzmsg.msgid).style.top = (parseInt(this.y) + this.mt) + 'px';
  },
  closewin : function(){
	 this.$(bzmsg.bgid).style.display='none';
     this.$(bzmsg.msgid).style.display='none';
	 if (!this.IsNull(this.url)&&this.url!='about:blank') this.$(this.iframeid).src="about:blank";
  },//关闭窗口
  getxy : function(){
    var dde = document.documentElement;
    if (window.innerWidth){
        
        var bgX = window.pageXOffset;
        var bgY = window.pageYOffset;
		//var bgX = window.innerWidth;
        //var bgY = window.innerHeight;
    }else{
        var ww = dde.offsetWidth;
        var wh = dde.offsetHeight;
        var bgX = dde.scrollLeft;
        var bgY = dde.scrollTop;
    }
	 
    this.x = bgX;
    this.y = bgY;
  }
}//end class
