// JavaScript Document
//  IFRAME RESIZER FOR WEBSTORE INTEGRATION
//  (C) SAGE-QUICK TECHHNOLOGIES INC.  ALL RIGHTS RESERVED.

function getFirstParam(){
	// This gets the height from the url of the iFrame hidden inside the framed page.
	// This is the first parameter from the url of the calling window
	var pair = window.location.search.substring( 1 );
	var parts = pair.split( '=' );
	var param = parseInt( parts[1] );
	return param;
}

function loadHiddenIframe(path) {
	// Get the height of the framed page by obtaining the height of the calling window 
	var height;
	if (navigator.userAgent.indexOf("Firefox")!=-1) {
		height = document.body.offsetHeight+40;
	}
	else {
		height = document.body.scrollHeight+40;
	}
	
	// Load the hidden page into the iFrame hidden inside the framed page, with height as a url parameter.
	// The hidden iFrame will then set the height of the main iFrame by calling the code in the top doc.
	var iframe = document.getElementById( 'HiddenIframe' );
	iframe.src = path + '?height=' + height;
}

function resizeIframe( framename, height ) { 
	var iframe = top.document.getElementById( framename ); 
	iframe.setAttribute( "height", height );
}

