// loads the contents of an external file into the layer

function DynLayerLoad(url,fn) {
	this.loadFinish = DynLayerLoadFinish
	if (is.ns) this.css.load(url,this.w)
	else if (is.ie) parent.bufferFrame.document.location = url
	this.evalfn = fn
}

function DynLayerLoadFinish() {
	if (is.ie) this.event.innerHTML = parent.bufferFrame.document.body.innerHTML
	eval(this.evalfn)
}

DynLayer.prototype.load = DynLayerLoad

// changes the background (the layer must be clipped)

function DynLayerSetbg(color) {
	if (is.ns) this.doc.bgColor = color
	else this.css.backgroundColor = color
}

DynLayer.prototype.setbg = DynLayerSetbg

// swaps an image in the layer

function DynLayerImg(imgName,imgObj) {
	this.doc.images[imgName].src = eval(imgObj+'.src')
}

DynLayer.prototype.img = DynLayerImg

// retrieves the real location of a relatively positioned layer

function DynLayerGetRelativeX() {
	return (is.ns)? this.css.pageX : this.elm.offsetLeft
}

function DynLayerGetRelativeY() {
	return (is.ns)? this.css.pageY : this.elm.offsetTop
}

DynLayer.prototype.getRelativeX = DynLayerGetRelativeX
DynLayer.prototype.getRelativeY = DynLayerGetRelativeY

// DynLayer GetContent Width/Height Methods
// retrieves the total width/height of the contents of the layer when they are not known

function DynLayerGetContentWidth(item,i)
{
	if (is.ns4) return (this.doc.width)
	if (is.ns5)
	{
	var fullLengthOfText=(item[i].text).length + 0;
	var lengthOfText=fullLengthOfText;
	var splCharAdj=new String(item.text);
				for(var m=0;m < fullLengthOfText;++m)
				{
					var y=splCharAdj.indexOf('&',m);
					if( y > -1)
					{
						m=y;
						var z=splCharAdj.indexOf(';',m);
						if( z > -1)
						{
							if( (z-y) > 8) alert("Error in umlauts");
							lengthOfText-=(z-y);
							m=z;
						}
					}
				}
				if (splCharAdj.indexOf('<') > -1)
				{lengthOfText-=7;}
			
				// Text length has to be mapped to pixel length
				var pixMap=9;
				var newLength=lengthOfText * pixMap;
				if(newLength > (15*pixMap))
				{
					newLength-=pixMap*(15-pixMap)/4;
				}
				else if(newLength > (20*pixMap))
				{
					newLength-=pixMap*(20-pixMap)/2;
				}
				else if (newLength < 10*pixMap)
				{
				 	newLength+= 2*pixMap;
				}
				w1 =Math.ceil(newLength);
				return(w1);

			
		}
	
	else return (this.elm.scrollWidth)

}

function DynLayerGetContentHeight() {
	return (is.ns)? this.doc.height : this.elm.scrollHeight
}

DynLayer.prototype.getContentWidth = DynLayerGetContentWidth
DynLayer.prototype.getContentHeight = DynLayerGetContentHeight
