var DYNIFS = {
	iframes: {},
	oldresize: null,
	ready: false,
	dim: [-1,-1],
	timerID: 0,
	getDim: function(d) {
		var w=200, h=200, scr_h, off_h;
		if( d.height ) { return [d.width,d.height]; }
		with( d.body ) {
			if( scrollHeight ) { h=scr_h=scrollHeight; w=scrollWidth; }
			if( offsetHeight ) { h=off_h=offsetHeight; w=offsetWidth; }
			if( scr_h && off_h ) h=Math.max(scr_h, off_h);
		}
		return [w,h];
	},
	onresize: function() {
		if( typeof this.oldresize == 'function' ) { this.oldresize(); }
		var dim = this.getDim(document);
		if( this.dim[0] == dim[0] && this.dim[1] == dim[1] ) return;
		if( this.timerID ) return;
		this.timerID = setTimeout('DYNIFS.deferred_resize();', 10);
	},
	deferred_resize: function() {
		for( var id in this.iframes ) this.resize(id);
		this.dim = this.getDim(document);
		this.timerID = 0;
	},
	resize: function(id) {
		if( !window.frames || !window.frames[id] || !document.getElementById || !document.body )
			return;
		var iframe = window.frames[id];
		var div = document.getElementById(id);
		if( !div ) return;
		if( !this.iframes[id] ) {
			this.iframes[id] = true;
		}
		if( !this.ready ) {
			this.ready = true;
			this.oldresize = window.onresize;
			window.onresize = new Function('DYNIFS.onresize();');
		}
		if( document.all ) div.style.height = '0px';
		var dim = this.getDim(iframe.document);
		div.style.height = (dim[1]+30) + 'px';
	}
};
