if( typeof(gpi) == "undefined" || typeof(opex) == "undefined" || typeof(purchase_price) == "undefined") { error('Cannot load widget because "gpi", "opex", or "purchase_price" is missing'); } else { var m_vacancy_rate = (typeof(vacancy_rate) == "undefined" || !isInteger(vacancy_rate) ) ? 0 : parseInt(vacancy_rate); var m_holding_period = (typeof(holding_period) == "undefined" || !isInteger(holding_period) ) ? 1 : parseInt(holding_period); var m_gpi_growth_rate = (typeof(gpi_growth_rate) == "undefined" || !isInteger(gpi_growth_rate) ) ? 0 : parseInt(gpi_growth_rate); var m_opex_growth_rate = (typeof(opex_growth_rate) == "undefined" || !isInteger(opex_growth_rate) ) ? 0 : parseInt(opex_growth_rate); var m_appreciation_rate = (typeof(appreciation_rate) == "undefined" || !isInteger(appreciation_rate) ) ? 0 : parseInt(appreciation_rate); if (typeof(financing) == "undefined") error('Mortgage data is missing'); else if (m_holding_period <= 0) error('Holding period must be greater than 0'); else { var financing_string ="___"; for(var i=0; i< financing.length; i++) financing_string += financing[i].principal + "_" + financing[i].interest_rate + "_" + financing[i].amortization_period + "_" + financing[i].interest_only + " "; var hash = window.location.href.indexOf("#"); var limit = ( hash == -1) ? window.location.href.length : window.location.href.substring(0, hash); var referer = window.location.href.substring(7, limit).replace(new RegExp(/\//g), " "); var url = 'http://www.redmol.com/analyzer/embed_data/' + encodeURIComponent(referer) + '/' + gpi + '/' + opex + '/' + purchase_price + '/' + financing_string + '/' + m_vacancy_rate+ '/' + m_holding_period+ '/' + m_gpi_growth_rate+ '/' + m_opex_growth_rate+ '/' + m_appreciation_rate; var ihtml = ''; document.write(ihtml); document.getElementById("redmol_analyzer").src = document.getElementById("redmol_analyzer").src; } } function error(msg) { var redmol_logo = ''; redmol_logo += '
'; redmol_logo += 'Powered by Real Estate Investment Analyzer by RedMol.com'; redmol_logo += '
'; var html = redmol_logo + '
' + msg + '
'; document.write(html); } function validateInt() { var o = document.frmInput.txtInput; switch (isInteger(o.value)) { case true: alert(o.value + " is an integer") break; case false: alert(o.value + " is not an integer") } } function validateRange() { var s = document.frmInput.txtInput.value; var A = document.frmInput.txtA.value; var B = document.frmInput.txtB.value; switch (isIntegerInRange(s, A, B)) { case true: alert(s + " is in range from " + A + " to " + B) break; case false: alert(s + " is not in range from " + A + " to " + B) } } // isIntegerInRange (STRING s, INTEGER a, INTEGER b) function isIntegerInRange (s, a, b) { if (isEmpty(s)) if (isIntegerInRange.arguments.length == 1) return false; else return (isIntegerInRange.arguments[1] == true); // Catch non-integer strings to avoid creating a NaN below, // which isn't available on JavaScript 1.0 for Windows. if (!isInteger(s, false)) return false; // Now, explicitly change the type to integer via parseInt // so that the comparison code below will work both on // JavaScript 1.2 (which typechecks in equality comparisons) // and JavaScript 1.1 and before (which doesn't). var num = parseInt (s); return ((num >= a) && (num <= b)); } function isInteger (s) { var i; if (isEmpty(s)) if (isInteger.arguments.length == 1) return 0; else return (isInteger.arguments[1] == true); for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (!isDigit(c)) return false; } return true; } function isEmpty(s) { return ((s == null) || (s.length == 0)) } function isDigit (c) { return ((c >= "0") && (c <= "9")) }