<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">var locked;
var old_modcat = old_id = false;
var lo_group = false;
var browser;

// Migrated from the &lt;body&gt; tag
$(window)
	.on('load', function() {
		doOnload();
	});

$(document)
	.on('click', function() {
		doOnBodyClick();
	});


if(navigator.userAgent.indexOf('Safari')!==-1)
{
	browser = 'Safari';
	browserVersion = navigator.userAgent.substring((navigator.userAgent.indexOf('Version/')+8),(navigator.userAgent.indexOf('Version/')+11));
	browserVersion = parseFloat(browserVersion);

}
else if(navigator.userAgent.indexOf('MSIE')!==-1)
{
	browser = 'IE';
	browserVersion = navigator.userAgent.substring((navigator.userAgent.indexOf('MSIE')+5),(navigator.userAgent.indexOf('MSIE')+8));
	browserVersion = parseFloat(browserVersion);
}
else if(navigator.userAgent.indexOf('Opera')!==-1)
{
	browser = 'Opera';
	browserVersion = navigator.appVersion.substring(0,3);
	browserVersion = parseFloat(browserVersion);
}
else
{
	browser = 'FFox';

	if(jQuery.browser) {
		browserVersion = jQuery.browser.version;
		browserVersion = parseFloat(browserVersion);
	}
}

function getQueryString(win) {
    var qs = win.location.search;
    var multimap = {};
    if (qs.length &gt; 1) {
        qs = qs.substr(1);
        qs.replace(/([^=&amp;]+)=([^&amp;]*)/g, function(match, hfname, hfvalue) {
            var name = decode(hfname);
            var value = decode(hfvalue);
            if (name.length &gt; 0) {
                if (!multimap.hasOwnProperty(name)) {
                    multimap[name] = [];
                }
                multimap[name].push(value);
            }
        });
    }
    return multimap;
}

function decode(s) {
    try {
        return decodeURIComponent(s).replace(/\r\n|\r|\n/g, "\r\n");
    } catch (e) {
        return "";
    }
}

(function($){$(function()
{
	$(document).on('click', '#site-session .site-session-package', function(e) {
		e.preventDefault();

		var $this       = $(this);
		var new_package = $this.val();

		$this
			.closest('form')
			.attr('action', 'Modules.php?force_package=' + new_package)
			.trigger('submit');
	});

	//Clickables
	$('.clickable').on('click focus', function() {
		//Don't know if this is actually needed but commenting it out
		//inputReplace(this);
	});

	//DatePickers
	(function($) {
		"use strict";

		// Add autocomplete="off" to all date inputs
		$(document).on('focus', 'input.date, input.newdate, input[type="date"]', function() {
			if(!this.hasAttribute('autocomplete')) {
				this.setAttribute('autocomplete', 'off');
			}
		});

		/**
		 * This handles DateInput / PrepareDate functions.
		 *
		 * Years values are always 2 digits.
		 * Month values can either be abbr (JAN-DEC) or digits (01-12)
		 * Day values are always 2 digits. (01-31)
		 */

		function getYearRange($parent) {
			var min;
			var max;
			var years = $parent.find('select[id^="yearSelect"] option');

			for(var i = 0; i != years.length; i++) {
				var $year = $(years[i]);
				var year = +$year.text();

				if(!min || year &lt; min) {
					min = year;
				}
				if(!max || year &gt; max) {
					max = year;
				}
			}

			return (min &amp;&amp; max) ? min+':'+max : false;
		}

		function getDatePicker($parent) {
			var picker = $parent.find('.datePicker');
			if(!picker.length) {
				return;
			}

			if(picker.hasClass('hasDatepicker')) {
				return $(picker);
			}

			return $(picker).datepicker({
				showOn: 'focus',
				changeYear: true,
				yearRange: getYearRange($parent),
				onSelect: function(date_string) {
					var date = new Date(date_string);

					var year  = date.getFullYear().toString();
					var month = date.getMonth().toString();
					var day   = date.getDate().toString();

					var dd_year  = $parent.find('select[id^="yearSelect"]');
					var dd_month = $parent.find('select[id^="monthSelect"]');
					var dd_day   = $parent.find('select[id^="daySelect"]');

					var year_options = dd_year.find('option[value!=""]');

					var days_in_month = date.getDate();
					var allow_na      = dd_day.find('option[value=""]').length;

					/**
					 * This is a gross hack. PrepareDate sets all year option vals to two digits.
					 * This makes no sense! If the value is 2 digits and the text is 4, then
					 * I will use the text over the value. This is still incorrect because it will
					 * still be submitted to the server as 2 digits. For whoever is BRAVE enough
					 * to change PrepareDate to set option vals to 4 digits then nothing
					 * below will need changed.
					 *
					 *  - ~Annoyed~ Preston
					 */
					if(year_options.length) {
						var first = year_options.first();

						var value = first.val();
						var text = first.text();

						if(value.length == 2) {
							if(text.length == 4) {
								value = text;
							} else {
								value = parseInt((parseInt(value, 10) &lt;= 30 ? '20' : '19') + value);
							}
						}

						var year_index = value - year;
						var year_option = year_options.get(year_index);
						$(year_option).prop('selected', true);
					}

					// NOTE: We don't select value since the value can be abbr or a number.
					// They Are always ordered 0 - Jan 11 - Dec
					var month_option = dd_month.find('option[value!=""]').get(month);
					$(month_option).prop('selected', true);

					dd_day.empty();

					if(allow_na) {
						dd_day.append($('&lt;option value=""&gt;N/A&lt;/option&gt;'));
					}

					for(let i = 1; i &lt;= days_in_month; i++) {
						let val = i.toString().length &lt; 2 ? '0' + i : i;
						dd_day.append($('&lt;option value="' + val + '"&gt;' + i + '&lt;/option&gt;'));
					}

					if(day.length &lt; 2) {
						day = '0' + day;
					}
					dd_day.val(day);

					// Trigger change event
					$parent.find('select[id^="yearSelect"], select[id^="monthSelect"], select[id^="daySelect"]').change();
				}
			});
		}

		$(document)
			// Calendar Icon
			.on('click', '.datePickerTrigger', function() {
				var $this   = $(this);
				var $parent = $this.parent();
				var $picker = getDatePicker($parent);

				if($picker === false) {
					return;
				}
				$picker.datepicker('show');

				// make it draggable since FOCUS-29176
				$("#ui-datepicker-div").draggable();
			})

			// Year/Month/Day - Update DatePicker date
			.on('change', 'select[id^="yearSelect"], select[id^="monthSelect"], select[id^="daySelect"]', function() {
				var $this   = $(this);
				var $parent = $this.parent();
				var $picker = getDatePicker($parent);

				if($picker === false) {
					return;
				}

				var date_string = $picker.datepicker('getDate');
				var date = new Date(date_string || Date.now());

				var dd_year  = $parent.find('select[id^="yearSelect"]');
				var dd_month = $parent.find('select[id^="monthSelect"]');
				var dd_day   = $parent.find('select[id^="daySelect"]');

				var year  = dd_year.val();
				var month = dd_month.val();
				var day   = dd_day.val();

				if(!year) {
					year = date.getFullYear().toString();
				}

				month = parseMonthAbbreviation(month);
				if(!month) {
					month = (date.getMonth() + 1).toString();
				}

				if(!day) {
					day = date.getDate().toString();
				}

				if(year &amp;&amp; month &amp;&amp; day) {
					/**
					 * This is a gross hack. PrepareDate sets all year option vals to two digits.
					 * This makes no sense! If the value is 2 digits and the text is 4, then
					 * I will use the text over the value. This is still incorrect because it will
					 * still be submitted to the server as 2 digits. For whoever is BRAVE enough
					 * to change PrepareDate to set option vals to 4 digits then nothing
					 * below will need changed.
					 *
					 *  - ~Annoyed~ Preston
					 */
					if(year.length == 2) {
						var year_hack = dd_year.find('option:checked').text();
						if(year_hack.length == 4) {
							year = year_hack;
						} else {
							year = parseInt((parseInt(year, 10) &lt;= 30 ? '20' : '19') + year).toString();
						}
					}

					if(month.length &lt; 2) {
						month = '0' + month;
					}

					if(day.length &lt; 2) {
						day = '0' + day;
					}
					$picker.datepicker('setDate', month + '/' + day + '/' + year);
				}
			})

			// Limit days when year / months are selected
			.on('change', 'select[id^="yearSelect"], select[id^="monthSelect"]', function() {
				var $this   = $(this);
				var $parent = $this.parent();
				var $picker = getDatePicker($parent);

				if($picker === false) {
					return;
				}

				var dd_year  = $parent.find('select[id^="yearSelect"]');
				var dd_month = $parent.find('select[id^="monthSelect"]');
				var dd_day   = $parent.find('select[id^="daySelect"]');

				var year     = dd_year.val();
				var month    = parseMonthAbbreviation(dd_month.val());
				var day      = dd_day.val();
				var allow_na = dd_day.find('option[value=""]').length;

				if(!year || !month) {
					return;
				}

				if(year.toString().length == 2) {
					year = parseInt((parseInt(year, 10) &lt;= 30 ? '20' : '19') + year);
				}

				var date = new Date(year, month, 0);
				var days_in_month = date.getDate();

				dd_day.empty();

				if(allow_na) {
					dd_day.append($('&lt;option value=""&gt;N/A&lt;/option&gt;'));
				}

				for(var i = 0; i != days_in_month; i++) {
					var val = i+1;
					if(val.toString().length &lt; 2) {
						val = '0' + val;
					}
					dd_day.append($('&lt;option value="' + val + '"&gt;' + (i + 1) + '&lt;/option&gt;'));
				}

				if(day &amp;&amp; day &gt; days_in_month) {
					day = days_in_month;
				}

				dd_day.val(day);
			});

	})(jQuery);


	//Input Validation
	(function($)
	{
		var tooltipTimeout    = null;
		var nonzero           = 'input.nonzero';
		var time_duration     = 'input.time, input.duration';
		var input_date        = 'input.date';
		var inputs            = 'input.number, input.integer, input.date, input.time, input.duration, input.regex';
		var inputs_red_submit = inputs + ', input.text-trigger, .select-trigger select, .select-trigger swift-box, .textarea-trigger textarea, input.checkbox-trigger, swift-box.select-trigger, .text-trigger input';

		$(document).on('tableData', '.dataTable', function() {
			if(window.skipDataTableValidation) {
				return;
			}

			$(document).find('input.date, input.time, input.duration').trigger('validate');
		});

		$(document).on('tablePaginate', '.dataTable', function() {
			if(window.skipDataTableValidation) {
				return;
			}

			$(document).find('input.time, input.duration').trigger('validate');
		});

		// Strip trailing decimals on number inputs
		// This uses event capturing (not bubbling) to ensure the values are fixed before anything else
		document.addEventListener('change', function(e) {
			const target = e.target;

			if(target.classList.contains('number')) {
				target.value = target.value.replace(/\.+$/, '');
			}
		}, true);

		//Generic validation
		$(document)
			.on('change', inputs_red_submit, function()
			{
				if(!(window.redSubmitDisabled || Focus.redSubmitDisabled) &amp;&amp; redSubmit) {
					//Make sure we aren't inside of a DataTable
					if(!$(this).closest('.dataTable').length) {
						redSubmit();
					}
				}
			})
			.on('input focusin change click', inputs, function(e)
			{
				if(this.disabled || this.hasAttribute('readonly')) {
					return;
				}

				var $this = $(this);

				var number     = $this.hasClass('number');
				var integer    = $this.hasClass('integer');
				var date       = $this.hasClass('date');
				var time       = $this.hasClass('time');
				var duration   = $this.hasClass('duration');
				var regex      = $this.hasClass('regex');
				var format     = $this.attr("data-format");
				var ignore_msg = this.hasAttribute("data-ignore-default-message");
				format         = (format == null) ? 'MM/DD/YYYY' : format;

				var military_time = window.Focus.use_military_time === 'Y';
				var time_format   = military_time ? 'hours:minutes' : 'hours:minutes am/pm';

				var pattern, patternFlag = '', message;

				// If entering 'n', use current time or date
				if(this.value === 'n' &amp;&amp; (time || date)) {

					if(time) {
						if(military_time) {
							this.value = moment().format('HH:mm');
						}
						else {
							this.value = moment().format('hh:mm a');
						}
					}
					else if(date) {
						this.value = (new Date()).toLocaleDateString([], {month: '2-digit', day: '2-digit', year: 'numeric'});
					}
				}

				//Determine the regex information if this is a number
				if(number || integer)
				{
					var positive	= $this.hasClass('positive');
					var negative	= $this.hasClass('negative');
					var nonzero		= $this.hasClass('nonzero');

					pattern			= '[\\d]*';
					message			= '';

					//Integer
					if(integer)
						message += 'Integers ';
					//Float
					else
					{
						pattern += '\\.?[\\d]*';
						message += 'Numbers ';
					}

					if(nonzero) {
						message = 'Non Zero '+message;
					}

					//Positive
					if(positive)
						message = 'Positive '+message;
					//Negative
					else if(negative)
					{
						pattern	= '-'+pattern+'|0';
						message	= 'Negative '+message;
					}
					//Both
					else pattern = '-?'+pattern;

					message += 'Only';

				}
				else if(date)
				{
					pattern = '(?:[\\d\\/\\-\\.]{1,10})?';
					message = 'Date ('+format.toLowerCase()+')';

					if($this.hasClass('future'))
						message = 'Future ' + message;
					else if($this.hasClass('past'))
						message = 'Past ' + message;
				}
				else if(time || duration)
				{
					patternFlag = time ? 'i' : '';
					pattern = '\\d{0,2}:?\\d{0,2}(?::\\d{0,2})?'+(time ? '\\s?[apAP]?m?' : '');
					message = time ? `Time (${time_format})` : 'Duration (hours:minutes)';
				}
				//Otherwise get the regex information from the attributes
				else if(regex)
				{
					pattern		= this.getAttribute('data-pattern');
					patternFlag	= this.getAttribute('data-pattern_flag') || '';
					message		= this.getAttribute('data-message') || 'Invalid Value';

					if(!pattern.length)
					{
						$this.removeClass('regex');
						return;
					}

					pattern = decodeURIComponent((pattern+'').replace(/\+/g, '%20'));
					message = decodeURIComponent((message+'').replace(/\+/g, '%20'));
				}

				//If we're focusing, just show the message (unless it's a regex input)
				if(e.type === 'focusin' &amp;&amp; !regex &amp;&amp; $this.closest('.dateContainer').length === 0)
				{
					if(message)
					{
						if(tooltipTimeout)
						{
							clearTimeout(tooltipTimeout);
							tooltipTimeout = null;
						}

						if(!ignore_msg) {
							showTooltip.call(this, t(message), 'input_validation_tooltip');
						}
					}
					return;
				}

				//If we've never encountered a previous value, assume it's blank
				if(typeof this.lastValue == 'undefined')
					this.lastValue = '';
				//If user pastes numeric string with commas, strip commas.
				if(number)
					this.value=this.value.replace(/[^\d\.\-]/g,'');
				//Get the current value
				var value = this.value;

				if(value.length)
				{
					//Run the value through the validation
					var parsedValue = new RegExp(pattern, patternFlag).exec(value);

					//If the validation fails
					if(parsedValue === null || parsedValue[0] != value)
					{

						//Reset the value
						this.value = this.lastValue;

						//Regex inputs only display the tooltip temporarily if validation fails
						if(regex)
						{
							//Clear any previous timeout
							if(tooltipTimeout)
							{
								clearTimeout(tooltipTimeout);
								tooltipTimeout = null;
							}

							//Show the tooltip
							if(!ignore_msg) {
								showTooltip.call(this, t(message), 'input_validation_tooltip');
							}

							//Set a timeout to hide the tooltip
							tooltipTimeout = setTimeout(function()
							{
								hideTooltip.call(this, 'input_validation_tooltip');
							}, 2000);
						}
					}
				}

				//If the validation passed, store the current value
				this.lastValue = this.value;
			})
			.on('focusout', inputs, function()
			{
				if(tooltipTimeout)
				{
					clearTimeout(tooltipTimeout);
					tooltipTimeout = null;
				}

				hideTooltip.call(this, 'input_validation_tooltip');
			})
			.on('blur validate', nonzero, function(e) {
				if(this.value == 0 &amp;&amp; this.value !== '') {
						this.value = '';
						this.lastValue ='';
						$(this).focus();
				}
			})
		//Time/Duration
			.on('change focusout validate', time_duration, function(e)
			{
				var $this              = $(this);
				var value              = this.value;
				var previous_value     = value;
				var time               = $this.hasClass('time') || false;
				var raw                = $this.hasClass('raw') || false;
				var ignore_blur        = this.hasAttribute('data-ignore-blur');
				var meridianSpecified  = false;
				var meridianUppercased = false;
				var meridian           = null;
				var military_time      = window.Focus.use_military_time === 'Y';

				if(time)
				{
					meridian          = (/[ap]m?$/i).exec(value);
					value             = value.replace(/[^0-9:n]+/, ''); // Only keep numbers, : and n
					meridianSpecified = meridian !== null;
					meridianUppercased = meridianSpecified ? meridian[0] === meridian[0].toUpperCase() : false;

					// If there is a meridian and it's 1 char (A|P) finish it with the M.
					if(meridianSpecified) {
						if(meridian[0].length == 1) {
							meridian = meridian[0] + (meridianUppercased ? 'M' : 'm');
						}
					} else {
						// If there is none, let's assume they are talking about AM.
						meridian = 'am';
					}
				}

				//Make sure we have at least one number
				if(isNaN(parseInt(this.value.replace(/[^\d]/g, ''))))
				{
					this.value = '';
					return;
				}

				var part1, part2;
				var colon = value.indexOf(':');

				if(colon &gt;= 0)
				{
					part1 = value.substr(0, colon) || '0';
					part2 = value.substr(colon + 1) || '0';

					if(part2.length == 1) {
						part2 = part2+'0';
					}

					if(part2.includes(':')) {
						part2 = part2.substring(0, part2.indexOf(':'));
					}
				}
				else if(value.length == 4)
				{
					part1 = value.substr(0,2);
					part2 = value.substr(2);
				}
				else if(value.length == 3)
				{
					part1 = value.substr(0,1);
					part2 = value.substr(1);
				}
				else
				{
					part1 = time ? value : '00';
					part2 = time ? '00' : value;
				}

				if(time)
				{
					if(part1 == 12 &amp;&amp; !meridianSpecified){
						meridian = meridianUppercased ? 'PM' : 'pm';
					}
					else if(part1 &gt; 12)
					{
						if(part1 == 24)
							meridian = meridianUppercased ? 'AM' : 'am';
						else
							meridian = meridianUppercased ? 'PM' : 'pm';
						part1 = (part1 % 12)+'';
					}
					else if(part1 &gt; 0 &amp;&amp; part1 &lt; 7 &amp;&amp; !meridianSpecified &amp;&amp; !raw) {
						if(part1.length === 2 &amp;&amp; part1.substring(0,1) === '0'){
							meridian = meridianUppercased ? 'AM' : 'am';
						}
						else {
							meridian = meridianUppercased ? 'PM' : 'pm';
						}
					}

					else if(part1 === '0' || part1 === '00'){
						part1 = '12';
						meridian = meridianUppercased ? 'AM' : 'am';
					}
				}

				if(!part1.length)
					part1 = '0';
				if(part1.length == 1)
					part1 = '0'+part1;

				if(!part2.length)
					part2 = '0';
				if(part2.length == 1)
					part2 = '0'+part2;

				if(part2 &gt; 59)
					part2 = '59';

				if(time &amp;&amp; part1 === '00') {
					meridian = meridianUppercased ? 'am' : 'am';
				}

				this.value = part1+':'+part2+(time ? ' '+meridian : '');

				// Convert time to military time
				if(time &amp;&amp; military_time) {
					meridian = '';
					this.value = moment(`1/1/2090 ${this.value}`).format('HH:mm');
				}

				var link = this.getAttribute('data-combo-link');
				if(link) {
					dateTimeCombo(e, link, 'time', this.value);
				}
				else if ((e.type == 'focusout' || e.type == 'change') &amp;&amp; !ignore_blur &amp;&amp; this.value !== previous_value) {
					$this.trigger('change');
				}
			})
			.on('change focusout validate', input_date, function(e)
			{
				var $this       = $(this);
				var value       = this.value;
				var valueHolder = this.nextSibling;
				var format      = $this.attr("data-format");
				format          = (format == null) ? 'MM/DD/YYYY' : format ;

				// If running automation make sure we have a full date
				if(Focus.running_automation &amp;&amp; Number(value.slice(-4)) &lt; 1900) {
					return;
				}

				while(valueHolder &amp;&amp; valueHolder.nodeType != 1)
					valueHolder = valueHolder.nextSibling;

				//If the value holder wasn't found, make one
				if(!valueHolder || valueHolder.tagName !== 'INPUT' || valueHolder.type != 'hidden')
				{
					valueHolder      = document.createElement('input');
					valueHolder.type = 'hidden';

					valueHolder.setAttribute('data-name', this.name || this.getAttribute('data-name') || '');

					if(!this.hasAttribute('data-keep-name')) {
						this.name = '';
					}

					this.parentNode.insertBefore(valueHolder, this.nextSibling);
				}

				//By default, the input will not be submitted by a form.
				//The first time this input is changed, allow it to be submitted
				if(valueHolder &amp;&amp; e.type === 'change')
				{
					var name = valueHolder.getAttribute('data-name');
					valueHolder.removeAttribute('data-name');
					if(name)
						valueHolder.name = name;
				}

				while(value.length)
				{
					var values = value.replace(/[\-\.]/g, '/').split('/');
					if(values.length === 1)
						values = [values[0].substr(0,2), values[0].substr(2,2), values[0].substr(4)];

					var month	= (values[0] || '').substr(0,2);
					var day		= (values[1] || '').substr(0,2);
					var year	= (values[2] || '').substr(0,4);

					//Focus only support 2 format(D/M/Y and M/D/Y)
					if (format != 'MM/DD/YYYY'){
						var tmp = day;
						day     = month;
						month   = tmp;
					}

					if(!month.length || !day.length || !year.length)
						break;

					if(month &gt; 12 || month &lt;= 0 || day &lt;= 0)
						break;

					//Convert years like 23 into 2023
					if(year.length == 1)
						year = '200'+year;
					if(year.length == 2)
						year = (year &lt; 50 ? '20' : '19')+year;
					else if(year.length == 3)
						year = '2'+year;
					else if (year === "0000")
						break;

					//Make sure the day is valid
					if(daysInMonth(month, year) &lt; day) {
						// This was a break, which stopped execution of this validation and left the date invalid, but it makes more sense
						// to simply correct the day to the last day of the month if the entered day exceeds the # of days in the month
						var originalDay = day;
						day             = daysInMonth(month, year);
						month           = (month.length == 1) ? '0'+month : month;

						alert("Invalid date " + month + "/" + originalDay + "/" + year + " corrected to " + month + "/" + day + "/" + year + ".");
					}

					//Pad the month and day with zeroes if needed
					if(month.length == 1)
						month = '0'+month;
					if(day.length == 1)
						day = '0'+day;

					//Generate the formatted dates
					var displayDate		= month+'/'+day+'/'+year;
					var formattedDate	= year+'-'+month+'-'+day;

					//Transforming from moment to datepicker format
					var splittedFormat 	= format.replace(/[\-\.]/g, '/').split('/');
					if (splittedFormat.length &gt; 1) {
						displayDate = '';
						for (var i in splittedFormat) {
							displayDate += (i &gt; 0) ? '/' : '';
							switch (splittedFormat[i]) {
								case 'DD':
									displayDate += day;
									break;
								case 'MM':
									displayDate += month;
									break;
								case 'YYYY':
									displayDate += year;
									break;
							}

						}
					}

					//Check if the date is in the future/past if needed
					var future	= $this.hasClass('future');
					var past	= $this.hasClass('past');
					if((future || past) &amp;&amp; !Focus.running_automation)
					{
						var today			= new Date();
						var currentMonth	= (today.getMonth()+1);
						var currentDay		= today.getDate();
						var currentYear		= today.getFullYear();

						if(currentMonth &lt; 10)
							currentMonth = '0'+currentMonth;
						if(currentDay &lt; 10)
							currentDay = '0'+currentDay;

						today = currentYear+'-'+currentMonth+'-'+currentDay;

						if((future &amp;&amp; formattedDate &lt; today) || (past &amp;&amp; formattedDate &gt; today))
							break;
					}

					var validRange = validateDateRange($this, formattedDate);

					if (!validRange["result"]) {
						this.value = displayDate;
						break;
					}

					this.value = displayDate;
					$this.removeClass('invalid');

					if(valueHolder) {
						valueHolder.value = formattedDate;
						if (valueHolder.onchange !== null) {
							$(valueHolder).change();
						}
					}

					var link = this.getAttribute('data-combo-link');
					if(link) {
						dateTimeCombo(e, link, 'date', formattedDate);
					}

					for (var i in validRange["elements"]) {
						validRange["elements"][i].trigger("change");
					}

					return;
				}

				if (value.length) {
					$this.addClass('invalid');
				} else {
					$this.removeClass('invalid');

					var validRange = validateDateRange($this, formattedDate);
					for (var i in validRange["elements"]) {
						validRange["elements"][i].trigger("change");
					}
				}

				if(valueHolder)
					valueHolder.value = '';
			})
			.on('click', input_date, function()
			{
				if(this.datepicker)
					$(this).datepicker('hide');
			});

		$(document).on('click', '.date_picker', function()
		{
			var input = $(this.parentNode).children('.date')[0];
			if(!input.datepicker)
			{
				//Transforming from moment to datepicker format
				var format         = $(input).attr("data-format");
				format             = (format == null) ? 'MM/DD/YYYY' : format;
				var dpFormat       = format;
				var splittedFormat = format.replace(/[\-\.]/g, '/').split('/');
				if (splittedFormat.length &gt; 1) {
					dpFormat = '';
					for (var i in splittedFormat) {
						dpFormat += (i &gt; 0) ? '/' : '';
						switch (splittedFormat[i]) {
							case 'DD':
								dpFormat += 'dd';
								break;
							case 'MM':
								dpFormat += 'mm';
								break;
							case 'YYYY':
								dpFormat += 'yy';
								break;
						}

					}
				}

				$(input).datepicker({
					showOn		: true,
					changeYear	: true,
					dateFormat	: dpFormat
				});
				input.datepicker = true;
			}
			$(input).datepicker('show');
		});

		// Time
		$(document).find('.timePickerInput').each(function(i, e) {
			(function(div) {
				var input = div.find('input');
				var span = div.find('span.clickable');
				input.datetimepicker({
					// Show AM/PM, not 24 hour.
					ampm: true,
					dateFormat: 'M d, yy',
					timeFormat: 'h:mm TT'
				});
				if (span.length) {
					span.click(function() {
						input.show();
						input.focus();
						span.hide();
					});
				} else {
					input.show();
				}
				input.change(function() {
					redSubmit();
				});
			})($(e));
		});


		function dateTimeCombo(event, link, input_type, value) {
			var field = $(document).find('[data-combo-link="' + link + '"]').not('.'+input_type).val();
			var time  = '';
			var date  = null;

			if(input_type === 'date') {
				time = convertTime(field) || '';
				date = value;
			}
			else {
				time = convertTime(value);
				date = field ? moment(field).format('YYYY-MM-DD') : moment().format('YYYY-MM-DD');
			}
			var date_time_value  = time ? (date + ' ' + time) : date;
			var $date_time_field = $('[data-field="' + link + '"]');

			$date_time_field.val(date_time_value);

			if(event.type === 'change') {
				$date_time_field.trigger('change');
			}
		}

		function convertTime(time) {
			if(!time) {
				return false;
			}

			var am_pm    = time.substr(-2, 1);
			var new_time = null;

			if(am_pm === 'a') {
				new_time =  time.replace(' am', ':00');
			}
			else {
				var tmp_time = time.replace(' pm', '').split(':');
				var hour     = (tmp_time[0] &lt; 12 ? +tmp_time[0] + 12 : 12).toString();
				new_time     = hour + ':' + tmp_time[1] + ':00';
			}

			return new_time;
		}

		/* Variables for tooltip logic */
		var mouseOnTooltip        = false;
		var mouseOnTooltipTrigger = false;
		var accessibleTooltip     = false;

		function showTooltip(text, tooltipId)
		{
			tooltipId = tooltipId || 'generic_tooltip';

			//Create/retrieve the tooltip element
			var popup     = document.getElementById(tooltipId);
			var className = "tooltip";

			if (accessibleTooltip) {
				className += " accessible-tooltip";
			}

			if(!popup)
			{
				popup = document.createElement('div');
				popup.id = tooltipId;
				document.body.appendChild(popup);
			}
			popup.style.maxWidth = '45rem';
			popup.style.display  = 'block';
			popup.className      = className;
			popup.style.left     = '-9999px';
			popup.style.top      = '-9999px';
			popup.style.zIndex   = '100002';

			if (accessibleTooltip) {
				popup.style.maxHeight = "300px";
				popup.style.overflowY = "auto";
			}

			//Only set the text if we have some, otherwise just use the old text
			if(text)
				popup.innerHTML	= text;

			//If showTooltip is being called on a node, use it's offset, otherwise use the mouse position
			var position = this.nodeType ? $(this).offset() : {left:this.pageX, top:this.pageY};

			//Position the tooltip
			var left		= position.left;
			var top			= position.top - popup.offsetHeight;
			var buffer		= 2; //Used to account for borders
			var offsetX		= this.nodeType ? 0 : -12; //Mouse tooltips should be positioned so the speech-bubble's tip lines up with the mouse (12 pixels off)
			var offsetY		= this.nodeType ? -5 : ((accessibleTooltip) ? 0 : -20); //Mouse tooltips should be 15 pixels away from the mouse (+5 for the tooltip's speech-bubble tip)

			//Make sure the right side of the tooltip isn't off the page
			if(left + offsetX + popup.offsetWidth + buffer &gt;= window.innerWidth)
			{
				popup.className += ' left';

				if(!this.nodeType)
				{
					left = position.left - popup.offsetWidth;
					offsetX *= -1;
				}

				if(this.nodeType || left + offsetX + popup.offsetWidth + buffer &gt;= window.innerWidth)
				{
					left = window.innerWidth - popup.offsetWidth - buffer;
					offsetX = 0;
				}
			}

			//Make sure the top of the tooltip isn't off the page
			if((top + offsetY - buffer &lt; 0) || (this.nodeType &amp;&amp; this.getAttribute('data-bottom-tooltip') !== null))
			{
				popup.className += ' bottom';
				top = position.top + (this.offsetHeight || 0);
				offsetY *= -1;
			}

			popup.style.top  = (top + offsetY)+'px';
			popup.style.left = (left + offsetX)+'px';
		}

		function hideTooltip(tooltipId)
		{
			tooltipId = tooltipId || 'generic_tooltip';
			var popup = document.getElementById(tooltipId);
			if(popup)
				popup.style.display = 'none';
		}

		var tooltipMousemove = function(e)
		{
			showTooltip.call(e);
		};

		var tooltip_event;

		function handleMouseover(attr_name) {
			return function(e) {
				accessibleTooltip = $(this)[0].hasAttribute("data-accessible-tooltip");

				if (attr_name == 'data-focus-tooltip') {
					if (typeof(tooltip_event) != 'undefined' &amp;&amp; tooltip_event == e) {
						return;
					} else {
						tooltip_event = e;
					}
				}

				if (mouseOnTooltip) {
					return;
				}

				var text              = this.getAttribute(attr_name);
				mouseOnTooltipTrigger = true;

				if(text)
				{
					showTooltip.call(e, text);

					if (!accessibleTooltip) {
						$(this).on('mousemove', tooltipMousemove);
					}
				}
			};
		}

		$('body')
			.on("mouseover", ".accessible-tooltip", function() {
				mouseOnTooltip = accessibleTooltip;
			})
			.on("mouseout", ".accessible-tooltip", function(e) {
				mouseOnTooltip = false;

				setTimeout(function() {
					if (!mouseOnTooltip &amp;&amp; !mouseOnTooltipTrigger) {
						hideTooltip.call(e);
					}
				}, 500);
			})
			.on('mouseover', '[data-focus-tooltip]', handleMouseover('data-focus-tooltip'))
			.on('mouseout', '[data-focus-tooltip]', function(e)
			{
				if (!accessibleTooltip) {
					$(this).off('mousemove', tooltipMousemove);
				}

				mouseOnTooltipTrigger = false;

				setTimeout(function() {
					if (!mouseOnTooltip &amp;&amp; !mouseOnTooltipTrigger) {
						hideTooltip.call(e);
					}
				}, 500);
			})
			;

	})(jQuery);

	function parseMonthAbbreviation(month)
	{
		return typeof month === 'number' ? month : (new Date(month + ' 1, 2000').getMonth() + 1);
	}

	function daysInMonth(month, year)
	{
		return new Date(year, parseMonthAbbreviation(month), 0).getDate();
	}

	$('form').submit(function(){
		if(window.disable_btn_save) {
			return;
		}

		if(typeof(RFS_STATUS) == "undefined" || RFS_STATUS == 0)
		{
			$(this).find('#bottom_submit, #top_submit').prop('disabled','disabled');
			$(this).append($("&lt;input type='hidden' name='btn_save' value='Save'&gt;"));
			return true;
		}
	});

	//run a short delay to make sure page has loaded, then switch all images with a data-src and no src
	setTimeout(function() {
		$postLoadImages = $("img[data-src]:not(src)");
			if($postLoadImages.length &gt; 0) {
				$postLoadImages.iterate(function(){$(this).attr('src', $(this).attr('data-src'))});
				handleContainerResize();
			}
	},100);

})})(jQuery);

function include(url)
{
  var script = document.createElement('script');
  script.setAttribute('type', 'text/javascript');
  script.setAttribute('src', url);
  document.getElementsByTagName('head').item(0).appendChild(script);
}

function check_cf() {
	if(window.submit_is_red &amp;&amp; !submit_pressed) {
		return "Your changes are not saved!";
	}
}

function doOnload()
{
	var root = window.addEventListener || window.attachEvent ? window : document.addEventListener ? document : null;
	var layer;

	(function($) {
		$(window)
			.on('resize', doOnresize)
			.on('scroll', doOnscroll);
	}(jQuery));

	if(typeof positionMenus == "function")
		positionMenus();

	// fix for story id 11445509 - FFox likes to autocomplete remembered passwords
	var pwelement = root.document.getElementById('currentPassword');
	if (browser == 'FFox' &amp;&amp; (pwelement) )
		root.document.getElementById('currentPassword').value = "";

	if(typeof handleContainerResize == "function")
		handleContainerResize();
}

function getBounds(element)
{
	var left = element.offsetLeft;
	var top = element.offsetTop;
	for (var parent = element.offsetParent; parent; parent = parent.offsetParent)
	{
		left += parent.offsetLeft - parent.scrollLeft;
		top += parent.offsetTop - parent.scrollTop;
	}

	return {left: left, top: top, width: element.offsetWidth, height: element.offsetHeight};
}

submit_is_red = false;
submit_pressed = false;

function redSubmit()
{
	if(submit_is_red==false)
	{
		var buttons = $('#top_submit');

		if (buttons.length &gt; 0)
		{
			handleContainerResize();
		}

		buttons = buttons.add('#bottom_submit, #savebutton, .focus-save-button');
		buttons.addClass('RedSubmit').addClass('active');

		// Submit cannot be red if the submit does not exist!
		if (buttons.length) {
			submit_is_red = true;
		}
	}
}

function synchronizeFields(obj) {
	return 1;
}

function _doOnresize()
{
	if(!window.resizeTimeBuffer) {
		return;
	}

	/**************************************Handle ListOutput Window Resize**************************************************/
	if(window.resizeTimeBuffer) {
		resizeTimeBuffer(); //buffered container resize
	}

	doOnload();
	doOnscroll();
}

var _doOnresizeTimer;
function doOnresize() {
	clearTimeout(_doOnresizeTimer);
	_doOnresizeTimer = setTimeout("_doOnresize()", 100);
}

var unlocking = false;

var old_modcat = false;
var opened = false;

function doOnBodyClick()
{
	if(old_modcat!=false &amp;&amp; opened==false)
	{
		old_modcat.style.backgroundPosition = "0px 0px";
		old_modcat.style.backgroundColor = "";
		old_modcat.style.color = "#212121";
		jQuery(old_modcat.childNodes[0].childNodes[0]).css('display', 'none');
		old_modcat = false;
	}
	opened = false;
}

function doOnscroll()
{
	if(browser=="IE")
	{
		var rh=(document.body.offsetHeight-parseInt($('.site-content').get(0).currentStyle.top,10))+"px";
		jQuery('.site-content').css('height', rh );
	}
	return true;
}

function getLeft(column_number)
{
	return true;
}

function getTop(row_number)
{
	var y = 0;
	if(document.layers)
		y = document.layers['LOy'+row_number].pageY;
	else if(document.all || document.getElementById)
	{
		var cell = document.all ? document.all['LOy'+row_number] : document.getElementById('LOy'+row_number);
		while(cell)
		{
			y += cell.offsetTop;
			cell = cell.offsetParent;
		}
	}
	return y-6;
}

function getListTop()
{
	return true;
}

function getListBottom(column_number)
{
	return true;
}

var runPutFocus = true;

function putFocus()
{
	var i, l, element;
	if(document.forms.length &gt; 0 &amp;&amp; runPutFocus==true)
	{
		// we don't want this function to do anything if it's being called a second time (for instance if a hidden field is clicked)
		runPutFocus = false;
		if(document.getElementById("red_button_form"))
		{
			with(document.getElementById('red_button_form'))
			{
				for(i=0;i&lt;length;i++)
				{
					element = elements[i];
					if(!element.attributes['nored'] || element.attributes['nored'].value!='nored')
					{
						if(element.type == "checkbox" || element.type == "radio")
						{
							element.prioronclick = element.onclick;
							element.onclick = function()
							{
								var ret = true;
								if(this.prioronclick)
									ret = this.prioronclick();

								redSubmit();
								return ret;
							};
							element.prioronkeypress = element.onkeypress;
							element.onkeypress = function()
							{
								var ret = true;
								if(this.prioronkeypress)
								{
									ret = this.prioronkeypress();
								}
								redSubmit();
								return ret;
							};
						}
						else
						{
							element.prioronchange = element.onchange;
							element.onchange = function()
							{
								var ret = true;
								if(this.prioronchange)
								{
									ret = this.prioronchange();
								}
								redSubmit();
								return ret;
							};
						}
					}
				}
			}
		}
		(function( $ ) {
				var $autofocus = $('.site-content :input[autofocus]').first();

				if($autofocus.length) {
					$autofocus.focus();

					return;
				}

				var inputs = $('.site-content :input').not('.clickable, [name="LO_search"], .newdate, .datetime, .date, .time, .nofocus').filter(':visible');
				var windowHeight = window.innerHeight;
				var windowWidth = window.innerWidth;
				var offset;

				for(var i = 0, l = inputs.length; i &lt; l; ++i) {
					var input = inputs[i];

					// Make sure the input is visible
					var offset = $(input).offset();
					if(offset.top &gt; windowHeight || offset.left &gt; windowWidth) {
						continue;
					}

					if(input.type === 'text' || input.tagName === 'select') {
						input.focus();
						break;
					}
					else if(input.tagName === 'SWIFT-BOX') {
						$(input).swiftbox('focus');
						break;
					}
				}
		})( jQuery );
	}
}

function getWindowHeight()
{
	if(window.innerHeight)
		return window.innerHeight;
	else if(document.documentElement &amp;&amp; document.documentElement.clientHeight)
		 return document.documentElement.clientHeight;
	else if(document.body)
		 return document.body.clientHeight;
}

function getWindowWidth()
{
	if(window.innerWidth)
		return window.innerWidth;
	else if(document.documentElement &amp;&amp; document.documentElement.clientWidth)
		 return document.documentElement.clientWidth;
	else if(document.body)
		return document.body.clientWidth;
}

function addHTML(html,id,replace)
{
	if(locked!=false)
	{
		var $elements = $('[id="' + id + '"]');

		$elements.each(function(i, element) {
			if(replace==true)
				element.innerHTML = html;
			else
				element.innerHTML = element.innerHTML + html;

			if(!unlocking)
			{
				//check to make sure we are not in a legacy listoutput, if we are only do container resize
				if($(element).closest('.lo_table').attr('id') == 'legacy_table')
				{
					handleContainerResize();
					handleContainerResize();
				}
				else
				{
					onClickResize(document.getElementById(id));
				}
			}
		});
	}
}

function changeHTML(show,hide)
{
	for(key in show)
		document.getElementById(key).innerHTML = document.getElementById(show[key]).innerHTML;
	for(i=0;i&lt;hide.length;i++)
		document.getElementById(hide[i]).innerHTML = '';
}

function checkAll(form,value,name_like)
{
	if(value==true)
		checked = true;
	else
		checked = false;

	for(i=0;i&lt;form.elements.length;i++)
	{
		if(form.elements[i].type=='checkbox' &amp;&amp;
		   form.elements[i].name!='controller' &amp;&amp;
		   form.elements[i].name.indexOf(name_like) == 0 &amp;&amp;
		   form.elements[i].disabled == false)
		   {
				form.elements[i].checked = checked;
			}
	}
}

function checkChildren(id,self,name_like)
{
	var ObjectRange = document.getElementById(id);

	inputItems = ObjectRange.getElementsByTagName('input');

	for (i=0;i&lt;inputItems.length;i++)
	{
		if(inputItems[i].type=='checkbox' &amp;&amp; inputItems[i].disabled == false)
		{
			if (name_like != false)
			{
				if (inputItems[i].name.indexOf(name_like) != -1)
				{
					if (inputItems[i].checked == true)
						inputItems[i].checked = self.checked;
					else
				 		inputItems[i].checked = self.checked;
				}
			}
			else
			{
				if (inputItems[i].checked == true)
					inputItems[i].checked = self.checked;
				else
			 		inputItems[i].checked = self.checked;
			}

		}
	}
}


function replaceAll(haystack,needle,replacement)
{
	haystack = haystack.replace(needle,replacement);
	if(haystack.match(needle))
		haystack = replaceAll(haystack,needle,replacement);
	return haystack;
}

function switchMenu(id, time, $context)
{
	if(isNaN(time))
		time = 300;

	if(typeof $context=='undefined')
		$context = $('body');

	var $arrow = $context.find('#'+id+'_arrow');
	if($context.find('#'+id).css('display')=='none')
	{
		if($arrow.length &gt; 0)
			$arrow.attr('src','assets/arrow_down.gif');
		$context.find('#'+id).slideDown((time - 100), function(){handleContainerResize();});
	}
	else
	{
		if($arrow.length &gt; 0 )
			$arrow.attr('src','assets/arrow_right.gif');

		$context.find('#'+id).slideUp(time, function(){handleContainerResize();});


	}
	if(typeof positionMenus == "function")
		positionMenus();
}

function switchMenuClass(tmp_class, time, $context)
{
	if(isNaN(time))
		time = 300;

	if(typeof $context=='undefined')
		$context = $('body');

	var $arrow = $context.find('.'+tmp_class+'_arrow');
	if($context.find('.'+tmp_class).css('display')=='none')
	{
		if($arrow.length &gt; 0)
			$arrow.attr('src','assets/arrow_down.gif');
		$context.find('.'+tmp_class).slideDown((time - 100), function(){handleContainerResize();});
	}
	else
	{
		if($arrow.length &gt; 0 )
			$arrow.attr('src','assets/arrow_right.gif');

		$context.find('.'+tmp_class).slideUp(time, function(){handleContainerResize();});


	}
	if(typeof positionMenus == "function")
		positionMenus();
}

function setSI(id,value)
{
	if (unlocking) {
		return true;
	}

	id = id.replace(/\[/g, "\\[").replace(/\]/g, "\\]");
	$('#' + id).val(value);
}

function addOptions(id, values)
{
	var parentElement = document.getElementById(id).parentElement;
	var id = id.replace(/\[/g, "\\[").replace(/\]/g, "\\]");
	var $element = $('#' + id);
	if ($element.hasClass('swiftbox')) {
		$element.swiftbox('addOptions', values, null);
	} else {
		values.forEach(function (value) {
			$element.append($('&lt;option&gt;&lt;/option&gt;')
				.val(value.value)
				.text(value.text));
		});
	}
	onClickResize(parentElement);
}

var single_quote = "'";
var double_quote = '``';

function hl_cb(cb)
{
	if(browser!="IE")
	{
		cb.checked=!cb.checked;
		hilite_checked(cb);
	}
}

function hilite_checked(cb, row)
{
	if(browser!="IE" &amp;&amp; false)
	{
		if(!row || row.tagName.toLowerCase()!='tr')
		{
			var i = 0;
			row = cb;
			do
			{
				row = row.parentNode;
				i++;
			} while (row.tagName.toLowerCase() != "tr" &amp;&amp; i&lt;5);
		}
		if(cb.checked)
		{
			row.className+=' hilite';
		}
		else
		{
			row.className=row.className.replace(/hilite/g,'');
		}
	}
}


function CheckAll_hilite(form,value,name_like)
{
	for(i=0;i&lt;form.elements.length;i++)
	{
		if(form.elements[i].type=='checkbox' &amp;&amp; form.elements[i].name!='controller' &amp;&amp; form.elements[i].name.substr(0,name_like.length)==name_like)
		{
			hilite_checked(form.elements[i]);
		}
	}
}

function hilite(obj)
{
	if(typeof obj == 'object')
	{
		$(obj).addClass('hilite1');
	}
	else
	{
		$('#'.obj).addClass('hilite1');
	}
}

function unlite(obj)
{
	if(typeof obj == 'object')
	{
		$(obj).removeClass('hilite1');
	}
	else
	{
		$('#'.obj).removeClass('hilite1');
	}
}

function enable_input(input, cb)
{
	document.getElementById(input).disabled = cb.checked;
}

function enable_all_inputs(form, name_like, enable)
{
	for(i=0;i&lt;form.elements.length;i++)
	{
		if((form.elements[i].type=='select-one' || form.elements[i].type=='checkbox' || form.elements[i].type=='text' || form.elements[i].type=='radio' ) &amp;&amp; form.elements[i].name.substr(0,name_like.length)==name_like)
		{
			form.elements[i].disabled = !enable;
		}
	}
}

function add_benchmark_card_longer_comments(form, name_like, value, replace)
{
	for(i=0;i&lt;form.elements.length;i++)
	{
		if((form.elements[i].type=='textarea') &amp;&amp; form.elements[i].name!='controller' &amp;&amp; form.elements[i].name.indexOf(name_like)!=-1)//substr(0,name_like.length)==name_like)
		{
			if(replace)
			{
				form.elements[i].value = value;
			}
			else
			{
				form.elements[i].value+=value;
			}
		}
	}
}


function Delete_file(Upload_file_field_id,FileID,log_field_name)
{
	if(confirm('Are you sure you want to delete file?'))
	{
		if(document.student)
		{
			document.student.action = document.student.action + '&amp;log_field_name='+log_field_name+ '&amp;DeleteFileOK=1&amp;FileID=' + FileID + '&amp;Upload_file_field_id=' + Upload_file_field_id;
			document.student.submit();
		}
		if(document.user)
		{
			document.user.action = document.user.action +'&amp;log_field_name='+log_field_name+  '&amp;DeleteFileOK=1&amp;FileID=' + FileID + '&amp;Upload_file_field_id=' + Upload_file_field_id;
			document.user.submit();
		}
		if(document.school)
		{
			_submitSchoolForm('save'+'&amp;log_field_name='+log_field_name+  '&amp;DeleteFileOK=1&amp;FileID=' + FileID + '&amp;Upload_file_field_id=' + Upload_file_field_id);
		}
		if(document.intervention)
		{
			document.intervention.action = document.intervention.action + '&amp;log_field_name='+log_field_name+ '&amp;DeleteFileOK=1&amp;FileID=' + FileID + '&amp;Upload_file_field_id=' + Upload_file_field_id;
			document.intervention.submit();
		}
		if (document.referral_add_form)
		{
			document.referral_add_form.action = document.referral_add_form.action + '&amp;log_field_name='+log_field_name+ '&amp;DeleteFileOK=1&amp;FileID=' + FileID + '&amp;Upload_file_field_id=' + Upload_file_field_id;
			document.referral_add_form.submit();
		}
	}
}

function prepare_OI_Fields()
{
	var OI_FIELDS_ARR = new Array();
	var OI_TABLE = $('#fields').parent();
	var OI_FIELDS_OBJ = OI_TABLE.children("tr");
	var FIELD_ID = 1;
	var complex_fnum = 0;
	OI_FIELDS_ARR["FIELDS"] = new Array();

	var object_nums = OI_FIELDS_OBJ.length;
	var i=0;

	$.each(OI_FIELDS_OBJ,function(){

		rows = $(this);
		cells = rows.children("td");

		if(cells.length == 1)
		{
			//Holder fields
			if(cells.text() != "" &amp;&amp; cells.children("table").length == 0)
			{
				index = cells.text().trim().toLowerCase().replace(/\s/g,"_");

				if(typeof(OI_FIELDS_ARR[index]) == "undefined")
				{
					OI_FIELDS_ARR[index] = new Array();
					OI_FIELDS_ARR[index][0] = new Array();
					OI_FIELDS_ARR[index][0]["object"] = rows;
					OI_FIELDS_ARR[index][0]["text"] = cells.text();
					OI_FIELDS_ARR[index][0]["FIELD_ID"] = FIELD_ID;
					OI_FIELDS_ARR[index][0]["TYPE"] = "PARENT";
				}
				else
				{
					OI_FIELDS_ARR[index][OI_FIELDS_ARR[index].length] = new Array();
					OI_FIELDS_ARR[index][OI_FIELDS_ARR[index].length]['object'] = rows;
					OI_FIELDS_ARR[index][OI_FIELDS_ARR[index].length]['text'] = cells.text();
					OI_FIELDS_ARR[index]["FIELD_ID"] = FIELD_ID;
					OI_FIELDS_ARR[index][OI_FIELDS_ARR[index].length]["TYPE"] = "PARENT";
				}

				FIELD_ID++;
			}//Logging fields
			else if(cells.children("table").length &gt; 0)
			{
				//index = cells.children().eq(0).text().trim().toLowerCase().replace(/\s/g,"_");
				index = cells.children("table").eq(0).text().trim().toLowerCase().replace(/\s/g,"_");

				complex_fnum++;
				OI_FIELDS_ARR["FIELDS"][complex_fnum] = new Array();
				OI_FIELDS_ARR["FIELDS"][complex_fnum]["object"] = rows;
				OI_FIELDS_ARR["FIELDS"][complex_fnum]["TYPE"] = "COMPLEX";
				OI_FIELDS_ARR["FIELDS"][complex_fnum]["PARENT_ID"] = (FIELD_ID-1);
				OI_FIELDS_ARR["FIELDS"][complex_fnum]["name"] = index;
			}
		}
		else if(cells.length == 2 &amp;&amp; (i+4) &lt; object_nums)
		{
			index = cells.eq(0).text().trim().toLowerCase().replace(/\s\*/g,"");
			index = index.replace(/\s/g,"_");

			complex_fnum++;
			OI_FIELDS_ARR["FIELDS"][complex_fnum] = new Array();
			OI_FIELDS_ARR["FIELDS"][complex_fnum]["object"] = rows;
			OI_FIELDS_ARR["FIELDS"][complex_fnum]["TYPE"] = "SIMPLE";
			OI_FIELDS_ARR["FIELDS"][complex_fnum]["PARENT_ID"] = (FIELD_ID-1);
			OI_FIELDS_ARR["FIELDS"][complex_fnum]["name"] = index;
		}

		i++;
	});

	return OI_FIELDS_ARR;
	//RFS Logic
	//OI_getRows(OI_FIELDS_ARR,"evaluation","COMPLEX");
	//console.log("OI_FIELDS_ARR Ready");
}

function OI_getRows(stack,index,type)
{
	var rows = new Array();
	var parentStack = stack[index];
	var internal_index = 0;

	if(parentStack.length == 1)
	{
		parent_id = parentStack[0]["FIELD_ID"];
		rows[internal_index] = parentStack[0];
		internal_index++;
	}
	else
		alert("Write processing for multiple holder fields");

	if(type != 'PARENT')
	{
		$.each(stack['FIELDS'],function(i){

			if(this["PARENT_ID"] == parent_id)
			{
				if(type == "ALL" || type == this["TYPE"])
				{
					rows[internal_index] = this;
					internal_index++
				}
			}
		});
	}

	return rows;
}

function OI_getRow(stack,index,rowName,type)
{
	var rows = new Array();
	var parent_id = stack[index][0]['FIELD_ID'];
	var internal_index = 0;
	var name = rowName.toLowerCase().replace(/\s/g,"_");

	rows[internal_index] = stack[index][0];
	internal_index++;

	$.each(stack['FIELDS'],function(){
		if(this["PARENT_ID"] == parent_id &amp;&amp; this["name"].indexOf(name) &gt; -1)
		{
			if(type == "ALL" || type == this["TYPE"])
			{
				rows[internal_index] = this;
				internal_index++;
			}
		}
	});

	return rows;
}

function togglePageContentFullScreen(img)
{
	$(document.documentElement).toggleClass('site-layout-hidden');
	$('.site-menu-container').toggleClass('hidden');
	$('.focus-menu').toggleClass('hidden');

	lo_box = jQuery(img).parents('.listoutputbox').first();

	if(lo_box.css('position') == 'fixed')
		lo_box.css({'position':'','width':'','z-index':'','height':'', 'top':'', 'left':''});
	else
		lo_box.css({'position':'fixed','width':'100%','z-index':'5000','height':'100%', 'top':'0px', 'left':'0'});

	handleContainerHeightResize(lo_box.find('.lo_container').first());
}

//shift menu buttons over if they break page width
jQuery(window).on('load', function() {
	setMenuOffsets();

	jQuery('#Page_Content').css('overflow-y', 'auto');

	jQuery('TD[class="SelectedTopTab"]').click(function(){openModcat(this);});
	jQuery('TD[class="SelectedTopTab"]').mouseover(function(){openRollover(this);});
	jQuery('TD[class="UnselectedTopTab"]').click(function(){openModcat(this);});
	jQuery('TD[class="UnselectedTopTab"]').mouseover(function(){openRollover(this);});

	if(browser != 'IE')
	{
		jQuery('.lo_table:not(.highlight_disabled) TBODY&gt;TR.lo_row').on('mouseover', function(){
			LOSetRowClass(jQuery(this), "hilite1", true);
		});

		jQuery('.lo_table TBODY&gt;TR.lo_row').on('mouseout', function(){
			LOSetRowClass(jQuery(this), "hilite1", false);
		});
	}

});


/**
 * Given a row in a ListOutput table, add or remove the specified class to the row itself, and corresponding
 * rows in the other panes.
 *
 * @param row a jQuery object containing a ListOutput tr
 * @param clazz the class to add or remove
 * @param state true to add the class, false to remove
 */
function LOSetRowClass(row, clazz, state) {
	var class_attr = row.attr('id').replace(' ','.');
	if (class_attr != '' &amp;&amp; class_attr != undefined &amp;&amp; class_attr != null)
	{
		var index = row.closest("TABLE.lo_table&gt;TBODY").children('TR.lo_row').index(row);
		if(row.closest('#legacy_table').length != 0)
		{
			if(state)
				row.addClass(clazz);
			else
				row.removeClass(clazz);
		}
		else
		{
			row.closest('.lo_container').find("#center_container, #left_container, #right_container").children("TABLE.lo_table").children("TBODY").each(function()
			{
				if (state) {
					jQuery(this).children("TR.lo_row").eq(index).children("TD:not([rowspan])").addClass(clazz);
				} else {
					jQuery(this).children("TR.lo_row").eq(index).children("TD:not([rowspan])").removeClass(clazz);
				}
			});
		}
	}
}
function setMenuOffsets()
{
	var left = 0;
	var body_pos = jQuery("#BodyDivContainer").offset();
	if(body_pos != undefined)
		left = body_pos.left;
	var window_width = jQuery("#BodyDivContainer").width() + left;
	var offset = "-1px";

	var Page_Content_Height = jQuery('#Page_Content').height();
	jQuery(".Top_Menu_Hidden").each(function(index, html)
	{
		//set the div to be hidden but displayed so that we can calculate width and pos
		jQuery(this).css("visibility", "visible");
		jQuery(this).show();
		//set all the positions back to left aligned to get an accurate account of how far off the page they display
		jQuery(this).css('right', '');
		jQuery(this).css('left', '-1px');

		//get position and width
		var position = jQuery(this).offset();
		var width = jQuery(this).find(".Top_Menu_Dropdown_UL").width();

		//if object pushes off the side of the page, swap it to be right aligned
		if((position.left + width) &gt; window_width)
		{
			jQuery(this).css('right', '1px');
			jQuery(this).css('left', '');
		}
		jQuery(this).height(jQuery(this).find(".Top_Menu_Dropdown_UL").outerHeight(true));

		if(jQuery(this).find(".Top_Menu_Dropdown_UL").height() &gt; Page_Content_Height)
		{
			jQuery(this).height(Page_Content_Height-2);
			jQuery(this).css("overflow", "auto");

			if(browser == "IE")
			{
				var drop_down_width = jQuery(this).find(".Top_Menu_Dropdown_UL").width();
				jQuery(this).find(".Top_Menu_Dropdown_UL").width(drop_down_width);
				jQuery(this).find("#iframe_cover").css({"width" : width, "height" : jQuery(this).find(".Top_Menu_Dropdown_UL").height()});
				jQuery(this).width(drop_down_width + 20);
				jQuery(this).css({'overflow-x' : 'hidden'});
			}
			else
			{
				jQuery(this).width('');
				jQuery(this).width(jQuery(this).find(".Top_Menu_Dropdown_UL").outerWidth(true)+15);
			}
		}
		else
		{
			jQuery(this).width(jQuery(this).find(".Top_Menu_Dropdown_UL").outerWidth(true)-2);
		}
		//if IE, draw a iframe below the dropdown and set it's width and height equal to it to fix select box hack
		//reset the style of display
		jQuery(this).css("visibility", "visible");
		jQuery(this).hide();

	});

}

// This will one day replace addHTML()
function inputReplace(element)
{
	$(element).removeClass('clickable');

	var jsonObject = $(element).data('html');
	if(!jsonObject)
		return;
	var input;
	var inputs = new Array;

	switch(jsonObject.tag)
	{
		case "input":
			if(jsonObject.elements)
			{
				input = new Array();
				for(var i in jsonObject.elements)
				{
					inputs.push(createInput(element, jsonObject.elements[i]));
				}
			}
			else
			{
				input = createInput(element, jsonObject);
			}
			break;

		case "select":
			input = createSelect(element, jsonObject);
			break;

		case "multi-select":
			input = createMultiSelect(element, jsonObject);
			break;

		case "textarea":
			input = createTextarea(element, jsonObject);
			break;

		case "weekdays":
			inputs = createWeekDays(element, jsonObject);
			element.style.width="200px";
			break;
	}
	if(inputs.length &gt; 0)
	{
		for(var i in inputs)
		{
			jQuery(element).append(inputs[i]);
		}
		$(inputs.slice(0)).focus();
	}
	else
	{
		jQuery(element).append(input);
		$(input).focus();
	}
}

function createInput(element, jsonObject) {
	const input   = document.createElement('input');
	const type    = jsonObject.type;
	let tmp_value = type === 'password' ? jsonObject.value : $(element).text();

	if(jsonObject.attributes) {
		handleAttributes(input, jsonObject);
	}

	input
		.setAttribute('type', type)
		.setAttribute('value', tmp_value);

	element.innerHTML = "";

	if(jsonObject.label)
	{
		var l = document.createElement('label');
		l.setAttribute('for', jsonObject.attributes['id'])
		for(var i in jsonObject.label.attributes)
		{
			l.setAttribute(i, jsonObject.label.attributes[i]);
		}
		switch(jsonObject.label['pos'])
		{
			case 'top':
				l.innerHTML=jsonObject.label['text'] + '&lt;BR&gt;';
				l.appendChild(input);
				break;
			case 'left':
				l.innerHTML=jsonObject.label['text'];
				l.appendChild(input);
				break;
			case 'bottom':
				l.appendChild(input);
				l.innerHTML += '&lt;BR&gt;'+jsonObject.label['text'];
				break;
			case 'right':
			default:
				l.appendChild(input);
				l.innerHTML+=jsonObject.label['text'];
				break;
		}
		return l;
	}
	return input;
}

function createTextarea(element, jsonObject)
{
	var input = document.createElement('textarea');
	if(jsonObject.attributes)
	{
		for(var i in jsonObject.attributes)
		{
			input.setAttribute(i, jsonObject.attributes[i]);
		}
	}
	input.innerHTML = element.innerHTML;
	element.innerHTML = "";
	return input;
}

function createSelect(element, jsonObject)
{

	var o_values = select_options_values[jsonObject.key];
	var o_displays = select_options_displays[jsonObject.key]
	var o_optgroups = select_options_optgroups[jsonObject.key]
	var input = document.createElement('select');
	for(var index in o_values)
	{
		//handle optGroups
		if(typeof(o_values[index]) == 'object')
		{
			var optGroup = document.createElement('optgroup');
			optGroup.setAttribute('LABEL', o_optgroups[index])
			for(var index2 in o_values[index])
			{
				var option = document.createElement('option');
				option.setAttribute('VALUE', o_values[index][index2]);
				option.innerHTML = o_displays[index][index2];
				if(element.innerHTML == o_displays[index][index2])
					option.setAttribute('selected','selected');

				optGroup.appendChild(option);
			}
			input.appendChild(optGroup);
			continue;
		}
		var option = document.createElement('option');
		option.setAttribute('VALUE', o_values[index]);
		option.innerHTML = o_displays[index];
		if(element.innerHTML == o_displays[index])
			option.setAttribute('selected','selected');
		input.appendChild(option);
	}
	element.innerHTML = "";
	return input;
}

function createMultiSelect(element, jsonObject)
{
	var options = select_options[jsonObject.key];
	var input = document.createElement('select');
	for(var value in options)
	{
		var option = document.createElement('option');
		option.setAttribute('VALUE', value);
		option.innerHTML = options[value];
		input.appendChild(option);
	}
	element.innerHTML = "";
	return input;
}

function createWeekDays(element, jsonObject)
{
	var pos;
	var id = jsonObject.attributes["name"];
	var inputs = new Array();
	var letter = new Array('U','M','T','W','H','F','S');
	var acronym = new Array('Sun','Mon','Tues','Wed','Thur','Fri','Sat');
	var full = new Array('Sunday','Monday','Tuesday','Wed','Thursday','Friday','Saturday');
	var display;
	if(jsonObject.pos)
		pos = jsonObject.pos;
	else
		pos = "bottom";
	switch(jsonObject.display)
	{
		case "full":
			display = full;
			break;
		case "acro":
			display = acronym;
			break;
		case "letter":
		default:
			display = letter;
			break;
	}
	for(i in jsonObject.checked)
	{
		var checked = '';
		if(jsonObject.checked[i] == "T")
			checked = ',"checked":"checked"'
		new_checkbox = '{"type":"checkbox","label":{"pos":"'+pos+'","text":"'+display[i]+'","attributes":{"text-align":"center", "style":"float:left; display:inline;"}},"attributes":{"name":"input"'+checked+',"id":"'+id+'['+letter[i]+']"}}';
		new_checkbox = eval('(' + new_checkbox + ')');
		inputs.push(createInput(element, new_checkbox));
	}
	return inputs;

}

function handleAttributes(element, jsonObject)
{
	var attributes = jsonObject.attributes;
	for(var attr_name in attributes)
	{
		attr_value = attributes[attr_name];
		if(attr_name == 'style' &amp;&amp; typeof(attr_value) == 'object')
		{
			var style_str = '';
			for(var style_name in attr_value)
			{
				style_str += style_name + ':' + attr_value['style_name'] + ';';
			}
			attr_value = style_str;

		}
		element.setAttribute(attr_name, attr_value);
	}
}

jQuery(window).on('load', function() {
	jQuery(".clickable").each(function(){
		if(jQuery(this).data('html') != undefined)
			jQuery(this).click(function(){inputReplace(this);});
	});
});

/************************************************************************/

jQuery( function(){
	//Global function for showing JS error messages
	jQuery.showMessage = function(msg){
		if(jQuery('.'+msg.cssName).length == 0)
		{
			jQuery('#'+msg.target).before('&lt;div class="'+msg.cssName+'"&gt;'+msg.Text+'&lt;/div&gt;');
			jQuery('.'+msg.cssName).fadeIn(500);
		}
		else
		{
			jQuery('.'+msg.cssName).fadeOut(1);
			jQuery('.'+msg.cssName).html(msg.Text);
			jQuery('.'+msg.cssName).fadeIn(500);
		}
	};
});

/**
 * Appends hidden inputs to the 'site-session' form
 * and submits the form when deselecting a student/user from the topright.
 * @param object url_vars Data used for the form's hidden inputs.
 */
function deselectTopRight(url_vars) {
	let form = $("#site-session");

	for(let i in url_vars){
		let input = $("&lt;input type=hidden name='"+i+"' value='"+url_vars[i]+"' &gt;");
		form.append(input);
	}

	form.submit();
}

//ajax call to save customize listoutput columns
function saveCustomizeColumns(element)
{
	var values = $(element).find(".customize_column").serialize();
	console.log($(element).find(".customize_column").serialize());
	$.post(
		"Modules.php?modname=misc/CustomizeColumns.php&amp;_FOCUS_PDF=true"
		,values
		,function(data, textStatus){
				var r=confirm("You have changed the listoutput columns display. Changes will take effect on page refresh. Would you like to refresh page now?");
				if(r==true)
					location.reload();
			}
		,"json"
	);
}

//jCaret - Manipulates the caret in a textfield - http://www.examplet.buss.hk/jquery/caret.php
(function(k,e,i,j){k.fn.caret=function(b,l){var a,c,f=this[0],d=k.browser.msie;if(typeof b==="object"&amp;&amp;typeof b.start==="number"&amp;&amp;typeof b.end==="number"){a=b.start;c=b.end}else if(typeof b==="number"&amp;&amp;typeof l==="number"){a=b;c=l}else if(typeof b==="string")if((a=f.value.indexOf(b))&gt;-1)c=a+b[e];else a=null;else if(Object.prototype.toString.call(b)==="[object RegExp]"){b=b.exec(f.value);if(b!=null){a=b.index;c=a+b[0][e]}}if(typeof a!="undefined"){if(d){d=this[0].createTextRange();d.collapse(true);
d.moveStart("character",a);d.moveEnd("character",c-a);d.select()}else{this[0].selectionStart=a;this[0].selectionEnd=c}this[0].focus();return this}else{if(d){c=document.selection;if(this[0].tagName.toLowerCase()!="textarea"){d=this.val();a=c[i]()[j]();a.moveEnd("character",d[e]);var g=a.text==""?d[e]:d.lastIndexOf(a.text);a=c[i]()[j]();a.moveStart("character",-d[e]);var h=a.text[e]}else{a=c[i]();c=a[j]();c.moveToElementText(this[0]);c.setEndPoint("EndToEnd",a);g=c.text[e]-a.text[e];h=g+a.text[e]}}else{g=
f.selectionStart;h=f.selectionEnd}a=f.value.substring(g,h);return{start:g,end:h,text:a,replace:function(m){return f.value.substring(0,g)+m+f.value.substring(h,f.value[e])}}}}})(jQuery,"length","createRange","duplicate");

(function($) {
 	$(document).ready(function(){
		$('.verticalAlignDiv').css('left', ($(window).width()/2)-($('.verticalAlignDiv').width()/2));
	});
}(jQuery));

//Showing and hiding computed field search terms
(function ($) {
	$('.expand_computedfield_terms').find('a').on('click', function () {
		var $this = $(this), $terms = $('.expand_computedfield_terms').find('.computedfield_terms');
		if ($terms.is(':visible')) {
			$this.text('Show..');
			$terms.hide(500);
		}
		else {
			$this.text('Hide');
			$terms.show(500);
		}
	});
})( jQuery );

(function ($) {
	$(document).on('focus', 'button.clickable', function() {
		var $parent = $(this).parent().parent();
		$(this).trigger('click');
		$parent.find(':input').first().focus();
	});
})( jQuery );

//functions for opening tests
function popitup(url) {
	$('#Ajax_Loading').show();
	//refresh window on refocus
	$(window).focus(function(){javascript:location.reload(true);});
	var params  = 'width='+screen.width;
	params += ', height='+screen.width;
	params += ', scrollbars=1, resize=0';
	newwindow=window.open(url,'name',params);
	if (window.focus) {newwindow.focus()}
		return false;
}

function lockdown_open()
{
	$('#Ajax_Loading').show();
	$('body').append('&lt;div id="lockdown_please_wait" style="position:absolute;top:50%;width:100%;color:#CCC;text-align:center;z-index:2000;"&gt;&lt;h1&gt;Please Wait...&lt;/h1&gt;&lt;/div&gt;')
	//refresh window on refocus

	var show_lockdown_download;
	var window_lockdown_reload = function() {
		clearTimeout(show_lockdown_download);
		$(window).focus(function(){javascript:location.reload(true);});
	};
	$(window).bind('blur', window_lockdown_reload);
	show_lockdown_download = setTimeout(function(){show_lockdown_browser_window()},3000,window_lockdown_reload);
}

function show_lockdown_browser_window(window_lockdown_reload) {
	$(window).unbind('blur', window_lockdown_reload);
	$('&lt;div title="Plugin Missing" style="text-align:center;"&gt;'+
	'This test requires you to install Focus Lockdown Browser. Choose the appropriate link below to install the plugin. After the installation, click the test to load. &lt;BR /&gt;&lt;BR /&gt;'+
	'&lt;TABLE style="width:100%"&gt;&lt;TR&gt;'+
	'&lt;TH style="width:50%;text-align:center;"&gt;&lt;a href="lockdown/Resources/Focus_Lockdown_Browser_Student_Edition.exe"&gt;&lt;img src="assets/windows.jpg"&gt;&lt;BR&gt;PC&lt;/a&gt;&lt;/TH&gt;'+
	'&lt;TH style="width:50%;text-align:center;"&gt;&lt;a href="lockdown/Resources/Focus_Lockdown_Browser.pkg"&gt;&lt;img src="assets/mac.png"&gt;&lt;BR&gt;Mac&lt;/a&gt;&lt;/TH&gt;'+
	'&lt;/TR&gt;&lt;/div&gt;').appendTo('body').dialog({width:500,height:200, zIndex:2500,
		close:function(ui, e) {
			$('#Ajax_Loading').hide();
			$('#lockdown_please_wait').remove();
		}
	});
}

function dynascanNotInstalled()
{
	$('&lt;div title="Plugin Missing" style="text-align:center;"&gt;'+
	'The plugin to run your scanner from Focus is not installed. Choose the appropriate link below to install the plugin. After the installation, please RESTART your browser.&lt;BR&gt;'+
	'&lt;TABLE style="width:100%"&gt;&lt;TR&gt;'+
	'&lt;TH style="width:50%;text-align:center;"&gt;&lt;a href="dynascan/Resources/DynamicWebTWAINPlugIn.msi"&gt;&lt;img src="assets/windows.jpg"&gt;&lt;BR&gt;PC&lt;/a&gt;&lt;/TH&gt;'+
	'&lt;TH style="width:50%;text-align:center;"&gt;&lt;a href="dynascan/Resources/DynamicWebTWAINMacEdition.pkg"&gt;&lt;img src="assets/mac.png"&gt;&lt;BR&gt;Mac&lt;/a&gt;&lt;/TH&gt;'+
	'&lt;/TR&gt;&lt;/div&gt;').appendTo('body').dialog({
		modal:true,
		resizable:false,
		draggable:false,
		buttons:{ Close:function(){$(this).dialog('destroy').remove();} }
	});
}

function dynascanNotEnabled()
{
	$('&lt;div title="Permission Error" style="text-align:center;"&gt;'+
	'You have not granted permissions for the Focus scanner plugin to operate. When prompted please select always allow and reload page.'+
	'&lt;/div&gt;').appendTo('body').dialog({
		modal:true,
		resizable:false,
		draggable:false,
		buttons:{ Close:function(){$(this).dialog('destroy').remove();} }
	});
}

function validateDateRange($this, formattedDate) {
	var elementsToTrigger = [];
	var result            = [];
	var type              = $this[0].hasAttribute("date-end")
		? "end"
		: (($this[0].hasAttribute("date-start"))
			? "start"
			: false);
	result["result"]      = true;

	if (type &amp;&amp; $this.attr("date-range-link")) {
		var otherType = (type === "end") ? "start" : "end";
		var link      = $this.attr("date-range-link");
		var $parent   = ($this.closest(".dataTable-row").length) ? $this.closest(".dataTable-row") : $this.closest("form");
		var good      = true;

		$parent.find(".date").each(function() {
			var $elem = $(this);

			if ($elem[0].hasAttribute("date-" + otherType) &amp;&amp; $elem.attr("date-range-link") === link &amp;&amp; $elem.val()) {
				var elemDate  = moment($elem.val()).format("YYYY-MM-DD");
				good          = (formattedDate)
					? ((type === "end")
						? formattedDate &gt;= elemDate
						: formattedDate &lt;= elemDate)
					: true;

				if ($elem.hasClass("invalid")) {
					elementsToTrigger.push($elem);
				}
			}
		});

		result["result"] = good || !formattedDate;
	}

	result["elements"] = elementsToTrigger;

	return result;
}


function StudentSearchModal(callback, passthru_data, searches) {
	SearchModal('Students/SearchInput.php', callback, passthru_data, searches);
}

function UserSearchModal(callback, passthru_data, searches) {
	SearchModal('Users/SearchInput.php', callback, passthru_data, searches);
}


//javascript function for creating modal that works with SearchInput.php
function SearchModal(module, callback, passthru_data, searches) {
	//handle null search data
	if(searches == null)
		searches = [];

	//only let one search term window be open
	if($("#student_search_popup").length) {
		return false;
	}
	let src = 'Modules.php?modname='+module+'&amp;include_top=false'+
			  '&amp;callback='+callback.name+'&amp;passthru_data='+encodeURIComponent(JSON.stringify(passthru_data));


	student_search_popup_modal = Focus.modal(
		`&lt;div&gt;
			&lt;div id="loading_search_terms" class="focus-modal animate"&gt;
				&lt;div id="loading_search_terms_label"&gt;Loading Search Module&lt;/div&gt;
				&lt;div class="focus-modal-overlay"&gt;&lt;/div&gt;
			&lt;/div&gt;
			&lt;iframe id="student_search_popup" width=800 height=550 style="border:none;visibility:hidden;" src='${src}'&gt;&lt;/iframe&gt;
		&lt;/div&gt;`);

	let progressbar_css = `z-index:2;margin:auto;width:100%;position:absolute;top:53%;overflow:hidden;`;
	//load indeterminate progres bar while page is loading
	$('#loading_search_terms', window.parent.document).append(`&lt;div id=progressbar style="${progressbar_css}"&gt;&lt;/div&gt;`);
	$progressbar = $("#loading_search_terms #progressbar", window.parent.document).progressbar({value:false});
	$progressbar.css({background:'url("assets/overlay.png")'});

	$("#student_search_popup").on('load', function() {
		var $ = this.contentWindow.jQuery;

		$(function() {
			$('.site-content').css({overflow:'hidden'});
			$('#menu_visiblesearch a:visible').click();
			$('div[id^="fields_"],.EntireBox').toggle();


			$.iterate(searches, function(name, value) {
				if(value instanceof Array) {
					recursiveSet(name, value, false)
				}
				else if(value instanceof Object) {
					recursiveSet(name, value, true);
				}
				else if(searches[name] != ''){
					if( $(`:checkbox[name="${name}"][value="${value}"]`).length) {
						var $cb = $(`:checkbox[name="${name}"][value="${value}"]`);
						$cb.prop('checked', true);
						$cb[0].dispatchEvent(new Event('change', { bubbles: true }));
					} else if ( $(`.swiftbox[data-swift-box-name="${name}"]`).length) {
						var sb = $(`.swiftbox[data-swift-box-name="${name}"]`);
						var new_value = searches[name];

						//check the swiftbox so if the value saved in the search
						//is the text display replace it with what the current value is
						var sb_options = sb.swiftbox('options');
						for(var index in sb_options) {
							if(new_value === sb_options[index].value)
								break;
							if(new_value === sb_options[index].text ) {
								new_value = sb_options[index].value;
								break;
							}
						}

						if(sb.prop('multiple')) {
							var existing_values = sb.val()||[];
							existing_values.push(new_value);
							sb.val(existing_values);
						} else {
							var val = new_value||"";
							sb.val(val);
						}
						sb[0].dispatchEvent(new Event('change', { bubbles: true }));
					} else {
						$input =  $(`:input[name="${name}"]`)
						if(!$input.length) {
							$input = $(`:input[name^="${name}]"][value="${value}"]`);
							$input.prop('checked', true);
						}
						else {
							//handle date
							if($input.parent().hasClass('dateContainer')) {
								$input = $input.parent().find('.date').first();
								try {
									searches[name] = moment(searches[name]).format($input.attr('data-format'));
								} catch(e){console.log(e);}
							}

							//make sure we are not changing the value of checkbox/radio button
							if($input.prop('type').toLowerCase().indexOf('checkbox', 'radio') &lt; 0) {
								$input.val(searches[name]).trigger('change');
							}
						}
					}
				}
			},
			{
				start:function(total) {
					$('#loading_search_terms_label',  window.parent.document).html('Loading Search Terms');
					//destroy indeterminate progress bar and load determinate progressbar
					$progressbar.progressbar({value:undefined,max:total});
					$progressbar.css({background:''});
					$progressbar.find( ".ui-progressbar-value" ).css({background:"#F66",alpha:1.0});
				},
				time:0,
				each:function(index, total){ if(index &lt;= total) $progressbar.progressbar({value:(index)}); },
				complete:function(){
					$progressbar.progressbar("destroy").remove();
					$('div[id^="fields_"],.EntireBox').toggle();
					$('#student_search_popup', window.parent.document).attr('style', 'border:none;');
					$('#loading_search_terms',window.parent.document).remove();
				}
			});

			function recursiveSet(baseName, searches, use_name) {
				for( name in searches) {
					if(searches[name] instanceof Array) {
						recursiveSet(baseName+'['+(use_name?name:'')+']', searches[name], false)
					}
					else if(searches[name] instanceof Object) {
						recursiveSet(baseName+'['+(use_name?name:'')+']', searches[name], true)
					} else if(searches[name] != '') {
						if( $(`:checkbox[name="${baseName}[${(use_name?name:'')}]"][value="${searches[name]}"]`).length) {
							var $cb = $(`:checkbox[name="${baseName}[${(use_name?name:'')}]"][value="${searches[name]}"]`);
							$cb.prop('checked', true);
							$cb[0].dispatchEvent(new Event('change', { bubbles: true }));
						} else if( $(`.swiftbox[data-swift-box-name="${baseName}[${(use_name?name:'')}]"]`).length ) {
							var sb =  $(`.swiftbox[data-swift-box-name="${baseName}[${(use_name?name:'')}]"]`);
							var new_value = searches[name];

							//check the swiftbox so if the value saved in the search
							//is the text display replace it with what the current value is
							var sb_options = sb.swiftbox('options');
							for(var index in sb_options) {
								if(new_value === sb_options[index].value)
									break;
								if(new_value === sb_options[index].text ) {
									new_value = sb_options[index].value;
									break;
								}
							}

							if(sb.prop('multiple')) {
								var existing_values = sb.val()||[];
								existing_values.push(new_value);
								sb.val(existing_values);
							} else {
								var val = new_value||"";
								sb.val(val);
							}
							sb[0].dispatchEvent(new Event('change', { bubbles: true }));
						} else {
							$input =  $(`:input[name="${baseName}[${(use_name?name:'')}]"]`);
							if(!$input.length) {
								$input = $(`:input[name^="${baseName}[${(use_name?name:'')}]"][value="${searches[name]}"]`);
								$input.prop('checked', true);
							}
							else {
								//handle date
								if($input.parent().hasClass('dateContainer')) {
									$input = $input.parent().find('.date').first();
									try{
										searches[name] = moment(searches[name]).format($input.attr('data-format'));
									} catch(e){console.log(e);}
								}

								//make sure we are not chaning the value of checkbox/radio button
								if($input.prop('type').toLowerCase().indexOf('checkbox', 'radio') &lt; 0)
								{
									$input.val(searches[name]).trigger('change');
								}
							}
						}
					}
				}
			}
		});
	});
}
window.knockoutModules = {};
</pre></body></html>