function bondSubmit() {
    var isPurchasePriceSet = (document.getElementById('bondPurchasePrice').value == "" || document.getElementById('bondPurchasePrice').value == "0") ? false : true;
//    var isLoanAmountSet = (document.getElementById('bondLoanAmount').value == "" || document.getElementById('bondLoanAmount').value == "0") ? false : true;
	var isLoanAmountSet = true;//we allow calculations without loan amounts
    var isLoanAmountOk = true;
    if (isLoanAmountSet) {
        isLoanAmountOk = (document.getElementById('bondLoanAmount').value.replace(/\,/g, '') == 0 || document.getElementById('bondLoanAmount').value.replace(/\,/g, '') >100000) ? true : false;
    }
    var isPurchasePriceOk = true;
    if (isPurchasePriceSet) {
        isPurchasePriceOk = document.getElementById('bondPurchasePrice').value <= 100000 ? false : true;
    }
    var isBondNatureSet = document.getElementById('bondNature').value == "" ? false : true;
    var isBondStatusSet = document.getElementById('bondStatus').value == "" ? false : true;
    var msg = "";
    var formOk = true;    
    if (!isPurchasePriceSet) {
//        var temp = prompt("The required field \"Purchase price\" was not set.\nPlease assign it a value now.",'');
//        document.getElementById('bondPurchasePrice').value = temp;
//        if (temp != "" && temp != null)
//        isPurchasePriceSet = true;
        msg +="- Please set purchase price.\n";
        formOk = false;
    }
    if (!isLoanAmountSet) {
//        var temp = prompt("The required field \"Loan amount\" was not set.\nPlease assign it a value now.",'');
//        document.getElementById('bondLoanAmount').value = "";
//        document.getElementById('bondLoanAmount').value = temp;
//        if (temp < 100000) {
//        temp = prompt("The required field \"Loan amount\" must be above 100,000",'');
//        }
//        if (temp != "" && temp != null && temp > 100000)
//        isLoanAmountSet = true;
        msg +="- Please set loan amount.\n";
        formOk = false;
    }
    if (!isLoanAmountOk) {
//    var val = document.getElementById('bondLoanAmount').value;
//    if (val <= 100000) {
//        isLoanAmountSet = false;
//        temp = prompt("The required field \"Loan amount\" must be above 100,000",'');
//        document.getElementById('bondLoanAmount').value = temp;
//        }
//        if (temp != "" && temp != null && temp > 100000)
//        isLoanAmountSet = true;
        msg +="- Please set loan amount above R 100 000 or equal to 0.\n";
        formOk = false;
    }

    if (!isPurchasePriceOk) {
        msg +="- Please set purchase price above R 100 000.\n";
        formOk = false;
    }
    
    if (!isBondNatureSet) {
        msg +="- Please select nature of status.\n";
        formOk = false;
    }
    if (!isBondStatusSet) {
        msg +="- Please select status of purchase.\n";
        formOk = false;
    }

    if (formOk) {
        document.getElementById('bondForm').submit();
    } else {
        alert(msg);
    }
}
function bondClear() {
    document.getElementById('bondReg').innerHTML = "R 0.00";
    document.getElementById('transCost').innerHTML = "R 0.00";
    document.getElementById('bondStamp').innerHTML = "R 0.00";
    document.getElementById('transDuty').innerHTML = "R 0.00";
    document.getElementById('bondLevy').innerHTML = "R 0.00";
    document.getElementById('transLevy').innerHTML = "R 0.00";
    document.getElementById('transMvp').innerHTML = "R 0.00";
    document.getElementById('bondPostAndPetty').innerHTML = "R 0.00";
    document.getElementById('bondInitiation').innerHTML = "R 0.00";
    document.getElementById('transPostAndPetty').innerHTML = "R 0.00";
    document.getElementById('bondTotal').innerHTML = "R 0.00";
    document.getElementById('transTotal').innerHTML = "R 0.00";
    document.getElementById('total').innerHTML = "R 0.00";
    document.getElementById('fica1').innerHTML = "R 0.00";
    document.getElementById('fica2').innerHTML = "R 0.00";
}
function bondEmail() {
    document.getElementById('bondAction').value = 'email';
    document.getElementById('bondForm').submit();
}

function bondPrint() {
    document.getElementById('bondAction').value='print';
    document.getElementById('bondForm').submit();
}
