
var timeout;   
 
function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}
 
 
function clickAction() {   
    frameFitting();   
    var fr = document.getElementById('demo_frame').contentWindow.document.body.getElementsByTagName('a');   
    for (var i=0; i<fr.length; i++) {   
        fr[i].onclick = function() {   
            clearInterval(timeout);   
            timeout = setInterval("frameFitting()",10);   
        }   
    }   
}   
  
function frameFitting() {   
//alert(getClientHeight()+"+"+document.getElementById('demo_frame').contentWindow.document.body.scrollHeight);
	if(getClientHeight()<300)
		hg = getClientHeight();
    else
		hg = 800;
	
	
	//document.getElementById('demo_frame').width = '100%'; 
	//alert(document.getElementById('demo_frame').contentWindow.document.body.scrollHeight);
	if(document.getElementById('demo_frame').contentWindow.document.body.scrollHeight>300) 
		document.getElementById('demo_frame').style.height = document.getElementById('demo_frame').contentWindow.document.body.scrollHeight+5+'px';

	else
		document.getElementById('demo_frame').style.height = hg+'px';
}   
  
// onload = clickAction;   
//-->  
