function getDocWidth(document) {
	var docWidth = 0, scrollWidth, offsetWidth;
	if (document.width) docWidth = document.width;
	else if (document.body) {
		if (document.body.scrollWidth) docWidth = scrollWidth = document.body.scrollWidth;
		if (document.body.offsetWidth) docWidth = offsetWidth = document.body.offsetWidth;
		if (scrollWidth && offsetWidth) docWidth = Math.max(scrollWidth, offsetWidth);
	}
	return docWidth;
}

function getDocHeight(document) {
	var docHeight = 0, scrollHeight, offsetHeight;
	if (document.height) docHeight = document.height;
	else if (document.body) {
		if (document.body.scrollHeight) docHeight = scrollHeight = document.body.scrollHeight;
		if (document.body.offsetHeight) docHeight = offsetHeight = document.body.offsetHeight;
		if (scrollHeight && offsetHeight) docHeight = Math.max(scrollHeight, offsetHeight);
	}
	return docHeight;
}

function setIFrameWidthHeight(iFrameName) {
	// alert('here ' + iFrameName);
	var iFrameWin = window.frames[iFrameName];
	var iFrameElement = document.getElementById ? document.getElementById(iFrameName) : document.all ? document.all[iFrameName] : null;
	if (iFrameElement && iFrameWin) {
		iFrameElement.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    
		var docWidth = getDocWidth(iFrameWin.document);
		// if (docWidth) iFrameElement.style.width = docWidth + 30 + "px";
		if (docWidth) iFrameElement.style.width = docWidth + "px";
		
		var docHeight = getDocHeight(iFrameWin.document);
		// if (docHeight) iFrameElement.style.height = docHeight + 30 + "px";
		if (docHeight) iFrameElement.style.height = docHeight + "px";
	}
}