// IFrame silent print script by Jonathan C. Nilson

function silentPrint (pSrc) {
	// Accept only 4.0+ browsers
	if ( parseInt(navigator.appVersion)<4 ) { return; }

	// Create an IFrame and insert it in the body if none exists already
	if (!parent["silentPFrame"]) {
		var iFrameTag = '<iframe src="' + pSrc + '" frameborder="0" height="0" width="0"  marginheight="0" marginwidth="0" hspace="0" vspace="0" name="silentPFrame" id="silentPFrame"></iframe>';
		document.body.innerHTML += iFrameTag;
	}
	
	// Link the IFrame to a var
	sPF = parent["silentPFrame"];
	
	//  Call the Sentinel to wait for load.
	sP_Sentinel();
}

function sP_Sentinel () {
// Checks for IFrame loading completion before attempting to print
	sPF = parent["silentPFrame"];

	if (!sPF.document) { 
		setTimeout("sP_Sentinel();",100);
	}
	else {
		// Call the Printing routine
		sP_DoPrint();
	}
}

function sP_DoPrint () {
// Prints after confirmation
	sPF = parent["silentPFrame"];

	// Confirm with the user
	if ( confirm("The document has finished loading and is ready to print.  Are you sure you want to print this document?") ) {
		sPF.focus();
		sPF.print();
		sPF.blur();
		top.focus();
	}
}