// ------------------------------------------------------------------------------
// This script is to perform the following task when loading the iframe:
// 1. Get the file name of the url to be loaded on the iframe.
// 2. Get the height of the document to be loaded.
// 3. Ajust the height of the iframe to fit the document to be loaded.
// 4. Update the file name to the address bar.
// How to call this script?  From the iframe tag, insert the following codes:
//      onLoad=loadiFrame('iframe_name');
// ------------------------------------------------------------------------------

function getElement(aID)
{
	return (document.getElementById) ?
		document.getElementById(aID) :document.all[aID];
}

function getIFrameDocument(aID){ 
	var rv = null; 
	var frame=getElement(aID);
	// if contentDocument exists, W3C compliant (e.g. Mozilla) 
	if (frame.contentDocument)
		rv = frame.contentDocument;
	else // bad Internet Explorer  ;)
		rv = document.frames[aID].document;
	return rv;
}

function adjustMyFrameHeight(p_iframe_name)
{
	var v_frame = getElement(p_iframe_name);
	var v_frameDoc = getIFrameDocument(p_iframe_name);
	v_frame.height = v_frameDoc.body.offsetHeight + 30;
}

function loadiFrame(v_iframe_name) 
{
	var v_iframe_url = document.getElementById(v_iframe_name).contentWindow.location.href;
	var v_file_name = v_iframe_url.substring(v_iframe_url.lastIndexOf('/') + 1);
	adjustMyFrameHeight(v_iframe_name);
    parent.location.hash = v_file_name;
}

