 /* *********************************************************************************
 * Name:		iframe-support.js
 * Description:	This file contains routines to support the use of 
 *				iframes across domains, specifically to allow
 *				dynamic resizing of the iframe based upon the 
 *				loaded content.
 *				
 *				This file is based upon javascript provided by 
 *				Simon Leadbetter of Cog Design.
 *
 * Requires:	No javascript libraaries are required 
 * 
 * Revision History:
 * -----------------
 * Version 1.1, 20090807, Added code to potentially force invisble spans to be set
 *                        to display none (commented out at present).
 * Version 1.0, 20090805, Initial build (full revision control held in SubVersion).
 * 
 * **********************************************************************************
 */

 
/* This function should be called in the onload event of the body tag:
*      <body onload="iframeLoader();"></body>
*   by any page that is served in an iframe.  The page should also
*	 contain an iframe as follows:
*	    <iframe id="inneriframe" width="10" height="50" frameborder="10" scrolling="no" marginwidth="0" marginheight="0"></iframe>
*   which is used in the resizing process.
*/

// This variable indicates 1 is the iframeLoader has areadly been fired
var iframeLoaderFired = 0;

function iframeLoader() {
	// Only resize if not already completed
	// if (iframeLoaderFired != 1){
		var iframe = document.getElementById( 'inneriframe' );
		var wrapper = document.getElementById( 'iframeWrapper' );
		// var height = Math.max( document.body.offsetHeight, document.body.scrollHeight );
		var height = wrapper.offsetHeight + 20;
		iframe.src = 'http://www.ism.org/register_forms/xssEnabler.html?height='+height;
		// alert('CMS Resizing to height of ' + height);
            
        // Make all span items with visibility:none also have display:none
        //$("span")filter(function (index) {
        //          return index == 1 || $(this).attr("visibility") == "hidden";
        //        })
        //    .css("display", "none");
        
		// iframeLoaderFired = 1;
	// }
}

// Some of 3Si Web Tools do not fire the onload event for the body for all
// browsers, so as a work around we are ensuring the iframeLoader is fired.
$(document).ready(function() {
	iframeLoader();
});    

