/*
	REQUIRES jQuery 1.2.6

	if it's a mozilla browser AND there is no cookie saying not to do this...
*/
if ($.browser.mozilla) {
	var head = $('head').eq(0);
	// add the additional scripts and css

	// DEBUG.add for uat: /icaa to paths
	if (typeof (virtualPathRoot) == 'undefined') {
	    var virtualPathRoot = "/";
	}
	document.writeln("<script type='text/javascript' src='" + virtualPathRoot + "js/modalwindow.js'><" + "/script>");
	document.writeln("<script type='text/javascript' src='" + virtualPathRoot + "js/textresizedetector.js'><" + "/script>");
	$("<link rel='stylesheet' type='text/css' href='" + virtualPathRoot + "css/lightbox.css' />").appendTo(head);


	// onload functionality
	$(function() {
	    //
	    //
	    // This 11 is a pixel value tied to #icaa_topmenu in global.css. They must be the same.
	    // Thusly, if one changes, they both must change.
	    var targetElementID = 'icaa_topmenu';
	    var icaa_topmenu_DefaultFontSize = 11;
	    var icaa_topmenu_FontSize = $('#icaa_topmenu').css('font-size').match(/\d+/);
	    //
	    //

	    var markup = "<div id='overlay'></div>" +
						"<div id='lightbox' class='loading'>" +
						"<div id='lbContent'>" +
						"<p>We have detected that your browser is currently set to a <strong>font size larger than this website can support</strong>.</p>" +
						"<p>Please change the font size to normal by going under the “View” menu. Failure to do so will affect the functionality of the website including the ability to access the login area.</p><br/>" +
						"<input type='checkbox' name='displayTextWarning' id='displayTextWarning' /><label for='displayTextWarning'>Ignore this warning in the future</label>" +
						"<div style='display:block; text-align:right;'>" +
						"<button id='TextWarningOK' name='TextWarningOK' >&nbsp;&nbsp;OK&nbsp;&nbsp;</button>" +
						"</div>" +
						"</div>" +
						"</div>"

	    // Onload, append the overlay markup to the page
	    $('body').eq(0).append(markup);

	    // id of element to check for and insert control
	    TextResizeDetector.TARGET_ELEMENT_ID = targetElementID;

	    // function to call once TextResizeDetector has init'd
	    TextResizeDetector.USER_INIT_FUNC = function() {
	        var iBase = TextResizeDetector.addEventListener(function(e, args) {

	            // if a cookie is set, then don't remind them of the warning
	            var showWarning = iomer.getCookie('icaa_showTextWarning');
	            if (showWarning !== null && showWarning !== '') return

	            var icaa_topmenu_FontSize = $('#icaa_topmenu').css('font-size').match(/\d+/);

	            // if the user increases the font size then display the warning
	            if (icaa_topmenu_FontSize > icaa_topmenu_DefaultFontSize) modalwindow.activate();
	        },
			null);
	    }
	    // when the close button is clicked set a cookie if the check box is selected		
	    $('#TextWarningOK').click(function(e) {
	        if ($('#displayTextWarning').attr('checked')) iomer.setCookie('icaa_showTextWarning', 'true', 60);
	        e.preventDefault();
	    });

	    // if a cookie is set, then don't remind them of the warning
	    var showWarning = iomer.getCookie('icaa_showTextWarning');

	    // Or, test to see if the user has the font size set higher.
	    if (!(showWarning !== null && showWarning !== '') && icaa_topmenu_FontSize > icaa_topmenu_DefaultFontSize) { modalwindow.activate(); }
	});
}