//-------------------------------------------------------------------------------------------------------------
String.prototype.trim = function()
{ return this.replace(/^\s+|\s+$/g, ''); }
//-------------------------------------------------------------------------------------------------------------
function emptyvalue(objectname)
{
    if( (document.getElementById(objectname) != null)&& (document.getElementById(objectname).value.trim() != "") ){ return false;}
    else { return true;}
}
//-------------------------------------------------------------------------------------------------------------
function emailCheck(objectname) {
        emailStr=document.getElementById(objectname).value.trim();

        var emailPat=/^(.+)@(.+)$/
        var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
        var validChars="\[^\\s" + specialChars + "\]"
        var quotedUser="(\"[^\"]*\")"
        var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
        var atom=validChars + '+'
        var word="(" + atom + "|" + quotedUser + ")"
        var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
        var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
        var matchArray=emailStr.match(emailPat)
        if (matchArray==null)
        {
            return false
        }
return true;
}
//-------------------------------------------------------------------------------------------------------------
function addCommas( sValue )
{
    var sRegExp = new RegExp('(-?[0-9]+)([0-9]{3})');
    
    while(sRegExp.test(sValue)) {
    sValue = sValue.replace(sRegExp, '$1,$2');
    }
    return sValue;
}
//-------------------------------------------------------------------------------------------------------------
function MaxLenMoveNext( currentFieldJ, nextFieldJ, maxLengthJ)
{    if( (document.getElementById(currentFieldJ) != null) && (document.getElementById(nextFieldJ) != null) && (document.getElementById(currentFieldJ).value.length == maxLengthJ) )
    {    document.getElementById(nextFieldJ).focus();}
}
//=================================================================
function ShowDivJ(thedivid)
{
    if (document.getElementById(thedivid) != null)
    {
        document.getElementById(thedivid).style.display="inline";
    }
}
//=================================================================
function HideDivJ(thedivid)
{
    if (document.getElementById(thedivid) != null)
    {
        document.getElementById(thedivid).style.display="none";
    }
}
//=================================================================
function ShowHideDivJ(thedivid)
{
    if (document.getElementById(thedivid) != null)
    {
        if(document.getElementById(thedivid).style.display.toLowerCase() =="none")
        {
            document.getElementById(thedivid).style.display="inline";
        }
        else
        {
            document.getElementById(thedivid).style.display="none";
        }
    }
}
//-------------------------------------------------------------------------------------------------------------
function checkformvarstep1__()
{
    var v_f_mortgate_payment = parseFloat(document.getElementById("mortgagepayment").value.replace("$","").replace(",","").trim());
    var v_gross_income = parseFloat(document.getElementById("grossincome").value.replace("$","").replace(",","").trim());
    var v_est_mortgage_balanace = parseFloat( document.getElementById("est_mortgage_balanace").value.replace("$","").replace(",","").trim());
    if(emptyvalue("mortgagepayment")) { document.getElementById("mortgagepayment").focus(); alert ("Please specify Current Monthly Mortgage Payment"); return false;}
    else if(emptyvalue("grossincome")) { document.getElementById("grossincome").focus(); alert ("Please specify Gross Monthly Income"); return false;}
    else if(v_f_mortgate_payment<=0)                 {   document.getElementById("mortgagepayment").focus();     alert ("Please Enter Valid Monthly Mortgage Payment"); return false;}
    else if(v_gross_income<=0)                         {   document.getElementById("grossincome").focus();         alert ("Please Enter Valid Monthly Gross Income"); return false;}
    else if(v_f_mortgate_payment > v_gross_income)     {   document.getElementById("mortgagepayment").focus();     alert ("Please Enter Valid Monthly Gross Income and Monthly Mortgage Payment"); return false;}
    else if(emptyvalue("est_mortgage_balanace")) { document.getElementById("est_mortgage_balanace").focus(); alert ("Please specify Estimated Mortgage Balance"); return false;}
    else if(v_est_mortgage_balanace<=0)     { document.getElementById("est_mortgage_balanace").focus();     alert ("Please Enter Valid Estimated Mortgage Balance"); return false;}
    else if(emptyvalue("zip")) { document.getElementById("zip").focus(); alert ("Please specify ZIP Code"); return false;}
    else if(document.getElementById("zip").value.length<5) { document.getElementById("zip").focus(); alert ("Please specify Valid ZIP Code"); return false;}
    else {    
         document.getElementById("SaveFormJ").value = 1;return true;
    }
}
//-------------------------------------------------------------------------------------------------------------
function checkformvarstep1()
{
    var v_what_mmp =0;    var v_what_gi =0;
    if(document.getElementById("what_mmp") != null) { v_what_mmp = parseFloat(document.getElementById("what_mmp").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("what_gi") != null) { v_what_gi = parseFloat(document.getElementById("what_gi").value.replace("$","").replace(",","").trim());}
    if(emptyvalue("what_mmp")) { document.getElementById("what_mmp").focus(); alert ("Please specify your monthly mortgage payment"); return false;}
    else if(emptyvalue("what_gi")) { document.getElementById("what_gi").focus(); alert ("Please specify your monthly gross income"); return false;}
    else if(v_what_mmp <= 0) { document.getElementById("what_mmp").focus(); alert ("Please specify valid values for your monthly mortgage payment"); return false;}
    else if( v_what_gi<= 0) { document.getElementById("what_gi").focus(); alert ("Please specify valid values for your monthly gross income"); return false;}
    else if(v_what_mmp > v_what_gi) { document.getElementById("what_mmp").focus(); alert ("Your monthly Gross Income is less than your Monthly Mortgage Payment!, its not allowed..."); return false;}
    else{
         document.getElementById("SaveFormJ").value = 1;return true;
    }
}
//-------------------------------------------------------------------------------------------------------------
function checkformvarstep2()
{
    var v_total_gi =0;    var v_total_ni =0; var v_mmp_first_mort =0;
    var v_mi_bo_co_tgincome=0; var v_mi_bo_co_netincome=0; var v_mhp_mortgage_1=0;
    var v_m_loan_amount1 =0;    var v_m_loan_rate1 =0;
    if(document.getElementById("mi_bo_co_tgincome") != null) { v_mi_bo_co_tgincome = parseFloat(document.getElementById("mi_bo_co_tgincome").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("mi_bo_co_netincome") != null) { v_mi_bo_co_netincome = parseFloat(document.getElementById("mi_bo_co_netincome").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("m_loan_amount1") != null) { v_m_loan_amount1 = parseFloat(document.getElementById("m_loan_amount1").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("m_loan_rate1") != null) { v_m_loan_rate1 = parseFloat(document.getElementById("m_loan_rate1").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("mhp_mortgage_1") != null) { v_mhp_mortgage_1 = parseFloat(document.getElementById("mhp_mortgage_1").value.replace("$","").replace(",","").trim());}
    if(emptyvalue("borrower_fname")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_fname").focus(); alert ("Please specify Borrower's First Name"); return false;}
    //else if(emptyvalue("borrower_lname")) { document.getElementById("borrower_lname").focus(); alert ("Please specify Borrower's Last Name"); return false;}
    else if(emptyvalue("borrower_email")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_email").focus(); alert ("Please specify Email Address"); return false;}
    else if(emailCheck("borrower_email")==false) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_email").focus(); alert ("Please specify Valid Email Address"); return false;}
    else if(emptyvalue("borrower_h_street")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_h_street").focus(); alert ("Please specify Complete Address for the Subject Property"); return false;}
    else if(emptyvalue("borrower_h_city")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_h_city").focus(); alert ("Please specify Complete Address for the Subject Property"); return false;}
    else if(emptyvalue("borrower_h_state")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_h_state").focus(); alert ("Please specify Complete Address for the Subject Property"); return false;}
    else if(emptyvalue("borrower_h_zip")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_h_zip").focus(); alert ("Please specify Complete Address for the Subject Property"); return false;}
    else if(emptyvalue("m_lender_name_1")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("m_lender_name_1").focus(); alert ("Please specify your First Mortgage Company"); return false;}
    else if(emptyvalue("m_loan_num_1")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("m_loan_num_1").focus(); alert ("Please specify your First Loan Number"); return false;}
    else if(emptyvalue("borrower_phone1_part1")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_phone1_part1").focus(); alert ("Please specify your Phone Number"); return false;}
    else if(emptyvalue("borrower_phone1_part2")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_phone1_part2").focus(); alert ("Please specify your Phone Number"); return false;}
    else if(emptyvalue("borrower_phone1_part3")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_phone1_part3").focus(); alert ("Please specify your Phone Number"); return false;}
    //else if(emptyvalue("hardship_reason1")) { document.getElementById("hardship_reason1").focus(); alert ("Please specify Hardship Reason"); return false;}
    else if(emptyvalue("m_loan_amount1")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("m_loan_amount1").focus(); alert ("Please specify Loan Amount"); return false;}
    else if(v_m_loan_amount1 <= 0) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("m_loan_amount1").focus(); alert ("Please specify valid Loan Amount"); return false;}
    else if(emptyvalue("m_loan_rate1")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("m_loan_rate1").focus(); alert ("Please specify Mortgage Rate"); return false;}
    else if(v_m_loan_rate1 <= 0) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("vm_loan_rate1").focus(); alert ("Please specify valid Mortgage Rate"); return false;}
    else if(emptyvalue("m_lender_name_1")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("m_lender_name_1").focus(); alert ("Please specify Mortgage Lender Name"); return false;}
    else if(emptyvalue("m_loan_num_1")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("m_loan_num_1").focus(); alert ("Please specify Loan number"); return false;}
    
    else if(emptyvalue("mi_bo_co_tgincome")) { ShowDivJ('div2_step1');HideDivJ('div1_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("mi_bo_co_tgincome").focus(); alert ("Please specify Total Gross Income"); return false;}
    else if(emptyvalue("mi_bo_co_netincome")) {  ShowDivJ('div2_step1');HideDivJ('div1_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("mi_bo_co_netincome").focus(); alert ("Please specify Total Net Income"); return false;}
    else if(v_mi_bo_co_tgincome <= 0) {  ShowDivJ('div2_step1');HideDivJ('div1_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("mi_bo_co_tgincome").focus(); alert ("Please specify valid values for Gross Income"); return false;}
    else if(v_mi_bo_co_netincome <= 0) {  ShowDivJ('div2_step1');HideDivJ('div1_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("mi_bo_co_netincome").focus(); alert ("Please specify valid values for Net Income"); return false;}

    else if(emptyvalue("mhp_mortgage_1")) { ShowDivJ('div3_step1');HideDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("mhp_mortgage_1").focus(); alert ("Please specify First monthly mortgage payment"); return false;}
    else if(v_mhp_mortgage_1 <= 0) {  ShowDivJ('div3_step1');HideDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("mhp_mortgage_1").focus(); alert ("Please specify valid values for First Monthly Morgate Payment"); return false;}
 
     else{
    document.getElementById("SaveFormJ2").value = 1;
    
    return true;
    }
}
//-------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------
function checkformvarstep2_in1()
{
    var v_total_gi =0;    var v_total_ni =0; var v_mmp_first_mort =0;
    var v_mi_bo_co_tgincome=0; var v_mi_bo_co_netincome=0; var v_mhp_mortgage_1=0;
    var v_m_loan_amount1 =0;    var v_m_loan_rate1 =0;
    if(document.getElementById("mi_bo_co_tgincome") != null) { v_mi_bo_co_tgincome = parseFloat(document.getElementById("mi_bo_co_tgincome").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("mi_bo_co_netincome") != null) { v_mi_bo_co_netincome = parseFloat(document.getElementById("mi_bo_co_netincome").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("m_loan_amount1") != null) { v_m_loan_amount1 = parseFloat(document.getElementById("m_loan_amount1").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("m_loan_rate1") != null) { v_m_loan_rate1 = parseFloat(document.getElementById("m_loan_rate1").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("mhp_mortgage_1") != null) { v_mhp_mortgage_1 = parseFloat(document.getElementById("mhp_mortgage_1").value.replace("$","").replace(",","").trim());}
    if(emptyvalue("borrower_fname")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_fname").focus(); alert ("Please specify Borrower's First Name"); return false;}
    else if(emptyvalue("last4ofssn")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("last4ofssn").focus(); alert ("Please specify Borrower's SSN"); return false;}
    //else if(emptyvalue("borrower_lname")) { document.getElementById("borrower_lname").focus(); alert ("Please specify Borrower's Last Name"); return false;}
    else if(emptyvalue("borrower_email")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_email").focus(); alert ("Please specify Email Address"); return false;}
    else if(emailCheck("borrower_email")==false) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_email").focus(); alert ("Please specify Valid Email Address"); return false;}
    else if(emptyvalue("borrower_h_street")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_h_street").focus(); alert ("Please specify Complete Address for the Subject Property"); return false;}
    else if(emptyvalue("borrower_h_city")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_h_city").focus(); alert ("Please specify Complete Address for the Subject Property"); return false;}
    else if(emptyvalue("borrower_h_state")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_h_state").focus(); alert ("Please specify Complete Address for the Subject Property"); return false;}
    else if(emptyvalue("borrower_h_zip")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_h_zip").focus(); alert ("Please specify Complete Address for the Subject Property"); return false;}
    else if(emptyvalue("borrower_phone1_part1")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1'); document.getElementById("borrower_phone1_part1").focus(); alert ("Please specify your Phone Number"); return false;}
    else if(emptyvalue("borrower_phone1_part2")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_phone1_part2").focus(); alert ("Please specify your Phone Number"); return false;}
    else if(emptyvalue("borrower_phone1_part3")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_phone1_part3").focus(); alert ("Please specify your Phone Number"); return false;}
    else if(emptyvalue("borrower_email")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_email").focus(); alert ("Please specify Email Address"); return false;}
    else if(emailCheck("borrower_email")==false) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("borrower_email").focus(); alert ("Please specify Valid Email Address"); return false;}
    //else if(emptyvalue("hardship_reason1")) { document.getElementById("hardship_reason1").focus(); alert ("Please specify Hardship Reason"); return false;}
    else if(emptyvalue("m_lender_name_1")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("m_lender_name_1").focus(); alert ("Please specify your First Mortgage Company"); return false;}
    else if(emptyvalue("m_loan_amount1")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("m_loan_amount1").focus(); alert ("Please specify Loan Amount"); return false;}
    else if(v_m_loan_amount1 <= 0) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("m_loan_amount1").focus(); alert ("Please specify valid Loan Amount"); return false;}
    else if(emptyvalue("m_loan_rate1")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("m_loan_rate1").focus(); alert ("Please specify Mortgage Rate"); return false;}
    else if(v_m_loan_rate1 <= 0) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("m_loan_rate1").focus(); alert ("Please specify valid Mortgage Rate"); return false;}
    else if(emptyvalue("m_lender_name_1")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("m_lender_name_1").focus(); alert ("Please specify Mortgage Lender Name"); return false;}
    else if(emptyvalue("m_loan_num_1")) { ShowDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("m_loan_num_1").focus(); alert ("Please specify Loan number"); return false;}
     else{
    ShowDivJ('div2_step1');HideDivJ('div1_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1');return true;
    }
}
//-------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------
function checkformvarstep2_in2()
{
    var v_total_gi =0;    var v_total_ni =0; var v_mmp_first_mort =0;
    var v_mi_bo_co_tgincome=0; var v_mi_bo_co_netincome=0; var v_mhp_mortgage_1=0;
    var v_m_loan_amount1 =0;    var v_m_loan_rate1 =0;
    if(document.getElementById("mi_bo_co_tgincome") != null) { v_mi_bo_co_tgincome = parseFloat(document.getElementById("mi_bo_co_tgincome").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("mi_bo_co_netincome") != null) { v_mi_bo_co_netincome = parseFloat(document.getElementById("mi_bo_co_netincome").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("m_loan_amount1") != null) { v_m_loan_amount1 = parseFloat(document.getElementById("m_loan_amount1").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("m_loan_rate1") != null) { v_m_loan_rate1 = parseFloat(document.getElementById("m_loan_rate1").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("mhp_mortgage_1") != null) { v_mhp_mortgage_1 = parseFloat(document.getElementById("mhp_mortgage_1").value.replace("$","").replace(",","").trim());}
    if(emptyvalue("mi_bo_co_tgincome")) { ShowDivJ('div2_step1');HideDivJ('div1_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("mi_bo_co_tgincome").focus(); alert ("Please specify Total Gross Income"); return false;}
    else if(emptyvalue("mi_bo_co_netincome")) {  ShowDivJ('div2_step1');HideDivJ('div1_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("mi_bo_co_netincome").focus(); alert ("Please specify Total Net Income"); return false;}
    else if(v_mi_bo_co_tgincome <= 0) {  ShowDivJ('div2_step1');HideDivJ('div1_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1'); document.getElementById("mi_bo_co_tgincome").focus(); alert ("Please specify valid values for Gross Income"); return false;}
    else if(v_mi_bo_co_netincome <= 0) {  ShowDivJ('div2_step1');HideDivJ('div1_step1');HideDivJ('div3_step1');HideDivJ('div4_step1');HideDivJ('div5_step1'); document.getElementById("mi_bo_co_netincome").focus(); alert ("Please specify valid values for Net Income"); return false;}
     else{
    ShowDivJ('div3_step1');HideDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1');return true;
    }
}
//-------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------
function checkformvarstep2_in3()
{
    var v_total_gi =0;    var v_total_ni =0; var v_mmp_first_mort =0;
    var v_mi_bo_co_tgincome=0; var v_mi_bo_co_netincome=0; var v_mhp_mortgage_1=0;
    var v_m_loan_amount1 =0;    var v_m_loan_rate1 =0;
    if(document.getElementById("mi_bo_co_tgincome") != null) { v_mi_bo_co_tgincome = parseFloat(document.getElementById("mi_bo_co_tgincome").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("mi_bo_co_netincome") != null) { v_mi_bo_co_netincome = parseFloat(document.getElementById("mi_bo_co_netincome").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("m_loan_amount1") != null) { v_m_loan_amount1 = parseFloat(document.getElementById("m_loan_amount1").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("m_loan_rate1") != null) { v_m_loan_rate1 = parseFloat(document.getElementById("m_loan_rate1").value.replace("$","").replace(",","").trim());}
    if(document.getElementById("mhp_mortgage_1") != null) { v_mhp_mortgage_1 = parseFloat(document.getElementById("mhp_mortgage_1").value.replace("$","").replace(",","").trim());}
    if(emptyvalue("mhp_mortgage_1")) { ShowDivJ('div3_step1');HideDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("mhp_mortgage_1").focus(); alert ("Please specify First monthly mortgage payment"); return false;}
    else if(v_mhp_mortgage_1 <= 0) {  ShowDivJ('div3_step1');HideDivJ('div1_step1');HideDivJ('div2_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');HideDivJ('div6_step1'); document.getElementById("mhp_mortgage_1").focus(); alert ("Please specify valid values for First Monthly Morgate Payment"); return false;}
      else{
    ShowDivJ('div4_step1');HideDivJ('div1_step1');HideDivJ('div3_step1');HideDivJ('div2_step1');HideDivJ('div5_step1');HideDivJ('div6_step1');return true;
    }
}
//-------------------------------------------------------------------------------------------------------------
function checkformvarstep2_in4()
{
    ShowDivJ('div5_step1');HideDivJ('div1_step1');HideDivJ('div3_step1');HideDivJ('div2_step1');HideDivJ('div4_step1');HideDivJ('div6_step1');return true;
}
//-------------------------------------------------------------------------------------------------------------
function checkformvarstep2_in5()
{
    ShowDivJ('div6_step1');HideDivJ('div1_step1');HideDivJ('div3_step1');HideDivJ('div2_step1');HideDivJ('div4_step1');HideDivJ('div5_step1');return true;
}
//-------------------------------------------------------------------------------------------------------------

function checkfinalstepformvars()
{
    var q1_val_j ="";    var q2_val_j ="";    var q3_val_j ="";
    if(document.getElementById("question_0") != null) { q1_val_j = document.getElementById("question_0").value;}
    if(document.getElementById("question_1") != null) { q2_val_j = document.getElementById("question_1").value;}
    if(document.getElementById("question_2") != null) { q3_val_j = document.getElementById("question_2").value;}
    if(emptyvalue("email")) { document.getElementById("email").focus(); alert ("Please specify Email Address"); return false;}
    else if(emailCheck("email")==false) { document.getElementById("email").focus(); alert ("Please specify Valid Email Address"); return false;}
    else if(emptyvalue("answer_0")) { document.getElementById("answer_0").focus(); alert ("Please Answer The Security Question 1"); return false;}
    else if(emptyvalue("answer_1")) { document.getElementById("answer_1").focus(); alert ("Please Answer The Security Question 2"); return false;}
    else if(emptyvalue("answer_2")) { document.getElementById("answer_2").focus(); alert ("Please The Security Question 3"); return false;}
    else if ( (q1_val_j == q2_val_j) || (q1_val_j == q3_val_j) || (q2_val_j == q3_val_j)) {document.getElementById("question_0").focus(); alert("Please select different questions"); return false;}
    else {return true; }
}
//-------------------------------------------------------------------------------------------------------------
function checkformvarstep3()
{

//    if(emptyvalue("cname"))             {     document.getElementById("cname").focus();         alert ("Please Enter Name On Card"); return false;}
    if(emptyvalue("ccnum")) { document.getElementById("ccnum").focus(); alert ("Please specify Credit Card Number"); return false;}
    else if(document.getElementById("ccnum").value.length != 15 && document.getElementById("ccnum").value.length != 16 ) { document.getElementById("ccnum").focus(); alert ("Please specify valid Credit Card Number"); return false;}
    else if(emptyvalue("expmon")) { document.getElementById("expmon").focus(); alert ("Please specify Credit Card Expiry Month"); return false;}
    else if(emptyvalue("expyr")) { document.getElementById("expyr").focus(); alert ("Please specify Credit Card Expiry Year"); return false;}
    else if(emptyvalue("cvv")) { document.getElementById("cvv").focus(); alert ("Please specify CVV/CVV2 (Security) Number"); return false;}
    else if(document.getElementById("cvv").value.length != 3 && document.getElementById("cvv").value.length != 4 ) { document.getElementById("cvv").focus(); alert ("Please specify valid CVV/CVV2 Number"); return false;}
    else if(document.getElementById("confirm_1").checked != true){ document.getElementById("confirm_1").focus(); alert ("Please Accept Agreement"); return false;}
    else
    {
    document.getElementById("submitstatp").value = 1;     return true;
    //alert("This Functionality Is Under Construction, You will be redirected to Thank You page now");     window.location.href="thankyou.html";    return false;
    }
}
//-------------------------------------------------------------------------------------------------------------
function checkactiveformvars()
{
    if(emptyvalue("purlma_ld_email")) { document.getElementById("purlma_ld_email").focus(); alert ("Please specify Login Email Address"); return false;}
    else if(emailCheck("purlma_ld_email")==false) { document.getElementById("purlma_ld_email").focus(); alert ("Please specify Valid Email Address"); return false;}
    else if(emptyvalue("purlma_ld_pwd")) { document.getElementById("purlma_ld_pwd").focus(); alert ("Please specify Password"); return false;}
    else if(emptyvalue("purlma_ld_cpwd")) { document.getElementById("purlma_ld_cpwd").focus(); alert ("Please specify Confirm Password"); return false;}
    else if(document.getElementById("purlma_ld_pwd").value != document.getElementById("purlma_ld_cpwd").value) { document.getElementById("purlma_ld_cpwd").focus(); alert ("Password and confirm password doesn't match"); return false;}

    else if(emptyvalue("borrower_name")) { document.getElementById("borrower_h_name").focus(); alert ("Please specify Borrower's Name"); return false;}
    else if(emptyvalue("borrower_h_street")) { document.getElementById("borrower_h_street").focus(); alert ("Please specify Subject property street address"); return false;}
    else if(emptyvalue("borrower_h_city")) { document.getElementById("borrower_h_city").focus(); alert ("Please specify Subject property city name "); return false;}
    else if(emptyvalue("borrower_h_state")) { document.getElementById("borrower_h_state").focus(); alert ("Please specify Subject property state name"); return false;}
    else if(emptyvalue("borrower_h_zip")) { document.getElementById("borrower_h_zip").focus(); alert ("Please specify Subject property ZIP name "); return false;}
    else if(emptyvalue("phone")) { document.getElementById("phone").focus(); alert ("Please specify Phone Number "); return false;}

    /*else if(document.getElementById("confirm_1").checked != true){ document.getElementById("confirm_1").focus(); alert ("Please read and agree to End User Licence Agreement (EULA)"); return false;}
    else if(document.getElementById("confirm_2").checked != true){ document.getElementById("confirm_2").focus(); alert ("Please read and agree to End User Licence Agreement (EULA)"); return false;}
    else if(document.getElementById("confirm_3").checked != true){ document.getElementById("confirm_3").focus(); alert ("Please read and agree to End User Licence Agreement (EULA)"); return false;}
    else if(document.getElementById("confirm_4").checked != true){ document.getElementById("confirm_4").focus(); alert ("Please read and agree to End User Licence Agreement (EULA)"); return false;}
    */
    else {return true;}
}
//-------------------------------------------------------------------------------------------------------------
function checkfullactiveformvars()
{
    if(emptyvalue("purlma_ld_email")) { document.getElementById("purlma_ld_email").focus(); alert ("Please specify Login Email Address"); return false;}
    else if(emailCheck("purlma_ld_email")==false) { document.getElementById("purlma_ld_email").focus(); alert ("Please specify Valid Email Address"); return false;}
    else if(emptyvalue("purlma_ld_pwd")) { document.getElementById("purlma_ld_pwd").focus(); alert ("Please specify Password"); return false;}
    else if(emptyvalue("purlma_ld_cpwd")) { document.getElementById("purlma_ld_cpwd").focus(); alert ("Please specify Confirm Password"); return false;}
    else if(document.getElementById("purlma_ld_pwd").value != document.getElementById("purlma_ld_cpwd").value) { document.getElementById("purlma_ld_cpwd").focus(); alert ("Password and confirm password doesn't match"); return false;}

    else if(emptyvalue("purlma_pd_fname")) { document.getElementById("purlma_pd_fname").focus(); alert ("Please specify your First name "); return false;}
    else if(emptyvalue("purlma_pd_lname")) { document.getElementById("purlma_pd_lname").focus(); alert ("Please specify your Last name "); return false;}
    else if(emptyvalue("purlma_pd_addr1")) { document.getElementById("purlma_pd_addr1").focus(); alert ("Please specify Address line 1 "); return false;}
    else if(emptyvalue("purlma_pd_city")) { document.getElementById("purlma_pd_city").focus(); alert ("Please specify City name"); return false;}
    else if(emptyvalue("purlma_pd_state")) { document.getElementById("purlma_pd_state").focus(); alert ("Please specify State name "); return false;}
    else if(emptyvalue("purlma_pd_zip")) { document.getElementById("purlma_pd_zip").focus(); alert ("Please specify ZIP code"); return false;}

    else if(emptyvalue("borrower_name")) { document.getElementById("borrower_h_name").focus(); alert ("Please specify Borrower's Name"); return false;}
    else if(emptyvalue("borrower_h_street")) { document.getElementById("borrower_h_street").focus(); alert ("Please specify Subject property street address"); return false;}
    else if(emptyvalue("borrower_h_city")) { document.getElementById("borrower_h_city").focus(); alert ("Please specify Subject property city name "); return false;}
    else if(emptyvalue("borrower_h_state")) { document.getElementById("borrower_h_state").focus(); alert ("Please specify Subject property state name"); return false;}
    else if(emptyvalue("borrower_h_zip")) { document.getElementById("borrower_h_zip").focus(); alert ("Please specify Subject property ZIP name "); return false;}

    else if(emptyvalue("purlma_pay_ccnum")) { document.getElementById("purlma_pay_ccnum").focus(); alert ("Please specify Credit Card Number"); return false;}
    else if(document.getElementById("purlma_pay_ccnum").value.length != 15 && document.getElementById("purlma_pay_ccnum").value.length != 16 ) { document.getElementById("purlma_pay_ccnum").focus(); alert ("Please specify valid Credit Card Number"); return false;}
    else if(emptyvalue("purlma_pay_cvv")) { document.getElementById("purlma_pay_cvv").focus(); alert ("Please specify CVV/CVV2 Number"); return false;}
    else if(document.getElementById("purlma_pay_cvv").value.length != 3 && document.getElementById("purlma_pay_cvv").value.length != 4 ) { document.getElementById("purlma_pay_cvv").focus(); alert ("Please specify valid CVV/CVV2 Number"); return false;}
    else if(emptyvalue("expmon")) { document.getElementById("expmon").focus(); alert ("Please specify Credit Card Expiry Month"); return false;}
    else if(emptyvalue("expyr")) { document.getElementById("expyr").focus(); alert ("Please specify Credit Card Expiry Year"); return false;}

    else if(emptyvalue("purlma_bd_fname")) { document.getElementById("purlma_bd_fname").focus(); alert ("Please specify your First name (for Billing Address)"); return false;}
    else if(emptyvalue("purlma_bd_lname")) { document.getElementById("purlma_bd_lname").focus(); alert ("Please specify your Last name  (for Billing Address)"); return false;}
    else if(emptyvalue("purlma_bd_addr1")) { document.getElementById("purlma_bd_addr1").focus(); alert ("Please specify Address line 1  (for Billing Address)"); return false;}
    else if(emptyvalue("purlma_bd_city")) { document.getElementById("purlma_bd_city").focus(); alert ("Please specify City name (for Billing Address)"); return false;}
    else if(emptyvalue("purlma_bd_state")) { document.getElementById("purlma_bd_state").focus(); alert ("Please specify State name  (for Billing Address)"); return false;}
    else if(emptyvalue("purlma_bd_zip")) { document.getElementById("purlma_bd_zip").focus(); alert ("Please specify ZIP code (for Billing Address)"); return false;}

    else if(document.getElementById("confirm_1").checked != true){ document.getElementById("confirm_1").focus(); alert ("Please read and agree to End User Licence Agreement (EULA)"); return false;}
    else if(document.getElementById("confirm_2").checked != true){ document.getElementById("confirm_2").focus(); alert ("Please read and agree to End User Licence Agreement (EULA)"); return false;}
    else if(document.getElementById("confirm_3").checked != true){ document.getElementById("confirm_3").focus(); alert ("Please read and agree to End User Licence Agreement (EULA)"); return false;}
    else if(document.getElementById("confirm_4").checked != true){ document.getElementById("confirm_4").focus(); alert ("Please read and agree to End User Licence Agreement (EULA)"); return false;}
    else { return true; }
}
//-------------------------------------------------------------------------------------------------------------
function copy_pr_sp()
{
    if(document.getElementById("sameaddress").checked == true)
    {
        document.getElementById("borrower_m_street").value =    document.getElementById("borrower_h_street").value ;
        document.getElementById("borrower_m_city").value =    document.getElementById("borrower_h_city").value;
        document.getElementById("borrower_m_state").value =    document.getElementById("borrower_h_state").value;
        document.getElementById("borrower_m_zip").value =    document.getElementById("borrower_h_zip").value;
    }
    else
    {
        document.getElementById("borrower_m_street").value = "";
        document.getElementById("borrower_m_city").value =    "";
        document.getElementById("borrower_m_state").value =    "";
        document.getElementById("borrower_m_zip").value = "";
    }
}
//-------------------------------------------------------------------------------------------------------------
function copy_pr_bi()
{
    if(document.getElementById("copy_bill").checked == true)
    {
        document.getElementById("purlma_bd_fname").value =    document.getElementById("purlma_pd_fname").value;
        document.getElementById("purlma_bd_lname").value =    document.getElementById("purlma_pd_lname").value;
        document.getElementById("purlma_bd_addr1").value =    document.getElementById("purlma_pd_addr1").value;
        document.getElementById("purlma_bd_addr2").value =    document.getElementById("purlma_pd_addr2").value;
        document.getElementById("purlma_bd_city").value =    document.getElementById("purlma_pd_city").value;
        document.getElementById("purlma_bd_state").value =    document.getElementById("purlma_pd_state").value;
        document.getElementById("purlma_bd_zip").value =    document.getElementById("purlma_pd_zip").value;
        document.getElementById("purlma_bd_tel").value =    document.getElementById("purlma_pd_tel").value;
        document.getElementById("purlma_bd_fax").value =    document.getElementById("purlma_pd_fax").value;
    }
    else
    {
        document.getElementById("purlma_bd_fname").value =    "";
        document.getElementById("purlma_bd_lname").value =    "";
        document.getElementById("purlma_bd_addr1").value =    "";
        document.getElementById("purlma_bd_city").value =    "";
        document.getElementById("purlma_bd_state").value =    "";
        document.getElementById("purlma_bd_zip").value =    "";
        document.getElementById("purlma_bd_tel").value =    "";
        document.getElementById("purlma_bd_fax").value =    "";
    }
}
//-------------------------------------------------------------------------------------------------------------
function checkforgetemailformvars()
{
    if(emptyvalue("ordernumber")) { document.getElementById("ordernumber").focus(); alert ("Please specify your Order Number to retrieve EMail address"); return false;}
}
//-------------------------------------------------------------------------------------------------------------
function check_email(thisField)
{
    
    if (thisField.value.indexOf('@') == -1 )
    {
        alert('Please enter valid e-mail ID');
        thisField.focus();
        thisField.select();
        flag=false;
    }    
    else if(thisField.value.substring(thisField.value.indexOf('@')+2).indexOf('@') >= 0||
        thisField.value.substring(thisField.value.indexOf('@')+2).indexOf('.') < 0 )
    {
            alert('Please enter valid e-mail ID');
            thisField.focus();
            thisField.select();            
            flag=false;
    }
    else if(thisField.value.charAt(thisField.value.length - 1) == '.')
    {
            alert('Please enter valid e-mail ID');
            thisField.focus();
            thisField.select();            
            flag=false;
    }
    else
        flag=true;
        return flag;
}
//-------------------------------------------------------------------------------------------------------------
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
//-------------------------------------------------------------------------------------------------------------
function alltrim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
//-------------------------------------------------------------------------------------------------------------
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
//-------------------------------------------------------------------------------------------------------------
function checkInternationalPhone(strPhone){
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("-")!=-1)bracket=bracket+1
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
var brchr=strPhone.indexOf("(")
if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
//-------------------------------------------------------------------------------------------------------------
function checkloginformvars()
{
    if(emptyvalue("email3")) { document.getElementById("email3").focus(); alert ("Please specify Login Email Address"); return false;}
    if(emptyvalue("password")) { document.getElementById("password").focus(); alert ("Please specify Password"); return false;}
    else {return true; }
}
//-------------------------------------------------------------------------------------------------------------
function checkloginformvars2()
{
    if(emptyvalue("email2")) { document.getElementById("email2").focus(); alert ("Please specify Login Email Address"); return false;}
    if(emptyvalue("password2")) { document.getElementById("password2").focus(); alert ("Please specify Password"); return false;}
    else {return true; }
}
//-------------------------------------------------------------------------------------------------------------
function update_applicaiton1()
{
    var mi_bo_co_tgincome = 0.0; if( (document.getElementById("mi_bo_co_tgincome")!=null) && (document.getElementById("mi_bo_co_tgincome").value !="") ){mi_bo_co_tgincome = parseFloat(document.getElementById("mi_bo_co_tgincome").value.replace(",","")).toFixed(2);}
    var mi_bo_co_bonus = 0.0; if( (document.getElementById("mi_bo_co_bonus")!=null) && (document.getElementById("mi_bo_co_bonus").value !="") ){mi_bo_co_bonus = parseFloat(document.getElementById("mi_bo_co_bonus").value.replace(",","")).toFixed(2);}
    var mi_bo_co_childsup = 0.0; if( (document.getElementById("mi_bo_co_childsup")!=null) && (document.getElementById("mi_bo_co_childsup").value !="") ){mi_bo_co_childsup = parseFloat(document.getElementById("mi_bo_co_childsup").value.replace(",","")).toFixed(2);}
    var mi_bo_co_ss = 0.0; if( (document.getElementById("mi_bo_co_ss")!=null) && (document.getElementById("mi_bo_co_ss").value !="") ){mi_bo_co_ss = parseFloat(document.getElementById("mi_bo_co_ss").value.replace(",","")).toFixed(2);}
    var mi_bo_co_retire = 0.0; if( (document.getElementById("mi_bo_co_retire")!=null) && (document.getElementById("mi_bo_co_retire").value !="") ){mi_bo_co_retire = parseFloat(document.getElementById("mi_bo_co_retire").value.replace(",","")).toFixed(2);}
    var mi_bo_co_tips = 0.0; if( (document.getElementById("mi_bo_co_tips")!=null) && (document.getElementById("mi_bo_co_tips").value !="") ){mi_bo_co_tips = parseFloat(document.getElementById("mi_bo_co_tips").value.replace(",","")).toFixed(2);}
    var mi_bo_co_rents = 0.0; if( (document.getElementById("mi_bo_co_rents")!=null) && (document.getElementById("mi_bo_co_rents").value !="") ){mi_bo_co_rents = parseFloat(document.getElementById("mi_bo_co_rents").value.replace(",","")).toFixed(2);}
    var mi_bo_co_unemp = 0.0; if( (document.getElementById("mi_bo_co_unemp")!=null) && (document.getElementById("mi_bo_co_unemp").value !="") ){mi_bo_co_unemp = parseFloat(document.getElementById("mi_bo_co_unemp").value.replace(",","")).toFixed(2);}
    var mi_bo_co_food = 0.0; if( (document.getElementById("mi_bo_co_food")!=null) && (document.getElementById("mi_bo_co_food").value !="") ){mi_bo_co_food = parseFloat(document.getElementById("mi_bo_co_food").value.replace(",","")).toFixed(2);}
    var mi_total_totmoninc = 0.0; if( (document.getElementById("mi_total_totmoninc")!=null) && (document.getElementById("mi_total_totmoninc").value !="") ){mi_total_totmoninc = parseFloat(document.getElementById("mi_total_totmoninc").value.replace(",","")).toFixed(2);}
    var mi_bo_co_netincome = 0.0; if( (document.getElementById("mi_bo_co_netincome")!=null) && (document.getElementById("mi_bo_co_netincome").value !="") ){mi_bo_co_netincome = parseFloat(document.getElementById("mi_bo_co_netincome").value.replace(",","")).toFixed(2);}
	//-------------
	var mi_coboonly_tgincome = 0.0; if( (document.getElementById("mi_coboonly_tgincome")!=null) && (document.getElementById("mi_coboonly_tgincome").value !="") ){mi_coboonly_tgincome = parseFloat(document.getElementById("mi_coboonly_tgincome").value.replace(",","")).toFixed(2);}
    var mi_coboonly_netincome = 0.0; if( (document.getElementById("mi_coboonly_netincome")!=null) && (document.getElementById("mi_coboonly_netincome").value !="") ){mi_coboonly_netincome = parseFloat(document.getElementById("mi_coboonly_netincome").value.replace(",","")).toFixed(2);}
	//-------------
    //var mi_total_totmoninc_g = parseFloat(mi_bo_co_tgincome) + parseFloat(mi_bo_co_bonus) + parseFloat(mi_bo_co_childsup) + parseFloat(mi_bo_co_ss) + parseFloat(mi_bo_co_retire) + parseFloat(mi_bo_co_tips) + parseFloat(mi_bo_co_rents) + parseFloat(mi_bo_co_unemp) + parseFloat(mi_bo_co_food) + parseFloat(mi_total_totmoninc) ;
    //var mi_bo_co_tnincome = parseFloat(mi_bo_co_netincome)+ parseFloat(mi_bo_co_bonus) + parseFloat(mi_bo_co_childsup) + parseFloat(mi_bo_co_ss) + parseFloat(mi_bo_co_retire) + parseFloat(mi_bo_co_tips) + parseFloat(mi_bo_co_rents) + parseFloat(mi_bo_co_unemp) + parseFloat(mi_bo_co_food) + parseFloat(mi_total_totmoninc) ;
    var mi_total_totmoninc_g = parseFloat(mi_bo_co_tgincome) + parseFloat(mi_bo_co_bonus) + parseFloat(mi_bo_co_childsup) + parseFloat(mi_bo_co_ss) + parseFloat(mi_bo_co_retire) + parseFloat(mi_bo_co_tips) + parseFloat(mi_bo_co_rents) + parseFloat(mi_bo_co_unemp) + parseFloat(mi_bo_co_food) + parseFloat(mi_total_totmoninc)  + parseFloat(mi_coboonly_tgincome) ;
    var mi_bo_co_tnincome = parseFloat(mi_bo_co_netincome)+ parseFloat(mi_bo_co_bonus) + parseFloat(mi_bo_co_childsup) + parseFloat(mi_bo_co_ss) + parseFloat(mi_bo_co_retire) + parseFloat(mi_bo_co_tips) + parseFloat(mi_bo_co_rents) + parseFloat(mi_bo_co_unemp) + parseFloat(mi_bo_co_food) + parseFloat(mi_total_totmoninc)  + parseFloat(mi_coboonly_netincome) ;
    if (document.getElementById("mi_bo_co_tnincome")!=null) { document.getElementById("mi_bo_co_tnincome").value = mi_bo_co_tnincome; }
    if (document.getElementById("mi_total_totmoninc_g")!=null) { document.getElementById("mi_total_totmoninc_g").value = mi_total_totmoninc_g; }
}
//-------------------------------------------------------------------------------------------------------------
function update_applicaiton2()
{
    var mhp_mortgage_1 = 0.0; if( (document.getElementById("mhp_mortgage_1")!=null) && (document.getElementById("mhp_mortgage_1").value !="") ){mhp_mortgage_1 = parseFloat(document.getElementById("mhp_mortgage_1").value.replace(",","")).toFixed(2);}
    var mhp_mortgage_2 = 0.0; if( (document.getElementById("mhp_mortgage_2")!=null) && (document.getElementById("mhp_mortgage_2").value !="") ){mhp_mortgage_2 = parseFloat(document.getElementById("mhp_mortgage_2").value.replace(",","")).toFixed(2);}
    var mhp_pmi = 0.0; if( (document.getElementById("mhp_pmi")!=null) && (document.getElementById("mhp_pmi").value !="") ){mhp_pmi = parseFloat(document.getElementById("mhp_pmi").value.replace(",","")).toFixed(2);}
    var mhp_total = 0.0; if( (document.getElementById("mhp_total")!=null) && (document.getElementById("mhp_total").value !="") ){mhp_total = parseFloat(document.getElementById("mhp_total").value.replace(",","")).toFixed(2);}
    var mhp_hoa = 0.0; if( (document.getElementById("mhp_hoa")!=null) && (document.getElementById("mhp_hoa").value !="") ){mhp_hoa = parseFloat(document.getElementById("mhp_hoa").value.replace(",","")).toFixed(2);}
    var mdp_auto_1_mp = 0.0; if( (document.getElementById("mdp_auto_1_mp")!=null) && (document.getElementById("mdp_auto_1_mp").value !="") ){mdp_auto_1_mp = parseFloat(document.getElementById("mdp_auto_1_mp").value.replace(",","")).toFixed(2);}
    var mdp_auto_2_mp = 0.0; if( (document.getElementById("mdp_auto_2_mp")!=null) && (document.getElementById("mdp_auto_2_mp").value !="") ){mdp_auto_2_mp = parseFloat(document.getElementById("mdp_auto_2_mp").value.replace(",","")).toFixed(2);}
    var mdp_bank_fin_mp = 0.0; if( (document.getElementById("mdp_bank_fin_mp")!=null) && (document.getElementById("mdp_bank_fin_mp").value !="") ){mdp_bank_fin_mp = parseFloat(document.getElementById("mdp_bank_fin_mp").value.replace(",","")).toFixed(2);}
    var mle_gt_bo_co = 0.0; if( (document.getElementById("mle_gt_bo_co")!=null) && (document.getElementById("mle_gt_bo_co").value !="") ){mle_gt_bo_co = parseFloat(document.getElementById("mle_gt_bo_co").value.replace(",","")).toFixed(2);}
    var mle_util_water_bo_co = 0.0; if( (document.getElementById("mle_util_water_bo_co")!=null) && (document.getElementById("mle_util_water_bo_co").value !="") ){mle_util_water_bo_co = parseFloat(document.getElementById("mle_util_water_bo_co").value.replace(",","")).toFixed(2);}
    var mle_child_care_bo_co = 0.0; if( (document.getElementById("mle_child_care_bo_co")!=null) && (document.getElementById("mle_child_care_bo_co").value !="") ){mle_child_care_bo_co = parseFloat(document.getElementById("mle_child_care_bo_co").value.replace(",","")).toFixed(2);}
    var mle_med_exp_bo_co = 0.0; if( (document.getElementById("mle_med_exp_bo_co")!=null) && (document.getElementById("mle_med_exp_bo_co").value !="") ){mle_med_exp_bo_co = parseFloat(document.getElementById("mle_med_exp_bo_co").value.replace(",","")).toFixed(2);}
    var mle_life_dis_ins_bo_co = 0.0; if( (document.getElementById("mle_life_dis_ins_bo_co")!=null) && (document.getElementById("mle_life_dis_ins_bo_co").value !="") ){mle_life_dis_ins_bo_co = parseFloat(document.getElementById("mle_life_dis_ins_bo_co").value.replace(",","")).toFixed(2);}
    var mle_cloth_bo_co = 0.0; if( (document.getElementById("mle_cloth_bo_co")!=null) && (document.getElementById("mle_cloth_bo_co").value !="") ){mle_cloth_bo_co = parseFloat(document.getElementById("mle_cloth_bo_co").value.replace(",","")).toFixed(2);}
    var mle_enter_bo_co = 0.0; if( (document.getElementById("mle_enter_bo_co")!=null) && (document.getElementById("mle_enter_bo_co").value !="") ){mle_enter_bo_co = parseFloat(document.getElementById("mle_enter_bo_co").value.replace(",","")).toFixed(2);}
    var mle_rent_bo_co = 0.0; if( (document.getElementById("mle_rent_bo_co")!=null) && (document.getElementById("mle_rent_bo_co").value !="") ){mle_rent_bo_co = parseFloat(document.getElementById("mle_rent_bo_co").value.replace(",","")).toFixed(2);}
    var mle_inci_bo_co = 0.0; if( (document.getElementById("mle_inci_bo_co")!=null) && (document.getElementById("mle_inci_bo_co").value !="") ){mle_inci_bo_co = parseFloat(document.getElementById("mle_inci_bo_co").value.replace(",","")).toFixed(2);}
    var tot_exp_debt = parseFloat(mhp_mortgage_1) + parseFloat(mhp_mortgage_2) + parseFloat(mhp_pmi) + parseFloat(mhp_total) + parseFloat(mhp_hoa) + parseFloat(mdp_auto_1_mp) + parseFloat(mdp_auto_2_mp) + parseFloat(mdp_bank_fin_mp) + parseFloat(mle_gt_bo_co) + parseFloat(mle_util_water_bo_co) + parseFloat(mle_child_care_bo_co) + parseFloat(mle_med_exp_bo_co) + parseFloat(mle_life_dis_ins_bo_co) + parseFloat(mle_cloth_bo_co) + parseFloat(mle_enter_bo_co) + parseFloat(mle_rent_bo_co) + parseFloat(mle_inci_bo_co) ;
    
    if (document.getElementById("tot_exp_debt")!=null) { document.getElementById("tot_exp_debt").value = tot_exp_debt; }
}
//-------------------------------------------------------------------------------------------------------------
function update_applicaiton3()
{
    var al_chkacctbal = 0.0; if( (document.getElementById("al_chkacctbal")!=null) && (document.getElementById("al_chkacctbal").value !="") ){al_chkacctbal = parseFloat(document.getElementById("al_chkacctbal").value.replace(",","")).toFixed(2);}
    var al_savacctbal = 0.0; if( (document.getElementById("al_savacctbal")!=null) && (document.getElementById("al_savacctbal").value !="") ){al_savacctbal = parseFloat(document.getElementById("al_savacctbal").value.replace(",","")).toFixed(2);}
    var al_cashlicbal = 0.0; if( (document.getElementById("al_cashlicbal")!=null) && (document.getElementById("al_cashlicbal").value !="") ){al_cashlicbal = parseFloat(document.getElementById("al_cashlicbal").value.replace(",","")).toFixed(2);}
    var al_stkbondmfbal = 0.0; if( (document.getElementById("al_stkbondmfbal")!=null) && (document.getElementById("al_stkbondmfbal").value !="") ){al_stkbondmfbal = parseFloat(document.getElementById("al_stkbondmfbal").value.replace(",","")).toFixed(2);}
    var al_home_a_b = 0.0; if( (document.getElementById("al_home_a_b")!=null) && (document.getElementById("al_home_a_b").value !="") ){al_home_a_b = parseFloat(document.getElementById("al_home_a_b").value.replace(",","")).toFixed(2);}
    var al_ore_a_b = 0.0; if( (document.getElementById("al_ore_a_b")!=null) && (document.getElementById("al_ore_a_b").value !="") ){al_ore_a_b = parseFloat(document.getElementById("al_ore_a_b").value.replace(",","")).toFixed(2);}
    var al_cars_a_b = 0.0; if( (document.getElementById("al_cars_a_b")!=null) && (document.getElementById("al_cars_a_b").value !="") ){al_cars_a_b = parseFloat(document.getElementById("al_cars_a_b").value.replace(",","")).toFixed(2);}
    var tot_assets = parseFloat(al_chkacctbal) + parseFloat(al_savacctbal) + parseFloat(al_cashlicbal) +  parseFloat(al_stkbondmfbal) + parseFloat(al_home_a_b) + parseFloat(al_ore_a_b) + parseFloat(al_cars_a_b);

    if (document.getElementById("tot_assets")!=null) { document.getElementById("tot_assets").value = tot_assets; }
}
//-------------------------------------------------------------------------------------------------------------
function update_applicaiton()
{
var mi_bo_co_tgincome = 0.0; if( (document.getElementById("mi_bo_co_tgincome")!=null) && (document.getElementById("mi_bo_co_tgincome").value !="") ){mi_bo_co_tgincome = parseFloat(document.getElementById("mi_bo_co_tgincome").value.replace(",","")).toFixed(2);}
var mi_bo_co_bonus = 0.0; if( (document.getElementById("mi_bo_co_bonus")!=null) && (document.getElementById("mi_bo_co_bonus").value !="") ){mi_bo_co_bonus = parseFloat(document.getElementById("mi_bo_co_bonus").value.replace(",","")).toFixed(2);}
var mi_bo_co_childsup = 0.0; if( (document.getElementById("mi_bo_co_childsup")!=null) && (document.getElementById("mi_bo_co_childsup").value !="") ){mi_bo_co_bonus = parseFloat(document.getElementById("mi_bo_co_childsup").value.replace(",","")).toFixed(2);}
var mi_bo_co_ss = 0.0; if( (document.getElementById("mi_bo_co_ss")!=null) && (document.getElementById("mi_bo_co_ss").value !="") ){mi_bo_co_ss = parseFloat(document.getElementById("mi_bo_co_ss").value.replace(",","")).toFixed(2);}
var mi_bo_co_retire = 0.0; if( (document.getElementById("mi_bo_co_retire")!=null) && (document.getElementById("mi_bo_co_retire").value !="") ){mi_bo_co_retire = parseFloat(document.getElementById("mi_bo_co_retire").value.replace(",","")).toFixed(2);}
var mi_bo_co_tips = 0.0; if( (document.getElementById("mi_bo_co_tips")!=null) && (document.getElementById("mi_bo_co_tips").value !="") ){mi_bo_co_tips = parseFloat(document.getElementById("mi_bo_co_tips").value.replace(",","")).toFixed(2);}
var mi_bo_co_rents = 0.0; if( (document.getElementById("mi_bo_co_rents")!=null) && (document.getElementById("mi_bo_co_rents").value !="") ){mi_bo_co_rents = parseFloat(document.getElementById("mi_bo_co_rents").value.replace(",","")).toFixed(2);}
var mi_bo_co_unemp = 0.0; if( (document.getElementById("mi_bo_co_unemp")!=null) && (document.getElementById("mi_bo_co_unemp").value !="") ){mi_bo_co_unemp = parseFloat(document.getElementById("mi_bo_co_unemp").value.replace(",","")).toFixed(2);}
var mi_bo_co_food = 0.0; if( (document.getElementById("mi_bo_co_food")!=null) && (document.getElementById("mi_bo_co_food").value !="") ){mi_bo_co_food = parseFloat(document.getElementById("mi_bo_co_food").value.replace(",","")).toFixed(2);}
var mi_total_totmoninc = 0.0; if( (document.getElementById("mi_total_totmoninc")!=null) && (document.getElementById("mi_total_totmoninc").value !="") ){mi_total_totmoninc = parseFloat(document.getElementById("mi_total_totmoninc").value.replace(",","")).toFixed(2);}
var mi_bo_co_netincome = 0.0; if( (document.getElementById("mi_bo_co_netincome")!=null) && (document.getElementById("mi_bo_co_netincome").value !="") ){mi_bo_co_netincome = parseFloat(document.getElementById("mi_bo_co_netincome").value.replace(",","")).toFixed(2);}

    var mi_total_totmoninc_g = parseFloat(mi_bo_co_tgincome) + parseFloat(mi_bo_co_bonus) + parseFloat(mi_bo_co_childsup) + parseFloat(mi_bo_co_ss) + parseFloat(mi_bo_co_retire) + parseFloat(mi_bo_co_tips) + parseFloat(mi_bo_co_rents) + parseFloat(mi_bo_co_unemp) + parseFloat(mi_bo_co_food) + parseFloat(mi_total_totmoninc) ;
    var mi_bo_co_tnincome = parseFloat(mi_bo_co_netincome)+ parseFloat(mi_bo_co_bonus) + parseFloat(mi_bo_co_childsup) + parseFloat(mi_bo_co_ss) + parseFloat(mi_bo_co_retire) + parseFloat(mi_bo_co_tips) + parseFloat(mi_bo_co_rents) + parseFloat(mi_bo_co_unemp) + parseFloat(mi_bo_co_food) + parseFloat(mi_total_totmoninc) ;

//-------------------

var mhp_mortgage_1 = 0.0; if( (document.getElementById("mhp_mortgage_1")!=null) && (document.getElementById("mhp_mortgage_1").value !="") ){mhp_mortgage_1 = parseFloat(document.getElementById("mhp_mortgage_1").value.replace(",","")).toFixed(2);}
var mhp_mortgage_2 = 0.0; if( (document.getElementById("mhp_mortgage_2")!=null) && (document.getElementById("mhp_mortgage_2").value !="") ){mhp_mortgage_2 = parseFloat(document.getElementById("mhp_mortgage_2").value.replace(",","")).toFixed(2);}
var mhp_pmi = 0.0; if( (document.getElementById("mhp_pmi")!=null) && (document.getElementById("mhp_pmi").value !="") ){mhp_pmi = parseFloat(document.getElementById("mhp_pmi").value.replace(",","")).toFixed(2);}
var mhp_total = 0.0; if( (document.getElementById("mhp_total")!=null) && (document.getElementById("mhp_total").value !="") ){mhp_total = parseFloat(document.getElementById("mhp_total").value.replace(",","")).toFixed(2);}
var mhp_hoa = 0.0; if( (document.getElementById("mhp_hoa")!=null) && (document.getElementById("mhp_hoa").value !="") ){mhp_hoa = parseFloat(document.getElementById("mhp_hoa").value.replace(",","")).toFixed(2);}
var mdp_auto_1_mp = 0.0; if( (document.getElementById("mdp_auto_1_mp")!=null) && (document.getElementById("mdp_auto_1_mp").value !="") ){mdp_auto_1_mp = parseFloat(document.getElementById("mdp_auto_1_mp").value.replace(",","")).toFixed(2);}
var mdp_bank_fin_mp = 0.0; if( (document.getElementById("mdp_bank_fin_mp")!=null) && (document.getElementById("mdp_bank_fin_mp").value !="") ){mdp_bank_fin_mp = parseFloat(document.getElementById("mdp_bank_fin_mp").value.replace(",","")).toFixed(2);}
var mle_gt_bo_co = 0.0; if( (document.getElementById("mle_gt_bo_co")!=null) && (document.getElementById("mle_gt_bo_co").value !="") ){mle_gt_bo_co = parseFloat(document.getElementById("mle_gt_bo_co").value.replace(",","")).toFixed(2);}
var mle_util_water_bo_co = 0.0; if( (document.getElementById("mle_util_water_bo_co")!=null) && (document.getElementById("mle_util_water_bo_co").value !="") ){mle_util_water_bo_co = parseFloat(document.getElementById("mle_util_water_bo_co").value.replace(",","")).toFixed(2);}
var mle_child_care_bo_co = 0.0; if( (document.getElementById("mle_child_care_bo_co")!=null) && (document.getElementById("mle_child_care_bo_co").value !="") ){mle_child_care_bo_co = parseFloat(document.getElementById("mle_child_care_bo_co").value.replace(",","")).toFixed(2);}
var mle_med_exp_bo_co = 0.0; if( (document.getElementById("mle_med_exp_bo_co")!=null) && (document.getElementById("mle_med_exp_bo_co").value !="") ){mle_med_exp_bo_co = parseFloat(document.getElementById("mle_med_exp_bo_co").value.replace(",","")).toFixed(2);}
var mle_life_dis_ins_bo_co = 0.0; if( (document.getElementById("mle_life_dis_ins_bo_co")!=null) && (document.getElementById("mle_life_dis_ins_bo_co").value !="") ){mle_life_dis_ins_bo_co = parseFloat(document.getElementById("mle_life_dis_ins_bo_co").value.replace(",","")).toFixed(2);}
var mle_cloth_bo_co = 0.0; if( (document.getElementById("mle_cloth_bo_co")!=null) && (document.getElementById("mle_cloth_bo_co").value !="") ){mle_cloth_bo_co = parseFloat(document.getElementById("mle_cloth_bo_co").value.replace(",","")).toFixed(2);}
var mle_enter_bo_co = 0.0; if( (document.getElementById("mle_enter_bo_co")!=null) && (document.getElementById("mle_enter_bo_co").value !="") ){mle_enter_bo_co = parseFloat(document.getElementById("mle_enter_bo_co").value.replace(",","")).toFixed(2);}
var mle_rent_bo_co = 0.0; if( (document.getElementById("mle_rent_bo_co")!=null) && (document.getElementById("mle_rent_bo_co").value !="") ){mle_rent_bo_co = parseFloat(document.getElementById("mle_rent_bo_co").value.replace(",","")).toFixed(2);}
var mle_inci_bo_co = 0.0; if( (document.getElementById("mle_inci_bo_co")!=null) && (document.getElementById("mle_inci_bo_co").value !="") ){mle_inci_bo_co = parseFloat(document.getElementById("mle_inci_bo_co").value.replace(",","")).toFixed(2);}
    var tot_exp_debt = parseFloat(mhp_mortgage_1) + parseFloat(mhp_mortgage_2) + parseFloat(mhp_pmi) + parseFloat(mhp_total) + parseFloat(mhp_hoa) + parseFloat(mdp_auto_1_mp) + parseFloat(mdp_bank_fin_mp) + parseFloat(mle_gt_bo_co) + parseFloat(mle_util_water_bo_co) + parseFloat(mle_child_care_bo_co) + parseFloat(mle_med_exp_bo_co) + parseFloat(mle_life_dis_ins_bo_co) + parseFloat(mle_cloth_bo_co) + parseFloat(mle_enter_bo_co) + parseFloat(mle_rent_bo_co) + parseFloat(mle_inci_bo_co) ;

//-------------------

var al_chkacctbal = 0.0; if( (document.getElementById("al_chkacctbal")!=null) && (document.getElementById("al_chkacctbal").value !="") ){al_chkacctbal = parseFloat(document.getElementById("al_chkacctbal").value.replace(",","")).toFixed(2);}
var al_savacctbal = 0.0; if( (document.getElementById("al_savacctbal")!=null) && (document.getElementById("al_savacctbal").value !="") ){al_savacctbal = parseFloat(document.getElementById("al_savacctbal").value.replace(",","")).toFixed(2);}
var al_cashlicbal = 0.0; if( (document.getElementById("al_cashlicbal")!=null) && (document.getElementById("al_cashlicbal").value !="") ){al_cashlicbal = parseFloat(document.getElementById("al_cashlicbal").value.replace(",","")).toFixed(2);}
var al_stkbondmfbal = 0.0; if( (document.getElementById("al_stkbondmfbal")!=null) && (document.getElementById("al_stkbondmfbal").value !="") ){al_stkbondmfbal = parseFloat(document.getElementById("al_stkbondmfbal").value.replace(",","")).toFixed(2);}
var al_home_a_b = 0.0; if( (document.getElementById("al_home_a_b")!=null) && (document.getElementById("al_home_a_b").value !="") ){al_home_a_b = parseFloat(document.getElementById("al_home_a_b").value.replace(",","")).toFixed(2);}
var al_ore_a_b = 0.0; if( (document.getElementById("al_ore_a_b")!=null) && (document.getElementById("al_ore_a_b").value !="") ){al_ore_a_b = parseFloat(document.getElementById("al_ore_a_b").value.replace(",","")).toFixed(2);}
var al_cars_a_b = 0.0; if( (document.getElementById("al_cars_a_b")!=null) && (document.getElementById("al_cars_a_b").value !="") ){al_cars_a_b = parseFloat(document.getElementById("al_cars_a_b").value.replace(",","")).toFixed(2);}
    var tot_assets = parseFloat(al_chkacctbal) + parseFloat(al_savacctbal) + parseFloat(al_cashlicbal) +  parseFloat(al_stkbondmfbal) + parseFloat(al_home_a_b) + parseFloat(al_ore_a_b) + parseFloat(al_cars_a_b);
//-------------------

if (document.getElementById("mi_bo_co_tnincome")!=null) { document.getElementById("mi_bo_co_tnincome").value = mi_bo_co_tnincome; }
if (document.getElementById("mi_total_totmoninc_g")!=null) { document.getElementById("mi_total_totmoninc_g").value = mi_total_totmoninc_g; }
if (document.getElementById("tot_exp_debt")!=null) { document.getElementById("tot_exp_debt").value = tot_exp_debt; }
if (document.getElementById("tot_assets")!=null) { document.getElementById("tot_assets").value = tot_assets; }


}
//-------------------------------------------------------------------------------------------------------------
function JUpdateQualification()
{
    if(document.getElementById("tcThePrincipalPercentRedTo") != null && document.getElementById("tcThePrincipalPercentRedTo").value != "" && document.getElementById("tcThePrincipalPercentRedTo").value.replace(/\,/g,"").replace("%","").replace("$","") >0)
    {}    else{ document.getElementById("tcThePrincipalPercentRedTo").focus(); alert ("Invalid Value For Principal"); return false;}

    if(document.getElementById("tcThePropRateValue") != null && document.getElementById("tcThePropRateValue").value != "" && document.getElementById("tcThePropRateValue").value.replace(",","").replace("%","").replace("$","") >0)
    {}    else{ document.getElementById("tcThePropRateValue").focus(); alert ("Invalid Value For Interest Rate \n OR \n Income Is Insufficient To Follow The Guidelines \n Please add any other income "); return false;}
//    alert(document.getElementById("tcThePropDuration").value.replace(",","").replace("%","").replace("$","").replace("Years","")
    if(document.getElementById("tcThePropDuration") != null && document.getElementById("tcThePropDuration").value != "" && document.getElementById("tcThePropDuration").value.replace(",","").replace("%","").replace("$","").replace("Years","") >0)
    {}    else{ document.getElementById("tcThePropDuration").focus(); alert ("Invalid Value For Loan Duration"); return false;}
    var var_tgi_to_use=0;    if(document.getElementById("tgi_to_use") != null) { var_tgi_to_use = document.getElementById("tgi_to_use").value.replace(",","");}
    var var_tni_to_use=0;    if(document.getElementById("tni_to_use") != null) { var_tni_to_use = document.getElementById("tni_to_use").value.replace(",","");}

    var aaa = document.getElementById("tcThePrincipalPercentRedTo").value.replace(/\,/g,"").replace("%","").replace("$","");
    var bbb = document.getElementById("tcThePropRateValue").value.replace(",","").replace("%","").replace("$","") ;
    var ccc = document.getElementById("tcThePropDuration").value.replace(",","").replace("%","").replace("$","").replace("Years","");
    var mb = document.getElementById("m_balance_1").value.replace(/\,/g,"").replace("%","").replace("$","");
    var saaa = document.getElementById("sThePrincipalPercentRedTo").value.replace(/\,/g,"").replace("%","").replace("$","");
    var sbbb = document.getElementById("sThePropRateValue").value.replace(",","").replace("%","").replace("$","");
    var sccc = document.getElementById("sThePropDuration").value.replace(",","").replace("%","").replace("$","");
    saaa = (mb * saaa ) /100;
    var n = ccc * 12;
    var r = bbb/(12*100);
    var p = (aaa * r *Math.pow((1+r),n))/(Math.pow((1+r),n)-1);
    var prin = Math.round(p*100)/100;
//    if(document.getElementById("kf_pm_dti") != null) {document.getElementById("kf_pm_dti").value  = ( ( (parseFloat(prin)/var_tgi_to_use) *100).toFixed(2) + "%");    var var_kf_pm_comments = ""; }
    var mhp_hoa;     var $mhp_pmi;     var mhp_prop_tax;
    if(document.getElementById("mhp_hoa") != null) { mhp_hoa = parseFloat(document.getElementById("mhp_hoa").value.replace(",","").replace("$",""));}
    if(document.getElementById("mhp_pmi") != null) { mhp_pmi = parseFloat(document.getElementById("mhp_pmi").value.replace(",","").replace("$",""));}
    if(document.getElementById("mhp_total") != null) { mhp_total = parseFloat(document.getElementById("mhp_total").value.replace(",","").replace("$",""));}
    var HcThePropMPayValue = 0;
    //alert(prin + "-> " +   mhp_hoa + "-> " + mhp_pmi + "-> " + mhp_prop_tax + "==>" + document.getElementById("mhp_total").value)
    HcThePropMPayValue = parseFloat(prin) + parseFloat(mhp_hoa) + parseFloat(mhp_pmi) + parseFloat(mhp_total);

    document.getElementById("tcThePropMPayValue").value = addCommas(prin.toFixed(2));
    if(document.getElementById("HtcThePropMPayValue") != null) {document.getElementById("HtcThePropMPayValue").value = addCommas(parseFloat(HcThePropMPayValue).toFixed(2));}
    //($HcThePropMPayValue / $keyfind_summary_g) * 100
    var keyfind_summary_g = parseFloat(document.getElementById("keyfind_summary_g").value.replace(",","").replace("$",""))
    var tot_exp_debt = parseFloat(document.getElementById("tot_exp_debt").value.replace(",","").replace("$",""))
    var mhp_mortgage_1 = parseFloat(document.getElementById("mhp_mortgage_1").value.replace(",","").replace("$",""))
    var postmod_hti=0; postmod_hti =  ( (HcThePropMPayValue / keyfind_summary_g) * 100 );
    if(document.getElementById("kf_pm_dti") != null) {document.getElementById("kf_pm_dti").value = addCommas(parseFloat(postmod_hti).toFixed(2));}
//    var postmod_exp =var_tni_to_use - (tot_exp_debt - mhp_mortgage_1 + prin);
    var postmod_exp = parseFloat(tot_exp_debt - mhp_mortgage_1 + prin).toFixed(2);
    var  kf_pm_di = parseFloat(var_tni_to_use - (postmod_exp)).toFixed(2);
    //alert(postmod_exp + ">>>" + kf_pm_di)
    if(document.getElementById("post_mod_exp") != null) {document.getElementById("post_mod_exp").value = addCommas(parseFloat(postmod_exp).toFixed(2));}
    if(document.getElementById("kf_pm_di") != null) {document.getElementById("kf_pm_di").value = addCommas(parseFloat(kf_pm_di).toFixed(2));}
    if(document.getElementById("span_kf_pm_di") != null) {document.getElementById("span_kf_pm_di").innerHTML = addCommas(parseFloat(kf_pm_di).toFixed(2));}
    document.getElementById("span_post_mod_hti").innerHTML = parseFloat(postmod_hti).toFixed(2);

if(kf_pm_di > 0)
    {
        
        document.getElementById("kf_rem_8").value = "";
        document.getElementById("div_post_mod_disp_inc_rem").innerHTML = "";
        document.getElementById("div_post_mod_disp_inc_res").innerHTML = "PASS";
        document.getElementById("kf_res_8").value = "PASS";
        document.getElementById("div_post_mod_disp_inc_res").className = "div_pass";
    }
    else
    {
        document.getElementById("kf_rem_8").value = "Some lenders may disqualify you as they don’t want to see you in a deficit after they modified your payment. ";
        document.getElementById("div_post_mod_disp_inc_rem").innerHTML = "Some lenders may disqualify you as they don’t want to see you in a deficit after they modified your payment. ";
        document.getElementById("div_post_mod_disp_inc_res").innerHTML = "ALERT";
        document.getElementById("kf_res_8").value = "ALERT";
        document.getElementById("div_post_mod_disp_inc_res").className = "div_alert";
    }
    //alert(Math.round(postmod_hti));
    if(Math.round(postmod_hti) == 31)
    {
        document.getElementById("kf_rem_10").value = "31% of your Gross Income can be used for your Housing Expense - This is the affordable level set by your lender ";
        document.getElementById("div_post_mod_hti_rem").innerHTML = "31% of your Gross Income can be used for your Housing Expense - This is the affordable level set by your lender ";
        document.getElementById("div_post_mod_hti_res").innerHTML = "PASS";
        document.getElementById("div_post_mod_hti_res").className = "div_pass";
        //document.getElementById("kf_rem_10").value = "31% of your Gross Income can be used for your Housing Expense - This is the affordable level set by your lender ";
        document.getElementById("kf_res_10").value = "PASS";
        
    }
    else
    {
        document.getElementById("kf_rem_10").value = "31% is the target Housing Expense to Income Ratio - By changing this Ratio, you may completely disqualify yourself for the program.";
        document.getElementById("div_post_mod_hti_rem").innerHTML = "31% is the target Housing Expense to Income Ratio - By changing this Ratio, you may completely disqualify yourself for the program.";
        document.getElementById("div_post_mod_hti_res").innerHTML = "FAIL";
        document.getElementById("div_post_mod_hti_res").className = "div_fail";
        //document.getElementById("kf_rem_10").value = "31% is the target Housing Expense to Income Ratio - By changing this Ratio, you may completely disqualify yourself for the program.";
        document.getElementById("kf_res_10").value = "FAIL";
    }
    
    var v_kf_res_1 = ""; if ( document.getElementById("kf_res_1") != null ) { v_kf_res_1 = document.getElementById("kf_res_1").value; }
    var v_kf_res_2 = ""; if ( document.getElementById("kf_res_2") != null ) { v_kf_res_2 = document.getElementById("kf_res_2").value; }
    var v_kf_res_3 = ""; if ( document.getElementById("kf_res_3") != null ) { v_kf_res_3 = document.getElementById("kf_res_3").value; }
    var v_kf_res_4 = ""; if ( document.getElementById("kf_res_4") != null ) { v_kf_res_4 = document.getElementById("kf_res_4").value; }
    var v_kf_res_5 = ""; if ( document.getElementById("kf_res_5") != null ) { v_kf_res_5 = document.getElementById("kf_res_5").value; }
    var v_kf_res_6 = ""; if ( document.getElementById("kf_res_6") != null ) { v_kf_res_6 = document.getElementById("kf_res_6").value; }
    var v_kf_res_7 = ""; if ( document.getElementById("kf_res_7") != null ) { v_kf_res_7 = document.getElementById("kf_res_7").value; }
    var v_kf_res_8 = ""; if ( document.getElementById("kf_res_8") != null ) { v_kf_res_8 = document.getElementById("kf_res_8").value; }
    var v_kf_res_9 = ""; if ( document.getElementById("kf_res_9") != null ) { v_kf_res_9 = document.getElementById("kf_res_9").value; }
    var v_kf_res_10 = ""; if ( document.getElementById("kf_res_10") != null ) { v_kf_res_10 = document.getElementById("kf_res_10").value; }
    var fail_count =0;
    if(v_kf_res_1 == "FAIL") {fail_count++;}
    if(v_kf_res_2 == "FAIL") {fail_count++;}
    if(v_kf_res_3 == "FAIL") {fail_count++;}
    if(v_kf_res_4 == "FAIL") {fail_count++;}
    if(v_kf_res_5 == "FAIL") {fail_count++;}
    if(v_kf_res_6 == "FAIL") {fail_count++;}
    if(v_kf_res_7 == "FAIL") {fail_count++;}
    if(v_kf_res_8 == "FAIL") {fail_count++;}
    if(v_kf_res_9 == "FAIL") {fail_count++;}
    if(v_kf_res_10 == "FAIL") {fail_count++;}
    //alert( var_tni_to_use + ">>" + tot_exp_debt + ">>" + mhp_mortgage_1 + ">>" + prin);
    if ( v_kf_res_1 =="PASS" && v_kf_res_2 == "PASS" && v_kf_res_3 == "PASS" && v_kf_res_4 == "PASS" && v_kf_res_5 == "PASS" &&
         v_kf_res_6 =="PASS" && v_kf_res_7 == "PASS" && v_kf_res_8 == "PASS" && v_kf_res_9 == "PASS" && v_kf_res_10 == "PASS" )
    {
        document.getElementById("span_gen_comments_p").style.display = "inline";
        document.getElementById("span_gen_comments_f").style.display = "none";
        document.getElementById("span_gen_comments_wm").value = "may";
    }
    else
    {
        document.getElementById("span_gen_comments_f").style.display = "inline";
        document.getElementById("span_gen_comments_p").style.display = "none";
    }
    
    if(fail_count == 1)
    {
        document.getElementById("span_gen_comments_wm").value = "may";
    }
    else if(fail_count > 1)
    {
        document.getElementById("span_gen_comments_wm").value = "will";
    }
    
    
}
//-------------------------------------------------------------------------------------------------------------
function loanJDef()
{
//        alert("Under Construction");return;
    var zzz= 0; var yyy=0; var xxx=0;
    if(document.getElementById("sThePrincipalPercentRedTo") != null ) { xxx = document.getElementById("sThePrincipalPercentRedTo").value;}
    if(document.getElementById("sThePropRateValue") != null ) { yyy = document.getElementById("sThePropRateValue").value;}
    if(document.getElementById("sThePropDuration") != null ) { zzz = document.getElementById("sThePropDuration").value;}
    var mb = document.getElementById("m_balance_1").value.replace(/\,/g,"").replace("%","");
    var xyz=parseFloat(mb) * parseFloat(xxx)/100;
    if(document.getElementById("tcThePrincipalPercentRedTo") != null ) {document.getElementById("tcThePrincipalPercentRedTo").value = ("$" + addCommas(parseFloat(xyz).toFixed(2)));}
    if(document.getElementById("tcThePropRateValue") != null ){document.getElementById("tcThePropRateValue").value = (parseFloat(yyy).toFixed(3) + "%");}
    if(document.getElementById("tcThePropDuration") != null ){document.getElementById("tcThePropDuration").value = (zzz + " Years");}
    var x=JUpdateQualification();
}
//--------------------------------------------------------------------------------------------------------------------
function xmlhttpPost(tranid) {
    var xmlHttpReq = false;
    var self = this;
    strURL = "upd_borrower_info.php";
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
       if (self.xmlHttpReq.readyState == 4)
       {
           //alert(self.xmlHttpReq.responseText)
                //updatepage(self.xmlHttpReq.responseText,num);
       }
    };
    self.xmlHttpReq.send(getquerystring(tranid));
}
//--------------------------------------------------------------------------------------------------------------------
function getquerystring(tranid)
{
        var valuetopass = "";
        valuetopass = "borrower_fname=" + escape(document.getElementById("borrower_fname").value);
        valuetopass += "&coborrower_name=" + escape(document.getElementById("coborrower_name").value);
        valuetopass += "&borrower_h_street=" + escape(document.getElementById("borrower_h_street").value);
        valuetopass += "&borrower_h_city=" + escape(document.getElementById("borrower_h_city").value);
        valuetopass += "&borrower_h_state=" + escape(document.getElementById("borrower_h_state").value);
        valuetopass += "&borrower_h_zip=" + escape(document.getElementById("borrower_h_zip").value);
        valuetopass += "&borrower_phone1_part1=" + escape(document.getElementById("borrower_phone1_part1").value);
        valuetopass += "&borrower_phone1_part2=" + escape(document.getElementById("borrower_phone1_part2").value);
        valuetopass += "&borrower_phone1_part3=" + escape(document.getElementById("borrower_phone1_part3").value);
        valuetopass += "&borrower_phone1_type=" + escape(document.getElementById("borrower_phone1_type").value);
        /*
        valuetopass += "&borrower_m_street=" + escape(document.getElementById("borrower_m_street").value);
        valuetopass += "&borrower_m_city=" + escape(document.getElementById("borrower_m_city").value);
        valuetopass += "&borrower_m_state=" + escape(document.getElementById("borrower_m_state").value);
        valuetopass += "&borrower_m_zip=" + escape(document.getElementById("borrower_m_zip").value);
        */
        valuetopass += "&borrower_m_street=" + escape(document.getElementById("borrower_h_street").value);
        valuetopass += "&borrower_m_city=" + escape(document.getElementById("borrower_h_city").value);
        valuetopass += "&borrower_m_state=" + escape(document.getElementById("borrower_h_state").value);
        valuetopass += "&borrower_m_zip=" + escape(document.getElementById("borrower_h_zip").value);

        valuetopass += "&borrower_phone2_part1=" + escape(document.getElementById("borrower_phone2_part1").value);
        valuetopass += "&borrower_phone2_part2=" + escape(document.getElementById("borrower_phone2_part2").value);
        valuetopass += "&borrower_phone2_part3=" + escape(document.getElementById("borrower_phone2_part3").value);
        valuetopass += "&borrower_phone2_type=" + escape(document.getElementById("borrower_phone2_type").value);
        valuetopass += "&m_lender_name_1=" + escape(document.getElementById("m_lender_name_1").value);
        valuetopass += "&m_loan_amount1=" + escape(document.getElementById("m_loan_amount1").value);
        valuetopass += "&m_loan_num_1=" + escape(document.getElementById("m_loan_num_1").value);
        valuetopass += "&m_loan_rate1=" + escape(document.getElementById("m_loan_rate1").value);
        valuetopass += "&borrower_email=" + escape(document.getElementById("borrower_email").value);
        valuetopass += "&tranid=" + escape(tranid);

        return ( valuetopass);

}
//-------------------------------------------------------------------------------------------------------------
function checkformvarlogin()
{
    if(emptyvalue("email")) { document.getElementById("email").focus(); alert ("Please specify your login email address"); return false;}
    else if(emailCheck("email")==false) {  document.getElementById("email").focus(); alert ("Please specify Valid Email Address"); return false;}
    else if(emptyvalue("password")) { document.getElementById("password").focus(); alert ("Please specify your password"); return false;}
    else{
        document.getElementById("submitlogin").value =1;
        return true;
    }
}
//-------------------------------------------------------------------------------------------------------------
function profileupdproplink(v1, v2)
{
        document.getElementById("thepropid").value = v1 +"_"+ v2;
        document.getElementById("submitprofile1").click();
}
//-------------------------------------------------------------------------------------------------------------
function checkforgetpass()
{
    if(emptyvalue("email")) { document.getElementById("email").focus(); alert ("Please specify your login email address"); return false;}
    else if(emailCheck("email")==false) {  document.getElementById("email").focus(); alert ("Please specify Valid Email Address"); return false;}
    else{
        document.getElementById("submitlogin").value =1;
        return true;
    }
}
//-------------------------------------------------------------------------------------------------------------
function payaplconfirm()
{
//    if(emptyvalue("cname"))             {     document.getElementById("cname").focus();         alert ("Please Enter Name On Card"); return false;}
    if(document.getElementById("confirm_1").checked != true){ document.getElementById("confirm_1").focus(); alert ("Please Accept Agreement"); return false;}
    else
    {
    document.getElementById("submitstatp").value = 1;     return true;
    //alert("This Functionality Is Under Construction, You will be redirected to Thank You page now");     window.location.href="thankyou.html";    return false;
    }
}
//-------------------------------------------------------------------------------------------------------------

function chkfrmcontactus()
{
    if(emptyvalue("pname")) { document.getElementById("pname").focus(); alert ("Please specify your name"); return false;}
    else if(emptyvalue("emailaddr")) { document.getElementById("emailaddr").focus(); alert ("Please specify your  email address"); return false;}
    else if(emailCheck("emailaddr")==false) {  document.getElementById("emailaddr").focus(); alert ("Please specify Valid Email Address"); return false;}
    else if(emptyvalue("phone")) { document.getElementById("phone").focus(); alert ("Please specify your phone number"); return false;}
    else if(emptyvalue("subject")) { document.getElementById("subject").focus(); alert ("Please specify subject"); return false;}
    else if(emptyvalue("comments")) { document.getElementById("comments").focus(); alert ("Please specify your comments/remarks/feedback"); return false;}
    else{
        document.getElementById("submitstatc").value =1;
        return true;
    }

}


//-------------------------------------------------------------------------------------------------------------
function checkscriptlog()
{
    if(emptyvalue("spoketo")) { document.getElementById("spoketo").focus(); alert ("Please specify name of the person you spoke to"); return false;}
    else if(emptyvalue("phone")) { document.getElementById("phone").focus(); alert ("Please specify phone number and extension (if applicable) on which you made call"); return false;}
    else if(emptyvalue("subject")) { document.getElementById("subject").focus(); alert ("Please specify subject"); return false;}
    else if(emptyvalue("outcome")) { document.getElementById("outcome").focus(); alert ("Please specify your outcome/comments/remarks about the call"); return false;}
    else{
        //document.getElementById("submitstatc").value =1;
        return true;
    }
    
}
//-------------------------------------------------------------------------------------------------------------
function checkaffapp()
{
    var chkcomm="";
    if(document.getElementById("aff_commchk1").checked == true) {    chkcomm = "S"};
    if(document.getElementById("aff_commchk2").checked == true) {    chkcomm = "B"};
    if(emptyvalue("aff_first_name")) { document.getElementById("aff_first_name").focus(); alert ("Please specify first name"); return false;}
    else if(emptyvalue("aff_last_name")) { document.getElementById("aff_last_name").focus(); alert ("Please specify last name"); return false;}
    else if(emptyvalue("aff_email")) { document.getElementById("aff_email").focus(); alert ("Please specify your  email address"); return false;}
    else if(emailCheck("aff_email")==false) {  document.getElementById("aff_email").focus(); alert ("Please specify Valid Email Address"); return false;}
    else if(emptyvalue("aff_phone")) { document.getElementById("aff_phone").focus(); alert ("Please specify your phone number"); return false;}
    else if(emptyvalue("aff_address")) { document.getElementById("aff_address").focus(); alert ("Please specify your street address"); return false;}
    else if(emptyvalue("aff_city")) { document.getElementById("aff_city").focus(); alert ("Please specify  city name "); return false;}
    else if(emptyvalue("aff_zip")) { document.getElementById("aff_zip").focus(); alert ("Please specify ZIP"); return false;}
    else if(chkcomm=="") { document.getElementById("aff_commchk1").focus(); alert ("Please specify how your commission check should be prepared (payable to you or your bussines)"); return false;}
    //else if(!document.getElementById("chk_agree").checked) {  document.getElementById("chk_agree").focus(); alert ("Please agree to the terms mentioned"); return false;}
    else{
        document.getElementById("submitstat").value =1;
        return true;
    }
}
//-------------------------------------------------------------------------------------------------------------
function checkbrkdemoapp()
{
    var chkcomm="";
    if(document.getElementById("brk_member_mots1").checked == true) {    chkcomm = "Y"};
    if(document.getElementById("brk_member_mots2").checked == true) {    chkcomm = "N"};
    if(emptyvalue("brk_first_name")) { document.getElementById("brk_first_name").focus(); alert ("Please specify first name"); return false;}
    else if(emptyvalue("brk_last_name")) { document.getElementById("brk_last_name").focus(); alert ("Please specify last name"); return false;}
    else if(emptyvalue("brk_phone")) { document.getElementById("brk_phone").focus(); alert ("Please specify your phone number"); return false;}
    else if(emptyvalue("brk_email")) { document.getElementById("brk_email").focus(); alert ("Please specify your  email address"); return false;}
    else if(emailCheck("brk_email")==false) {  document.getElementById("brk_email").focus(); alert ("Please specify Valid Email Address"); return false;}
    else if(emptyvalue("brk_address")) { document.getElementById("brk_address").focus(); alert ("Please specify your street address"); return false;}
    else if(emptyvalue("brk_city")) { document.getElementById("brk_city").focus(); alert ("Please specify  city name "); return false;}
    else if(emptyvalue("brk_zip")) { document.getElementById("brk_zip").focus(); alert ("Please specify ZIP"); return false;}
    else if(chkcomm=="") { document.getElementById("brk_member_mots1").focus(); alert ("Please specify whether you are already a member of ModOnTheSpot or not"); return false;}
    else{
        document.getElementById("submitstat").value =1;
        return true;
    }
}
//-------------------------------------------------------------------------------------------------------------
function checkbrkdemoact()
{
    var brk_password = document.getElementById("brk_password").value;
    var brk_password2 = document.getElementById("brk_password2").value;
    if(emptyvalue("brk_first_name")) { document.getElementById("brk_first_name").focus(); alert ("Please specify first name"); return false;}
    else if(emptyvalue("brk_last_name")) { document.getElementById("brk_last_name").focus(); alert ("Please specify last name"); return false;}
    else if(emptyvalue("brk_loginemail")) { document.getElementById("brk_loginemail").focus(); alert ("Please specify your  email address"); return false;}
    else if(emailCheck("brk_loginemail")==false) {  document.getElementById("brk_loginemail").focus(); alert ("Please specify Valid Email Address"); return false;}
    else if(emptyvalue("brk_password")) { document.getElementById("brk_password").focus(); alert ("Please specify password"); return false;}
    else if(emptyvalue("brk_password2")) { document.getElementById("brk_password2").focus(); alert ("Please reenter password"); return false;}
    else if(brk_password != brk_password2) { document.getElementById("brk_password").focus(); alert ("Passwords do not match, please reenter"); return false;}
    else if(emptyvalue("brk_mobile")) { document.getElementById("brk_mobile").focus(); alert ("Please specify mobile number "); return false;}
    else if(emptyvalue("brk_address")) { document.getElementById("brk_address").focus(); alert ("Please specify your street address"); return false;}
    else if(emptyvalue("brk_city")) { document.getElementById("brk_city").focus(); alert ("Please specify  city name "); return false;}
    else if(emptyvalue("brk_zip")) { document.getElementById("brk_zip").focus(); alert ("Please specify ZIP"); return false;}
    else{
        document.getElementById("submitstat").value =1;
        return true;
    }
}
//-------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------
function checkbrkdemoact2()
{
    if(emptyvalue("brk_first_name")) { document.getElementById("brk_first_name").focus(); alert ("Please specify first name"); return false;}
    else if(emptyvalue("brk_last_name")) { document.getElementById("brk_last_name").focus(); alert ("Please specify last name"); return false;}
    else if(emptyvalue("brk_mobile")) { document.getElementById("brk_mobile").focus(); alert ("Please specify mobile number "); return false;}
    else if(emptyvalue("brk_address")) { document.getElementById("brk_address").focus(); alert ("Please specify your street address"); return false;}
    else if(emptyvalue("brk_city")) { document.getElementById("brk_city").focus(); alert ("Please specify  city name "); return false;}
    else if(emptyvalue("brk_zip")) { document.getElementById("brk_zip").focus(); alert ("Please specify ZIP"); return false;}
    else{
        document.getElementById("submitstat").value =1;
        return true;
    }
}
//-------------------------------------------------------------------------------------------------------------
function upd_brok_bill()
{
    var fee1_phase1 = 0.0; if( document.getElementById("fee1_phase1") != null) { fee1_phase1 = parseFloat(document.getElementById("fee1_phase1").value.replace(",","").replace("$","")); }
    var fee1_phase2 = 0.0; if( document.getElementById("fee1_phase2") != null) { fee1_phase2 = parseFloat(document.getElementById("fee1_phase2").value.replace(",","").replace("$","")); }
    var fee1_phase3 = 0.0; if( document.getElementById("fee1_phase3") != null) { fee1_phase3 = parseFloat(document.getElementById("fee1_phase3").value.replace(",","").replace("$","")); }

    var fee2_phase1 = 0.0; if( document.getElementById("fee2_phase1") != null) { fee2_phase1 = parseFloat(document.getElementById("fee2_phase1").value.replace(",","").replace("$","")); }
    var fee2_phase2 = 0.0; if( document.getElementById("fee2_phase2") != null) { fee2_phase2 = parseFloat(document.getElementById("fee2_phase2").value.replace(",","").replace("$","")); }
    var fee2_phase3 = 0.0; if( document.getElementById("fee2_phase3") != null) { fee2_phase3 = parseFloat(document.getElementById("fee2_phase3").value.replace(",","").replace("$","")); }

    var tot_phase1 = 0.0; tot_phase1 = parseFloat(fee1_phase1) + parseFloat(fee2_phase1);
    var tot_phase2 = 0.0; tot_phase2 = parseFloat(fee1_phase2) + parseFloat(fee2_phase2);
    var tot_phase3 = 0.0; tot_phase3 = parseFloat(fee1_phase3) + parseFloat(fee2_phase3);
    
    if(document.getElementById("tot_phase1") != null) { document.getElementById("tot_phase1").value = tot_phase1.toFixed(2); }
    if(document.getElementById("tot_phase2") != null) { document.getElementById("tot_phase2").value = tot_phase2.toFixed(2); }
    if(document.getElementById("tot_phase3") != null) { document.getElementById("tot_phase3").value = tot_phase3.toFixed(2); }
}
//-------------------------------------------------------------------------------------------------------------
