//prototype counter var prototypeWindowID = 1; // Get validation libs Scriptaculous.require("fValidate.core.js"); Scriptaculous.require("fValidate.config.js"); Scriptaculous.require("fValidate.basic.js"); Scriptaculous.require("fValidate.extended.js"); Scriptaculous.require("fValidate.numbers.js"); Scriptaculous.require("fValidate.datetime.js"); Scriptaculous.require("fValidate.logical.js"); Scriptaculous.require("fValidate.web.js"); Scriptaculous.require("fValidate.controls.js"); //Scriptaculous.require("fValidate.international.js"); Scriptaculous.require("fValidate.ecommerce.js"); Scriptaculous.require("fValidate.special.js"); Scriptaculous.require("fValidate.lang.js.asp"); // Behaviour library Scriptaculous.require("behaviour.js"); // Check co/borrower age Scriptaculous.require("checktext.js.asp"); // Reverse a string (used in Number.formatCurrency) String.prototype.reverse = function() { var r = ""; var i = 0; for (i = this.length - 1 ; i >= 0 ; i--) { r += this.substring(i, i+1); } return r; } // Round to a given decimal place (uses common rounding, not round to nearest even) Number.prototype.round = function(digits) { r = this + (0.5 / Math.pow(10, digits)); r *= Math.pow(10, digits); r = Math.floor(r); r /= Math.pow(10, digits); return r; } // Format a number as currency (e.g. $1,234,567.89) Number.prototype.formatCurrency = function() { // Round number, break up number and decimal portions var n = this.round(2); var s = "" + n + ""; var tmp = s.split("."); var d = "00"; var i = 0; // Get whole number portion as string n = "" + tmp[0] + ""; // Get decimal portion as string if (tmp.length > 1) { d = "" + tmp[1] + ""; } if (d.length < 2) { d += "0"; } // Add commas (reverse the number, add a comma every 3 places, reverse again) s = ""; n = n.reverse(); for (i = 0 ; i < n.length ; i++) { s += n.substring(i, i+1); if ((i + 1) % 3 == 0 && (i + 1) < n.length) { s += ","; } } s = s.reverse(); // Assemble the number, decimal, and currency symbol and format in // accounting notation (negative numbers are put in parentheses) if (this.round(2) < 0) { s = "($" + s.replace("-", "") + "." + d + ")"; } else { s = "$" + s + "." + d; } // Return return s; } // Email obfuscation function LQ_EM_Swap(that, first, middle, last) { that.href = "mai" + "lto:" + first + "@" + middle + "." + last; that.onmouseover=""; } // Open payment stream /*function showPaymentStream(args) { var psWin = window.open("payment_stream.asp?" + args, "psWin", "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=330"); if (psWin) { psWin.focus(); } else { alert("A popup blocker has prevented this window from opening. Please disable any popup blocking software and try again."); } }*/ function showPaymentStream(args) { contentWin = new Window( { className: 'dialog', title: 'Show Payments', width:450, height:480, minimizable: false, maximizable: false, closable: true, resizable: true, url: 'payment_stream.asp?' + args, showEffect: Element.show, hideEffect: Element.hide, recenterAuto: false } ) contentWin.showCenter(false); } // Open closing cost /*function showClosingCosts(args) { var psWin = window.open("closing_costs.asp?" + args, "psWin", "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=590"); if (psWin) { psWin.focus(); } else { alert("A popup blocker has prevented this window from opening. Please disable any popup blocking software and try again."); } } */ function showClosingCosts(args) { contentWin = new Window( { className: 'dialog', title: 'Closing costs', width:500, height:400, minimizable: false, maximizable: false, closable: true, resizable: true, url: 'closing_costs.asp?' + args, showEffect: Element.show, hideEffect: Element.hide, destroyOnClose: true, recenterAuto: false } ) contentWin.showCenter(false); } // Validate dependent ages field function dependentAge(f) { // Get field value var dependentAges = $F(f); // How many dependents did they say they had? var numDependents = 0; if (f == "Borrower_Dependent_Age1") { numDependents = parseInt($F("Borrower_No_Dependents")); } else if (f == "CoBorrower_Dependent_Age1") { numDependents = parseInt($F("CoBorr_No_Dependents")); } else { return false; } // If they have 0 dependents, but they've listed ages, something's wrong if (parseInt(numDependents) == 0 && dependentAges.length > 0) { return false; } // Validate the ages are only numbers, commas, or spaces if (!dependentAges.match(/^\d+(,[ ]*\d+)*$/)) { return false; } // Break the ages apart var ages = dependentAges.replace(/,[\s]+/, ",").split(","); if (numDependents != ages.length) { return false; } // Make sure each age is reasonable (0 <= age <= 120?) var i = 0 for (i = 0 ; i < ages.length ; i++) { if (parseInt(ages[i]) < 0 || parseInt(ages[i]) > 120) { return false; } } // Nothing left to check return true; } /********************************************************************************************\ Function: scalePopinWin Created : 09.03.2009 #4261 Chris L *** Requires prototype windows *** Purpose : Scales popin window to a percentage of the available space. iPercent: percentage of window to take up iMargin: margin left around popin window (default 20) iMenuH: lq menu height (default 60) iTitleH: combined height of the popin title bar & footer bar (default 40) bCancelMove: cancel the move of the popin window \********************************************************************************************/ function scalePopinWin(iPercent, iMargin, iMenuH, iTitleH, bCancelMove){ if (!Windows.getFocusedWindow){return} if(!iMargin){iMargin=20} if(!iMenuH){iMenuH=60} if(!iTitleH){iTitleH=40} var workingWin = Windows.getFocusedWindow(); var fullW =(window.innerWidth)?window.innerWidth:(document.documentElement.clientWidth)?document.documentElement.clientWidth:document.body.clientWidth; var fullH = (window.innerHeight)?window.innerHeight:(document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight; var newW = (fullW * iPercent / 100) - (2*iMargin) - 10; var newH = (fullH * iPercent / 100) - (2*iMargin) - iTitleH - iMenuH; workingWin.setSize(newW, newH); if(!bCancelMove){ var newL = (fullW - newW)/2; var newT = (fullH - newH)/2;//+ iMenuH - iMenuH workingWin.setLocation(newT, newL); } } /********************************************************************************************\ Function: resizePopinWin Created : 10.05.2009 #4261 Chris L *** Requires prototype windows *** Purpose : Resizes active popin window to a given size. iWidth: New width iHeight: New height iMargin: margin left around popin window (default 20) iMenuH: lq menu height (default 60) iTitleH: combined height of the popin title bar & footer bar (default 40) bCancelMove: cancel the move of the popin window \********************************************************************************************/ function resizePopinWin(iWidth, iHeight, iMargin, iMenuH, iTitleH, bCancelMove){ if (!Windows.getFocusedWindow){return} if(!iMargin){iMargin=20} if(!iMenuH){iMenuH=60} if(!iTitleH){iTitleH=40} var workingWin = Windows.getFocusedWindow(); var fullW =(window.innerWidth)?window.innerWidth:(document.documentElement.clientWidth)?document.documentElement.clientWidth:document.body.clientWidth; var fullH = (window.innerHeight)?window.innerHeight:(document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight; if (iWidth > fullW - (2*iMargin) - 10){ iWidth = fullW - (2*iMargin) - 10 } if (iHeight > fullH - (2*iMargin) - iTitleH - iMenuH){ iHeight = fullH - (2*iMargin) - iTitleH - iMenuH } workingWin.setSize(iWidth, iHeight); if(!bCancelMove){ var newL = (fullW - iWidth)/2; var newT = (fullH - iHeight)/2;//+ iMenuH - iMenuH workingWin.setLocation(newT, newL); } }