function getElement(id) {
     return document.getElementById ? document.getElementById(id) :
     document.all ? document.all(id) : null;
}

function getIFRAME_doc_height(oIframe) {
     return document.body && document.body.scrollHeight ? oIframe.document.body.scrollHeight :
     oIframe.document.height ? oIframe.document.height : null;
}

function IFRAME_size_to_content(iframe_id) {
     var oIframe = frames[iframe_id];
     if (typeof (oIframe) != 'undefined') {
         var elem = getElement(iframe_id);
         if (!elem) return;
         var wid = elem.offsetWidth;
         var hgt = getIFRAME_doc_height(oIframe);
alert (wid + " x " + hgt);
         if (wid && hgt) oIframe.resizeTo(wid,hgt);
   }
}

//window.onload = function() {
//	IFRAME_size_to_content(FRAME_ID);
//}
window.onresize = function() {
	IFRAME_size_to_content(FRAME_ID);
}


function getWindowClientHeight() {
	var myHeight = 0;
	if( typeof (window.innerHeight ) == 'number') {
		//Non-IE
		myHeight = window.innerHeight;
	} else {
		if (document.documentElement && document.documentElement.clientHeight) {
			//IE 6+ in 'standards compliant mode'
			myHeight = document.documentElement.clientHeight;
		} else {
			if (document.body && document.body.clientHeight) {
				//IE 4 compatible
				myHeight = document.body.clientHeight;
			}
		}
	}
	return myHeight;
}
function getWindowClientWidth() {
	var myWidth = 0;
	if( typeof (window.innerWidth ) == 'number') {
		//Non-IE
		myWidth = window.innerWidth;
	} else {
		if (document.documentElement && document.documentElement.clientWidth) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
		} else {
			if( document.body && document.body.clientWidth) {
				//IE 4 compatible
				myWidth = document.body.clientWidth;
			}
		}
	}
	return myWidth;
}
function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curtop += obj.y;
	}
	return curtop;
}
function findPosX(obj) {
	var curLeft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curLeft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	} else if (obj.y) {
		curLeft += obj.y;
	}
	return curLeft;
}
function resizeToFit () {
	if (typeof (document.getElementById) != "undefined") {
		var elem = document.getElementById (FRAME_ID);
		if (elem && (typeof (elem.parentNode) != "undefined")) {
			if (typeof (elem.style) == "object") {
				// adjust height
				var y = findPosY(elem);
				var windowHeight = getWindowClientHeight();
				if (windowHeight > y)
					elem.style.height = (windowHeight - y) + "px";
				// set height for ie
				var x = findPosX(elem);
				//elem.style.width = (getWindowClientWidth()-x - 180) + "px";
				elem.style.width = "100%";
				// set borders
				elem.style.margin = "0px";
				elem.style.padding = "0px";
				// adhust scrolling
				elem.style.overflow = "auto";
				elem.style.overflowX = "hidden";
				elem.style.overflowY = "auto";
			}
		}
	}
}

window.onresize=resizeToFit;
window.onload=resizeToFit;
var FRAME_ID = "inhalt"; // "sframe"

