function validateFields(){
    var shallWeContinue;    //This variable stays true until a test fails.
    shallWeContinue = true; //If it becomes false the remaining tests will not run
    if (isNaN(document.forms["frmPayOnline"].txtAmount_Gross.value)){
        alert('The total payment needs to be a number. Please update the payment amount and click Recalculate.');
        document.forms["frmPayOnline"].txtAmount_Gross.focus();
        shallWeContinue = false;
    }
    if (document.forms["frmPayOnline"].txtAmount_Gross.value < 1){
        alert('The minimum payment is one dollar. Please update the payment amount and click Recalculate.');
        document.forms["frmPayOnline"].txtAmount_Gross.focus();
        shallWeContinue = false;
    }
    if(shallWeContinue){shallWeContinue = fieldProfiler('frmPayOnline','txtAmount_Gross','Payment Amount','NumericCurrency','no');}
    if(shallWeContinue){document.forms["frmPayOnline"].submit();}
}

function calculatePaymentAmount() {
    var amountNet = document.forms[0].txtAmount_Net.value;
    amountNet = amountNet.replace(",","");    //Remove commas
    amountNet = amountNet.replace("$","");    //Remove dollar signs

    var amountGross = amountNet * 1.05;
    document.forms[0].txtAmount_Gross.value = amountGross.toFixed(2)

    var amountServiceCharge = amountNet * 0.05;
    document.forms[0].txtAmount_ServiceCharge.value = amountServiceCharge.toFixed(2);
    
    document.forms[0].txtAmount_Net.value = (amountGross - amountServiceCharge).toFixed(2);
}

