function layer(src,width,height) {
	this.src=src;
	this.width=width;
	this.height=height;

	this.create=function () {
		var iframe=document.createElement("iframe");
		iframe.style.visibility='hidden';
		if (this.src) iframe.src=this.src;
		iframe.frameBorder='no';
		iframe.marginHeight=0;
		iframe.marginWidth=0;
		iframe.scrolling='no';
		iframe.style.position="absolute";
		iframe.style.zIndex=9999;
		iframe.style.width=this.width+'px';
		iframe.style.height=this.height+'px';
		iframe.style.border="none";
		iframe.style.overflow="hidden";
		this.iframe=document.body.appendChild(iframe);
	}

	this.show=function(relTo,top,left,sticky) {
		if (!this.iframe) this.create();
		if (relTo) {
			var pos=getElementPosition(relTo);
			if (top==null) top=0;
			if (left==null) left=pos.width;
			top+=pos.y;
			left+=pos.x;
		}
		if (relTo==null && top==null && left==null) {
			left=((getInnerWidth() - this.width)>>1)+getScrollX();
			top=((getInnerHeight() - this.height)>>1)+getScrollY();
			sticky=true;
		}
		var pos=this.fitTopLeft2Page(left, top, parseInt(this.iframe.style.width), parseInt(this.iframe.style.height));
		this.iframe.style.left = pos.top +  "px";
		this.iframe.style.top = pos.left + "px";
		this.iframe.style.visibility='visible';
		var me=this;
		if (sticky) {
			this.lastSX=getScrollX();
			this.lastSY=getScrollY();
			setTimeout(function () {me.stickyMove()}, 30);
		}
	}

	this.stickyMove=function() {
		var me=this;
		if (this.iframe.style.visibility=='visible') {
			this.iframe.style.left=parseInt(this.iframe.style.left)+getScrollX()-this.lastSX;
			this.iframe.style.top=parseInt(this.iframe.style.top)+getScrollY()-this.lastSY;
			this.lastSX=getScrollX();
			this.lastSY=getScrollY();
			setTimeout(function () {me.stickyMove()}, 50);
		}
	}

	this.hide=function() {
		if (this.iframe) this.iframe.style.visibility='hidden';
	}

	this.fitTopLeft2Page=function(x, y, w, h) {
		var sx=getScrollX();
		var sy=getScrollY();
		x-=sx;
		y-=sy;
		var pw=getInnerWidth();
		var ph=getInnerHeight();
	
	//	if((y + h) > (ph-21)) y -= (y + h) - (ph-21);
		if((y + h) > ph) y -= (y + h) - ph;
		if(y < 10) y=10;
		if((x + w) > (pw-21)) x -= (x + w) - (pw-21);
		if(x < 10) x=10;

		var ret=new Object();
		ret.top=x+sx;
		ret.left=y+sy;
		return ret;
	}
	
	this.isVisible=function() {
		return this.iframe?this.iframe.style.visibility=='visible':false;
	}
}