PageSourceSearch

https://hmbcdirect.com/wp-content/plugins/mortgage-calculators-wp/assets/js/bundle.js?ver=1784576992

js hmbcdirect.com collected 2026-09-29 08:55:26 UTC 133,142 bytes, 3,371 lines download raw bytes

1(function ($) {
2	"use strict";
3	function getElementSelection(that) {
4		var position = {};
5		if (that.selectionStart === undefined) {
6			that.focus();
7			var select = document.selection.createRange();
8			position.length = select.text.length;
9			select.moveStart("character", -that.value.length);
10			position.end = select.text.length;
11			position.start = position.end - position.length;
12		} else {
13			position.start = that.selectionStart;
14			position.end = that.selectionEnd;
15			position.length = position.end - position.start;
16		}
17		return position;
18	}
19	function setElementSelection(that, start, end) {
20		if (that.selectionStart === undefined) {
21			that.focus();
22			var r = that.createTextRange();
23			r.collapse(true);
24			r.moveEnd("character", end);
25			r.moveStart("character", start);
26			r.select();
27		} else {
28			that.selectionStart = start;
29			that.selectionEnd = end;
30		}
31	}
32	function runCallbacks($this, settings) {
33		$.each(settings, function (k, val) {
34			if (typeof val === "function") {
35				settings[k] = val($this, settings, k);
36			} else if (typeof $this.autoNumeric[val] === "function") {
37				settings[k] = $this.autoNumeric[val]($this, settings, k);
38			}
39		});
40	}
41	function convertKeyToNumber(settings, key) {
42		if (typeof settings[key] === "string") {
43			settings[key] *= 1;
44		}
45	}
46	function autoCode($this, settings) {
47		runCallbacks($this, settings);
48		settings.oEvent = null;
49		settings.tagList = ["b", "caption", "cite", "code", "dd", "del", "div", "dfn", "dt", "em", "h1", "h2", "h3", "h4", "h5", "h6", "ins", "kdb", "label", "li", "output", "p", "q", "s", "sample", "span", "strong", "td", "th", "u", "var"];
50		var vmax = settings.vMax.toString().split("."),
51			vmin = !settings.vMin && settings.vMin !== 0 ? [] : settings.vMin.toString().split(".");
52		convertKeyToNumber(settings, "vMax");
53		convertKeyToNumber(settings, "vMin");
54		convertKeyToNumber(settings, "mDec");
55		settings.mDec = settings.mRound === "CHF" ? "2" : settings.mDec;
56		settings.allowLeading = true;
57		settings.aNeg = settings.vMin < 0 ? "-" : "";
58		vmax[0] = vmax[0].replace("-", "");
59		vmin[0] = vmin[0].replace("-", "");
60		settings.mInt = Math.max(vmax[0].length, vmin[0].length, 1);
61		if (settings.mDec === null) {
62			var vmaxLength = 0,
63				vminLength = 0;
64			if (vmax[1]) {
65				vmaxLength = vmax[1].length;
66			}
67			if (vmin[1]) {
68				vminLength = vmin[1].length;
69			}
70			settings.mDec = Math.max(vmaxLength, vminLength);
71		}
72		if (settings.altDec === null && settings.mDec > 0) {
73			if (settings.aDec === "." && settings.aSep !== ",") {
74				settings.altDec = ",";
75			} else if (settings.aDec === "," && settings.aSep !== ".") {
76				settings.altDec = ".";
77			}
78		}
79		var aNegReg = settings.aNeg ? "([-\\" + settings.aNeg + "]?)" : "(-?)";
80		settings.aNegRegAutoStrip = aNegReg;
81		settings.skipFirstAutoStrip = new RegExp(aNegReg + "[^-" + (settings.aNeg ? "\\" + settings.aNeg : "") + "\\" + settings.aDec + "\\d]" + ".*?(\\d|\\" + settings.aDec + "\\d)");
82		settings.skipLastAutoStrip = new RegExp("(\\d\\" + settings.aDec + "?)[^\\" + settings.aDec + "\\d]\\D*$");
83		var allowed = "-" + settings.aNum + "\\" + settings.aDec;
84		settings.allowedAutoStrip = new RegExp("[^" + allowed + "]", "gi");
85		settings.numRegAutoStrip = new RegExp(aNegReg + "(?:\\" + settings.aDec + "?(\\d+\\" + settings.aDec + "\\d+)|(\\d*(?:\\" + settings.aDec + "\\d*)?))");
86		return settings;
87	}
88	function autoStrip(s, settings, strip_zero) {
89		if (settings.aSign) {
90			while (s.indexOf(settings.aSign) > -1) {
91				s = s.replace(settings.aSign, "");
92			}
93		}
94		s = s.replace(settings.skipFirstAutoStrip, "$1$2");
95		s = s.replace(settings.skipLastAutoStrip, "$1");
96		s = s.replace(settings.allowedAutoStrip, "");
97		if (settings.altDec) {
98			s = s.replace(settings.altDec, settings.aDec);
99		}
100		var m = s.match(settings.numRegAutoStrip);
101		s = m ? [m[1], m[2], m[3]].join("") : "";
102		if ((settings.lZero === "allow" || settings.lZero === "keep") && strip_zero !== "strip") {
103			var parts = [],
104				nSign = "";
105			parts = s.split(settings.aDec);
106			if (parts[0].indexOf("-") !== -1) {
107				nSign = "-";
108				parts[0] = parts[0].replace("-", "");
109			}
110			if (parts[0].length > settings.mInt && parts[0].charAt(0) === "0") {
111				parts[0] = parts[0].slice(1);
112			}
113			s = nSign + parts.join(settings.aDec);
114		}
115		if ((strip_zero && settings.lZero === "deny") || (strip_zero && settings.lZero === "allow" && settings.allowLeading === false)) {
116			var strip_reg = "^" + settings.aNegRegAutoStrip + "0*(\\d" + (strip_zero === "leading" ? ")" : "|$)");
117			strip_reg = new RegExp(strip_reg);
118			s = s.replace(strip_reg, "$1$2");
119		}
120		return s;
121	}
122	function negativeBracket(s, nBracket, oEvent) {
123		nBracket = nBracket.split(",");
124		if (oEvent === "set" || oEvent === "focusout") {
125			s = s.replace("-", "");
126			s = nBracket[0] + s + nBracket[1];
127		} else if ((oEvent === "get" || oEvent === "focusin" || oEvent === "pageLoad") && s.charAt(0) === nBracket[0]) {
128			s = s.replace(nBracket[0], "-");
129			s = s.replace(nBracket[1], "");
130		}
131		return s;
132	}
133	function truncateDecimal(s, aDec, mDec) {
134		if (aDec && mDec) {
135			var parts = s.split(aDec);
136			if (parts[1] && parts[1].length > mDec) {
137				if (mDec > 0) {
138					parts[1] = parts[1].substring(0, mDec);
139					s = parts.join(aDec);
140				} else {
141					s = parts[0];
142				}
143			}
144		}
145		return s;
146	}
147	function fixNumber(s, aDec, aNeg) {
148		if (aDec && aDec !== ".") {
149			s = s.replace(aDec, ".");
150		}
151		if (aNeg && aNeg !== "-") {
152			s = s.replace(aNeg, "-");
153		}
154		if (!s.match(/\d/)) {
155			s += "0";
156		}
157		return s;
158	}
159	function checkValue(value, settings) {
160		if (value) {
161			var checkSmall = +value;
162			if (checkSmall < 1e-6 && checkSmall > -1) {
163				value = +value;
164				if (value < 1e-6 && value > 0) {
165					value = (value + 10).toString();
166					value = value.substring(1);
167				}
168				if (value < 0 && value > -1) {
169					value = (value - 10).toString();
170					value = "-" + value.substring(2);
171				}
172				value = value.toString();
173			} else {
174				var parts = value.split(".");
175				if (parts[1] !== undefined) {
176					if (+parts[1] === 0) {
177						value = parts[0];
178					} else {
179						parts[1] = parts[1].replace(/0*$/, "");
180						value = parts.join(".");
181					}
182				}
183			}
184		}
185		return settings.lZero === "keep" ? value : value.replace(/^0*(\d)/, "$1");
186	}
187	function presentNumber(s, aDec, aNeg) {
188		if (aNeg && aNeg !== "-") {
189			s = s.replace("-", aNeg);
190		}
191		if (aDec && aDec !== ".") {
192			s = s.replace(".", aDec);
193		}
194		return s;
195	}
196	function autoCheck(s, settings) {
197		s = autoStrip(s, settings);
198		s = truncateDecimal(s, settings.aDec, settings.mDec);
199		s = fixNumber(s, settings.aDec, settings.aNeg);
200		var value = +s;
201		if (settings.oEvent === "set" && (value < settings.vMin || value > settings.vMax)) {
202			$.error("The value (" + value + ") from the 'set' method falls outside of the vMin / vMax range");
203		}
204		return value >= settings.vMin && value <= settings.vMax;
205	}
206	function checkEmpty(iv, settings, signOnEmpty) {
207		if (iv === "" || iv === settings.aNeg) {
208			if (settings.wEmpty === "zero") {
209				return iv + "0";
210			}
211			if (settings.wEmpty === "sign" || signOnEmpty) {
212				return iv + settings.aSign;
213			}
214			return iv;
215		}
216		return null;
217	}
218	function autoGroup(iv, settings) {
219		iv = autoStrip(iv, settings);
220		var testNeg = iv.replace(",", "."),
221			empty = checkEmpty(iv, settings, true);
222		if (empty !== null) {
223			return empty;
224		}
225		var digitalGroup = "";
226		if (settings.dGroup === 2) {
227			digitalGroup = /(\d)((\d)(\d{2}?)+)$/;
228		} else if (settings.dGroup === 4) {
229			digitalGroup = /(\d)((\d{4}?)+)$/;
230		} else {
231			digitalGroup = /(\d)((\d{3}?)+)$/;
232		}
233		var ivSplit = iv.split(settings.aDec);
234		if (settings.altDec && ivSplit.length === 1) {
235			ivSplit = iv.split(settings.altDec);
236		}
237		var s = ivSplit[0];
238		if (settings.aSep) {
239			while (digitalGroup.test(s)) {
240				s = s.replace(digitalGroup, "$1" + settings.aSep + "$2");
241			}
242		}
243		if (settings.mDec !== 0 && ivSplit.length > 1) {
244			if (ivSplit[1].length > settings.mDec) {
245				ivSplit[1] = ivSplit[1].substring(0, settings.mDec);
246			}
247			iv = s + settings.aDec + ivSplit[1];
248		} else {
249			iv = s;
250		}
251		if (settings.aSign) {
252			var has_aNeg = iv.indexOf(settings.aNeg) !== -1;
253			iv = iv.replace(settings.aNeg, "");
254			iv = settings.pSign === "p" ? settings.aSign + iv : iv + settings.aSign;
255			if (has_aNeg) {
256				iv = settings.aNeg + iv;
257			}
258		}
259		if (settings.oEvent === "set" && testNeg < 0 && settings.nBracket !== null) {
260			iv = negativeBracket(iv, settings.nBracket, settings.oEvent);
261		}
262		return iv;
263	}
264	function autoRound(iv, settings) {
265		iv = iv === "" ? "0" : iv.toString();
266		convertKeyToNumber(settings, "mDec");
267		if (settings.mRound === "CHF") {
268			iv = (Math.round(iv * 20) / 20).toString();
269		}
270		var ivRounded = "",
271			i = 0,
272			nSign = "",
273			rDec = typeof settings.aPad === "boolean" || settings.aPad === null ? (settings.aPad ? settings.mDec : 0) : +settings.aPad;
274		var truncateZeros = function (ivRounded) {
275			var regex = rDec === 0 ? /(\.(?:\d*[1-9])?)0*$/ : rDec === 1 ? /(\.\d(?:\d*[1-9])?)0*$/ : new RegExp("(\\.\\d{" + rDec + "}(?:\\d*[1-9])?)0*$");
276			ivRounded = ivRounded.replace(regex, "$1");
277			if (rDec === 0) {
278				ivRounded = ivRounded.replace(/\.$/, "");
279			}
280			return ivRounded;
281		};
282		if (iv.charAt(0) === "-") {
283			nSign = "-";
284			iv = iv.replace("-", "");
285		}
286		if (!iv.match(/^\d/)) {
287			iv = "0" + iv;
288		}
289		if (nSign === "-" && +iv === 0) {
290			nSign = "";
291		}
292		if ((+iv > 0 && settings.lZero !== "keep") || (iv.length > 0 && settings.lZero === "allow")) {
293			iv = iv.replace(/^0*(\d)/, "$1");
294		}
295		var dPos = iv.lastIndexOf("."),
296			vdPos = dPos === -1 ? iv.length - 1 : dPos,
297			cDec = iv.length - 1 - vdPos;
298		if (cDec <= settings.mDec) {
299			ivRounded = iv;
300			if (cDec < rDec) {
301				if (dPos === -1) {
302					ivRounded += ".";
303				}
304				var zeros = "000000";
305				while (cDec < rDec) {
306					zeros = zeros.substring(0, rDec - cDec);
307					ivRounded += zeros;
308					cDec += zeros.length;
309				}
310			} else if (cDec > rDec) {
311				ivRounded = truncateZeros(ivRounded);
312			} else if (cDec === 0 && rDec === 0) {
313				ivRounded = ivRounded.replace(/\.$/, "");
314			}
315			if (settings.mRound !== "CHF") {
316				return +ivRounded === 0 ? ivRounded : nSign + ivRounded;
317			}
318			if (settings.mRound === "CHF") {
319				dPos = ivRounded.lastIndexOf(".");
320				iv = ivRounded;
321			}
322		}
323		var rLength = dPos + settings.mDec,
324			tRound = +iv.charAt(rLength + 1),
325			ivArray = iv.substring(0, rLength + 1).split(""),
326			odd = iv.charAt(rLength) === "." ? iv.charAt(rLength - 1) % 2 : iv.charAt(rLength) % 2,
327			onePass = true;
328		if (odd !== 1) {
329			odd = odd === 0 && iv.substring(rLength + 2, iv.length) > 0 ? 1 : 0;
330		}
331		if (
332			(tRound > 4 && settings.mRound === "S") ||
333			(tRound > 4 && settings.mRound === "A" && nSign === "") ||
334			(tRound > 5 && settings.mRound === "A" && nSign === "-") ||
335			(tRound > 5 && settings.mRound === "s") ||
336			(tRound > 5 && settings.mRound === "a" && nSign === "") ||
337			(tRound > 4 && settings.mRound === "a" && nSign === "-") ||
338			(tRound > 5 && settings.mRound === "B") ||
339			(tRound === 5 && settings.mRound === "B" && odd === 1) ||
340			(tRound > 0 && settings.mRound === "C" && nSign === "") ||
341			(tRound > 0 && settings.mRound === "F" && nSign === "-") ||
342			(tRound > 0 && settings.mRound === "U") ||
343			settings.mRound === "CHF"
344		) {
345			for (i = ivArray.length - 1; i >= 0; i -= 1) {
346				if (ivArray[i] !== ".") {
347					if (settings.mRound === "CHF" && ivArray[i] <= 2 && onePass) {
348						ivArray[i] = 0;
349						onePass = false;
350						break;
351					}
352					if (settings.mRound === "CHF" && ivArray[i] <= 7 && onePass) {
353						ivArray[i] = 5;
354						onePass = false;
355						break;
356					}
357					if (settings.mRound === "CHF" && onePass) {
358						ivArray[i] = 10;
359						onePass = false;
360					} else {
361						ivArray[i] = +ivArray[i] + 1;
362					}
363					if (ivArray[i] < 10) {
364						break;
365					}
366					if (i > 0) {
367						ivArray[i] = "0";
368					}
369				}
370			}
371		}
372		ivArray = ivArray.slice(0, rLength + 1);
373		ivRounded = truncateZeros(ivArray.join(""));
374		return +ivRounded === 0 ? ivRounded : nSign + ivRounded;
375	}
376	function AutoNumericHolder(that, settings) {
377		this.settings = settings;
378		this.that = that;
379		this.$that = $(that);
380		this.formatted = false;
381		this.settingsClone = autoCode(this.$that, this.settings);
382		this.value = that.value;
383	}
384	AutoNumericHolder.prototype = {
385		init: function (e) {
386			this.value = this.that.value;
387			this.settingsClone = autoCode(this.$that, this.settings);
388			this.ctrlKey = e.ctrlKey;
389			this.cmdKey = e.metaKey;
390			this.shiftKey = e.shiftKey;
391			this.selection = getElementSelection(this.that);
392			if (e.type === "keydown" || e.type === "keyup") {
393				this.kdCode = e.keyCode;
394			}
395			this.which = e.which;
396			this.processed = false;
397			this.formatted = false;
398		},
399		setSelection: function (start, end, setReal) {
400			start = Math.max(start, 0);
401			end = Math.min(end, this.that.value.length);
402			this.selection = { start: start, end: end, length: end - start };
403			if (setReal === undefined || setReal) {
404				setElementSelection(this.that, start, end);
405			}
406		},
407		setPosition: function (pos, setReal) {
408			this.setSelection(pos, pos, setReal);
409		},
410		getBeforeAfter: function () {
411			var value = this.value,
412				left = value.substring(0, this.selection.start),
413				right = value.substring(this.selection.end, value.length);
414			return [left, right];
415		},
416		getBeforeAfterStriped: function () {
417			var parts = this.getBeforeAfter();
418			parts[0] = autoStrip(parts[0], this.settingsClone);
419			parts[1] = autoStrip(parts[1], this.settingsClone);
420			return parts;
421		},
422		normalizeParts: function (left, right) {
423			var settingsClone = this.settingsClone;
424			right = autoStrip(right, settingsClone);
425			var strip = right.match(/^\d/) ? true : "leading";
426			left = autoStrip(left, settingsClone, strip);
427			if ((left === "" || left === settingsClone.aNeg) && settingsClone.lZero === "deny") {
428				if (right > "") {
429					right = right.replace(/^0*(\d)/, "$1");
430				}
431			}
432			var new_value = left + right;
433			if (settingsClone.aDec) {
434				var m = new_value.match(new RegExp("^" + settingsClone.aNegRegAutoStrip + "\\" + settingsClone.aDec));
435				if (m) {
436					left = left.replace(m[1], m[1] + "0");
437					new_value = left + right;
438				}
439			}
440			if (settingsClone.wEmpty === "zero" && (new_value === settingsClone.aNeg || new_value === "")) {
441				left += "0";
442			}
443			return [left, right];
444		},
445		setValueParts: function (left, right) {
446			var settingsClone = this.settingsClone,
447				parts = this.normalizeParts(left, right),
448				new_value = parts.join(""),
449				position = parts[0].length;
450			if (autoCheck(new_value, settingsClone)) {
451				new_value = truncateDecimal(new_value, settingsClone.aDec, settingsClone.mDec);
452				if (position > new_value.length) {
453					position = new_value.length;
454				}
455				this.value = new_value;
456				this.setPosition(position, false);
457				return true;
458			}
459			return false;
460		},
461		signPosition: function () {
462			var settingsClone = this.settingsClone,
463				aSign = settingsClone.aSign,
464				that = this.that;
465			if (aSign) {
466				var aSignLen = aSign.length;
467				if (settingsClone.pSign === "p") {
468					var hasNeg = settingsClone.aNeg && that.value && that.value.charAt(0) === settingsClone.aNeg;
469					return hasNeg ? [1, aSignLen + 1] : [0, aSignLen];
470				}
471				var valueLen = that.value.length;
472				return [valueLen - aSignLen, valueLen];
473			}
474			return [1e3, -1];
475		},
476		expandSelectionOnSign: function (setReal) {
477			var sign_position = this.signPosition(),
478				selection = this.selection;
479			if (selection.start < sign_position[1] && selection.end > sign_position[0]) {
480				if ((selection.start < sign_position[0] || selection.end > sign_position[1]) && this.value.substring(Math.max(selection.start, sign_position[0]), Math.min(selection.end, sign_position[1])).match(/^\s*$/)) {
481					if (selection.start < sign_position[0]) {
482						this.setSelection(selection.start, sign_position[0], setReal);
483					} else {
484						this.setSelection(sign_position[1], selection.end, setReal);
485					}
486				} else {
487					this.setSelection(Math.min(selection.start, sign_position[0]), Math.max(selection.end, sign_position[1]), setReal);
488				}
489			}
490		},
491		checkPaste: function () {
492			if (this.valuePartsBeforePaste !== undefined) {
493				var parts = this.getBeforeAfter(),
494					oldParts = this.valuePartsBeforePaste;
495				delete this.valuePartsBeforePaste;
496				parts[0] = parts[0].substr(0, oldParts[0].length) + autoStrip(parts[0].substr(oldParts[0].length), this.settingsClone);
497				if (!this.setValueParts(parts[0], parts[1])) {
498					this.value = oldParts.join("");
499					this.setPosition(oldParts[0].length, false);
500				}
501			}
502		},
503		skipAllways: function (e) {
504			var kdCode = this.kdCode,
505				which = this.which,
506				ctrlKey = this.ctrlKey,
507				cmdKey = this.cmdKey,
508				shiftKey = this.shiftKey;
509			if (((ctrlKey || cmdKey) && e.type === "keyup" && this.valuePartsBeforePaste !== undefined) || (shiftKey && kdCode === 45)) {
510				this.checkPaste();
511				return false;
512			}
513			if ((kdCode >= 112 && kdCode <= 123) || (kdCode >= 91 && kdCode <= 93) || (kdCode >= 9 && kdCode <= 31) || (kdCode < 8 && (which === 0 || which === kdCode)) || kdCode === 144 || kdCode === 145 || kdCode === 45) {
514				return true;
515			}
516			if ((ctrlKey || cmdKey) && kdCode === 65) {
517				return true;
518			}
519			if ((ctrlKey || cmdKey) && (kdCode === 67 || kdCode === 86 || kdCode === 88)) {
520				if (e.type === "keydown") {
521					this.expandSelectionOnSign();
522				}
523				if (kdCode === 86 || kdCode === 45) {
524					if (e.type === "keydown" || e.type === "keypress") {
525						if (this.valuePartsBeforePaste === undefined) {
526							this.valuePartsBeforePaste = this.getBeforeAfter();
527						}
528					} else {
529						this.checkPaste();
530					}
531				}
532				return e.type === "keydown" || e.type === "keypress" || kdCode === 67;
533			}
534			if (ctrlKey || cmdKey) {
535				return true;
536			}
537			if (kdCode === 37 || kdCode === 39) {
538				var aSep = this.settingsClone.aSep,
539					start = this.selection.start,
540					value = this.that.value;
541				if (e.type === "keydown" && aSep && !this.shiftKey) {
542					if (kdCode === 37 && value.charAt(start - 2) === aSep) {
543						this.setPosition(start - 1);
544					} else if (kdCode === 39 && value.charAt(start + 1) === aSep) {
545						this.setPosition(start + 1);
546					}
547				}
548				return true;
549			}
550			if (kdCode >= 34 && kdCode <= 40) {
551				return true;
552			}
553			return false;
554		},
555		processAllways: function () {
556			var parts;
557			if (this.kdCode === 8 || this.kdCode === 46) {
558				if (!this.selection.length) {
559					parts = this.getBeforeAfterStriped();
560					if (this.kdCode === 8) {
561						parts[0] = parts[0].substring(0, parts[0].length - 1);
562					} else {
563						parts[1] = parts[1].substring(1, parts[1].length);
564					}
565					this.setValueParts(parts[0], parts[1]);
566				} else {
567					this.expandSelectionOnSign(false);
568					parts = this.getBeforeAfterStriped();
569					this.setValueParts(parts[0], parts[1]);
570				}
571				return true;
572			}
573			return false;
574		},
575		processKeypress: function () {
576			var settingsClone = this.settingsClone,
577				cCode = String.fromCharCode(this.which),
578				parts = this.getBeforeAfterStriped(),
579				left = parts[0],
580				right = parts[1];
581			if (cCode === settingsClone.aDec || (settingsClone.altDec && cCode === settingsClone.altDec) || ((cCode === "." || cCode === ",") && this.kdCode === 110)) {
582				if (!settingsClone.mDec || !settingsClone.aDec) {
583					return true;
584				}
585				if (settingsClone.aNeg && right.indexOf(settingsClone.aNeg) > -1) {
586					return true;
587				}
588				if (left.indexOf(settingsClone.aDec) > -1) {
589					return true;
590				}
591				if (right.indexOf(settingsClone.aDec) > 0) {
592					return true;
593				}
594				if (right.indexOf(settingsClone.aDec) === 0) {
595					right = right.substr(1);
596				}
597				this.setValueParts(left + settingsClone.aDec, right);
598				return true;
599			}
600			if (cCode === "-" || cCode === "+") {
601				if (!settingsClone.aNeg) {
602					return true;
603				}
604				if (left === "" && right.indexOf(settingsClone.aNeg) > -1) {
605					left = settingsClone.aNeg;
606					right = right.substring(1, right.length);
607				}
608				if (left.charAt(0) === settingsClone.aNeg) {
609					left = left.substring(1, left.length);
610				} else {
611					left = cCode === "-" ? settingsClone.aNeg + left : left;
612				}
613				this.setValueParts(left, right);
614				return true;
615			}
616			if (cCode >= "0" && cCode <= "9") {
617				if (settingsClone.aNeg && left === "" && right.indexOf(settingsClone.aNeg) > -1) {
618					left = settingsClone.aNeg;
619					right = right.substring(1, right.length);
620				}
621				if (settingsClone.vMax <= 0 && settingsClone.vMin < settingsClone.vMax && this.value.indexOf(settingsClone.aNeg) === -1 && cCode !== "0") {
622					left = settingsClone.aNeg + left;
623				}
624				this.setValueParts(left + cCode, right);
625				return true;
626			}
627			return true;
628		},
629		formatQuick: function () {
630			var settingsClone = this.settingsClone,
631				parts = this.getBeforeAfterStriped(),
632				leftLength = this.value;
633			if ((settingsClone.aSep === "" || (settingsClone.aSep !== "" && leftLength.indexOf(settingsClone.aSep) === -1)) && (settingsClone.aSign === "" || (settingsClone.aSign !== "" && leftLength.indexOf(settingsClone.aSign) === -1))) {
634				var subParts = [],
635					nSign = "";
636				subParts = leftLength.split(settingsClone.aDec);
637				if (subParts[0].indexOf("-") > -1) {
638					nSign = "-";
639					subParts[0] = subParts[0].replace("-", "");
640					parts[0] = parts[0].replace("-", "");
641				}
642				if (subParts[0].length > settingsClone.mInt && parts[0].charAt(0) === "0") {
643					parts[0] = parts[0].slice(1);
644				}
645				parts[0] = nSign + parts[0];
646			}
647			var value = autoGroup(this.value, this.settingsClone),
648				position = value.length;
649			if (value) {
650				var left_ar = parts[0].split(""),
651					i = 0;
652				for (i; i < left_ar.length; i += 1) {
653					if (!left_ar[i].match("\\d")) {
654						left_ar[i] = "\\" + left_ar[i];
655					}
656				}
657				var leftReg = new RegExp("^.*?" + left_ar.join(".*?"));
658				var newLeft = value.match(leftReg);
659				if (newLeft) {
660					position = newLeft[0].length;
661					if (((position === 0 && value.charAt(0) !== settingsClone.aNeg) || (position === 1 && value.charAt(0) === settingsClone.aNeg)) && settingsClone.aSign && settingsClone.pSign === "p") {
662						position = this.settingsClone.aSign.length + (value.charAt(0) === "-" ? 1 : 0);
663					}
664				} else if (settingsClone.aSign && settingsClone.pSign === "s") {
665					position -= settingsClone.aSign.length;
666				}
667			}
668			this.that.value = value;
669			this.setPosition(position);
670			this.formatted = true;
671		},
672	};
673	function autoGet(obj) {
674		if (typeof obj === "string") {
675			obj = obj.replace(/\[/g, "\\[").replace(/\]/g, "\\]");
676			obj = "#" + obj.replace(/(:|\.)/g, "\\$1");
677		}
678		return $(obj);
679	}
680	function getHolder($that, settings, update) {
681		var data = $that.data("autoNumeric");
682		if (!data) {
683			data = {};
684			$that.data("autoNumeric", data);
685		}
686		var holder = data.holder;
687		if ((holder === undefined && settings) || update) {
688			holder = new AutoNumericHolder($that.get(0), settings);
689			data.holder = holder;
690		}
691		return holder;
692	}
693	var methods = {
694		init: function (options) {
695			return this.each(function () {
696				var $this = $(this),
697					settings = $this.data("autoNumeric"),
698					tagData = $this.data();
699				if (typeof settings !== "object") {
700					var defaults = {
701						aNum: "0123456789",
702						aSep: ",",
703						dGroup: "3",
704						aDec: ".",
705						altDec: null,
706						aSign: "",
707						pSign: "p",
708						vMax: "9999999999999.99",
709						vMin: "0.00",
710						mDec: null,
711						mRound: "S",
712						aPad: true,
713						nBracket: null,
714						wEmpty: "empty",
715						lZero: "allow",
716						aForm: true,
717						onSomeEvent: function () {},
718					};
719					settings = $.extend({}, defaults, tagData, options);
720					if (settings.aDec === settings.aSep) {
721						$.error("autoNumeric will not function properly when the decimal character aDec: '" + settings.aDec + "' and thousand separator aSep: '" + settings.aSep + "' are the same character");
722						return this;
723					}
724					$this.data("autoNumeric", settings);
725				} else {
726					return this;
727				}
728				settings.runOnce = false;
729				var holder = getHolder($this, settings);
730				if ($.inArray($this.prop("tagName").toLowerCase(), settings.tagList) === -1 && $this.prop("tagName").toLowerCase() !== "input") {
731					$.error("The <" + $this.prop("tagName").toLowerCase() + "> is not supported by autoNumeric()");
732					return this;
733				}
734				if (settings.runOnce === false && settings.aForm) {
735					if ($this.is("input[type=text], input[type=hidden], input[type=tel], input:not([type])")) {
736						var setValue = true;
737						if ($this[0].value === "" && settings.wEmpty === "empty") {
738							$this[0].value = "";
739							setValue = false;
740						}
741						if ($this[0].value === "" && settings.wEmpty === "sign") {
742							$this[0].value = settings.aSign;
743							setValue = false;
744						}
745						if (setValue) {
746							$this.autoNumeric("set", $this.val());
747						}
748					}
749					if ($.inArray($this.prop("tagName").toLowerCase(), settings.tagList) !== -1 && $this.text() !== "") {
750						$this.autoNumeric("set", $this.text());
751					}
752				}
753				settings.runOnce = true;
754				if ($this.is("input[type=text], input[type=hidden], input[type=tel], input
754:not([type])")) {
755					$this.on("keydown.autoNumeric", function (e) {
756						holder = getHolder($this);
757						if (holder.settings.aDec === holder.settings.aSep) {
758							$.error("autoNumeric will not function properly when the decimal character aDec: '" + holder.settings.aDec + "' and thousand separator aSep: '" + holder.settings.aSep + "' are the same character");
759							return this;
760						}
761						if (holder.that.readOnly) {
762							holder.processed = true;
763							return true;
764						}
765						holder.init(e);
766						holder.settings.oEvent = "keydown";
767						if (holder.skipAllways(e)) {
768							holder.processed = true;
769							return true;
770						}
771						if (holder.processAllways()) {
772							holder.processed = true;
773							holder.formatQuick();
774							e.preventDefault();
775							return false;
776						}
777						holder.formatted = false;
778						return true;
779					});
780					$this.on("keypress.autoNumeric", function (e) {
781						var holder = getHolder($this),
782							processed = holder.processed;
783						holder.init(e);
784						holder.settings.oEvent = "keypress";
785						if (holder.skipAllways(e)) {
786							return true;
787						}
788						if (processed) {
789							e.preventDefault();
790							return false;
791						}
792						if (holder.processAllways() || holder.processKeypress()) {
793							holder.formatQuick();
794							e.preventDefault();
795							return false;
796						}
797						holder.formatted = false;
798					});
799					$this.on("keyup.autoNumeric", function (e) {
800						var holder = getHolder($this);
801						holder.init(e);
802						holder.settings.oEvent = "keyup";
803						var skip = holder.skipAllways(e);
804						holder.kdCode = 0;
805						delete holder.valuePartsBeforePaste;
806						if ($this[0].value === holder.settings.aSign) {
807							if (holder.settings.pSign === "s") {
808								setElementSelection(this, 0, 0);
809							} else {
810								setElementSelection(this, holder.settings.aSign.length, holder.settings.aSign.length);
811							}
812						}
813						if (skip) {
814							return true;
815						}
816						if (this.value === "") {
817							return true;
818						}
819						if (!holder.formatted) {
820							holder.formatQuick();
821						}
822					});
823					$this.on("focusin.autoNumeric", function () {
824						var holder = getHolder($this);
825						holder.settingsClone.oEvent = "focusin";
826						if (holder.settingsClone.nBracket !== null) {
827							var checkVal = $this.val();
828							$this.val(negativeBracket(checkVal, holder.settingsClone.nBracket, holder.settingsClone.oEvent));
829						}
830						holder.inVal = $this.val();
831						var onempty = checkEmpty(holder.inVal, holder.settingsClone, true);
832						if (onempty !== null) {
833							$this.val(onempty);
834							if (holder.settings.pSign === "s") {
835								setElementSelection(this, 0, 0);
836							} else {
837								setElementSelection(this, holder.settings.aSign.length, holder.settings.aSign.length);
838							}
839						}
840					});
841					$this.on("focusout.autoNumeric", function () {
842						var holder = getHolder($this),
843							settingsClone = holder.settingsClone,
844							value = $this.val(),
845							origValue = value;
846						holder.settingsClone.oEvent = "focusout";
847						var strip_zero = "";
848						if (settingsClone.lZero === "allow") {
849							settingsClone.allowLeading = false;
850							strip_zero = "leading";
851						}
852						if (value !== "") {
853							value = autoStrip(value, settingsClone, strip_zero);
854							if (checkEmpty(value, settingsClone) === null && autoCheck(value, settingsClone, $this[0])) {
855								value = fixNumber(value, settingsClone.aDec, settingsClone.aNeg);
856								value = autoRound(value, settingsClone);
857								value = presentNumber(value, settingsClone.aDec, settingsClone.aNeg);
858							} else {
859								value = "";
860							}
861						}
862						var groupedValue = checkEmpty(value, settingsClone, false);
863						if (groupedValue === null) {
864							groupedValue = autoGroup(value, settingsClone);
865						}
866						if (groupedValue !== origValue) {
867							$this.val(groupedValue);
868						}
869						if (groupedValue !== holder.inVal) {
870							$this.change();
871							delete holder.inVal;
872						}
873						if (settingsClone.nBracket !== null && $this.autoNumeric("get") < 0) {
874							holder.settingsClone.oEvent = "focusout";
875							$this.val(negativeBracket($this.val(), settingsClone.nBracket, settingsClone.oEvent));
876						}
877					});
878				}
879			});
880		},
881		destroy: function () {
882			return $(this).each(function () {
883				var $this = $(this);
884				$this.off(".autoNumeric");
885				$this.removeData("autoNumeric");
886			});
887		},
888		update: function (options) {
889			return $(this).each(function () {
890				var $this = autoGet($(this)),
891					settings = $this.data("autoNumeric");
892				if (typeof settings !== "object") {
893					$.error("You must initialize autoNumeric('init', {options}) prior to calling the 'update' method");
894					return this;
895				}
896				var strip = $this.autoNumeric("get");
897				settings = $.extend(settings, options);
898				getHolder($this, settings, true);
899				if (settings.aDec === settings.aSep) {
900					$.error("autoNumeric will not function properly when the decimal character aDec: '" + settings.aDec + "' and thousand separator aSep: '" + settings.aSep + "' are the same character");
901					return this;
902				}
903				$this.data("autoNumeric", settings);
904				if ($this.val() !== "" || $this.text() !== "") {
905					return $this.autoNumeric("set", strip);
906				}
907				return;
908			});
909		},
910		set: function (valueIn) {
911			if (valueIn === null) {
912				return;
913			}
914			return $(this).each(function () {
915				var $this = autoGet($(this)),
916					settings = $this.data("autoNumeric"),
917					value = valueIn.toString(),
918					testValue = valueIn.toString();
919				if (typeof settings !== "object") {
920					$.error("You must initialize autoNumeric('init', {options}) prior to calling the 'set' method");
921					return this;
922				}
923				if (testValue !== $this.attr("value") && $this.prop("tagName").toLowerCase() === "input" && settings.runOnce === false) {
924					value = settings.nBracket !== null ? negativeBracket($this.val(), settings.nBracket, "pageLoad") : value;
925					value = autoStrip(value, settings);
926				}
927				if ((testValue === $this.attr("value") || testValue === $this.text()) && settings.runOnce === false) {
928					value = value.replace(",", ".");
929				}
930				if (!$.isNumeric(+value)) {
931					return "";
932				}
933				value = checkValue(value, settings);
934				settings.oEvent = "set";
935				value.toString();
936				if (value !== "") {
937					value = autoRound(value, settings);
938				}
939				value = presentNumber(value, settings.aDec, settings.aNeg);
940				if (!autoCheck(value, settings)) {
941					value = autoRound("", settings);
942				}
943				value = autoGroup(value, settings);
944				if ($this.is("input[type=text], input[type=hidden], input[type=tel], input:not([type])")) {
945					return $this.val(value);
946				}
947				if ($.inArray($this.prop("tagName").toLowerCase(), settings.tagList) !== -1) {
948					return $this.text(value);
949				}
950				$.error("The <" + $this.prop("tagName").toLowerCase() + "> is not supported by autoNumeric()");
951				return false;
952			});
953		},
954		get: function () {
955			var $this = autoGet($(this)),
956				settings = $this.data("autoNumeric");
957			if (typeof settings !== "object") {
958				$.error("You must initialize autoNumeric('init', {options}) prior to calling the 'get' method");
959				return this;
960			}
961			settings.oEvent = "get";
962			var getValue = "";
963			if ($this.is("input[type=text], input[type=hidden], input[type=tel], input:not([type])")) {
964				getValue = $this.eq(0).val();
965			} else if ($.inArray($this.prop("tagName").toLowerCase(), settings.tagList) !== -1) {
966				getValue = $this.eq(0).text();
967			} else {
968				$.error("The <" + $this.prop("tagName").toLowerCase() + "> is not supported by autoNumeric()");
969				return false;
970			}
971			if ((getValue === "" && settings.wEmpty === "empty") || (getValue === settings.aSign && (settings.wEmpty === "sign" || settings.wEmpty === "empty"))) {
972				return "";
973			}
974			if (settings.nBracket !== null && getValue !== "") {
975				getValue = negativeBracket(getValue, settings.nBracket, settings.oEvent);
976			}
977			if (settings.runOnce || settings.aForm === false) {
978				getValue = autoStrip(getValue, settings);
979			}
980			getValue = fixNumber(getValue, settings.aDec, settings.aNeg);
981			if (+getValue === 0 && settings.lZero !== "keep") {
982				getValue = "0";
983			}
984			if (settings.lZero === "keep") {
985				return getValue;
986			}
987			getValue = checkValue(getValue, settings);
988			return getValue;
989		},
990		getString: function () {
991			var isAutoNumeric = false,
992				$this = autoGet($(this)),
993				str = $this.serialize(),
994				parts = str.split("&"),
995				formIndex = $("form").index($this),
996				i = 0;
997			for (i; i < parts.length; i += 1) {
998				var miniParts = parts[i].split("="),
999					$field = $("form:eq(" + formIndex + ') input[name="' + decodeURIComponent(miniParts[0]) + '"]'),
1000					settings = $field.data("autoNumeric");
1001				if (typeof settings === "object") {
1002					if (miniParts[1] !== null) {
1003						miniParts[1] = $field.autoNumeric("get");
1004						parts[i] = miniParts.join("=");
1005						isAutoNumeric = true;
1006					}
1007				}
1008			}
1009			if (isAutoNumeric === true) {
1010				return parts.join("&");
1011			}
1012			return str;
1013		},
1014		getArray: function () {
1015			var isAutoNumeric = false,
1016				$this = autoGet($(this)),
1017				formFields = $this.serializeArray(),
1018				formIndex = $("form").index($this);
1019			$.each(formFields, function (i, field) {
1020				var $field = $("form:eq(" + formIndex + ') input[name="' + decodeURIComponent(field.name) + '"]'),
1021					settings = $field.data("autoNumeric");
1022				if (typeof settings === "object") {
1023					if (field.value !== "") {
1024						field.value = $field.autoNumeric("get").toString();
1025					}
1026					isAutoNumeric = true;
1027				}
1028			});
1029			if (isAutoNumeric === true) {
1030				return formFields;
1031			}
1032			return this;
1033		},
1034		getSettings: function () {
1035			var $this = autoGet($(this));
1036			return $this.eq(0).data("autoNumeric");
1037		},
1038	};
1039	$.fn.autoNumeric = function (method) {
1040		if (methods[method]) {
1041			return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
1042		}
1043		if (typeof method === "object" || !method) {
1044			return methods.init.apply(this, arguments);
1045		}
1046		$.error('Method "' + method + '" is not supported by autoNumeric()');
1047	};
1048})(jQuery);
1049var _typeof =
1050	typeof Symbol === "function" && typeof Symbol.iterator === "symbol"
1051		? function (obj) {
1052				return typeof obj;
1053		  }
1054		: function (obj) {
1055				return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1056		  };
1057var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(window)) === "object";
1058(function (factory) {
1059	if (typeof define === "function" && define.amd) {
1060		define(["jquery"], factory);
1061	} else if ((typeof module === "undefined" ? "undefined" : _typeof(module)) === "object" && module.exports) {
1062		var jQuery;
1063		try {
1064			jQuery = require("jquery");
1065		} catch (err) {
1066			jQuery = null;
1067		}
1068		module.exports = factory(jQuery);
1069	} else if (window) {
1070		window.Slider = factory(window.jQuery);
1071	}
1072})(function ($) {
1073	var NAMESPACE_MAIN = "slider";
1074	var NAMESPACE_ALTERNATE = "bootstrapSlider";
1075	if (windowIsDefined && !window.console) {
1076		window.console = {};
1077	}
1078	if (windowIsDefined && !window.console.log) {
1079		window.console.log = function () {};
1080	}
1081	if (windowIsDefined && !window.console.warn) {
1082		window.console.warn = function () {};
1083	}
1084	var Slider;
1085	(function ($) {
1086		"use strict";
1087		var slice = Array.prototype.slice;
1088		function noop() {}
1089		function defineBridget($) {
1090			if (!$) {
1091				return;
1092			}
1093			function addOptionMethod(PluginClass) {
1094				if (PluginClass.prototype.option) {
1095					return;
1096				}
1097				PluginClass.prototype.option = function (opts) {
1098					if (!$.isPlainObject(opts)) {
1099						return;
1100					}
1101					this.options = $.extend(true, this.options, opts);
1102				};
1103			}
1104			var logError =
1105				typeof console === "undefined"
1106					? noop
1107					: function (message) {
1108							console.error(message);
1109					  };
1110			function bridge(namespace, PluginClass) {
1111				$.fn[namespace] = function (options) {
1112					if (typeof options === "string") {
1113						var args = slice.call(arguments, 1);
1114						for (var i = 0, len = this.length; i < len; i++) {
1115							var elem = this[i];
1116							var instance = $.data(elem, namespace);
1117							if (!instance) {
1118								logError("cannot call methods on " + namespace + " prior to initialization; " + "attempted to call '" + options + "'");
1119								continue;
1120							}
1121							if (!$.isFunction(instance[options]) || options.charAt(0) === "_") {
1122								logError("no such method '" + options + "' for " + namespace + " instance");
1123								continue;
1124							}
1125							var returnValue = instance[options].apply(instance, args);
1126							if (returnValue !== undefined && returnValue !== instance) {
1127								return returnValue;
1128							}
1129						}
1130						return this;
1131					} else {
1132						var objects = this.map(function () {
1133							var instance = $.data(this, namespace);
1134							if (instance) {
1135								instance.option(options);
1136								instance._init();
1137							} else {
1138								instance = new PluginClass(this, options);
1139								$.data(this, namespace, instance);
1140							}
1141							return $(this);
1142						});
1143						if (!objects || objects.length > 1) {
1144							return objects;
1145						} else {
1146							return objects[0];
1147						}
1148					}
1149				};
1150			}
1151			$.bridget = function (namespace, PluginClass) {
1152				addOptionMethod(PluginClass);
1153				bridge(namespace, PluginClass);
1154			};
1155			return $.bridget;
1156		}
1157		defineBridget($);
1158	})($);
1159	(function ($) {
1160		var ErrorMsgs = {
1161			formatInvalidInputErrorMsg: function formatInvalidInputErrorMsg(input) {
1162				return "Invalid input value '" + input + "' passed in";
1163			},
1164			callingContextNotSliderInstance: "Calling context element does not have instance of Slider bound to it. Check your code to make sure the JQuery object returned from the call to the slider() initializer is calling the method",
1165		};
1166		var SliderScale = {
1167			linear: {
1168				toValue: function toValue(percentage) {
1169					var rawValue = (percentage / 100) * (this.options.max - this.options.min);
1170					var shouldAdjustWithBase = true;
1171					if (this.options.ticks_positions.length > 0) {
1172						var minv,
1173							maxv,
1174							minp,
1175							maxp = 0;
1176						for (var i = 1; i < this.options.ticks_positions.length; i++) {
1177							if (percentage <= this.options.ticks_positions[i]) {
1178								minv = this.options.ticks[i - 1];
1179								minp = this.options.ticks_positions[i - 1];
1180								maxv = this.options.ticks[i];
1181								maxp = this.options.ticks_positions[i];
1182								break;
1183							}
1184						}
1185						var partialPercentage = (percentage - minp) / (maxp - minp);
1186						rawValue = minv + partialPercentage * (maxv - minv);
1187						shouldAdjustWithBase = false;
1188					}
1189					var adjustment = shouldAdjustWithBase ? this.options.min : 0;
1190					var value = adjustment + Math.round(rawValue / this.options.step) * this.options.step;
1191					if (value < this.options.min) {
1192						return this.options.min;
1193					} else if (value > this.options.max) {
1194						return this.options.max;
1195					} else {
1196						return value;
1197					}
1198				},
1199				toPercentage: function toPercentage(value) {
1200					if (this.options.max === this.options.min) {
1201						return 0;
1202					}
1203					if (this.options.ticks_positions.length > 0) {
1204						var minv,
1205							maxv,
1206							minp,
1207							maxp = 0;
1208						for (var i = 0; i < this.options.ticks.length; i++) {
1209							if (value <= this.options.ticks[i]) {
1210								minv = i > 0 ? this.options.ticks[i - 1] : 0;
1211								minp = i > 0 ? this.options.ticks_positions[i - 1] : 0;
1212								maxv = this.options.ticks[i];
1213								maxp = this.options.ticks_positions[i];
1214								break;
1215							}
1216						}
1217						if (i > 0) {
1218							var partialPercentage = (value - minv) / (maxv - minv);
1219							return minp + partialPercentage * (maxp - minp);
1220						}
1221					}
1222					return (100 * (value - this.options.min)) / (this.options.max - this.options.min);
1223				},
1224			},
1225			logarithmic: {
1226				toValue: function toValue(percentage) {
1227					var min = this.options.min === 0 ? 0 : Math.log(this.options.min);
1228					var max = Math.log(this.options.max);
1229					var value = Math.exp(min + ((max - min) * percentage) / 100);
1230					if (Math.round(value) === this.options.max) {
1231						return this.options.max;
1232					}
1233					value = this.options.min + Math.round((value - this.options.min) / this.options.step) * this.options.step;
1234					if (value < this.options.min) {
1235						return this.options.min;
1236					} else if (value > this.options.max) {
1237						return this.options.max;
1238					} else {
1239						return value;
1240					}
1241				},
1242				toPercentage: function toPercentage(value) {
1243					if (this.options.max === this.options.min) {
1244						return 0;
1245					} else {
1246						var max = Math.log(this.options.max);
1247						var min = this.options.min === 0 ? 0 : Math.log(this.options.min);
1248						var v = value === 0 ? 0 : Math.log(value);
1249						return (100 * (v - min)) / (max - min);
1250					}
1251				},
1252			},
1253		};
1254		Slider = function Slider(element, options) {
1255			createNewSlider.call(this, element, options);
1256			return this;
1257		};
1258		function createNewSlider(element, options) {
1259			this._state = {
1260				value: null,
1261				enabled: null,
1262				offset: null,
1263				size: null,
1264				percentage: null,
1265				inDrag: false,
1266				over: false,
1267			};
1268			this.ticksCallbackMap = {};
1269			this.handleCallbackMap = {};
1270			if (typeof element === "string") {
1271				this.element = document.querySelector(element);
1272			} else if (element instanceof HTMLElement) {
1273				this.element = element;
1274			}
1275			options = options ? options : {};
1276			var optionTypes = Object.keys(this.defaultOptions);
1277			for (var i = 0; i < optionTypes.length; i++) {
1278				var optName = optionTypes[i];
vendor: 36,919 bytes, lines 1279-2146
1279				var val = options[optName];
1280				val = typeof val !== "undefined" ? val : getDataAttrib(this.element, optName);
1281				val = val !== null ? val : this.defaultOptions[optName];
1282				if (!this.options) {
1283					this.options = {};
1284				}
1285				this.options[optName] = val;
1286			}
1287			if (this.options.rtl === "auto") {
1288				this.options.rtl = window.getComputedStyle(this.element).direction === "rtl";
1289			}
1290			if (this.options.orientation === "vertical" && (this.options.tooltip_position === "top" || this.options.tooltip_position === "bottom")) {
1291				if (this.options.rtl) {
1292					this.options.tooltip_position = "left";
1293				} else {
1294					this.options.tooltip_position = "right";
1295				}
1296			} else if (this.options.orientation === "horizontal" && (this.options.tooltip_position === "left" || this.options.tooltip_position === "right")) {
1297				this.options.tooltip_position = "top";
1298			}
1299			function getDataAttrib(element, optName) {
1300				var dataName = "data-slider-" + optName.replace(/_/g, "-");
1301				var dataValString = element.getAttribute(dataName);
1302				try {
1303					return JSON.parse(dataValString);
1304				} catch (err) {
1305					return dataValString;
1306				}
1307			}
1308			var origWidth = this.element.style.width;
1309			var updateSlider = false;
1310			var parent = this.element.parentNode;
1311			var sliderTrackSelection;
1312			var sliderTrackLow, sliderTrackHigh;
1313			var sliderMinHandle;
1314			var sliderMaxHandle;
1315			if (this.sliderElem) {
1316				updateSlider = true;
1317			} else {
1318				this.sliderElem = document.createElement("div");
1319				this.sliderElem.className = "slider";
1320				var sliderTrack = document.createElement("div");
1321				sliderTrack.className = "slider-track";
1322				sliderTrackLow = document.createElement("div");
1323				sliderTrackLow.className = "slider-track-low";
1324				sliderTrackSelection = document.createElement("div");
1325				sliderTrackSelection.className = "slider-selection";
1326				sliderTrackHigh = document.createElement("div");
1327				sliderTrackHigh.className = "slider-track-high";
1328				sliderMinHandle = document.createElement("div");
1329				sliderMinHandle.className = "slider-handle min-slider-handle";
1330				sliderMinHandle.setAttribute("role", "slider");
1331				sliderMinHandle.setAttribute("aria-valuemin", "0");
1332				sliderMinHandle.setAttribute("aria-valuemax", this.options.max);
1333				sliderMinHandle.setAttribute("aria-label", this.options.arialabel);
1334				sliderMaxHandle = document.createElement("div");
1335				sliderMaxHandle.className = "slider-handle max-slider-handle";
1336				sliderMaxHandle.setAttribute("role", "slider");
1337				sliderMaxHandle.setAttribute("aria-valuemin", this.options.min);
1338				sliderMaxHandle.setAttribute("aria-valuemax", this.options.max);
1339				sliderTrack.appendChild(sliderTrackLow);
1340				sliderTrack.appendChild(sliderTrackSelection);
1341				sliderTrack.appendChild(sliderTrackHigh);
1342				this.rangeHighlightElements = [];
1343				var rangeHighlightsOpts = this.options.rangeHighlights;
1344				if (Array.isArray(rangeHighlightsOpts) && rangeHighlightsOpts.length > 0) {
1345					for (var j = 0; j < rangeHighlightsOpts.length; j++) {
1346						var rangeHighlightElement = document.createElement("div");
1347						var customClassString = rangeHighlightsOpts[j].class || "";
1348						rangeHighlightElement.className = "slider-rangeHighlight slider-selection " + customClassString;
1349						this.rangeHighlightElements.push(rangeHighlightElement);
1350						sliderTrack.appendChild(rangeHighlightElement);
1351					}
1352				}
1353				var isLabelledbyArray = Array.isArray(this.options.labelledby);
1354				if (isLabelledbyArray && this.options.labelledby[0]) {
1355					sliderMinHandle.setAttribute("aria-labelledby", this.options.labelledby[0]);
1356				}
1357				if (isLabelledbyArray && this.options.labelledby[1]) {
1358					sliderMaxHandle.setAttribute("aria-labelledby", this.options.labelledby[1]);
1359				}
1360				if (!isLabelledbyArray && this.options.labelledby) {
1361					sliderMinHandle.setAttribute("aria-labelledby", this.options.labelledby);
1362					sliderMaxHandle.setAttribute("aria-labelledby", this.options.labelledby);
1363				}
1364				this.ticks = [];
1365				if (Array.isArray(this.options.ticks) && this.options.ticks.length > 0) {
1366					this.ticksContainer = document.createElement("div");
1367					this.ticksContainer.className = "slider-tick-container";
1368					for (i = 0; i < this.options.ticks.length; i++) {
1369						var tick = document.createElement("div");
1370						tick.className = "slider-tick";
1371						if (this.options.ticks_tooltip) {
1372							var tickListenerReference = this._addTickListener();
1373							var enterCallback = tickListenerReference.addMouseEnter(this, tick, i);
1374							var leaveCallback = tickListenerReference.addMouseLeave(this, tick);
1375							this.ticksCallbackMap[i] = {
1376								mouseEnter: enterCallback,
1377								mouseLeave: leaveCallback,
1378							};
1379						}
1380						this.ticks.push(tick);
1381						this.ticksContainer.appendChild(tick);
1382					}
1383					sliderTrackSelection.className += " tick-slider-selection";
1384				}
1385				this.tickLabels = [];
1386				if (Array.isArray(this.options.ticks_labels) && this.options.ticks_labels.length > 0) {
1387					this.tickLabelContainer = document.createElement("div");
1388					this.tickLabelContainer.className = "slider-tick-label-container";
1389					for (i = 0; i < this.options.ticks_labels.length; i++) {
1390						var label = document.createElement("div");
1391						var noTickPositionsSpecified = this.options.ticks_positions.length === 0;
1392						var tickLabelsIndex = this.options.reversed && noTickPositionsSpecified ? this.options.ticks_labels.length - (i + 1) : i;
1393						label.className = "slider-tick-label";
1394						label.innerHTML = this.options.ticks_labels[tickLabelsIndex];
1395						this.tickLabels.push(label);
1396						this.tickLabelContainer.appendChild(label);
1397					}
1398				}
1399				var createAndAppendTooltipSubElements = function createAndAppendTooltipSubElements(tooltipElem) {
1400					var arrow = document.createElement("div");
1401					arrow.className = "tooltip-arrow";
1402					var inner = document.createElement("div");
1403					inner.className = "tooltip-inner";
1404					tooltipElem.appendChild(arrow);
1405					tooltipElem.appendChild(inner);
1406				};
1407				var sliderTooltip = document.createElement("div");
1408				sliderTooltip.className = "tooltip tooltip-main";
1409				sliderTooltip.setAttribute("role", "presentation");
1410				createAndAppendTooltipSubElements(sliderTooltip);
1411				var sliderTooltipMin = document.createElement("div");
1412				sliderTooltipMin.className = "tooltip tooltip-min";
1413				sliderTooltipMin.setAttribute("role", "presentation");
1414				createAndAppendTooltipSubElements(sliderTooltipMin);
1415				var sliderTooltipMax = document.createElement("div");
1416				sliderTooltipMax.className = "tooltip tooltip-max";
1417				sliderTooltipMax.setAttribute("role", "presentation");
1418				createAndAppendTooltipSubElements(sliderTooltipMax);
1419				this.sliderElem.appendChild(sliderTrack);
1420				this.sliderElem.appendChild(sliderTooltip);
1421				this.sliderElem.appendChild(sliderTooltipMin);
1422				this.sliderElem.appendChild(sliderTooltipMax);
1423				if (this.tickLabelContainer) {
1424					this.sliderElem.appendChild(this.tickLabelContainer);
1425				}
1426				if (this.ticksContainer) {
1427					this.sliderElem.appendChild(this.ticksContainer);
1428				}
1429				this.sliderElem.appendChild(sliderMinHandle);
1430				this.sliderElem.appendChild(sliderMaxHandle);
1431				parent.insertBefore(this.sliderElem, this.element);
1432				this.element.style.display = "none";
1433			}
1434			if ($) {
1435				this.$element = $(this.element);
1436				this.$sliderElem = $(this.sliderElem);
1437			}
1438			this.eventToCallbackMap = {};
1439			this.sliderElem.id = this.options.id;
1440			this.touchCapable = "ontouchstart" in window || (window.DocumentTouch && document instanceof window.DocumentTouch);
1441			this.touchX = 0;
1442			this.touchY = 0;
1443			this.tooltip = this.sliderElem.querySelector(".tooltip-main");
1444			this.tooltipInner = this.tooltip.querySelector(".tooltip-inner");
1445			this.tooltip_min = this.sliderElem.querySelector(".tooltip-min");
1446			this.tooltipInner_min = this.tooltip_min.querySelector(".tooltip-inner");
1447			this.tooltip_max = this.sliderElem.querySelector(".tooltip-max");
1448			this.tooltipInner_max = this.tooltip_max.querySelector(".tooltip-inner");
1449			if (SliderScale[this.options.scale]) {
1450				this.options.scale = SliderScale[this.options.scale];
1451			}
1452			if (updateSlider === true) {
1453				this._removeClass(this.sliderElem, "slider-horizontal");
1454				this._removeClass(this.sliderElem, "slider-vertical");
1455				this._removeClass(this.sliderElem, "slider-rtl");
1456				this._removeClass(this.tooltip, "hide");
1457				this._removeClass(this.tooltip_min, "hide");
1458				this._removeClass(this.tooltip_max, "hide");
1459				["left", "right", "top", "width", "height"].forEach(function (prop) {
1460					this._removeProperty(this.trackLow, prop);
1461					this._removeProperty(this.trackSelection, prop);
1462					this._removeProperty(this.trackHigh, prop);
1463				}, this);
1464				[this.handle1, this.handle2].forEach(function (handle) {
1465					this._removeProperty(handle, "left");
1466					this._removeProperty(handle, "right");
1467					this._removeProperty(handle, "top");
1468				}, this);
1469				[this.tooltip, this.tooltip_min, this.tooltip_max].forEach(function (tooltip) {
1470					this._removeProperty(tooltip, "left");
1471					this._removeProperty(tooltip, "right");
1472					this._removeProperty(tooltip, "top");
1473					this._removeClass(tooltip, "right");
1474					this._removeClass(tooltip, "left");
1475					this._removeClass(tooltip, "top");
1476				}, this);
1477			}
1478			if (this.options.orientation === "vertical") {
1479				this._addClass(this.sliderElem, "slider-vertical");
1480				this.stylePos = "top";
1481				this.mousePos = "pageY";
1482				this.sizePos = "offsetHeight";
1483			} else {
1484				this._addClass(this.sliderElem, "slider-horizontal");
1485				this.sliderElem.style.width = origWidth;
1486				this.options.orientation = "horizontal";
1487				if (this.options.rtl) {
1488					this.stylePos = "right";
1489				} else {
1490					this.stylePos = "left";
1491				}
1492				this.mousePos = "pageX";
1493				this.sizePos = "offsetWidth";
1494			}
1495			if (this.options.rtl) {
1496				this._addClass(this.sliderElem, "slider-rtl");
1497			}
1498			this._setTooltipPosition();
1499			if (Array.isArray(this.options.ticks) && this.options.ticks.length > 0) {
1500				this.options.max = Math.max.apply(Math, this.options.ticks);
1501				this.options.min = Math.min.apply(Math, this.options.ticks);
1502			}
1503			if (Array.isArray(this.options.value)) {
1504				this.options.range = true;
1505				this._state.value = this.options.value;
1506			} else if (this.options.range) {
1507				this._state.value = [this.options.value, this.options.max];
1508			} else {
1509				this._state.value = this.options.value;
1510			}
1511			this.trackLow = sliderTrackLow || this.trackLow;
1512			this.trackSelection = sliderTrackSelection || this.trackSelection;
1513			this.trackHigh = sliderTrackHigh || this.trackHigh;
1514			if (this.options.selection === "none") {
1515				this._addClass(this.trackLow, "hide");
1516				this._addClass(this.trackSelection, "hide");
1517				this._addClass(this.trackHigh, "hide");
1518			} else if (this.options.selection === "after" || this.options.selection === "before") {
1519				this._removeClass(this.trackLow, "hide");
1520				this._removeClass(this.trackSelection, "hide");
1521				this._removeClass(this.trackHigh, "hide");
1522			}
1523			this.handle1 = sliderMinHandle || this.handle1;
1524			this.handle2 = sliderMaxHandle || this.handle2;
1525			if (updateSlider === true) {
1526				this._removeClass(this.handle1, "round triangle");
1527				this._removeClass(this.handle2, "round triangle hide");
1528				for (i = 0; i < this.ticks.length; i++) {
1529					this._removeClass(this.ticks[i], "round triangle hide");
1530				}
1531			}
1532			var availableHandleModifiers = ["round", "triangle", "custom"];
1533			var isValidHandleType = availableHandleModifiers.indexOf(this.options.handle) !== -1;
1534			if (isValidHandleType) {
1535				this._addClass(this.handle1, this.options.handle);
1536				this._addClass(this.handle2, this.options.handle);
1537				for (i = 0; i < this.ticks.length; i++) {
1538					this._addClass(this.ticks[i], this.options.handle);
1539				}
1540			}
1541			this._state.offset = this._offset(this.sliderElem);
1542			this._state.size = this.sliderElem[this.sizePos];
1543			this.setValue(this._state.value);
1544			this.handle1Keydown = this._keydown.bind(this, 0);
1545			this.handle1.addEventListener("keydown", this.handle1Keydown, false);
1546			this.handle2Keydown = this._keydown.bind(this, 1);
1547			this.handle2.addEventListener("keydown", this.handle2Keydown, false);
1548			this.mousedown = this._mousedown.bind(this);
1549			this.touchstart = this._touchstart.bind(this);
1550			this.touchmove = this._touchmove.bind(this);
1551			if (this.touchCapable) {
1552				var supportsPassive = false;
1553				try {
1554					var opts = Object.defineProperty({}, "passive", {
1555						get: function get() {
1556							supportsPassive = true;
1557						},
1558					});
1559					window.addEventListener("test", null, opts);
1560				} catch (e) {}
1561				var eventOptions = supportsPassive ? { passive: true } : false;
1562				this.sliderElem.addEventListener("touchstart", this.touchstart, eventOptions);
1563				this.sliderElem.addEventListener("touchmove", this.touchmove, eventOptions);
1564			}
1565			this.sliderElem.addEventListener("mousedown", this.mousedown, false);
1566			this.resize = this._resize.bind(this);
1567			window.addEventListener("resize", this.resize, false);
1568			if (this.options.tooltip === "hide") {
1569				this._addClass(this.tooltip, "hide");
1570				this._addClass(this.tooltip_min, "hide");
1571				this._addClass(this.tooltip_max, "hide");
1572			} else if (this.options.tooltip === "always") {
1573				this._showTooltip();
1574				this._alwaysShowTooltip = true;
1575			} else {
1576				this.showTooltip = this._showTooltip.bind(this);
1577				this.hideTooltip = this._hideTooltip.bind(this);
1578				if (this.options.ticks_tooltip) {
1579					var callbackHandle = this._addTickListener();
1580					var mouseEnter = callbackHandle.addMouseEnter(this, this.handle1);
1581					var mouseLeave = callbackHandle.addMouseLeave(this, this.handle1);
1582					this.handleCallbackMap.handle1 = {
1583						mouseEnter: mouseEnter,
1584						mouseLeave: mouseLeave,
1585					};
1586					mouseEnter = callbackHandle.addMouseEnter(this, this.handle2);
1587					mouseLeave = callbackHandle.addMouseLeave(this, this.handle2);
1588					this.handleCallbackMap.handle2 = {
1589						mouseEnter: mouseEnter,
1590						mouseLeave: mouseLeave,
1591					};
1592				} else {
1593					this.sliderElem.addEventListener("mouseenter", this.showTooltip, false);
1594					this.sliderElem.addEventListener("mouseleave", this.hideTooltip, false);
1595				}
1596				this.handle1.addEventListener("focus", this.showTooltip, false);
1597				this.handle1.addEventListener("blur", this.hideTooltip, false);
1598				this.handle2.addEventListener("focus", this.showTooltip, false);
1599				this.handle2.addEventListener("blur", this.hideTooltip, false);
1600			}
1601			if (this.options.enabled) {
1602				this.enable();
1603			} else {
1604				this.disable();
1605			}
1606		}
1607		Slider.prototype = {
1608			_init: function _init() {},
1609			constructor: Slider,
1610			defaultOptions: {
1611				id: "",
1612				min: 0,
1613				max: 10,
1614				step: 1,
1615				precision: 0,
1616				orientation: "horizontal",
1617				value: 5,
1618				range: false,
1619				selection: "before",
1620				tooltip: "show",
1621				tooltip_split: false,
1622				handle: "round",
1623				reversed: false,
1624				rtl: "auto",
1625				enabled: true,
1626				formatter: function formatter(val) {
1627					if (Array.isArray(val)) {
1628						return val[0] + " : " + val[1];
1629					} else {
1630						return val;
1631					}
1632				},
1633				natural_arrow_keys: false,
1634				ticks: [],
1635				ticks_positions: [],
1636				ticks_labels: [],
1637				ticks_snap_bounds: 0,
1638				ticks_tooltip: false,
1639				scale: "linear",
1640				focus: false,
1641				tooltip_position: null,
1642				labelledby: null,
1643				rangeHighlights: [],
1644			},
1645			getElement: function getElement() {
1646				return this.sliderElem;
1647			},
1648			getValue: function getValue() {
1649				if (this.options.range) {
1650					return this._state.value;
1651				} else {
1652					return this._state.value[0];
1653				}
1654			},
1655			setValue: function setValue(val, triggerSlideEvent, triggerChangeEvent) {
1656				if (!val) {
1657					val = 0;
1658				}
1659				var oldValue = this.getValue();
1660				this._state.value = this._validateInputValue(val);
1661				var applyPrecision = this._applyPrecision.bind(this);
1662				if (this.options.range) {
1663					this._state.value[0] = applyPrecision(this._state.value[0]);
1664					this._state.value[1] = applyPrecision(this._state.value[1]);
1665					this._state.value[0] = Math.max(this.options.min, Math.min(this.options.max, this._state.value[0]));
1666					this._state.value[1] = Math.max(this.options.min, Math.min(this.options.max, this._state.value[1]));
1667				} else {
1668					this._state.value = applyPrecision(this._state.value);
1669					this._state.value = [Math.max(this.options.min, Math.min(this.options.max, this._state.value))];
1670					this._addClass(this.handle2, "hide");
1671					if (this.options.selection === "after") {
1672						this._state.value[1] = this.options.max;
1673					} else {
1674						this._state.value[1] = this.options.min;
1675					}
1676				}
1677				if (this.options.max > this.options.min) {
1678					this._state.percentage = [this._toPercentage(this._state.value[0]), this._toPercentage(this._state.value[1]), (this.options.step * 100) / (this.options.max - this.options.min)];
1679				} else {
1680					this._state.percentage = [0, 0, 100];
1681				}
1682				this._layout();
1683				var newValue = this.options.range ? this._state.value : this._state.value[0];
1684				this._setDataVal(newValue);
1685				if (triggerSlideEvent === true) {
1686					this._trigger("slide", newValue);
1687				}
1688				if (oldValue !== newValue && triggerChangeEvent === true) {
1689					this._trigger("change", { oldValue: oldValue, newValue: newValue });
1690				}
1691				return this;
1692			},
1693			destroy: function destroy() {
1694				this._removeSliderEventHandlers();
1695				this.sliderElem.parentNode.removeChild(this.sliderElem);
1696				this.element.style.display = "";
1697				this._cleanUpEventCallbacksMap();
1698				this.element.removeAttribute("data");
1699				if ($) {
1700					this._unbindJQueryEventHandlers();
1701					this.$element.removeData("slider");
1702				}
1703			},
1704			disable: function disable() {
1705				this._state.enabled = false;
1706				this.handle1.removeAttribute("tabindex");
1707				this.handle2.removeAttribute("tabindex");
1708				this._addClass(this.sliderElem, "slider-disabled");
1709				this._trigger("slideDisabled");
1710				return this;
1711			},
1712			enable: function enable() {
1713				this._state.enabled = true;
1714				this.handle1.setAttribute("tabindex", 0);
1715				this.handle2.setAttribute("tabindex", 0);
1716				this._removeClass(this.sliderElem, "slider-disabled");
1717				this._trigger("slideEnabled");
1718				return this;
1719			},
1720			toggle: function toggle() {
1721				if (this._state.enabled) {
1722					this.disable();
1723				} else {
1724					this.enable();
1725				}
1726				return this;
1727			},
1728			isEnabled: function isEnabled() {
1729				return this._state.enabled;
1730			},
1731			on: function on(evt, callback) {
1732				this._bindNonQueryEventHandler(evt, callback);
1733				return this;
1734			},
1735			off: function off(evt, callback) {
1736				if ($) {
1737					this.$element.off(evt, callback);
1738					this.$sliderElem.off(evt, callback);
1739				} else {
1740					this._unbindNonQueryEventHandler(evt, callback);
1741				}
1742			},
1743			getAttribute: function getAttribute(attribute) {
1744				if (attribute) {
1745					return this.options[attribute];
1746				} else {
1747					return this.options;
1748				}
1749			},
1750			setAttribute: function setAttribute(attribute, value) {
1751				this.options[attribute] = value;
1752				return this;
1753			},
1754			refresh: function refresh() {
1755				this._removeSliderEventHandlers();
1756				createNewSlider.call(this, this.element, this.options);
1757				if ($) {
1758					$.data(this.element, "slider", this);
1759				}
1760				return this;
1761			},
1762			relayout: function relayout() {
1763				this._resize();
1764				this._layout();
1765				return this;
1766			},
1767			_removeSliderEventHandlers: function _removeSliderEventHandlers() {
1768				this.handle1.removeEventListener("keydown", this.handle1Keydown, false);
1769				this.handle2.removeEventListener("keydown", this.handle2Keydown, false);
1770				if (this.options.ticks_tooltip) {
1771					var ticks = this.ticksContainer.getElementsByClassName("slider-tick");
1772					for (var i = 0; i < ticks.length; i++) {
1773						ticks[i].removeEventListener("mouseenter", this.ticksCallbackMap[i].mouseEnter, false);
1774						ticks[i].removeEventListener("mouseleave", this.ticksCallbackMap[i].mouseLeave, false);
1775					}
1776					this.handle1.removeEventListener("mouseenter", this.handleCallbackMap.handle1.mouseEnter, false);
1777					this.handle2.removeEventListener("mouseenter", this.handleCallbackMap.handle2.mouseEnter, false);
1778					this.handle1.removeEventListener("mouseleave", this.handleCallbackMap.handle1.mouseLeave, false);
1779					this.handle2.removeEventListener("mouseleave", this.handleCallbackMap.handle2.mouseLeave, false);
1780				}
1781				this.handleCallbackMap = null;
1782				this.ticksCallbackMap = null;
1783				if (this.showTooltip) {
1784					this.handle1.removeEventListener("focus", this.showTooltip, false);
1785					this.handle2.removeEventListener("focus", this.showTooltip, false);
1786				}
1787				if (this.hideTooltip) {
1788					this.handle1.removeEventListener("blur", this.hideTooltip, false);
1789					this.handle2.removeEventListener("blur", this.hideTooltip, false);
1790				}
1791				if (this.showTooltip) {
1792					this.sliderElem.removeEventListener("mouseenter", this.showTooltip, false);
1793				}
1794				if (this.hideTooltip) {
1795					this.sliderElem.removeEventListener("mouseleave", this.hideTooltip, false);
1796				}
1797				this.sliderElem.removeEventListener("touchstart", this.touchstart, false);
1798				this.sliderElem.removeEventListener("touchmove", this.touchmove, false);
1799				this.sliderElem.removeEventListener("mousedown", this.mousedown, false);
1800				window.removeEventListener("resize", this.resize, false);
1801			},
1802			_bindNonQueryEventHandler: function _bindNonQueryEventHandler(evt, callback) {
1803				if (this.eventToCallbackMap[evt] === undefined) {
1804					this.eventToCallbackMap[evt] = [];
1805				}
1806				this.eventToCallbackMap[evt].push(callback);
1807			},
1808			_unbindNonQueryEventHandler: function _unbindNonQueryEventHandler(evt, callback) {
1809				var callbacks = this.eventToCallbackMap[evt];
1810				if (callbacks !== undefined) {
1811					for (var i = 0; i < callbacks.length; i++) {
1812						if (callbacks[i] === callback) {
1813							callbacks.splice(i, 1);
1814							break;
1815						}
1816					}
1817				}
1818			},
1819			_cleanUpEventCallbacksMap: function _cleanUpEventCallbacksMap() {
1820				var eventNames = Object.keys(this.eventToCallbackMap);
1821				for (var i = 0; i < eventNames.length; i++) {
1822					var eventName = eventNames[i];
1823					delete this.eventToCallbackMap[eventName];
1824				}
1825			},
1826			_showTooltip: function _showTooltip() {
1827				if (this.options.tooltip_split === false) {
1828					this._addClass(this.tooltip, "in");
1829					this.tooltip_min.style.display = "none";
1830					this.tooltip_max.style.display = "none";
1831				} else {
1832					this._addClass(this.tooltip_min, "in");
1833					this._addClass(this.tooltip_max, "in");
1834					this.tooltip.style.display = "none";
1835				}
1836				this._state.over = true;
1837			},
1838			_hideTooltip: function _hideTooltip() {
1839				if (this._state.inDrag === false && this.alwaysShowTooltip !== true) {
1840					this._removeClass(this.tooltip, "in");
1841					this._removeClass(this.tooltip_min, "in");
1842					this._removeClass(this.tooltip_max, "in");
1843				}
1844				this._state.over = false;
1845			},
1846			_setToolTipOnMouseOver: function _setToolTipOnMouseOver(tempState) {
1847				var formattedTooltipVal = this.options.formatter(!tempState ? this._state.value[0] : tempState.value[0]);
1848				var positionPercentages = !tempState ? getPositionPercentages(this._state, this.options.reversed) : getPositionPercentages(tempState, this.options.reversed);
1849				this._setText(this.tooltipInner, formattedTooltipVal);
1850				this.tooltip.style[this.stylePos] = positionPercentages[0] + "%";
1851				function getPositionPercentages(state, reversed) {
1852					if (reversed) {
1853						return [100 - state.percentage[0], this.options.range ? 100 - state.percentage[1] : state.percentage[1]];
1854					}
1855					return [state.percentage[0], state.percentage[1]];
1856				}
1857			},
1858			_addTickListener: function _addTickListener() {
1859				return {
1860					addMouseEnter: function addMouseEnter(reference, tick, index) {
1861						var enter = function enter() {
1862							var tempState = reference._state;
1863							var idString = index >= 0 ? index : this.attributes["aria-valuenow"].value;
1864							var hoverIndex = parseInt(idString, 10);
1865							tempState.value[0] = hoverIndex;
1866							tempState.percentage[0] = reference.options.ticks_positions[hoverIndex];
1867							reference._setToolTipOnMouseOver(tempState);
1868							reference._showTooltip();
1869						};
1870						tick.addEventListener("mouseenter", enter, false);
1871						return enter;
1872					},
1873					addMouseLeave: function addMouseLeave(reference, tick) {
1874						var leave = function leave() {
1875							reference._hideTooltip();
1876						};
1877						tick.addEventListener("mouseleave", leave, false);
1878						return leave;
1879					},
1880				};
1881			},
1882			_layout: function _layout() {
1883				var positionPercentages;
1884				if (this.options.reversed) {
1885					positionPercentages = [100 - this._state.percentage[0], this.options.range ? 100 - this._state.percentage[1] : this._state.percentage[1]];
1886				} else {
1887					positionPercentages = [this._state.percentage[0], this._state.percentage[1]];
1888				}
1889				this.handle1.style[this.stylePos] = positionPercentages[0] + "%";
1890				this.handle1.setAttribute("aria-valuenow", this._state.value[0]);
1891				if (isNaN(this.options.formatter(this._state.value[0]))) {
1892					this.handle1.setAttribute("aria-valuetext", this.options.formatter(this._state.value[0]));
1893				}
1894				this.handle2.style[this.stylePos] = positionPercentages[1] + "%";
1895				this.handle2.setAttribute("aria-valuenow", this._state.value[1]);
1896				if (isNaN(this.options.formatter(this._state.value[1]))) {
1897					this.handle2.setAttribute("aria-valuetext", this.options.formatter(this._state.value[1]));
1898				}
1899				if (this.rangeHighlightElements.length > 0 && Array.isArray(this.options.rangeHighlights) && this.options.rangeHighlights.length > 0) {
1900					for (var _i = 0; _i < this.options.rangeHighlights.length; _i++) {
1901						var startPercent = this._toPercentage(this.options.rangeHighlights[_i].start);
1902						var endPercent = this._toPercentage(this.options.rangeHighlights[_i].end);
1903						if (this.options.reversed) {
1904							var sp = 100 - endPercent;
1905							endPercent = 100 - startPercent;
1906							startPercent = sp;
1907						}
1908						var currentRange = this._createHighlightRange(startPercent, endPercent);
1909						if (currentRange) {
1910							if (this.options.orientation === "vertical") {
1911								this.rangeHighlightElements[_i].style.top = currentRange.start + "%";
1912								this.rangeHighlightElements[_i].style.height = currentRange.size + "%";
1913							} else {
1914								if (this.options.rtl) {
1915									this.rangeHighlightElements[_i].style.right = currentRange.start + "%";
1916								} else {
1917									this.rangeHighlightElements[_i].style.left = currentRange.start + "%";
1918								}
1919								this.rangeHighlightElements[_i].style.width = currentRange.size + "%";
1920							}
1921						} else {
1922							this.rangeHighlightElements[_i].style.display = "none";
1923						}
1924					}
1925				}
1926				if (Array.isArray(this.options.ticks) && this.options.ticks.length > 0) {
1927					var styleSize = this.options.orientation === "vertical" ? "height" : "width";
1928					var styleMargin;
1929					if (this.options.orientation === "vertical") {
1930						styleMargin = "marginTop";
1931					} else {
1932						if (this.options.rtl) {
1933							styleMargin = "marginRight";
1934						} else {
1935							styleMargin = "marginLeft";
1936						}
1937					}
1938					var labelSize = this._state.size / (this.options.ticks.length - 1);
1939					if (this.tickLabelContainer) {
1940						var extraMargin = 0;
1941						if (this.options.ticks_positions.length === 0) {
1942							if (this.options.orientation !== "vertical") {
1943								this.tickLabelContainer.style[styleMargin] = -labelSize / 2 + "px";
1944							}
1945							extraMargin = this.tickLabelContainer.offsetHeight;
1946						} else {
1947							for (i = 0; i < this.tickLabelContainer.childNodes.length; i++) {
1948								if (this.tickLabelContainer.childNodes[i].offsetHeight > extraMargin) {
1949									extraMargin = this.tickLabelContainer.childNodes[i].offsetHeight;
1950								}
1951							}
1952						}
1953						if (this.options.orientation === "horizontal") {
1954							this.sliderElem.style.marginBottom = extraMargin + "px";
1955						}
1956					}
1957					for (var i = 0; i < this.options.ticks.length; i++) {
1958						var percentage = this.options.ticks_positions[i] || this._toPercentage(this.options.ticks[i]);
1959						if (this.options.reversed) {
1960							percentage = 100 - percentage;
1961						}
1962						this.ticks[i].style[this.stylePos] = percentage + "%";
1963						this._removeClass(this.ticks[i], "in-selection");
1964						if (!this.options.range) {
1965							if (this.options.selection === "after" && percentage >= positionPercentages[0]) {
1966								this._addClass(this.ticks[i], "in-selection");
1967							} else if (this.options.selection === "before" && percentage <= positionPercentages[0]) {
1968								this._addClass(this.ticks[i], "in-selection");
1969							}
1970						} else if (percentage >= positionPercentages[0] && percentage <= positionPercentages[1]) {
1971							this._addClass(this.ticks[i], "in-selection");
1972						}
1973						if (this.tickLabels[i]) {
1974							this.tickLabels[i].style[styleSize] = labelSize + "px";
1975							if (this.options.orientation !== "vertical" && this.options.ticks_positions[i] !== undefined) {
1976								this.tickLabels[i].style.position = "absolute";
1977								this.tickLabels[i].style[this.stylePos] = percentage + "%";
1978								this.tickLabels[i].style[styleMargin] = -labelSize / 2 + "px";
1979							} else if (this.options.orientation === "vertical") {
1980								if (this.options.rtl) {
1981									this.tickLabels[i].style["marginRight"] = this.sliderElem.offsetWidth + "px";
1982								} else {
1983									this.tickLabels[i].style["marginLeft"] = this.sliderElem.offsetWidth + "px";
1984								}
1985								this.tickLabelContainer.style[styleMargin] = (this.sliderElem.offsetWidth / 2) * -1 + "px";
1986							}
1987						}
1988					}
1989				}
1990				var formattedTooltipVal;
1991				if (this.options.range) {
1992					formattedTooltipVal = this.options.formatter(this._state.value);
1993					this._setText(this.tooltipInner, formattedTooltipVal);
1994					this.tooltip.style[this.stylePos] = (positionPercentages[1] + positionPercentages[0]) / 2 + "%";
1995					var innerTooltipMinText = this.options.formatter(this._state.value[0]);
1996					this._setText(this.tooltipInner_min, innerTooltipMinText);
1997					var innerTooltipMaxText = this.options.formatter(this._state.value[1]);
1998					this._setText(this.tooltipInner_max, innerTooltipMaxText);
1999					this.tooltip_min.style[this.stylePos] = positionPercentages[0] + "%";
2000					this.tooltip_max.style[this.stylePos] = positionPercentages[1] + "%";
2001				} else {
2002					formattedTooltipVal = this.options.formatter(this._state.value[0]);
2003					this._setText(this.tooltipInner, formattedTooltipVal);
2004					this.tooltip.style[this.stylePos] = positionPercentages[0] + "%";
2005				}
2006				if (this.options.orientation === "vertical") {
2007					this.trackLow.style.top = "0";
2008					this.trackLow.style.height = Math.min(positionPercentages[0], positionPercentages[1]) + "%";
2009					this.trackSelection.style.top = Math.min(positionPercentages[0], positionPercentages[1]) + "%";
2010					this.trackSelection.style.height = Math.abs(positionPercentages[0] - positionPercentages[1]) + "%";
2011					this.trackHigh.style.bottom = "0";
2012					this.trackHigh.style.height = 100 - Math.min(positionPercentages[0], positionPercentages[1]) - Math.abs(positionPercentages[0] - positionPercentages[1]) + "%";
2013				} else {
2014					if (this.stylePos === "right") {
2015						this.trackLow.style.right = "0";
2016					} else {
2017						this.trackLow.style.left = "0";
2018					}
2019					this.trackLow.style.width = Math.min(positionPercentages[0], positionPercentages[1]) + "%";
2020					if (this.stylePos === "right") {
2021						this.trackSelection.style.right = Math.min(positionPercentages[0], positionPercentages[1]) + "%";
2022					} else {
2023						this.trackSelection.style.left = Math.min(positionPercentages[0], positionPercentages[1]) + "%";
2024					}
2025					this.trackSelection.style.width = Math.abs(positionPercentages[0] - positionPercentages[1]) + "%";
2026					if (this.stylePos === "right") {
2027						this.trackHigh.style.left = "0";
2028					} else {
2029						this.trackHigh.style.right = "0";
2030					}
2031					this.trackHigh.style.width = 100 - Math.min(positionPercentages[0], positionPercentages[1]) - Math.abs(positionPercentages[0] - positionPercentages[1]) + "%";
2032					var offset_min = this.tooltip_min.getBoundingClientRect();
2033					var offset_max = this.tooltip_max.getBoundingClientRect();
2034					if (this.options.tooltip_position === "bottom") {
2035						if (offset_min.right > offset_max.left) {
2036							this._removeClass(this.tooltip_max, "bottom");
2037							this._addClass(this.tooltip_max, "top");
2038							this.tooltip_max.style.top = "";
2039							this.tooltip_max.style.bottom = 22 + "px";
2040						} else {
2041							this._removeClass(this.tooltip_max, "top");
2042							this._addClass(this.tooltip_max, "bottom");
2043							this.tooltip_max.style.top = this.tooltip_min.style.top;
2044							this.tooltip_max.style.bottom = "";
2045						}
2046					} else {
2047						if (offset_min.right > offset_max.left) {
2048							this._removeClass(this.tooltip_max, "top");
2049							this._addClass(this.tooltip_max, "bottom");
2050							this.tooltip_max.style.top = 18 + "px";
2051						} else {
2052							this._removeClass(this.tooltip_max, "bottom");
2053							this._addClass(this.tooltip_max, "top");
2054							this.tooltip_max.style.top = this.tooltip_min.style.top;
2055						}
2056					}
2057				}
2058			},
2059			_createHighlightRange: function _createHighlightRange(start, end) {
2060				if (this._isHighlightRange(start, end)) {
2061					if (start > end) {
2062						return { start: end, size: start - end };
2063					}
2064					return { start: start, size: end - start };
2065				}
2066				return null;
2067			},
2068			_isHighlightRange: function _isHighlightRange(start, end) {
2069				if (0 <= start && start <= 100 && 0 <= end && end <= 100) {
2070					return true;
2071				} else {
2072					return false;
2073				}
2074			},
2075			_resize: function _resize(ev) {
2076				this._state.offset = this._offset(this.sliderElem);
2077				this._state.size = this.sliderElem[this.sizePos];
2078				this._layout();
2079			},
2080			_removeProperty: function _removeProperty(element, prop) {
2081				if (element.style.removeProperty) {
2082					element.style.removeProperty(prop);
2083				} else {
2084					element.style.removeAttribute(prop);
2085				}
2086			},
2087			_mousedown: function _mousedown(ev) {
2088				if (!this._state.enabled) {
2089					return false;
2090				}
2091				this._state.offset = this._offset(this.sliderElem);
2092				this._state.size = this.sliderElem[this.sizePos];
2093				var percentage = this._getPercentage(ev);
2094				if (this.options.range) {
2095					var diff1 = Math.abs(this._state.percentage[0] - percentage);
2096					var diff2 = Math.abs(this._state.percentage[1] - percentage);
2097					this._state.dragged = diff1 < diff2 ? 0 : 1;
2098					this._adjustPercentageForRangeSliders(percentage);
2099				} else {
2100					this._state.dragged = 0;
2101				}
2102				this._state.percentage[this._state.dragged] = percentage;
2103				this._layout();
2104				if (this.touchCapable) {
2105					document.removeEventListener("touchmove", this.mousemove, false);
2106					document.removeEventListener("touchend", this.mouseup, false);
2107				}
2108				if (this.mousemove) {
2109					document.removeEventListener("mousemove", this.mousemove, false);
2110				}
2111				if (this.mouseup) {
2112					document.removeEventListener("mouseup", this.mouseup, false);
2113				}
2114				this.mousemove = this._mousemove.bind(this);
2115				this.mouseup = this._mouseup.bind(this);
2116				if (this.touchCapable) {
2117					document.addEventListener("touchmove", this.mousemove, false);
2118					document.addEventListener("touchend", this.mouseup, false);
2119				}
2120				document.addEventListener("mousemove", this.mousemove, false);
2121				document.addEventListener("mouseup", this.mouseup, false);
2122				this._state.inDrag = true;
2123				var newValue = this._calculateValue();
2124				this._trigger("slideStart", newValue);
2125				this._setDataVal(newValue);
2126				this.setValue(newValue, false, true);
2127				ev.returnValue = false;
2128				if (this.options.focus) {
2129					this._triggerFocusOnHandle(this._state.dragged);
2130				}
2131				return true;
2132			},
2133			_touchstart: function _touchstart(ev) {
2134				if (ev.changedTouches === undefined) {
2135					this._mousedown(ev);
2136					return;
2137				}
2138				var touch = ev.changedTouches[0];
2139				this.touchX = touch.pageX;
2140				this.touchY = touch.pageY;
2141			},
2142			_triggerFocusOnHandle: function _triggerFocusOnHandle(handleIdx) {
2143				if (handleIdx === 0) {
2144					this.handle1.focus();
2145				}
2146				if (handleIdx === 1) {
2147					this.handle2.focus();
2148				}
2149			},
2150			_keydown: function _keydown(handleIdx, ev) {
2151				if (!this._state.enabled) {
2152					return false;
2153				}
2154				var dir;
2155				switch (ev.keyCode) {
2156					case 37:
2157					case 40:
2158						dir = -1;
2159						break;
2160					case 39:
2161					case 38:
2162						dir = 1;
2163						break;
2164				}
2165				if (!dir) {
2166					return;
2167				}
2168				if (this.options.natural_arrow_keys) {
2169					var ifVerticalAndNotReversed = this.options.orientation === "vertical" && !this.options.reversed;
2170					var ifHorizontalAndReversed = this.options.orientation === "horizontal" && this.options.reversed;
2171					if (ifVerticalAndNotReversed || ifHorizontalAndReversed) {
2172						dir = -dir;
2173					}
2174				}
2175				var val = this._state.value[handleIdx] + dir * this.options.step;
2176				var percentage = (val / this.options.max) * 100;
2177				this._state.keyCtrl = handleIdx;
2178				if (this.options.range) {
2179					this._adjustPercentageForRangeSliders(percentage);
2180					var val1 = !this._state.keyCtrl ? val : this._state.value[0];
2181					var val2 = this._state.keyCtrl ? val : this._state.value[1];
2182					val = [val1, val2];
2183				}
2184				this._trigger("slideStart", val);
2185				this._setDataVal(val);
2186				this.setValue(val, true, true);
2187				this._setDataVal(val);
2188				this._trigger("slideStop", val);
2189				this._layout();
2190				this._pauseEvent(ev);
2191				delete this._state.keyCtrl;
2192				return false;
2193			},
2194			_pauseEvent: function _pauseEvent(ev) {
2195				if (ev.stopPropagation) {
2196					ev.stopPropagation();
2197				}
2198				if (ev.preventDefault) {
2199					ev.preventDefault();
2200				}
2201				ev.cancelBubble = true;
2202				ev.returnValue = false;
2203			},
2204			_mousemove: function _mousemove(ev) {
2205				if (!this._state.enabled) {
2206					return false;
2207				}
2208				var percentage = this._getPercentage(ev);
2209				this._adjustPercentageForRangeSliders(percentage);
2210				this._state.percentage[this._state.dragged] = percentage;
2211				this._layout();
2212				var val = this._calculateValue(true);
2213				this.setValue(val, true, true);
2214				return false;
2215			},
2216			_touchmove: function _touchmove(ev) {
2217				if (ev.changedTouches === undefined) {
2218					return;
2219				}
2220				var touch = ev.changedTouches[0];
2221				var xDiff = touch.pageX - this.touchX;
2222				var yDiff = touch.pageY - this.touchY;
2223				if (!this._state.inDrag) {
2224					if (this.options.orientation === "vertical" && xDiff <= 5 && xDiff >= -5 && (yDiff >= 15 || yDiff <= -15)) {
2225						this._mousedown(ev);
2226					} else if (yDiff <= 5 && yDiff >= -5 && (xDiff >= 15 || xDiff <= -15)) {
2227						this._mousedown(ev);
2228					}
2229				}
2230			},
2231			_adjustPercentageForRangeSliders: function _adjustPercentageForRangeSliders(percentage) {
2232				if (this.options.range) {
2233					var precision = this._getNumDigitsAfterDecimalPlace(percentage);
2234					precision = precision ? precision - 1 : 0;
2235					var percentageWithAdjustedPrecision = this._applyToFixedAndParseFloat(percentage, precision);
2236					if (this._state.dragged === 0 && this._applyToFixedAndParseFloat(this._state.percentage[1], precision) < percentageWithAdjustedPrecision) {
2237						this._state.percentage[0] = this._state.percentage[1];
2238						this._state.dragged = 1;
2239					} else if (this._state.dragged === 1 && this._applyToFixedAndParseFloat(this._state.percentage[0], precision) > percentageWithAdjustedPrecision) {
2240						this._state.percentage[1] = this._state.percentage[0];
2241						this._state.dragged = 0;
2242					} else if (this._state.keyCtrl === 0 && (this._state.value[1] / this.options.max) * 100 < percentage) {
2243						this._state.percentage[0] = this._state.percentage[1];
2244						this._state.keyCtrl = 1;
2245						this.handle2.focus();
2246					} else if (this._state.keyCtrl === 1 && (this._state.value[0] / this.options.max) * 100 > percentage) {
2247						this._state.percentage[1] = this._state.percentage[0];
2248						this._state.keyCtrl = 0;
2249						this.handle1.focus();
2250					}
2251				}
2252			},
2253			_mouseup: function _mouseup() {
2254				if (!this._state.enabled) {
2255					return false;
2256				}
2257				if (this.touchCapable) {
2258					document.removeEventListener("touchmove", this.mousemove, false);
2259					document.removeEventListener("touchend", this.mouseup, false);
2260				}
2261				document.removeEventListener("mousemove", this.mousemove, false);
2262				document.removeEventListener("mouseup", this.mouseup, false);
2263				this._state.inDrag = false;
2264				if (this._state.over === false) {
2265					this._hideTooltip();
2266				}
2267				var val = this._calculateValue(true);
2268				this._layout();
2269				this._setDataVal(val);
2270				this._trigger("slideStop", val);
2271				return false;
2272			},
2273			_calculateValue: function _calculateValue(snapToClosestTick) {
2274				var val;
2275				if (this.options.range) {
2276					val = [this.options.min, this.options.max];
2277					if (this._state.percentage[0] !== 0) {
2278						val[0] = this._toValue(this._state.percentage[0]);
2279						val[0] = this._applyPrecision(val[0]);
2280					}
2281					if (this._state.percentage[1] !== 100) {
2282						val[1] = this._toValue(this._state.percentage[1]);
2283						val[1] = this._applyPrecision(val[1]);
2284					}
2285				} else {
2286					val = this._toValue(this._state.percentage[0]);
2287					val = parseFloat(val);
2288					val = this._applyPrecision(val);
2289				}
2290				if (snapToClosestTick) {
2291					var min = [val, Infinity];
2292					for (var i = 0; i < this.options.ticks.length; i++) {
2293						var diff = Math.abs(this.options.ticks[i] - val);
2294						if (diff <= min[1]) {
2295							min = [this.options.ticks[i], diff];
2296						}
2297					}
2298					if (min[1] <= this.options.ticks_snap_bounds) {
2299						return min[0];
2300					}
2301				}
2302				return val;
2303			},
2304			_applyPrecision: function _applyPrecision(val) {
2305				var precision = this.options.precision || this._getNumDigitsAfterDecimalPlace(this.options.step);
2306				return this._applyToFixedAndParseFloat(val, precision);
2307			},
2308			_getNumDigitsAfterDecimalPlace: function _getNumDigitsAfterDecimalPlace(num) {
2309				var match = ("" + num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
2310				if (!match) {
2311					return 0;
2312				}
2313				return Math.max(0, (match[1] ? match[1].length : 0) - (match[2] ? +match[2] : 0));
2314			},
2315			_applyToFixedAndParseFloat: function _applyToFixedAndParseFloat(num, toFixedInput) {
2316				var truncatedNum = num.toFixed(toFixedInput);
2317				return parseFloat(truncatedNum);
2318			},
2319			_getPercentage: function _getPercentage(ev) {
2320				if (this.touchCapable && (ev.type === "touchstart" || ev.type === "touchmove")) {
2321					ev = ev.touches[0];
2322				}
2323				var eventPosition = ev[this.mousePos];
2324				var sliderOffset = this._state.offset[this.stylePos];
2325				var distanceToSlide = eventPosition - sliderOffset;
2326				if (this.stylePos === "right") {
2327					distanceToSlide = -distanceToSlide;
2328				}
2329				var percentage = (distanceToSlide / this._state.size) * 100;
2330				percentage = Math.round(percentage / this._state.percentage[2]) * this._state.percentage[2];
2331				if (this.options.reversed) {
2332					percentage = 100 - percentage;
2333				}
2334				return Math.max(0, Math.min(100, percentage));
2335			},
2336			_validateInputValue: function _validateInputValue(val) {
2337				if (!isNaN(+val)) {
2338					return +val;
2339				} else if (Array.isArray(val)) {
vendor: 5,134 bytes, lines 2340-2494
2340					this._validateArray(val);
2341					return val;
2342				} else {
2343					throw new Error(ErrorMsgs.formatInvalidInputErrorMsg(val));
2344				}
2345			},
2346			_validateArray: function _validateArray(val) {
2347				for (var i = 0; i < val.length; i++) {
2348					var input = val[i];
2349					if (typeof input !== "number") {
2350						throw new Error(ErrorMsgs.formatInvalidInputErrorMsg(input));
2351					}
2352				}
2353			},
2354			_setDataVal: function _setDataVal(val) {
2355				this.element.setAttribute("data-value", val);
2356				this.element.setAttribute("value", val);
2357				this.element.value = val;
2358			},
2359			_trigger: function _trigger(evt, val) {
2360				val = val || val === 0 ? val : undefined;
2361				var callbackFnArray = this.eventToCallbackMap[evt];
2362				if (callbackFnArray && callbackFnArray.length) {
2363					for (var i = 0; i < callbackFnArray.length; i++) {
2364						var callbackFn = callbackFnArray[i];
2365						callbackFn(val);
2366					}
2367				}
2368				if ($) {
2369					this._triggerJQueryEvent(evt, val);
2370				}
2371			},
2372			_triggerJQueryEvent: function _triggerJQueryEvent(evt, val) {
2373				var eventData = { type: evt, value: val };
2374				this.$element.trigger(eventData);
2375				this.$sliderElem.trigger(eventData);
2376			},
2377			_unbindJQueryEventHandlers: function _unbindJQueryEventHandlers() {
2378				this.$element.off();
2379				this.$sliderElem.off();
2380			},
2381			_setText: function _setText(element, text) {
2382				if (typeof element.textContent !== "undefined") {
2383					element.textContent = text;
2384				} else if (typeof element.innerText !== "undefined") {
2385					element.innerText = text;
2386				}
2387			},
2388			_removeClass: function _removeClass(element, classString) {
2389				var classes = classString.split(" ");
2390				var newClasses = element.className;
2391				for (var i = 0; i < classes.length; i++) {
2392					var classTag = classes[i];
2393					var regex = new RegExp("(?:\\s|^)" + classTag + "(?:\\s|$)");
2394					newClasses = newClasses.replace(regex, " ");
2395				}
2396				element.className = newClasses.trim();
2397			},
2398			_addClass: function _addClass(element, classString) {
2399				var classes = classString.split(" ");
2400				var newClasses = element.className;
2401				for (var i = 0; i < classes.length; i++) {
2402					var classTag = classes[i];
2403					var regex = new RegExp("(?:\\s|^)" + classTag + "(?:\\s|$)");
2404					var ifClassExists = regex.test(newClasses);
2405					if (!ifClassExists) {
2406						newClasses += " " + classTag;
2407					}
2408				}
2409				element.className = newClasses.trim();
2410			},
2411			_offsetLeft: function _offsetLeft(obj) {
2412				return obj.getBoundingClientRect().left;
2413			},
2414			_offsetRight: function _offsetRight(obj) {
2415				return obj.getBoundingClientRect().right;
2416			},
2417			_offsetTop: function _offsetTop(obj) {
2418				var offsetTop = obj.offsetTop;
2419				while ((obj = obj.offsetParent) && !isNaN(obj.offsetTop)) {
2420					offsetTop += obj.offsetTop;
2421					if (obj.tagName !== "BODY") {
2422						offsetTop -= obj.scrollTop;
2423					}
2424				}
2425				return offsetTop;
2426			},
2427			_offset: function _offset(obj) {
2428				return {
2429					left: this._offsetLeft(obj),
2430					right: this._offsetRight(obj),
2431					top: this._offsetTop(obj),
2432				};
2433			},
2434			_css: function _css(elementRef, styleName, value) {
2435				if ($) {
2436					$.style(elementRef, styleName, value);
2437				} else {
2438					var style = styleName.replace(/^-ms-/, "ms-").replace(/-([\da-z])/gi, function (all, letter) {
2439						return letter.toUpperCase();
2440					});
2441					elementRef.style[style] = value;
2442				}
2443			},
2444			_toValue: function _toValue(percentage) {
2445				return this.options.scale.toValue.apply(this, [percentage]);
2446			},
2447			_toPercentage: function _toPercentage(value) {
2448				return this.options.scale.toPercentage.apply(this, [value]);
2449			},
2450			_setTooltipPosition: function _setTooltipPosition() {
2451				var tooltips = [this.tooltip, this.tooltip_min, this.tooltip_max];
2452				if (this.options.orientation === "vertical") {
2453					var tooltipPos;
2454					if (this.options.tooltip_position) {
2455						tooltipPos = this.options.tooltip_position;
2456					} else {
2457						if (this.options.rtl) {
2458							tooltipPos = "left";
2459						} else {
2460							tooltipPos = "right";
2461						}
2462					}
2463					var oppositeSide = tooltipPos === "left" ? "right" : "left";
2464					tooltips.forEach(
2465						function (tooltip) {
2466							this._addClass(tooltip, tooltipPos);
2467							tooltip.style[oppositeSide] = "100%";
2468						}.bind(this)
2469					);
2470				} else if (this.options.tooltip_position === "bottom") {
2471					tooltips.forEach(
2472						function (tooltip) {
2473							this._addClass(tooltip, "bottom");
2474							tooltip.style.top = 22 + "px";
2475						}.bind(this)
2476					);
2477				} else {
2478					tooltips.forEach(
2479						function (tooltip) {
2480							this._addClass(tooltip, "top");
2481							tooltip.style.top = -this.tooltip.outerHeight - 14 + "px";
2482						}.bind(this)
2483					);
2484				}
2485			},
2486		};
2487		if ($ && $.fn) {
2488			var autoRegisterNamespace = void 0;
2489			if (!$.fn.slider) {
2490				$.bridget(NAMESPACE_MAIN, Slider);
2491				autoRegisterNamespace = NAMESPACE_MAIN;
2492			} else {
2493				if (windowIsDefined) {
2494					window.console.warn("bootstrap-slider.js - WARNING: $.fn.slider namespace is already bound. Use the $.fn.bootstrapSl
2494ider namespace instead.");
2495				}
2496				autoRegisterNamespace = NAMESPACE_ALTERNATE;
2497			}
2498			$.bridget(NAMESPACE_ALTERNATE, Slider);
2499			$(function () {
2500				$("input[data-provide=slider]")[autoRegisterNamespace]();
2501			});
2502		}
2503	})($);
2504	return Slider;
2505});
2506var $mcwp = jQuery.noConflict();
2507$mcwp(function ($) {
2508	$(document).on("click", ".mcwp-submit", function (e) {
2509		e.preventDefault();
2510		if (typeof navigator != "undefined" && navigator.webdriver) {
2511			alert(mcwp_ajax.calc_res);
2512			return false;
2513		}
2514		grecaptcha.execute().then((token) => {
2515			var forma = $(this).closest("form");
2516			$(forma).find("#g-recaptcha-response").val(token);
2517			sendForm(forma);
2518		});
2519	});
2520	function sendForm(forma) {
2521		var serializaFrom = $(forma).serializeArray();
2522		var post_data = {};
2523		$.each($(forma).serializeArray(), function () {
2524			post_data[this.name] = this.value;
2525		});
2526		console.log(post_data);
2527		currentFormEmail = $('input[type="email"]', forma).val();
2528		if (!validateEmail(currentFormEmail)) {
2529			alert("Your Email is not valid!");
2530			return false;
2531		}
2532		$.post(mcwp_ajax.ajaxurl, post_data, function (response) {
2533			if (response.status === "captcha_required") {
2534				if (forma.find('input[name="adc_1"]').length === 0) {
2535					forma.append('<input type="hidden" name="adc_1" value="' + response.adc_1 + '">');
2536				} else {
2537					forma.find('input[name="adc_1"]').val(response.adc_1);
2538				}
2539
2540				if (forma.find('input[name="adc_2"]').length === 0) {
2541					forma.append('<input type="hidden" name="adc_2" value="' + response.adc_2 + '">');
2542				} else {
2543					forma.find('input[name="adc_2"]').val(response.adc_2);
2544				}
2545
2546				var label = forma.find('label[for="cal1_email"]');
2547				if (label.length !== 0) {
2548					label.text(response.question).css("color", "red").css("font-weight", "bold");
2549				}
2550
2551				if (forma.find('input[name="adc_3"]').length === 0) {
2552					forma.find('input[type="email"]').before('<input type="number" name="adc_3" placeholder="Your answer here.">');
2553				}
2554
2555				forma.find('input[type="email"]').hide();
2556			} else {
2557				alert(response.message);
2558			}
2559			if (response.status === "success") {
2560				alert(response.message);
2561			}
2562			console.log(response);
2563			// alert(mcwp_ajax.calc_res);
2564		});
2565	}
2566	function validateEmail(email) {
2567		var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
2568		return re.test(String(email).toLowerCase());
2569	}
2570	$(".ex1").bootstrapSlider();
2571	function addCommas(intNum) {
2572		val = intNum;
2573		var parts = val.toString().split(".");
2574		parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2575		return parts.join(".");
2576	}
2577	function removeco(val) {
2578		return val.replace(/,/g, "");
2579	}
2580	$("form.mcalc-conventional").each(function () {
2581		var $parent = $(this);
2582		var purchase_price = removeco($("#inp_purchase_price", $parent).val());
2583		var down_payment_percent = $(".down_payment_scrl", $parent).val();
2584		var down_payment = (purchase_price * down_payment_percent) / 100;
2585		var interest_rate = $(".interest_rate_scrl", $parent).val();
2586		var insurance_rate = $(".insurance_rate_scrl", $parent).val();
2587		var mortgage_term = $("#mortgage_term_yr", $parent).val();
2588		var annual_tax_percent = $(".annual_tax_scrl", $parent).val();
2589		var annual_tax = (purchase_price * annual_tax_percent) / 100;
2590		var monthly_tax = annual_tax / 12;
2591		var monthly_insurance = $("#annual_insurance_inp", $parent).val() / 12;
2592		var mountly_pmi = (purchase_price * insurance_rate) / 12;
2593		var monthly_hoa = $("#monthly_hoa_inp", $parent).val();
2594		$("#down_payment_inp", $parent).val(addCommas(down_payment));
2595		$("#annual_tax_inp", $parent).val(addCommas(annual_tax));
2596		mortgage_calc($parent);
2597		$parent.find("#mortgage_term_yr").on("change", function (event) {
2598			if (this.value == 15) {
2599				mortgage_term_yr = 0.0045;
2600			} else {
2601				mortgage_term_yr = 0.0085;
2602			}
2603			mortgage_calc($parent);
2604		});
2605		$parent.find("#monthly_hoa_inp").on("keyup", function (event) {
2606			monthly_hoa = $(this).val() == "" ? 0 : $(this).val();
2607			$(this).val(function (index, value) {
2608				return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2609			});
2610			mortgage_calc($parent);
2611		});
2612		$parent.find(".ex1").on("change", function (slideEvt) {
2613			if ($(this).hasClass("down_payment_scrl")) {
2614				down_payment_percent = slideEvt.value.newValue;
2615				$(this)
2616					.next("p")
2617					.text(roundOff(down_payment_percent) + "%");
2618				down_payment = (purchase_price * down_payment_percent) / 100;
2619				$("#down_payment_inp", $parent).val(addCommas(down_payment));
2620			}
2621			if ($(this).hasClass("annual_tax_scrl")) {
2622				annual_tax_percent = slideEvt.value.newValue;
2623				$(this)
2624					.next("p")
2625					.text(annual_tax_percent + "%");
2626				annual_tax = (purchase_price * annual_tax_percent) / 100;
2627				monthly_tax = annual_tax / 12;
2628				$("#annual_tax_inp", $parent).val(addCommas(roundOff(annual_tax)));
2629			}
2630			if ($(this).hasClass("interest_rate_scrl")) {
2631				interest_rate = slideEvt.value.newValue;
2632				$(this)
2633					.next("p")
2634					.text(interest_rate + "%");
2635			}
2636			if ($(this).hasClass("insurance_rate_scrl")) {
2637				insurance_rate = slideEvt.value.newValue;
2638				$(this)
2639					.next("p")
2640					.text(insurance_rate + "%");
2641			}
2642			mortgage_calc($parent);
2643		});
2644		$parent.find("#inp_purchase_price").keyup(function () {
2645			purchase_price = $(this).val() == "" ? 0 : $(this).val();
2646			purchase_price = removeco(purchase_price);
2647			down_payment = (purchase_price * down_payment_percent) / 100;
2648			$("#down_payment_inp", $parent).val(addCommas(down_payment));
2649
2650			// added by bill bailey 1/30/2023
2651			annual_tax = (purchase_price * annual_tax_percent) / 100;
2652			$("#annual_tax_inp", $parent).val(addCommas(roundOff(annual_tax)));
2653			// end added by bill bailey 1/30/2023
2654
2655			$(this).val(function (index, value) {
2656				return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2657			});
2658			mortgage_calc($parent);
2659		});
2660		$parent.find("#down_payment_inp").keyup(function () {
2661			down_payment = removeco($(this).val()) == "" ? 0 : removeco($(this).val());
2662			down_payment_percent = (down_payment / purchase_price) * 100;
2663			$(".down_payment_scrl", $parent)
2664				.bootstrapSlider("setValue", down_payment_percent)
2665				.next("p")
2666				.text(roundOff(down_payment_percent) + "%");
2667			$(this).val(function (index, value) {
2668				return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2669			});
2670			mortgage_calc($parent);
2671		});
2672		$parent.find("#annual_tax_inp").keyup(function () {
2673			annual_tax = $(this).val() == "" ? 0 : removeco($(this).val());
2674			annual_tax_percent = (annual_tax / purchase_price) * 100;
2675			$(".annual_tax_scrl", $parent)
2676				.bootstrapSlider("setValue", annual_tax_percent)
2677				.next("p")
2678				.text(roundOff(annual_tax_percent) + "%");
2679			$(this).val(function (index, value) {
2680				return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2681			});
2682			$("#annual_tax_inp", $parent).val(addCommas(annual_tax));
2683			monthly_tax = annual_tax / 12;
2684			mortgage_calc($parent);
2685		});
2686		$parent.find("#annual_insurance_inp").keyup(function () {
2687			monthly_insurance = $(this).val() == "" ? 0 : removeco($(this).val()) / 12;
2688			$(this).val(function (index, value) {
2689				return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2690			});
2691			mortgage_calc($parent);
2692		});
2693	});
2694	function mortgage_calc($parent) {
2695		price = removeco($("#inp_purchase_price", $parent).val());
2696		down_payment = removeco($("#down_payment_inp", $parent).val()) == "" ? 0 : removeco($("#down_payment_inp", $parent).val());
2697		down_payment_percent = (down_payment / price) * 100;
2698		down = (price * down_payment_percent) / 100;
2699		rate = $(".interest_rate_scrl", $parent).val();
2700		inrate = $(".insurance_rate_scrl", $parent).val();
2701		term = $("#mortgage_term_yr", $parent).val();
2702		annual_tax_percentNew = $(".annual_tax_scrl", $parent).next("p").text();
2703		annual_tax_percentNew = annual_tax_percentNew.replace("%", "");
2704		annual_tax = (price * annual_tax_percentNew) / 100;
2705		tax = annual_tax / 12;
2706		mpmi = ((inrate / 100) * (price - down)) / 12;
2707		insurance = removeco($("#annual_insurance_inp", $parent).val()) / 12;
2708		hoa = removeco($("#monthly_hoa_inp").val()) == "" ? 0 : removeco($("#monthly_hoa_inp", $parent).val());
2709		var n = parseInt(term) * 12;
2710		var c = parseFloat(rate) / 1200;
2711		var L = parseInt(price) - parseFloat(down);
2712		var p = Math.round((L * (c * Math.pow(1 + c, n))) / (Math.pow(1 + c, n) - 1));
2713		var emmp = parseFloat(p) + parseFloat(tax) + parseFloat(insurance) + parseFloat(hoa);
2714		changethis = roundOff(emmp, 2);
2715
2716		// edited by bill bailey 2/6/2023
2717		// moved the check for down payment percent above where value are output to html and add the pmi
2718		if (down_payment_percent >= 20) {
2719			$(".mcwp-insurance-rate").hide();
2720			$(".mcwp-insurance-rate-disabled").show();
2721			mpmi = 0;
2722		} else {
2723			$(".mcwp-insurance-rate").show();
2724			$(".mcwp-insurance-rate-disabled").hide();
2725			emmp = emmp + parseFloat(mpmi);
2726		}
2727		// end edited by bill bailey 2/6/2023
2728
2729		$("#emmp_div_span", $parent).text(addCommas(roundOff(emmp, 2)));
2730		$("#pi_div_span", $parent).text(addCommas(p));
2731		$("#mtax_div_span", $parent).text(addCommas(roundOff(tax, 2)));
2732		$("#minsure_div_span", $parent).text(addCommas(roundOff(insurance, 2)));
2733		$("#hoa_div_span", $parent).text(addCommas(hoa));
2734		$("#mpmi", $parent).text(addCommas(roundOff(mpmi, 2)));
2735		$(".emmp_div_span", $parent).val(addCommas(roundOff(emmp, 2)));
2736		$(".pi_div_span", $parent).val(addCommas(p));
2737		$(".mtax_div_span", $parent).val(addCommas(roundOff(tax, 2)));
2738		$(".minsure_div_span", $parent).val(addCommas(roundOff(insurance, 2)));
2739		$(".mpmi_div_span", $parent).val(addCommas(roundOff(mpmi, 2)));
2740		$(".hoa_div_span", $parent).val(addCommas(hoa));
2741	}
2742	if ($("#fha_inp_purchase_price").val()) {
2743		var fha_purchase_price = removeco($("#fha_inp_purchase_price").val());
2744		var fha_down_payment_percent = $(".fha_down_payment_scrl").val();
2745		var fha_down_payment = (fha_purchase_price * fha_down_payment_percent) / 100;
2746		var fha_interest_rate = $(".fha_interest_rate_scrl").val();
2747		var fha_mortgage_term = $("#fha_mortgage_term_yr").val();
2748		var fha_annual_tax_percent = $(".fha_annual_tax_scrl").val();
2749		var fha_annual_tax = (fha_purchase_price * fha_annual_tax_percent) / 100;
2750		var fha_monthly_tax = fha_annual_tax / 12;
2751		var fha_monthly_insurance = $("#fha_annual_insurance_inp").val() / 12;
2752		var monthly_mortgage_insurance = $("#fha_mmi_div_span").val() / 200;
2753		var fha_monthly_hoa = $("#fha_monthly_hoa_inp").val();
2754		$("#fha_down_payment_inp").val(addCommas(fha_down_payment));
2755		$("#fha_annual_tax_inp").val(addCommas(fha_annual_tax));
2756		fha_mortgage_calc(fha_purchase_price, fha_down_payment, fha_interest_rate, fha_mortgage_term, fha_monthly_tax, fha_annual_tax_percent, fha_monthly_insurance, fha_monthly_hoa);
2757	}
2758	$(document).on("change", "#fha_mortgage_term_yr", function () {
2759		fha_mortgage_calc(fha_purchase_price, fha_down_payment, fha_interest_rate, this.value, fha_monthly_tax, fha_annual_tax_percent, fha_monthly_insurance, fha_monthly_hoa);
2760	});
2761	$(".ex1").on("change", function (slideEvt) {
2762		if ($(this).hasClass("fha_down_payment_scrl")) {
2763			fha_down_payment_percent = slideEvt.value.newValue;
2764			$(this)
2765				.next("p")
2766				.text(roundOff(fha_down_payment_percent) + "%");
2767			fha_down_payment = (fha_purchase_price * fha_down_payment_percent) / 100;
2768			$("#fha_down_payment_inp").val(addCommas(fha_down_payment));
2769			fha_mortgage_calc(fha_purchase_price, fha_down_payment, fha_interest_rate, fha_mortgage_term, fha_monthly_tax, fha_annual_tax_percent, fha_monthly_insurance, fha_monthly_hoa);
2770		}
2771		if ($(this).hasClass("fha_annual_tax_scrl")) {
2772			fha_annual_tax_percent = slideEvt.value.newValue;
2773			$(this)
2774				.next("p")
2775				.text(fha_annual_tax_percent + "%");
2776			fha_annual_tax = (fha_purchase_price * fha_annual_tax_percent) / 100;
2777			fha_monthly_tax = fha_annual_tax / 12;
2778			$("#fha_annual_tax_inp").val(addCommas(roundOff(fha_annual_tax)));
2779			fha_mortgage_calc(fha_purchase_price, fha_down_payment, fha_interest_rate, fha_mortgage_term, fha_monthly_tax, fha_annual_tax_percent, fha_monthly_insurance, fha_monthly_hoa, "no");
2780		}
2781		if ($(this).hasClass("fha_interest_rate_scrl")) {
2782			fha_interest_rate = slideEvt.value.newValue;
2783			$(this).next("p").text(fha_interest_rate) + "%";
2784			fha_mortgage_calc(fha_purchase_price, fha_down_payment, fha_interest_rate, fha_mortgage_term, fha_monthly_tax, fha_annual_tax_percent, fha_monthly_insurance, fha_monthly_hoa);
2785		}
2786	});
2787	$("#fha_inp_purchase_price").keyup(function () {
2788		fha_down_payment_percent = Number($(".fha_down_payment_scrl").val());
2789		fha_purchase_price = $(this).val() == "" ? 0 : removeco($(this).val());
2790		fha_down_payment = (fha_purchase_price * fha_down_payment_percent) / 100;
2791		fha_down_payment = fha_down_payment;
2792
2793		// added by bill bailey 1/30/2023
2794		fha_annual_tax = (fha_purchase_price * fha_annual_tax_percent) / 100;
2795		fha_monthly_tax = fha_annual_tax / 12;
2796		$("#fha_annual_tax_inp").val(addCommas(roundOff(fha_annual_tax)));
2797		// end added by bill bailey 1/30/2023
2798
2799		$("#fha_down_payment_inp").val(addCommas(fha_down_payment));
2800		$(this).val(function (index, value) {
2801			return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2802		});
2803		fha_mortgage_calc(fha_purchase_price, fha_down_payment, fha_interest_rate, fha_mortgage_term, fha_monthly_tax, fha_annual_tax_percent, fha_monthly_insurance, fha_monthly_hoa);
2804	});
2805	$("#fha_down_payment_inp").keyup(function () {
2806		fha_down_payment = $(this).val() == "" ? 0 : removeco($(this).val());
2807		fha_down_payment = parseInt(fha_down_payment);
2808		fha_down_payment_percent = (fha_down_payment / fha_purchase_price) * 100;
2809		$(".fha_down_payment_scrl")
2810			.bootstrapSlider("setValue", fha_down_payment_percent)
2811			.next("p")
2812			.text(roundOff(fha_down_payment_percent) + "%");
2813		$(this).val(function (index, value) {
2814			return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2815		});
2816		fha_mortgage_calc(fha_purchase_price, fha_down_payment, fha_interest_rate, fha_mortgage_term, fha_monthly_tax, fha_annual_tax_percent, fha_monthly_insurance, fha_monthly_hoa);
2817	});
2818	$("#fha_annual_tax_inp").keyup(function () {
2819		fha_annual_tax = $(this).val() == "" ? 0 : removeco($(this).val());
2820		fha_annual_tax = Number(fha_annual_tax);
2821		fha_annual_tax = roundOff(fha_annual_tax);
2822		fha_annual_tax_percent = (fha_annual_tax / fha_purchase_price) * 100;
2823		$(".fha_annual_tax_scrl")
2824			.bootstrapSlider("setValue", fha_annual_tax_percent)
2825			.next("p")
2826			.text(roundOff(fha_annual_tax_percent) + "%");
2827		$(this).val(function (index, value) {
2828			newval = value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2829			return newval;
2830		});
2831		fha_mortgage_calc(fha_purchase_price, fha_down_payment, fha_interest_rate, fha_mortgage_term, fha_monthly_tax, fha_annual_tax_percent, fha_monthly_insurance, fha_monthly_hoa);
2832		fha_monthly_tax = fha_annual_tax / 12;
2833		$(".mtchange").empty();
2834		$(".mtchange")
2835			.empty()
2836			.text(addCommas(roundOff(fha_monthly_tax, 2)));
2837	});
2838	$("#fha_annual_insurance_inp").keyup(function () {
2839		fha_monthly_insurance = $(this).val() == "" ? 0 : $(this).val() / 12;
2840		$(this).val(function (index, value) {
2841			return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2842		});
2843		fha_mortgage_calc(fha_purchase_price, fha_down_payment, fha_interest_rate, fha_mortgage_term, fha_monthly_tax, fha_annual_tax_percent, fha_monthly_insurance, fha_monthly_hoa);
2844	});
2845	$("#fha_mmi_div_span").keyup(function () {
2846		monthly_mortgage_insurance = $(this).val() == "" ? 0 : $(this).val() / 0;
2847		$(this).val(function (index, value) {
2848			return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2849		});
2850		fha_mortgage_calc(fha_purchase_price, fha_down_payment, fha_interest_rate, fha_mortgage_term, fha_monthly_tax, fha_annual_tax_percent, fha_monthly_insurance, monthly_mortgage_insurance, fha_monthly_hoa);
2851	});
2852	$("#fha_monthly_hoa_inp").keyup(function () {
2853		fha_monthly_hoa = $(this).val() == "" ? 0 : $(this).val();
2854		$(this).val(function (index, value) {
2855			return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2856		});
2857		fha_mortgage_calc(fha_purchase_price, fha_down_payment, fha_interest_rate, fha_mortgage_term, fha_monthly_tax, fha_annual_tax_percent, fha_monthly_insurance, fha_monthly_hoa);
2858	});
2859	function calculate_mip(loan_amount, loan_to_value, term) {
2860		let mip_rate;
2861
2862		if (term > 15) {
2863			if (loan_amount <= 726200) {
2864				if (loan_to_value <= 90) {
2865					mip_rate = 0.005;
2866				} else if (loan_to_value > 90 && loan_to_value <= 95) {
2867					mip_rate = 0.005;
2868				} else {
2869					mip_rate = 0.0055;
2870				}
2871			} else {
2872				if (loan_to_value <= 90) {
2873					mip_rate = 0.007;
2874				} else if (loan_to_value > 90 && loan_to_value <= 95) {
2875					mip_rate = 0.007;
2876				} else {
2877					mip_rate = 0.0075;
2878				}
2879			}
2880		} else {
2881			if (loan_amount <= 726200) {
2882				if (loan_to_value <= 90) {
2883					mip_rate = 0.0015;
2884				} else {
2885					mip_rate = 0.004;
2886				}
2887			} else {
2888				if (loan_to_value <= 78) {
2889					mip_rate = 0.0015;
2890				} else if (loan_to_value > 78 && loan_to_value <= 90) {
2891					mip_rate = 0.004;
2892				} else {
2893					mip_rate = 0.0065;
2894				}
2895			}
2896		}
2897
2898		return mip_rate * loan_amount;
2899	}
2900	function fha_mortgage_calc(price, down, rate, term, tax, tax_prcnt, insurance, hoa, show) {
2901		price = removeco($("#fha_inp_purchase_price").val());
2902		fha_down_payment_percent = $(".fha_down_payment_scrl").val();
2903		down = (price * fha_down_payment_percent) / 100;
2904		rate = $(".fha_interest_rate_scrl").val();
2905		term = $("#fha_mortgage_term_yr").val();
2906		insurance = removeco($("#fha_annual_insurance_inp").val()) / 12;
2907		hoa = removeco($("#fha_monthly_hoa_inp").val()) == "" ? 0 : removeco($("#fha_monthly_hoa_inp").val());
2908		var n = parseInt(term) * 12;
2909		var c = parseFloat(rate) / 1200;
2910		var L = parseInt(price) - parseFloat(down);
2911		// Calculate UPMIP
2912		var upmip_rate = 0.0175;
2913		var upmip = L * upmip_rate;
2914
2915		// Add UPMIP to the loan amount
2916		L = L + upmip;
2917
2918		var p = Math.round((L * (c * Math.pow(1 + c, n))) / (Math.pow(1 + c, n) - 1));
2919		if (term == 15) {
2920			tax_prcnt = 0.45;
2921		} else if (term == 30) {
2922			tax_prcnt = 0.85;
2923		}
2924		var loan_to_value = ((price - down) / price) * 100;
2925		var mip_annual = calculate_mip(L, loan_to_value, parseInt(term));
2926		var mmi = Math.round(mip_annual / 12);
2927
2928		var emmp = parseFloat(p) + parseFloat(tax) + parseFloat(insurance) + parseFloat(hoa) + parseFloat(mmi);
2929		$("#fha_emmp_div_span").text(addCommas(roundOff(emmp, 2)));
2930		$("#fha_pi_div_span").text(addCommas(p));
2931		$("#fha_mtax_div_span").text(addCommas(roundOff(tax, 2)));
2932		$("#fha_minsure_div_span").text(addCommas(roundOff(insurance, 2)));
2933		if (show != "no") {
2934			$("#fha_mmi_div_span").text(addCommas(roundOff(mmi)));
2935		}
2936		$("#fha_upmip_div_span").text(addCommas(roundOff(upmip)));
2937		$("#fha_hoa_div_span").text(addCommas(hoa));
2938		$(".fha_emmp_div_span").val(addCommas(roundOff(emmp, 2)));
2939		$(".fha_pi_div_span").val(addCommas(p));
2940		$(".fha_mtax_div_span").val(addCommas(roundOff(tax, 2)));
2941		$(".fha_minsure_div_span").val(addCommas(roundOff(insurance, 2)));
2942		if (show != "no") {
2943			$(".fha_mmi_div_span").val(addCommas(mmi));
2944		}
2945		$(".fha_hoa_div_span").val(addCommas(hoa));
2946	}
2947	if ($("#va_inp_purchase_price").val()) {
2948		var va_purchase_price = $("#va_inp_purchase_price").val();
2949		va_purchase_price = removeco(va_purchase_price);
2950		var va_down_payment_percent = $(".va_down_payment_scrl").val();
2951		var va_down_payment = (va_purchase_price * va_down_payment_percent) / 100;
2952		var va_interest_rate = $(".va_interest_rate_scrl").val();
2953		var va_mortgage_term = $("#va_mortgage_term_yr").val();
2954		var va_annual_tax_percent = $(".va_annual_tax_scrl").val();
2955		var va_annual_tax = (va_purchase_price * va_annual_tax_percent) / 100;
2956		var va_monthly_tax = va_annual_tax / 12;
2957		var va_monthly_insurance = removeco($("#va_annual_insurance_inp").val()) / 12;
2958		var va_monthly_hoa = $("#va_monthly_hoa_inp").val();
2959		$("#va_down_payment_inp").val(addCommas(va_down_payment));
2960		$("#va_annual_tax_inp").val(addCommas(va_annual_tax));
2961		va_mortgage_calc(va_purchase_price, va_down_payment, va_interest_rate, va_mortgage_term, va_monthly_tax, va_down_payment_percent, va_monthly_insurance, va_monthly_hoa);
2962	}
2963	$(document).on("change", "#va_mortgage_term_yr", function () {
2964		va_mortgage_calc(va_purchase_price, va_down_payment, va_interest_rate, this.value, va_monthly_tax, va_down_payment_percent, va_monthly_insurance, va_monthly_hoa);
2965	});
2966	$(".ex1").on("change", function (slideEvt) {
2967		if ($(this).hasClass("va_down_payment_scrl")) {
2968			va_down_payment_percent = slideEvt.value.newValue;
2969			$(this)
2970				.next("p")
2971				.text(va_down_payment_percent + "%");
2972			va_down_payment = (va_purchase_price * va_down_payment_percent) / 100;
2973			$("#va_down_payment_inp").val(addCommas(va_down_payment));
2974			va_mortgage_calc(va_purchase_price, va_down_payment, va_interest_rate, va_mortgage_term, va_monthly_tax, va_down_payment_percent, va_monthly_insurance, va_monthly_hoa);
2975		}
2976		if ($(this).hasClass("va_annual_tax_scrl")) {
2977			va_annual_tax_percent = slideEvt.value.newValue;
2978			$(this)
2979				.next("p")
2980				.text(roundOff(va_annual_tax_percent, 1) + "%");
2981			va_annual_tax = (va_purchase_price * va_annual_tax_percent) / 100;
2982			va_monthly_tax = va_annual_tax / 12;
2983			$("#va_annual_tax_inp").val(addCommas(roundOff(va_annual_tax)));
2984			va_mortgage_calc(va_purchase_price, va_down_payment, va_interest_rate, va_mortgage_term, va_monthly_tax, va_down_payment_percent, va_monthly_insurance, va_monthly_hoa);
2985		}
2986		if ($(this).hasClass("va_interest_rate_scrl")) {
2987			va_interest_rate = slideEvt.value.newValue;
2988			$(this).next("p").text(va_interest_rate) + "%";
2989			va_mortgage_calc(va_purchase_price, va_down_payment, va_interest_rate, va_mortgage_term, va_monthly_tax, va_down_payment_percent, va_monthly_insurance, va_monthly_hoa);
2990		}
2991	});
2992	$("#va_inp_purchase_price").keyup(function () {
2993		va_purchase_price = $(this).val() == "" ? 0 : $(this).val();
2994		va_purchase_price = removeco(va_purchase_price);
2995		va_down_payment = (va_purchase_price * va_down_payment_percent) / 100;
2996		$("#va_down_payment_inp").val(addCommas(va_down_payment));
2997
2998		// added by bill bailey 1/30/2023
2999		va_annual_tax = (va_purchase_price * va_annual_tax_percent) / 100;
3000		va_monthly_tax = va_annual_tax / 12;
3001		$("#va_annual_tax_inp").val(addCommas(roundOff(va_annual_tax)));
3002		// end added by bill bailey 1/30/2023
3003
3004		$(this).val(function (index, value) {
3005			return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
3006		});
3007		va_mortgage_calc(va_purchase_price, va_down_payment, va_interest_rate, va_mortgage_term, va_monthly_tax, va_down_payment_percent, va_monthly_insurance, va_monthly_hoa);
3008	});
3009	$("#va_down_payment_inp").keyup(function () {
3010		va_down_payment = $(this).val() == "" ? 0 : $(this).val();
3011		va_down_payment = removeco(va_down_payment);
3012		va_down_payment_percent = (va_down_payment / va_purchase_price) * 100;
3013		$(".va_down_payment_scrl")
3014			.bootstrapSlider("setValue", va_down_payment_percent)
3015			.next("p")
3016			.text(roundOff(va_down_payment_percent) + "%");
3017		$(this).val(function (index, value) {
3018			return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
3019		});
3020		va_mortgage_calc(va_purchase_price, va_down_payment, va_interest_rate, va_mortgage_term, va_monthly_tax, va_down_payment_percent, va_monthly_insurance, va_monthly_hoa);
3021	});
3022	$("#va_annual_tax_inp").keyup(function () {
3023		va_annual_tax = $(this).val() == "" ? 0 : $(this).val();
3024		va_annual_tax = removeco(va_annual_tax);
3025		va_annual_tax_percent = (va_annual_tax / va_purchase_price) * 100;
3026		$(this).val(function (index, value) {
3027			return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
3028		});
3029		va_monthly_tax = va_annual_tax / 12;
3030		$(".va_annual_tax_scrl")
3031			.bootstrapSlider("setValue", va_annual_tax_percent)
3032			.next("p")
3033			.text(va_annual_tax_percent + "%");
3034		va_mortgage_calc(va_purchase_price, va_down_payment, va_interest_rate, va_mortgage_term, va_monthly_tax, va_down_payment_percent, va_monthly_insurance, va_monthly_hoa);
3035	});
3036	$("#va_annual_insurance_inp").keyup(function () {
3037		va_monthly_insurance = $(this).val() == "" ? 0 : removeco($(this).val()) / 12;
3038		$(this).val(function (index, value) {
3039			return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
3040		});
3041		va_mortgage_calc(va_purchase_price, va_down_payment, va_interest_rate, va_mortgage_term, va_monthly_tax, va_down_payment_percent, va_monthly_insurance, va_monthly_hoa);
3042	});
3043	$("#va_monthly_hoa_inp").keyup(function () {
3044		va_monthly_hoa = $(this).val() == "" ? 0 : $(this).val();
3045		$(this).val(function (index, value) {
3046			return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
3047		});
3048		va_mortgage_calc(va_purchase_price, va_down_payment, va_interest_rate, va_mortgage_term, va_monthly_tax, va_down_payment_percent, va_monthly_insurance, va_monthly_hoa);
3049	});
3050	$(document).on("change", "#va_service_type", function () {
3051		va_monthly_insurance = removeco($("#va_annual_insurance_inp").val()) / 12;
3052		va_mortgage_calc(va_purchase_price, va_down_payment, va_interest_rate, va_mortgage_term, va_monthly_tax, va_down_payment_percent, va_monthly_insurance, va_monthly_hoa);
3053	});
3054	$(document).on("change", "#va_frist_time", function () {
3055		va_monthly_insurance = removeco($("#va_annual_insurance_inp").val()) / 12;
3056		va_mortgage_calc(va_purchase_price, va_down_payment, va_interest_rate, va_mortgage_term, va_monthly_tax, va_down_payment_percent, va_monthly_insurance, va_monthly_hoa);
3057	});
3058	function va_mortgage_calc(price, down, rate, term, tax, down_prcnt, insurance, hoa) {
3059		var va_purchase_price = $("#va_inp_purchase_price").val();
3060		price = removeco(va_purchase_price);
3061		va_down_payment_percent = $(".va_down_payment_scrl").val();
3062		down = (price * va_down_payment_percent) / 100;
3063		rate = $(".va_interest_rate_scrl").val();
3064		term = $("#va_mortgage_term_yr").val();
3065		a_annual_tax_percent = $(".va_annual_tax_scrl").val();
3066		va_annual_tax = (price * va_annual_tax_percent) / 100;
3067		tax = va_annual_tax / 12;
3068		insurance = removeco($("#va_annual_insurance_inp").val()) / 12;
3069		hoa = removeco($("#va_monthly_hoa_inp").val()) == "" ? 0 : removeco($("#va_monthly_hoa_inp").val());
3070		if ($("#va_frist_time").val() == "yes") {
3071			if (down_prcnt < 5) {
3072				e_rate = 2.15;
3073			}
3074			if (down_prcnt >= 5 && down_prcnt < 10) {
3075				e_rate = 1.5;
3076			}
3077			if (down_prcnt >= 10) {
3078				e_rate = 1.25;
3079			}
3080		} else {
3081			if (down_prcnt < 5) {
3082				e_rate = 3.3;
3083			}
3084			if (down_prcnt >= 5 && down_prcnt < 10) {
3085				e_rate = 1.5;
3086			}
3087			if (down_prcnt >= 10) {
3088				e_rate = 1.25;
3089			}
3090		}
3091		var n = parseInt(term) * 12;
3092		var c = parseFloat(rate) / 1200;
3093		var L = parseInt(price) - parseFloat(down);
3094
3095		// var p = Math.round(
3096		//   (L * (c * Math.pow(1 + c, n))) / (Math.pow(1 + c, n) - 1)
3097		// );
3098		// var vaff = Math.round((L * e_rate) / 18e3);
3099		// updated by bill bailey 2/23/2023
3100		// vaff monthly calculations incorrect.
3101
3102		var p = (L * (c * Math.pow(1 + c, n))) / (Math.pow(1 + c, n) - 1);
3103		var vaff = (((L * e_rate) / 100) * (c * Math.pow(1 + c, n))) / (Math.pow(1 + c, n) - 1);
3104
3105		var emmp = parseFloat(p) + parseFloat(tax) + parseFloat(insurance) + parseFloat(hoa) + parseFloat(vaff);
3106		$("#va_emmp_div_span").text(addCommas(roundOff(emmp, 2)));
3107		$("#va_pi_div_span").text(addCommas(roundOff(p, 2)));
3108		$("#va_mtax_div_span").text(addCommas(roundOff(tax, 2)));
3109		$("#va_minsure_div_span").text(addCommas(roundOff(insurance, 2)));
3110		$("#va_hoa_div_span").text(addCommas(hoa));
3111		$("#va_purchase_p_span").text(addCommas(price));
3112		$("#va_funding_fee_p_span").html(addCommas(roundOff((L * e_rate) / 100, 2)));
3113		va_funding_fee_p_span = removeco($("#va_funding_fee_p_span").text());
3114		va_funding_fee_p_span = Number(va_funding_fee_p_span);
3115		va_purchase_price = removeco($("#va_inp_purchase_price").val());
3116		va_purchase_price = Number(va_purchase_price);
3117		va_down_payment_percent = $(".va_down_payment_scrl").val();
3118		va_down_payment_percent = Number(va_down_payment_percent);
3119		va_down_payment = (va_purchase_price * va_down_payment_percent) / 100;
3120		va_amount_finance_p_span = va_purchase_price - va_down_payment + va_funding_fee_p_span;
3121		$("#va_amount_finance_p_span").html(addCommas(roundOff(Number(va_amount_finance_p_span))));
3122		$(".va_emmp_div_span").val($("#va_emmp_div_span").text());
3123		$(".va_pi_div_span").val($("#va_pi_div_span").text());
3124		$(".va_mtax_div_span").val($("#va_mtax_div_span").text());
3125		$(".va_minsure_div_span").val($("#va_minsure_div_span").text());
3126		$(".va_hoa_div_span").val($("#va_hoa_div_span").text());
3127		$(".va_funding_fee_p_span").val($("#va_funding_fee_p_span").text());
3128		$(".va_amount_finance_p_span").val($("#va_amount_finance_p_span").text());
3129	}
3130
3131	// updated by bill bailey to fix the issue with ".00" returned 1/31/2023
3132	function roundOff(number, precision) {
3133		num = number;
3134		return parseFloat(num.toFixed(precision));
3135	}
3136	// end update
3137
3138	function mha_mortgage_calc() {
3139		var mha_annual_income = removeco($("#mha_annual_income").val());
3140		$("#mha_annual_income").val(addCommas(mha_annual_income));
3141		var mha_interest_rate = removeco($("#mha_interest_rate").val());
3142		$("#mha_interest_rate").val(addCommas(mha_interest_rate));
3143		var mha_monthly_debts = removeco($("#mha_monthly_debts").val());
3144		$("#mha_monthly_debts").val(addCommas(mha_monthly_debts));
3145		var mha_estimated_annual_home_insurance = removeco($("#mha_estimated_annual_home_insurance").val());
3146		$("#mha_estimated_annual_home_insurance").val(addCommas(mha_estimated_annual_home_insurance));
3147		var mha_estimated_annual_property_taxes = removeco($("#mha_estimated_annual_property_taxes").val());
3148		$("#mha_estimated_annual_property_taxes").val(addCommas(mha_estimated_annual_property_taxes));
3149		var mha_down_payment = removeco($("#mha_down_payment").val());
3150		$("#mha_down_payment").val(addCommas(mha_down_payment));
3151		var mha_loan_term = removeco($("#mha_loan_term").val());
3152		$("#mha_loan_term").val(addCommas(mha_loan_term));
3153		if (mha_loan_term == "") {
3154			mha_loan_term = 30;
3155		}
3156		if (mha_annual_income != "" && mha_interest_rate != "") {
3157			var minimum_monthly_debts = (mha_annual_income * 8) / 100 / 12;
3158			if (mha_monthly_debts == "" || mha_monthly_debts < minimum_monthly_debts) {
3159				var mha_est_monthly_payment = (mha_annual_income / 12) * 0.4 - minimum_monthly_debts;
3160				if (mha_estimated_annual_property_taxes != "") {
3161					var mha_taxes = mha_estimated_annual_property_taxes / 12;
3162				} else {
3163					var mha_taxes = 0;
3164				}
3165				if (mha_estimated_annual_home_insurance != "") {
3166					var mha_insurance = mha_estimated_annual_home_insurance / 12;
3167				} else {
3168					var mha_insurance = 0;
3169				}
3170				var mha_P_I = mha_est_monthly_payment - (mha_taxes + mha_insurance);
3171				var aaaaa = mha_interest_rate / 100 / 12;
3172				var mpowerdata = Math.pow(1 + mha_interest_rate / 100 / 12, -mha_loan_term * 12);
3173				var bbbbb = 1 - mpowerdata;
3174				var ab = bbbbb / aaaaa;
3175				if (ab < 0) {
3176					var temp = ab * mha_P_I;
3177					var ab_total = temp - parseInt(mha_down_payment);
3178				} else {
3179					var temp = ab * mha_P_I;
3180					var ab_total = temp + parseInt(mha_down_payment);
3181				}
3182				if (ab_total <= 0) {
3183					$("#mha_afford_house_div_span").html("0");
3184				} else {
3185					$("#mha_afford_house_div_span").html(Number(Math.round(ab_total)).toLocaleString("en"));
3186				}
3187				if (mha_est_monthly_payment <= 0) {
3188					$("#mha_emmp_div_span").html("0");
3189				} else {
3190					$("#mha_emmp_div_span").html(Number(Math.round(mha_est_monthly_payment)).toLocaleString("en"));
3191				}
3192				if (mha_P_I <= 0) {
3193					$("#mha_pi_div_span").html("0");
3194				} else {
3195					$("#mha_pi_div_span").html(Number(Math.round(mha_P_I)).toLocaleString("en"));
3196				}
3197				if (mha_taxes <= 0) {
3198					$("#mha_taxes_div_span").html("0");
3199				} else {
3200					$("#mha_taxes_div_span").html(Number(Math.round(mha_taxes)).toLocaleString("en"));
3201				}
3202				if (mha_insurance <= 0) {
3203					$("#mha_insurance_div_span").html("0");
3204				} else {
3205					$("#mha_insurance_div_span").html(Number(Math.round(mha_insurance)).toLocaleString("en"));
3206				}
3207			} else {
3208				var mha_est_monthly_payment = (mha_annual_income / 12) * 0.4 - mha_monthly_debts;
3209				if (mha_estimated_annual_property_taxes != "") {
3210					var mha_taxes = mha_estimated_annual_property_taxes / 12;
3211				} else {
3212					var mha_taxes = 0;
3213				}
3214				if (mha_estimated_annual_home_insurance != "") {
3215					var mha_insurance = mha_estimated_annual_home_insurance / 12;
3216				} else {
3217					var mha_insurance = 0;
3218				}
3219				var mha_P_I = mha_est_monthly_payment - (mha_taxes + mha_insurance);
3220				var aaaaa = mha_interest_rate / 100 / 12;
3221				var mpowerdata = Math.pow(1 + mha_interest_rate / 100 / 12, -mha_loan_term * 12);
3222				var bbbbb = 1 - mpowerdata;
3223				var ab = bbbbb / aaaaa;
3224				if (ab < 0) {
3225					var temp = ab * mha_P_I;
3226					var ab_total = temp - parseInt(mha_down_payment);
3227				} else {
3228					var temp = ab * mha_P_I;
3229					var ab_total = temp + parseInt(mha_down_payment);
3230				}
3231				if (ab_total <= 0) {
3232					$("#mha_afford_house_div_span").html("0");
3233				} else {
3234					$("#mha_afford_house_div_span").html(Number(Math.round(ab_total)).toLocaleStr
3234ing("en"));
3235				}
3236				if (mha_est_monthly_payment <= 0) {
3237					$("#mha_emmp_div_span").html("0");
3238				} else {
3239					$("#mha_emmp_div_span").html(Number(Math.round(mha_est_monthly_payment)).toLocaleString("en"));
3240				}
3241				if (mha_P_I <= 0) {
3242					$("#mha_pi_div_span").html("0");
3243				} else {
3244					$("#mha_pi_div_span").html(Number(Math.round(mha_P_I)).toLocaleString("en"));
3245				}
3246				if (mha_taxes <= 0) {
3247					$("#mha_taxes_div_span").html("0");
3248				} else {
3249					$("#mha_taxes_div_span").html(Number(Math.round(mha_taxes)).toLocaleString("en"));
3250				}
3251				if (mha_insurance <= 0) {
3252					$("#mha_insurance_div_span").html("0");
3253				} else {
3254					$("#mha_insurance_div_span").html(Number(Math.round(mha_insurance)).toLocaleString("en"));
3255				}
3256			}
3257		}
3258	}
3259	$("form.mcalc-ha").each(function () {
3260		var este = $(this);
3261		mha_mortgage_calc();
3262		mha_input_vals(este);
3263		$("input", este).each(function () {
3264			$(this).on("keyup", function () {
3265				mha_mortgage_calc();
3266				mha_input_vals(este);
3267			});
3268		});
3269		$("select", este).each(function () {
3270			$(this).on("change", function () {
3271				mha_mortgage_calc();
3272				mha_input_vals(este);
3273			});
3274		});
3275	});
3276	function mha_input_vals(este) {
3277		$(".mha_insurance_div_span", este).val($("#mha_insurance_div_span", este).text());
3278		$(".mha_taxes_div_span", este).val($("#mha_taxes_div_span", este).text());
3279		$(".mha_pi_div_span", este).val($("#mha_pi_div_span", este).text());
3280		$(".mha_emmp_div_span", este).val($("#mha_emmp_div_span", este).text());
3281		$(".mha_afford_house_div_span", este).val($("#mha_afford_house_div_span", este).text());
3282	}
3283	function rc_mortgage_calc() {
3284		var rc_original_loan_amount = removeco($("#rc_original_loan_amount").val());
3285		$("#rc_original_loan_amount").val(addCommas(rc_original_loan_amount));
3286		var rc_interest_rate = removeco($("#rc_interest_rate").val());
3287		$("#rc_interest_rate").val(addCommas(rc_interest_rate));
3288		var rc_current_term = removeco($("#rc_current_term").val());
3289		$("#rc_current_term").val(addCommas(rc_current_term));
3290		var rc_new_loan_amount = removeco($("#rc_new_loan_amount").val());
3291		$("#rc_new_loan_amount").val(addCommas(rc_new_loan_amount));
3292		var rc_new_interest_rate = removeco($("#rc_new_interest_rate").val());
3293		$("#rc_new_interest_rate").val(addCommas(rc_new_interest_rate));
3294		var rc_new_loan_term = removeco($("#rc_new_loan_term").val());
3295		$("#rc_new_loan_term").val(addCommas(rc_new_loan_term));
3296		var rc_new_refinance_fees = removeco($("#rc_new_refinance_fees").val());
3297		$("#rc_new_refinance_fees").val(addCommas(rc_new_refinance_fees));
3298		var rc_origination_year = $("#rc_origination_year").val();
3299		if (rc_new_loan_amount == "") {
3300			rc_new_loan_amount = 0;
3301		}
3302		if (rc_original_loan_amount == "") {
3303			rc_original_loan_amount = 0;
3304		}
3305		if (rc_new_loan_amount == 0 && rc_original_loan_amount == 0) {
3306			$("#rc_pi_div_span").html(rc_new_refinance_fees);
3307			$("#rc_afford_house_div_span").html("0");
3308			$("#rc_emmp_div_span").html("0");
3309			$("#rc_lifetime_div_span").html("0");
3310		} else if (parseInt(rc_new_loan_amount) > parseInt(rc_original_loan_amount)) {
3311			var nleft_data = (rc_new_interest_rate / 100 / 12) * rc_new_loan_amount;
3312			var nmpowerdata = Math.pow(1 + rc_new_interest_rate / 100 / 12, -rc_new_loan_term);
3313			var nright_data = 1 - nmpowerdata;
3314			newloanpayment = nleft_data / nright_data;
3315			$("#rc_afford_house_div_span").html("0");
3316			$("#rc_emmp_div_span").html(Number(Math.round(newloanpayment)).toLocaleString("en"));
3317			$("#rc_pi_div_span").html("0");
3318			$("#rc_lifetime_div_span").html("0");
3319		} else {
3320			var cleft_data = (rc_interest_rate / 100 / 12) * rc_original_loan_amount;
3321			var mpowerdata = Math.pow(1 + rc_interest_rate / 100 / 12, -rc_current_term);
3322			var cright_data = 1 - mpowerdata;
3323			currentloanpayment = cleft_data / cright_data;
3324			var nleft_data = (rc_new_interest_rate / 100 / 12) * rc_new_loan_amount;
3325			var nmpowerdata = Math.pow(1 + rc_new_interest_rate / 100 / 12, -rc_new_loan_term);
3326			var nright_data = 1 - nmpowerdata;
3327			newloanpayment = nleft_data / nright_data;
3328			monthlysavings = currentloanpayment - newloanpayment;
3329			$("#rc_afford_house_div_span").html(Number(Math.round(monthlysavings)).toLocaleStr
3329ing("en"));
3330			if (Number(Math.round(monthlysavings)).toLocaleString("en") == 0) {
3331				$("#rc_emmp_div_span").html("0");
3332				$("#rc_pi_div_span").html("0");
3333				$("#rc_lifetime_div_span").html("0");
3334			} else {
3335				$("#rc_emmp_div_span").html(Number(Math.round(newloanpayment)).toLocaleString("en"));
3336				$("#rc_pi_div_span").html(Number(Math.round(rc_new_refinance_fees)).toLocaleString("en"));
3337				var current_year = new Date().getFullYear();
3338				if (rc_origination_year <= current_year) {
3339					rc_origination_year = parseInt(rc_origination_year);
3340					monthlysavings = Number(Math.round(monthlysavings)).toLocaleString("en");
3341					monthlysavings = parseInt(monthlysavings);
3342					newloanpayment = parseInt(newloanpayment);
3343					rc_new_loan_term = parseInt(rc_new_loan_term);
3344					rc_new_refinance_fees = parseInt(rc_new_refinance_fees);
3345					rc_current_term = parseInt(rc_current_term);
3346					var newcurrentloanpayment = removeco($("#rc_original_loan_amount").val());
3347					newcurrentloanpayment = parseInt(newcurrentloanpayment);
3348					lifetimesavings = currentloanpayment * (rc_current_term - (current_year - rc_origination_year) * 12 - 6) - (newloanpayment * rc_new_loan_term + rc_new_refinance_fees);
3349					$("#rc_lifetime_div_span").html(Number(Math.round(lifetimesavings)).toLocaleString("en"));
3350				}
3351			}
3352		}
3353	}
3354	$("form.mcalc-refi").each(function () {
3355		var este = $(this);
3356		rc_mortgage_calc();
3357		rc_input_vals(este);
3358		$("input", este).each(function () {
3359			$(this).on("keyup", function () {
3360				rc_mortgage_calc();
3361				rc_input_vals(este);
3362			});
3363		});
3364	});
3365	function rc_input_vals(este) {
3366		$(".rc_afford_house_div_span", este).val($("#rc_afford_house_div_span", este).text());
3367		$(".rc_emmp_div_span", este).val($("#rc_emmp_div_span", este).text());
3368		$(".rc_pi_div_span", este).val($("#rc_pi_div_span", este).text());
3369		$(".rc_lifetime_div_span", este).val($("#rc_lifetime_div_span", este).text());
3370	}
3371});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.