
var cover=new Object();

cover=function(element, backColor, opacity){
	this.element=element;
	this.backColor=(backColor) ? backColor : "#000000";
	this.opacity=(opacity) ? opacity : "50";
	this.bodyTag=TAG(document, "body")[0];
	this.bodyTag.id="cover";
	this.backgroundIframe=document.createElement("iframe");
	this.backgroundIframe.style.position="absolute";
	this.backgroundIframe.style.zIndex="19";
	this.backgroundIframe.style.top="0px";
	this.backgroundIframe.style.left="0px";
	this.backgroundIframe.style.display="none";
	this.outLineTable=document.createElement("table");
	this.outLineTable.style.position="absolute";
	this.outLineTable.style.zIndex="20";
	this.outLineTable.style.top="0px";
	this.outLineTable.style.left="0px";
	this.outLineTable.style.display="none";
	this.outLineTbody=document.createElement("tbody");
	this.outLineTr=document.createElement("tr");
	this.outLineTd=document.createElement("td");
	this.contentTable=document.createElement("table");
	this.contentTable.style.position="absolute";
	this.contentTable.style.zIndex="20";
	this.contentTable.style.display="none";
	this.contentTbody=document.createElement("tbody");
	this.contentTr=document.createElement("tr");
	this.contentTd=document.createElement("td");
	this.outLineTd.coverClose=this.contentTd.coverClose=true;

	this.coveClickrOff=bindAsListener(this.clickOff, this);
	addListener(this.outLineTable, "click", this.coveClickrOff);
	addListener(this.contentTable, "click", this.coveClickrOff);

	if(navigator.userAgent.lastIndexOf("MSIE")!=-1){
		this.outLineTable.style.backgroundColor=this.backColor;
		this.outLineTable.style.filter="alpha(opacity="+this.opacity+")";
		this.backgroundIframe.style.filter="alpha(opacity=0)";
	}else{
		this.outLineTable.style.backgroundColor=this.backColor;
		this.outLineTable.style.opacity=this.opacity/100;
		this.backgroundIframe.style.opacity=0;
	}
	
	this.element.style.display="block";

	this.contentTd.appendChild(this.element);
	this.contentTr.appendChild(this.contentTd);
	this.contentTbody.appendChild(this.contentTr);
	this.contentTable.appendChild(this.contentTbody);
	this.outLineTr.appendChild(this.outLineTd);
	this.outLineTbody.appendChild(this.outLineTr);
	this.outLineTable.appendChild(this.outLineTbody);

	this.bodyTag.appendChild(this.backgroundIframe);
	this.bodyTag.appendChild(this.outLineTable);
	this.bodyTag.appendChild(this.contentTable);
}

cover.prototype={
	on:function(){
		this.backgroundIframe.width=this.outLineTable.style.width=this.outLineTd.style.width=document.documentElement.scrollWidth+"px";
		this.backgroundIframe.height=this.outLineTable.style.height=this.outLineTd.style.height=document.documentElement.scrollHeight+"px";
		this.contentTable.style.width=this.contentTd.style.width=document.documentElement.clientWidth+"px";
		this.contentTable.style.height=this.contentTd.style.height=document.documentElement.clientHeight+"px";
		this.contentTable.style.top=document.documentElement.scrollTop+"px";
		this.contentTable.style.left=document.documentElement.scrollLeft+"px";
		this.backgroundIframe.style.display="block";
		this.outLineTable.style.display="block";
		this.contentTable.style.display="block";
	},

	clickOff:function(e){
		var event=window.event || e;
		var target=getTarget(event);

		if(target.coverClose){
			this.backgroundIframe.style.display="none";
			this.outLineTable.style.display="none";
			this.contentTable.style.display="none";
		}
	},

	off:function(){
		this.backgroundIframe.style.display="none";
		this.outLineTable.style.display="none";
		this.contentTable.style.display="none";
	}
}