function tool_setup() { var n = $(document), t = $("body"), i = $(".validation", t); n.foundation("reveal", { closeOnBackgroundClick: !1 }); n.foundation(); $.validator.setDefaults({ onfocusout: !1, onkeyup: !1 }); $.ajaxSetup({ cache: !1 }); $.valHooks.text = {}; $.valHooks.text.set = function (n, t) { if ($(n).is(".formatted_field")) { var i = $(this).data("entered_value"); return ( $(n).data("entered_value", t), (n.value = format_field($(n).data("field_format"), t)), t !== i && $(n).trigger("change_complete"), n.value ); } return undefined; }; $.valHooks.text.get = function (n) { if ($(n).is(".formatted_field")) { var t = $(n).data("entered_value"); return typeof t == "undefined" ? n.value : t; } return undefined; }; n.on("focusout", ".formatted_field", function () { $(this).val(this.value); (typeof populating_form != "undefined" && populating_form) || $(this).valid(); }); n.on("focusin", "input.formatted_field", function () { this.value = $(this).val(); }); n.on("change", "input:not(.formatted_field)", function () { $(this).trigger("change_complete"); }); n.on("focusout", "input:not(.formatted_field)", function () { (typeof populating_form != "undefined" && populating_form) || $(this).valid(); }); n.on("keyup", ".numeric", function () { var n = this.value.replace(/[^0-9\.\-]/g, ""); this.value !== n && (this.value = n); }); n.on("change", 'input[type="range"]', function () { if ($(this).attr("name")) { var n = $(this).attr("name").replace("_range", ""); $('input[name="' + n + '"]').val($(this).val()); (typeof populating_form != "undefined" && populating_form) || $('input[name="' + n + '"]').valid(); } }); n.on("change", 'input[type="text"]', function () { var n = $(this).attr("name"); $('input[name="' + n + '_range"]').val(this.value); }); $("select").each(function () { $(this).next(".custom.dropdown").attr("title", this.title); }); n.on("click", ".top_of_page_link", function (n) { return n.preventDefault(), $(document).scrollTo($("body")), !1; }); $(".upload_file_size_limit_message").text( "Please note: maximum file size for uploads is 1.94MB" ); i.on("click", "a.validate-link", function (n) { var i = $(this), r = $(':input[name="' + i.attr("for") + '"]', t), f = i.attr("href"), u = r; $(window).scrollTo(u, 500, { offset: -30, axis: "y" }); setTimeout(function () { r.focus().select(); }, 400); n.preventDefault(); }); } function get_modules_id() { var n = modules_id === null ? getCookie("MemberID") : this.modules_id; try { Raven.setUser({ id: n }); } catch (t) {} return n; } function get_auth_token() { var n, t; if (auth_token === null) { if (((n = getCookie("APIMemberJSON")), !n)) return ""; try { return (t = $.parseJSON(decodeURIComponent(n))), t.AuthToken; } catch (i) { return ""; } } else return auth_token; } function get_profile_country_code() { var n, t; if (portfolioCountry === null) { if (((n = getCookie("APIMemberJSON")), !n)) return ""; try { return (t = $.parseJSON(decodeURIComponent(n))), t.PortfolioCountry; } catch (i) { return ""; } } else return portfolioCountry; } function get_user_country_code() { var n, t; if (userCountry === null) { if (((n = getCookie("APIMemberJSON")), !n)) return ""; try { return (t = $.parseJSON(decodeURIComponent(n))), t.Country; } catch (i) { return ""; } } else return userCountry; } function get_member_name() { var n, t; if (memberName === null) { if (((n = getCookie("APIMemberJSON")), !n)) return ""; try { return ( (t = $.parseJSON(decodeURIComponent(n))), t.FirstName + " " + t.LastName ); } catch (i) { return ""; } } else return memberName; } function get_user_roles() { var n, t; if (userRoles === null) { if (((n = getCookie("APIMemberJSON")), !n)) return ""; try { return (t = $.parseJSON(decodeURIComponent(n))), t.Roles; } catch (i) { return ""; } } else return userRoles; } function check_user_roles(n) { if (typeof n == "undefined" || n.length === 0) return !1; typeof n == "string" && (n = [n]); for ( var u = get_user_roles(), e = u.length, f = !1, o = n.length, r, i, t = 0; t < o; t++ ) { for (r = !1, i = 0; i < e; i++) if (n[t] === u[i].Module) { r = !0; break; } if (!r) { f = !0; break; } } return !f; } function api_url(n, t, i, r, u, f) { var e, o; switch ($("#rei_account_details").data("rei_api")) { case "dev_env": e = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/security", service_name: "AuthService", }; o = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/analyserdev", service_name: "AnalyserService", }; tracker_api = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/trackerdev", service_name: "PortfolioService", }; search_api = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/searchdev", service_name: "PropertySearchService", }; parameter_api = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/searchdev", service_name: "ParameterService", }; xeroauth_api = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/Xero", service_name: "XeroAuthService", }; xerodata_api = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/Xero", service_name: "XeroDataService", }; fileupload_api = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/upload", service_name: "FileUploadService", }; break; case "future_live": e = { protocol: "http://", host: "sec.realestateinvestar.com", port: 80, path: "/v2/security", service_name: "AuthService", }; o = { protocol: "http://", host: "api.realestateinvestar.com", port: 80, path: "/v2/analyser", service_name: "AnalyserService", }; tracker_api = { protocol: "http://", host: "api.realestateinvestar.com", port: 80, path: "/v2/tracker", service_name: "PortfolioService", }; search_api = { protocol: "http://", host: "api.realestateinvestar.com", port: 80, path: "/v2/search", service_name: "PropertySearchService", }; parameter_api = { protocol: "http://", host: "api.realestateinvestar.com", port: 80, path: "/v2/analyser", service_name: "ParameterService", }; xeroauth_api = { protocol: "http://", host: "api.realestateinvestar.com", port: 80, path: "/v2/xero", service_name: "XeroAuthService", }; xerodata_api = { protocol: "http://", host: "api.realestateinvestar.com", port: 80, path: "/v2/xero", service_name: "XeroDataService", }; fileupload_api = { protocol: "http://", host: "121.50.209.112", port: 80, path: "", service_name: "FileUploadService", }; break; default: e = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/security", service_name: "AuthService", }; o = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/analyser", service_name: "AnalyserService", }; tracker_api = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/tracker", service_name: "PortfolioService", }; search_api = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/search", service_name: "PropertySearchService", }; parameter_api = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/search", service_name: "ParameterService", }; xeroauth_api = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/Xero", service_name: "XeroAuthService", }; xerodata_api = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/Xero", service_name: "XeroDataService", }; fileupload_api = { protocol: "https://", host: "sec.realestateinvestar.com", port: 443, path: "/v1_0/upload", service_name: "FileUploadService", }; } typeof t == "undefined" && ($("#tracker_tool").length ? (t = "PortfolioService") : $("#analyser_tool").length ? (t = "AnalyserService") : $("#search_tool").length && (t = "PropertySearchService")); switch (t) { case "AuthService": api_details = e; break; case "PortfolioService": api_details = tracker_api; break; case "PropertySearchService": api_details = search_api; break; case "ParameterService": api_details = parameter_api; break; case "XeroAuthService": api_details = xeroauth_api; break; case "XeroDataService": api_details = xerodata_api; break; case "FileUploadService": api_details = fileupload_api; break; default: case "AnalyserService": api_details = o; } return ( (u = typeof u == "undefined" ? api_details.protocol : u), (i = typeof i == "undefined" ? api_details.host : i), (r = typeof r == "undefined" ? api_details.port : r), (f = typeof f == "undefined" ? api_details.path : f), (t = typeof t == "undefined" ? api_details.service_name : t), u + i + ":" + parseInt(r) + f + "/" + t + ".svc/API/" + n ); } function authenticate_user(n, t) { var r = { UserName: n, Password: t, SessionType: 0 }, i = new $.Deferred(); return ( $.ajax({ url: api_url("Security/AuthMember/", "AuthService"), data: JSON.stringify(r), type: "POST", contentType: "application/json", headers: { APIUserName: api_username, APIPassword: api_password }, dataType: "json", }) .fail(function () { i.reject(); }) .done(function (n) { $.ajax({ url: api_url("Security/Member/" + n.MemberID, "AuthService"), type: "GET", contentType: "application/json", headers: { APIUserName: api_username, APIPassword: api_password, UserToken: n.AuthToken, }, dataType: "json", }) .fail(function () { i.reject(); }) .done(function (t) { n.ValidLogin && n.MemberID !== "" ? ((modules_id = n.MemberID), (auth_token = n.AuthToken), (userCountry = t.Country), (memberName = t.FirstName + " " + t.LastName), (userRoles = t.Roles), (portfolioCountry = t.PortfolioCountry)) : i.reject(); i.resolve(); }); }), i ); } function open_valuer_window(n) { if (n.toUpperCase() === "NZ") { window.open("http://www.rpnz.co.nz/", "_blank"); return; } window.open( "https://info.realestateinvestar.com.au/pricefinder-redirect", "_blank" ); } function integer_with_commas(n) { var t = Math.round(n); return Math.floor(Math.abs(t)) < 1e3 ? t.toString() : t.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); } function rounded_decimal(n, t) { var i = Math.round(n * Math.pow(10, t)) / Math.pow(10, t), r = Math.floor(Math.abs(i)); return r < 1e4 ? i.toString() : i.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); } function zero_pad_decimal(n, t) { n = String(n); var i = n.indexOf("."); return ( i === -1 && ((n = n + "."), (i = n.length - 1)), (n + "00000000000000000000000000000000000000000000000000").substr( 0, i + t + 1 ) ); } function format_field(n, t) { if ((t === "-" && (t = ""), t === "")) return ""; var i; switch (n) { case "integer": i = integer_with_commas(t); break; case "number_1dp": i = rounded_decimal(t, 1); break; case "number_2dp": i = rounded_decimal(t, 2); break; case "number_2fdp": i = zero_pad_decimal(rounded_decimal(t, 2), 2); break; default: i = t; } return i; } function simple_integer(n, t) { if (n === "NA") return "N/A"; var i = integer_with_commas(n); return ( n < 0 && t !== !1 && (i = '' + String(i).replace("-", "") + ""), i ); } function dollar_value(n, t) { var i = "$" + integer_with_commas(n); return ( n < 0 && t !== !1 && (i = '' + String(i).replace("-", "") + ""), i ); } function percentage_value(n, t, i, r) { var f = rounded_decimal(n, typeof t == "undefined" ? 1 : t), u; return ( typeof r != "undefined" && (f = zero_pad_decimal(f, r)), (u = f + "%"), n < 0 && i !== !1 && (u = '' + String(u).replace("-", "") + ""), u ); } function percentage_int(n, t) { return percentage_value(n, 0, t); } function percentage_1dp(n, t) { return percentage_value(n, 1, t); } function percentage_2dp(n, t) { return percentage_value(n, 2, t); } function percentage_2fdp(n, t) { return percentage_value(n, 2, t, 2); } function float_value(n, t, i, r) { t = typeof t == "undefined" ? 1 : t; r = typeof r != "undefined" && r; var u = rounded_decimal(n, t); return ( (u = r ? parseFloat(u).toFixed(t) : u), n < 0 && i !== !1 && (u = '' + String(u).replace("-", "") + ""), u ); } function float_1dp(n) { return float_value(n, 1); } function float_2dp(n) { return float_value(n, 2); } function float_2dp_fixed(n) { return float_value(n, 2, !0, !0); } function plain_text(n) { return n; } function display_years(n) { return float_1dp(n) + " yrs"; } function shortened_date(n) { return String(n) === "" || n === null ? "" : String(n).substr(0, n.length - 4) + n.substr(-2); } function shortened_mortgage_type(n) { var t; switch (n) { case "P & I": t = "P&I"; break; case "Interest Only": t = "I.O."; break; default: t = n; } return t; } function date_string(n) { return String( n.getDate() + "/" + String(n.getMonth() + 1) + "/" + String(n.getFullYear()) ); } function date_from_string(n) { var t = n.split("/"); return new Date( parseInt(t[2]) || 0, (parseInt(t[1]) || 1) - 1, parseInt(t[0]) || 0 ); } function nth(n) { if (n > 3 && n < 21) return "th"; switch (n % 10) { case 1: return "st"; case 2: return "nd"; case 3: return "rd"; default: return "th"; } } function filter_value_from_id(n, t, i, r) { typeof r == "undefined" && (r = "Label"); for (var u = 0; u < n.length; u++) if (String(n[u][i]) === String(t)) return n[u][r]; return null; } function body_corporate_applies(n) { return ( n.toLowerCase() === "unit/apartment" || n.toLowerCase() === "townhouse" ); } function global_country_list() { return g_filters.hasOwnProperty("AU") ? g_filters.AU.Countries : g_filters.Country.values; } function country_code_from_id(n) { var i = global_country_list(), r = parseInt(n), t; if (isNaN(r)) return !1; for (t = 0; t < i.length; t++) if (i[t].CountryID === r || i[t].FilterCountryId === r) return i[t].CountryCode; return !1; } function country_name_from_id(n) { var i = global_country_list(), r = parseInt(n), t; if (isNaN(r)) return !1; for (t = 0; t < i.length; t++) if (i[t].CountryID === r || i[t].FilterCountryId === r) return i[t].Label; return !1; } function country_id_from_code(n) { for (var i = global_country_list(), t = 0; t < i.length; t++) if (i[t].CountryCode.toLowerCase() === String(n).toLowerCase()) return i[t].CountryID || i[t].FilterCountryId; return !1; } function country_name_from_code(n) { for (var i = global_country_list(), t = 0; t < i.length; t++) if (i[t].CountryCode.toLowerCase() === String(n).toLowerCase()) return i[t].Label; return !1; } function current_financial_year_bounds(n) { var u, r, l, t, f, e, o, i, s, h, c; if (!($("#tracker_tool").length < 1)) { try { for ( u = g_filters[n.toUpperCase()].CurrentFiscalYear, r = 0, l = u.length; r < l; r++ ) u[r].CountryCode.toUpperCase() === n.toUpperCase() && ((t = u[r].StartDate.split("/")), isNaN(parseInt(t[0])) || (f = parseInt(t[0])), isNaN(parseInt(t[1])) || (e = parseInt(t[1])), isNaN(parseInt(t[2])) || (o = parseInt(t[2])), (i = u[r].EndDate.split("/")), isNaN(parseInt(i[0])) || (s = parseInt(i[0])), isNaN(parseInt(i[1])) || (h = parseInt(i[1])), isNaN(parseInt(i[2])) || (c = parseInt(i[2]))); } catch (a) { console.log("ERROR: Could not establish current financial year.", n, a); return; } return ( (financial_year_start = new Date(o, e - 1, f)), (financial_year_end = new Date(c, h - 1, s)), [financial_year_start, financial_year_end] ); } } function in_current_financial_year(n, t) { var r = current_financial_year_bounds(t), i; return ( typeof n != "object" && ((i = n.split("/")), (n = new Date(i[2], i[1] - 1, i[0]))), n >= r[0] && n <= r[1] ); } function current_financial_year(n) { return new Date(current_financial_year_bounds(n)[1]).getFullYear(); } function round_to_places(n, t) { return Math.round(n * Math.pow(10, t)) / Math.pow(10, t); } function toTitleCase(n) { return n.replace(/\w\S*/g, function (n) { return n.charAt(0).toUpperCase() + n.substr(1).toLowerCase(); }); } function set_area_display_status(n, t) { $area_element = typeof n == "string" ? $(n) : n; $area_element.children(".preparing_indicator").toggle(t === "preparing"); $area_element.children(".loading_indicator").toggle(t === "loading"); $area_element.children(".loading_failure_alert").toggle(t === "failed"); $area_element.children(".updating_indicator").toggle(t === "updating"); $area_element .children(".updating_failure_indicator") .toggle(t === "updating_failed"); $area_element.children(".area_content").toggle(t === "loaded"); } function set_area_display_status_v2(n, t, i) { $(n + " > .area_indicator").hide(); t !== "" && $(n + " > .area_indicator." + t).show(); typeof i == "undefined" && (i = !1); $(n + " > .area_content").toggle(i); } function set_editing_state(n, t) { (typeof t == "undefined" || t !== "edit") && (t = "display"); $(".edit_state_display", n).toggle(t === "display"); $(".edit_state_input", n).toggle(t === "edit"); $(".edit_state_cancel_button", n).toggle(t === "edit"); $(".edit_state_save_button", n).toggle(t === "edit"); n.data("editing_state", t); } function fetch_document_list(n, t) { var i = new $.Deferred(); return ( $.ajax({ url: api_url("Documents/AllFiles/" + t, "FileUploadService"), type: "GET", contentType: "application/json; charset=utf-8", headers: { APIUserName: api_username, APIPassword: api_password, UserToken: get_auth_token(), }, dataType: "json", timeout: 2e4, }) .done(function (t, r, u) { var f; switch (n) { case "attachment": f = t.Attachements; break; case "image": f = t.PropertyImages; break; default: case "all": f = t; } i.resolve(f, r, u); }) .fail(function (n, t, r) { if (check_session_expiry(n, t, r)) { handle_session_expiry(n); return; } i.reject(n, t, r); }), i ); } function uploadFile(n, t, i, r, u) { var f = api_url("Documents/Uploads/HtmlClient/", "FileUploadService"); $.ajax({ url: f, type: "POST", data: n, headers: { APIUserName: api_username, APIPassword: api_password, UserToken: get_auth_token(), }, processData: !1, beforeSend: function (i) { i.setRequestHeader("FileName", n.name); i.setRequestHeader("FileSize", n.size); i.setRequestHeader("MemberPropertyID", u); i.setRequestHeader("UserToken", get_auth_token()); i.setRequestHeader("IsAttachement", t === "attachment" ? "1" : "0"); }, }) .done(i) .fail(r); } function deleteFile(n, t) { function u(n, t, i) { if (check_session_expiry(n, t, i)) { handle_session_expiry(n); return; } alert("Sorry, an error occurred while deleting your file."); } var i = api_url("Documents/DeleteFiles/", "FileUploadService"), r = { MemberPropertyId: n, FileNames: [t] }; return $.ajax({ url: i, type: "POST", contentType: "application/json; charset=utf-8", data: JSON.stringify(r), headers: { APIUserName: api_username, APIPassword: api_password, UserToken: get_auth_token(), }, timeout: 3e4, }).fail(u); } function getCookie(n) { for ( var t, r = n + "=", u = document.cookie.split(";"), i = 0, f = u.length; i < f; i++ ) if (((t = u[i].trim()), t.indexOf(r) === 0)) return t.substring(r.length, t.length); return null; } function UserProfile(n, t) { var i = this, r = null; this.entities = []; this.environment = {}; this.construct = function (n, t) { i.user_id = n; i.environment = t; i.initialise_interactions(); }; this.initialise_interactions = function () { var n = $("#form_profile"); n.validate({ onfocusout: !1, onkeyup: !1 }); $("#profile_defaults_overlay").on("closed", function () { $("#profile_defaults_overlay").data("action_on_close").apply(); $("#profile_defaults_overlay").data("action_on_close", function () {}); }); $("#profile_defaults_discard_changes").on("click", function () { i.discard_changes(); }); $("#profile_defaults_save").on("click", function (n) { return ( n.preventDefault(), $("#form_profile").valid() && i.save_defaults(!1), !1 ); }); $("input.control_group_switcher", n).on("change_complete", function () { $(this).prop("checked") && i.switch_controls($(this).data("control_group"), $(this).val()); }); $("#profile_entities_select").on("change", function () { var t = $(this).find(":selected"); $(".selected_ent", n).text(t.text()); $(".selected_entity_link", n).attr( "href", $("#rei_tool_wrapper .rei_tool").attr( "data-rei_tracker_url_" + get_user_country_code().toLowerCase() ) + "&my_entities=" + t.val() ); }); }; this.open_editor = function (n) { function t(n) { i.get_entities().done(function () { i.populate_editor(n); var t = !0; typeof n.UserDetailDefault != "undefined" && typeof n.UserDetailDefault.HasDefault != "undefined" && (t = n.UserDetailDefault.HasDefault === "1"); $("#profile_defaults_overlay .default_profile_heading").text( t ? "Edit Default Profile" : "Create Default Profile" ); i.set_editor_state("loaded"); }); } function r(n, t, r) { if (i.environment.check_session_expiry(n, t, r)) { $("#profile_defaults_overlay").foundation("reveal", "close"); i.environment.handle_session_expiry(n); return; } i.set_editor_state("error"); } typeof n == "function" ? $("#profile_defaults_overlay").data("action_on_close", n) : $("#profile_defaults_overlay").data("action_on_close", function () {}); i.set_editor_state("loading"); $("#profile_defaults_overlay").foundation("reveal", "open"); i.populate_defaults_loan_length_menu(i.environment.user_country_code); $.ajax({ url: api_url( "Analyser/UserDefault?ModulesID=" + i.environment.modules_id + "&Country=" + i.environment.user_country_code + "&memberName=" + i.environment.member_name, "AnalyserService" ), contentType: "application/json; charset=utf-8", headers: { APIUserName: i.environment.api_username, APIPassword: i.environment.api_password, UserToken: i.environment.auth_token, }, dataType: "json", timeout: 3e4, }) .done(t) .fail(r); }; this.get_entities = function () { return this.environment .load_user_entities() .done(function (n) { i.entities = n; i.populate_entities_list(); }) .fail(function (n, t, r) { if (i.environment.check_session_expiry(n, t, r)) { $("#profile_defaults_overlay").foundation("reveal", "close"); i.environment.handle_session_expiry(n); return; } i.set_editor_state("error"); }); }; this.set_editor_state = function (n) { var t = $("#profile_defaults_overlay"); switch (n) { case "loading": r && r.stop(); $(".saving_indicator", t).hide(); $(".loading_indicator .close-reveal-modal", t).hide(); $(".loading_indicator .alert-box", t).hide(); $(".content", t).hide(); $(".loading_message", t).show(); $(".loading_indicator", t).show(); break; case "error": $(".loading_message", t).hide(); $(".loading_indicator .alert-box", t).show(); $(".loading_indicator .close-reveal-modal", t).show(); $(".content", t).hide(); $(".loading_indicator", t).show(); break; case "loaded": $(".loading_indicator", t).hide(); $(".content", t).show(); r = Ladda.create($("#profile_defaults_save").get(0)); break; case "saving": r.start(); $(".saving_indicator .close-reveal-modal", t).hide(); $(".saving_indicator .alert-box", t).hide(); $(".saving_indicator", t).show(); break; case "saving_error": r.stop(); $(".saving_indicator .alert-box", t).show(); $(".saving_indicator .close-reveal-modal", t).show(); } }; this.populate_entities_list = function () { var n = $("#form_profile"), t; for ( i.entities.length === 1 && n.find(".profile_entities_selection").hide(), n.find(".profile_entities").show(), n.find('select[name="entity"]').empty(), t = 0; t < i.entities.length; t++ ) n.find('select[name="entity"]').append( $( '" ) ); n.find(".entities_page_link").attr( "href", $("#rei_tool_wrapper .rei_tool").attr( "data-rei_tracker_url_" + get_user_country_code().toLowerCase() ) + "&my_entities=0" ); }; this.populate_defaults_loan_length_menu = function () { var t = $( '#profile_defaults_overlay select[name="mortgage_type_loan_length"]' ), n, r, u; for (t.empty(), n = 0; n < i.environment.loan_length_values.length; n++) (r = i.environment.loan_length_values[n]), (u = $("