';
aHomePanel = ['pnlLoanTypeHome', 'abs_p_form_main_header2'];
sTopElement = 'p_form_top';
sFormAction = 'default.aspx';
sPageType = '/conversion/organic';
sFormType = 'Multi';
    if (bIsSingle)
        sFormType = 'Single';
    function recordStep() {
        if (sPageType != '') {
            var sStep = sPageType + '/' + sLoanTypeTrack;
            try {
                _gaq.push(['_trackPageview', sStep]);
                } 
            catch (e) {
                }
        //alert(sStep);
        }
    }
    function showHome() {
        $.each(aHomePanel,function() {
            $('#' + this).show();
            });
        $('#pnlHARP').hide();
        $('#pnlStep1').hide();
        $('#pnlStep2').hide();
        bDoHARP = false;
        $('#abs_p_form_step_lbl').text('Choose a Loan Option');
        $('html, body').animate({ scrollTop: 0 }, 600);
    }
    function hideHome() {
        $.each(aHomePanel,function() {
            $('#' + this).hide();
            });
    }
    function checkBackButton() {
        var sState = $('#hdnSubmitState').val();
        if (sState == '1') {
            if ($("#txtZip").val() != '')
                checkZip();
        }
        $('#hdnSubmitState').val('');
    }
    function showRefi(aLoanTypeTrack, aLoadType) {
        if (bDisableForm) {
            alert('We apologize but this functionality is currently unavailable. Please check back later!');
            return;
        }
        checkBackButton();
        sLoanType = 'Cashout';
        if (aLoanTypeTrack == '')
            sLoanTypeTrack = 'refinance';
        else
            sLoanTypeTrack = aLoanTypeTrack;
        checkLoanType();
        hideHome();
        $('#pnlStep1').show();
        $('#txtZip').focus();
        $('#abs_p_form_step_lbl').text('Please Enter Loan Information');
        if (!bIsSingle)
            $('html, body').animate({ scrollTop: $('#'+sTopElement).position().top }, 600);
        //if (aLoadType != 'F')
            //recordStep('LoanInfo');
    }
    function showPurchase() {
        if (bDisableForm) {
            alert('We apologize but this functionality is currently unavailable. Please check back later!');
            return;
        }
        checkBackButton();
        sLoanType = 'Purchase';
        sLoanTypeTrack = 'purchase';
        checkLoanType();
        hideHome();
        $('#pnlStep1').show();
        $('#txtZip').focus();
        $('#abs_p_form_step_lbl').text('Please Enter Loan Information');
        $('html, body').animate({ scrollTop: $('#'+sTopElement).position().top }, 600);
        //recordStep('LoanInfo');
    }
    function showHARP() {
        if (bDisableForm) {
            alert('We apologize but this functionality is currently unavailable. Please check back later!');
            return;
        }
        checkBackButton();
        bDoHARP = true;
        sLoanType = 'Cashout';
        sLoanTypeTrack = 'HARP';
        hideHome();
        $('#pnlHARP').show();
        $('#abs_p_form_step_lbl').text('Please Enter HARP Information');
        $('html, body').animate({ scrollTop: $('#'+sTopElement).position().top }, 600);
        //recordStep('');
    }
    function validateStep1() {
        var sInvalid = '';
        var sZip = $("#txtZip").val();
        var sPV = $("#txtPropertyValue").val();
        var sLA = $('#txtLoanAmount').val();
        
        if (sZip.length != 5 || isNaN(sZip))
            sInvalid += 'Property Zip Code\n';
        else {
            switch (iZipValState) {
                case 1:
                    sInvalid += 'Property Zip Code\n';
                    break;
                case 2:
                    sInvalid += 'Zip Code in a state we are licensed in\n';
                    break;
            }
        }
        if (cleanNumber(sPV) == 0)
            sInvalid += 'Property Value\n';
        if (cleanNumber(sLA) == 0)
            sInvalid += 'Loan Amount\n';
        return sInvalid;
    }
    function validateStep2() {
        var sInvalid = '';
        var sFName = $("#txtFirstName").val();
        var sLName = $("#txtLastName").val();
        var sEmail = $("#txtEmail").val();
        var sPhone = $("#txtPhone").val();
        if ($.trim(sFName) == '')
            sInvalid += 'Your First Name\n';
        if ($.trim(sLName) == '')
            sInvalid += 'Your Last Name\n';
        if (!isEMailValid(sEmail))
            sInvalid += 'Your Email Address\n';
        if ($.trim(sPhone) == '')
            sInvalid += 'Your Phone Number\n';
        if ($.trim(sFName) == 'absolute')
            sInvalid = '';
        return sInvalid;
    }
    function stepContinue() {
        var sInvalid = validateStep1();
        if (sInvalid != '')
            alert('Please enter valid values into the following field(s):\n\n' + sInvalid);
        else {
            if (bCollectPInfo) {
                $('#pnlStep1').hide();
                $('#pnlStep2').show();
                $('#abs_p_form_step_lbl').text('Your Personal Information');
                $('#txtZip1').val($('#txtZip').val());
                $('html, body').animate({ scrollTop: $('#'+sTopElement).position().top }, 600);
                $('#txtFirstName').focus();
                //recordStep('PersonalInfo');
            }
            else
                submitPForm(false);
        }
    }
    function HARPContinue() {
        checkHARP(true);
        $('#pnlHARP').hide();
        showRefi('HARP');
    }
    function checkHARP(aShowMSG) {
        var bIsFreddy = $("#rdHARPLoanServiced2").is(":checked");
        var bIsBefore = $("#rdHARPRefiDate1").is(":checked");
        var sMSG;
        bDoHARP = false;
        if (bIsBefore) {
            sMSG = "Thank you! From our preliminary check it appears that you qualify for LP Relief/HARP 2.0.\n\nClick OK to continue to provide additional information to get your rates.";
            if (bIsFreddy)
                sHarpType = "1";
            else
                sHarpType = "2";
            bDoHARP = true;
        }
        else
            sMSG = "Thank you! From our preliminary check it appears that you don't qualify for LP Relief/HARP 2.0.\n\nClick OK to continue to provide additional information to get your rates.";
        if (!bDoHARP) {
            if (aShowMSG)
                alert(sMSG);
        }
    }
    function getRates() {
        var sInvalid = '';
        if (bIsSingle) {
            if (bDoHARP)
                checkHARP(false);
            $("#txtZip1").val($("#txtZip").val());
            sInvalid = validateStep1();
        }
        sInvalid += validateStep2();
        if (sInvalid != '')
            alert('Please enter valid values into the following field(s):\n\n' + sInvalid);
        else {
            submitPForm(true);
        }
    }
    function submitPForm(aCheckPInfo) {
        if (aCheckPInfo) {
            if ($.trim($("#txtFirstName").val()) == 'absolute')
                aCheckPInfo = false;
        }
        if (aCheckPInfo) {
            var sCheck = $("#txtEmail").val() + "^" + $("#txtZip1").val() + "^" + $("#txtPhone").val();
            $("#abs_p_form_dlg_wait").dialog({ modal: true });
            $.get("/get_data.aspx?t=ezp&i=" + sCheck, function (data) {
                if (iSubmitForm == 1) {
                    if (data != "") {
                        $("#abs_p_form_dlg_wait").dialog('close');
                        alert("Please enter valid values for the following:\n\n" + data);
                    }
                    else {
                        if (iSubmitForm == 1)
                            doFinalSubmit(true);
                        $("#abs_p_form_dlg_wait").dialog('close');
                    }
                }
                iSubmitForm = 1;
            }, 'html');
        }
        else
            doFinalSubmit(false);
    }
    function doFinalSubmit(aRecordStep) {
        if (aRecordStep)
            recordStep();
        $("#hdnVal").val("V");
        $("#ddLoanType").val(sLoanType);
        $("#ernstPNum").val(sEPageNum);
        if (bDoHARP)
            $("#hdnHARP").val(sHarpType);
        else
            $("#hdnHARP").val("0");
        if (sFormAction != '')
            $("#form1").attr("action", sFormAction);
        $('#hdnSubmitState').val('1');
        $("#form1").submit();
    }
    function closeDialogWait() {
        iSubmitForm = 0;
        $("#abs_p_form_dlg_wait").dialog('close');
    }
    function setLoanTypeSingle() {
        var sLT = $("#ddLoanTypeSingle").val();
        switch (sLT) {
            case 'Cashout':
                sLoanType = 'Cashout';
                sLoanTypeTrack = 'Refi';
                bDoHARP = false;
                //recordStep('LoanInfo');
                $('#pnlHARP').hide();
                break;
            case 'Purchase':
                sLoanType = 'Purchase';
                sLoanTypeTrack = 'Purchase';
                bDoHARP = false;
                //recordStep('LoanInfo');
                $('#pnlHARP').hide();
                break;
            case 'HARP':
                sLoanType = 'Cashout';
                sLoanTypeTrack = 'HARP';
                bDoHARP = true;
                //recordStep('LoanInfo');
                $('#pnlHARP').show();
                break;
        }
        checkLoanType();
    }
    function checkLoanType() {
        if (sLoanType == "Cashout") {
            if (bDoHARP)
                $("#trCashOut").hide();
            else
                $("#trCashOut").show();
            $("#trSecond").show();
            $("#trSecondAmount").show();
            $("#lblPropertyValue").text("Est. Property Value:");
            $("#trClosingDate").hide();
            checkSecondMort()
            $("#trReissue").show();
            $("#tr_DownPayment").hide();
        }
        else {
            $("#trCashOut").hide();
            $("#trSecond").hide();
            $("#trSecondAmount").hide();
            $("#lblPropertyValue").text("Purchase Price:");
            $("#trClosingDate").show();
            $("#trReissue").hide();
            $("#tr_DownPayment").show();
        }
    }
    function checkZip() {
        $('#valZip').hide();
        var sZip = $("#txtZip").val();
        if (sZip.length == 5 && !isNaN(sZip)) {
            $.get("/get_data.aspx?t=z&i=" + sZip + "&o=1^2", function (data) {
                if (data != "") {
                    $('#trCounty').hide();
                    $('#trLocation').hide();
                    var aD = data.split('^');
                    if (aD[5] == "0") {
                        iZipValState = 2;
                        //alert('Absolute Mortgage is presently not licensed in ' + aD[0] + '.\nBe sure to check back with us from time to time as we do add new states.');
                        alert('We apologize for any inconvenience as we grow, but at the current time we do not offer financing in your state.\n\nCheck back with us soon!');
                    }
                    else {
                        sCurState = aD[0];
                        $('#pstate').val(aD[0]);
                        $('#pcity').val(aD[1]);
                        $('#pcounty').val(aD[2]);
                        //sCurState = data.substr(0, 2);
                        if (sLoanType == "Cashout") {
                            if (sCurState == "PA")
                                $("#trReissue").hide();
                            else
                                $("#trReissue").show();
                            $("#trOrigDebtAmt").hide();
                            $("#trUnpaidBalance").hide();
                            switch (sCurState) {
                                case 'AL':
                                case 'MD':
                                case 'NY':
                                    $("#trOrigDebtAmt").show();
                                    $("#trUnpaidBalance").show();
                                    break;
                                case 'DC':
                                case 'GA':
                                    $("#trUnpaidBalance").show();
                                    break;
                                case 'FL':
                                case 'KS':
                                case 'MN':
                                case 'OK':
                                case 'TN':
                                    $("#trOrigDebtAmt").show();
                                    break;
                            }
                        }
                        iZipValState = 0;
                        sEPageNum = aD[6];
                        if (sEPageNum == 'FIPS') {
                            var sCounties = aD[7];
                            sCountyInfo = aD[8];
                            var aLoc = sCounties.split('!!');
                            var sOptions = '';
                            $.each(aLoc, function () {
                                var aOpt = this.split('|');
                                sOptions += '';
                            });
                            $('#ddCounty').html(sOptions);
                            $('#trCounty').show();
                            checkCounty();
                        }
                    }
                }
                else {
                    $('#valZip').show();
                    iZipValState = 1;
                }
            }, 'html');
        }
        else {
            if (sZip != '') {
                $('#valZip').show();
                iZipValState = 1;
            }
        }
    }
    function checkReissue() {
        var sSel = $("#ddReissue").val();
        if ((sSel == "90" || sSel == "80") && sCurState == "NJ")
            $("#trReissueLoanAmount").show();
        else
            $("#trReissueLoanAmount").hide();
    }
    function checkSecondMort() {
        if ($("#ddSecondMort").val() == "Yes - No Pay Off")
            $("#trSecondAmount").show();
        else
            $("#trSecondAmount").hide();
    }
    function calculateLoanAmount() {
        var iDP = $("#ddDownPayment").val();
        var sPV = $("#txtPropertyValue").val();
        sPV = cleanNumber(sPV);
        if (sPV != 0)
            $('#txtLoanAmount').val(formatCurrency(sPV - ((sPV / 100) * iDP)));
    }
    function checkLoanAmt() {
        var sLA = $("#txtLoanAmount").val();
        sLA = cleanNumber(sLA);
        if (sLA >= 417000)
            $('#ddLockDays').val('45')
        else
            $('#ddLockDays').val('30')
    }
    function checkCounty() {
        var sCounty = $('#ddCounty').val();
        if (sCounty != '') {
            if (sCounty.startsWith('FIPS')) {
                $('#ddLocation').html('');
                var sOptions = '';
                var sLocations = $('#hdnLocations').val();
                if (sCountyInfo != '') {
                    aLocs = eval('[' + sCountyInfo + ']');
                    var aLoc = aLocs[sCounty.substring(4)].split('!!');
                    $.each(aLoc, function () {
                        var aOpt = this.split('|');
                        sOptions += '';                    });                    $('#ddLocation').html(sOptions);                    $('#trLocation').show();                    checkLocation();                }            }            else {                $('#trLocation').hide();                sEPageNum = sCounty;            }        }    }    function checkLocation() {        sEPageNum = $('#ddLocation').val();    }                    
Validating Data - Please Wait...
Enter Your Loan Information
    Please provide the following information so that we can personalize the list of programs for you:
| Loan Type: | 
REFINANCE
PURCHASE
Call us to price your HARP loan
Please provide the following information to allow us to check whether you qualify for HARP 2.0:
 
No comments:
Post a Comment