// TextSizeTweak.js

// The fix only works in modern, DOM-capable browsers; detection is taken care of by the first if statement. 
// So far it's been tested in Win IE5/5.5/6, Mac IE5 and Netscape 6.

// A hidden div containing a few lines of text is written into the page. Its height is then measured, and if it's 
// too small the font size applied to the body tag is increased to compensate. An extra % value is added for Win IE
// just to nudge it into being more accurate.

// All font sizes within the page must be in ems.

// This script won't 'dynamically' resize the page if the user changes the text size while viewing it.  In that case
// a refresh is required for the script to reszie the page.  But given that most users will set the font size once,
// and then leave it alone, this shouldn't be an issue.

// A certain amount of tweaking may be require to the % values (i.e. scaling=?? in this script to get it working correctly.

function TextSizeTweakSmall()
{
	if ((document.createElement) && (document.createTextNode))
	{
		document.writeln('<div id="emsTest" style="position:absolute; visibility:hidden; font-family:arial,helvetica,sans-serif">&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br /></div>');
		var scaling=61;
		if ((navigator.platform=="Win32") && (navigator.appName=="Microsoft Internet Explorer")) scaling=62.5;
		var h=999;
		if (document.getElementById('emsTest').clientHeight) h=parseInt(document.getElementById('emsTest').clientHeight);
		else if (document.getElementById('emsTest').offsetHeight) h=parseInt(document.getElementById('emsTest').offsetHeight);
		if (h<85) document.body.style.fontSize=Math.round(scaling*90/h)+"%";
	}
}


function TextSizeTweakLarge()
{
	if ((document.createElement) && (document.createTextNode))
	{
		document.writeln('<div id="emsTest" style="position:absolute; visibility:hidden; font-family:arial,helvetica,sans-serif">&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br /></div>');
		var scaling=61;
		if ((navigator.platform=="Win32") && (navigator.appName=="Microsoft Internet Explorer")) scaling=62.5;
		var h=999;
		if (document.getElementById('emsTest').clientHeight) h=parseInt(document.getElementById('emsTest').clientHeight);
		else if (document.getElementById('emsTest').offsetHeight) h=parseInt(document.getElementById('emsTest').offsetHeight);
		if (h>85) document.body.style.fontSize=Math.round(scaling*89/h)+"%";
	}
}