function calcIFrameHeight(ifrm) {
	//find the height of the internal page
	var the_height=document.getElementById(ifrm).contentWindow.document.body.scrollHeight;

	//change the height of the iframe
	document.getElementById(ifrm).height=the_height;
}

function loadIframe(iframeName, url) {
	if ( window.frames[iframeName] ) {
		window.frames[iframeName].location = url;
		calcIFrameHeight(iframeName);
		return false;
	}
	else return true;
}


	var childsize= new Array();	// hashtable containing height for frames
	
	// Find the x,y location in pixels for a relatively positioned object
	// returns an object with .x and .y properties.
	function FindXY(obj){
	var x=0,y=0;
	while (obj!=null){
		x+=obj.offsetLeft-obj.scrollLeft;
		y+=obj.offsetTop-obj.scrollTop;
		obj=obj.offsetParent;
	}
	return {x:x,y:y};
	}
	
	function areImagesLoading(doc)	// return true if some of the images are still loading
	{
		var images=doc.getElementsByTagName("IMG");
		var finished=true;
		for(var i=0;i<images.length;i++)
		{	finished &= images[i].complete; }		
		 return (!finished);
	}
	
	function heightChanged( framename , newheight ) // frame height has changed -> called by children
	{
		//alert("got "+framename+"="+newheight);
		childsize[framename]=newheight;	// store height for frame
		resizeAll();					// resize children and myself	
	}
		
	function resizeAll() // change height for all children (except ones explicitly named) and also for myself
	{
		var desiredheight=100;	// minimum height of frames
		//var excluded = ",left,"	// children excluded from resize
		var excluded = ",hiddenIFrame,"	// children excluded from resize
		
		var iframes=document.getElementsByTagName("IFRAME"); // get all iframes in this page
		
		// calc frame height as max of child declared size
		for(var i = 0; i < iframes.length; i++)	
		{
			var iframeid = "" + iframes[i].id;
			if ( childsize[iframeid] !=undefined)
			desiredheight=Math.max(desiredheight, childsize[iframeid]);
		}

		// resize all iframes excluding those with id in excluded
		for(var i = 0; i < iframes.length; i++)
		{	
			var frameid = "" + iframes[i].id; 
			if ( excluded.indexOf(","+frameid+",") == -1 )	// do not resize iframes with name in excluded list
			{
				//alert("resizing:"+frameid);
				iframes[i].height = desiredheight;
			}
		}
	}
