/* id of element to check for and insert test SPAN into */
TextResizeDetector.TARGET_ELEMENT_ID = 'wrapper';
/* function to call once TextResizeDetector was initialized */
TextResizeDetector.USER_INIT_FUNC = function() {
	var iBase = TextResizeDetector.addEventListener(onFontResize,null);
	var baseClass;

	if (iBase >= 18) baseClass = 'fontsize-18';
	if (iBase >= 21) baseClass = 'fontsize-23';
	if (iBase >= 27) baseClass = 'fontsize-27';
	if (iBase >= 31) baseClass = 'fontsize-31';

	if (baseClass) $('body').addClass(baseClass);
	if (iBase < 18) $('#topnav .subtitle').show();
	else $('#topnav .subtitle').hide();
}

function onFontResize(e, args) {
	/*var msg = "\nThe base font size in pixels: " + args[0].iBase;
	msg +="\nThe current font size in pixels: " + args[0].iSize;
	msg += "\nThe change in pixels from the last size:" + args[0].iDelta;
	alert( msg );*/

	var newClass;
	var oldClass;

	newSize = args[0].iSize;
	oldSize = (args[0].iSize - args[0].iDelta.substring(0,args[0].iDelta.length-2));
		
	if (newSize >= 18) newClass = 'fontsize-18';
	if (newSize >= 21) newClass = 'fontsize-23';
	if (newSize >= 27) newClass = 'fontsize-27';
	if (newSize >= 31) newClass = 'fontsize-31';

	if (oldSize >= 18) oldClass = 'fontsize-18';
	if (oldSize >= 21) oldClass = 'fontsize-23';
	if (oldSize >= 27) oldClass = 'fontsize-27';
	if (oldSize >= 31) oldClass = 'fontsize-31';

	if (oldClass) $('body').removeClass(oldClass);
	if (newClass) $('body').addClass(newClass);
	if (args[0].iSize < 18) $('#topnav .subtitle').show();
	else $('#topnav .subtitle').hide();
}

