﻿function checkForm() {
    var stringMsg = '';
    var stringMsg1994 = '';
    var validated = true;

    document.getElementById('txtSecurityType').style.backgroundColor = "White";
    document.getElementById('txtFinanceInfo').style.backgroundColor = "White";
    document.getElementById('cboSecurity').style.backgroundColor = "White";
    //document.getElementById('txtYearManufacturer').style.backgroundColor = "White";

    //Select security type
    if (document.getElementById('txtSecurityType').value == 'Please select') {
        stringMsg += '** Please select an item for Security Offered. *\n';
        document.getElementById('txtSecurityType').style.backgroundColor = "Red";
        validated = false;
    }

    //Is security under finance...compulsory
    if (document.getElementById('cboSecurity').value == 'Select') {
        stringMsg += '** Please select an item for Security under finance. *\n';
        document.getElementById('cboSecurity').style.backgroundColor = "Red";
        validated = false;
    }


    //If under finance, which company is compulsory
    if (document.getElementById('cboSecurity').value == 'Yes') {
        if (document.getElementById('txtFinanceInfo').value.length == 0) {
            stringMsg += '** Please enter the name of the finance company or bank.\n';
            document.getElementById('txtFinanceInfo').style.backgroundColor = "Red";
            validated = false;
        }
    }

    if (!document.getElementById('chkApplicant1').checked) {
        stringMsg += '** Please tick Applicant 1 *';
        validated = false;
    }

    //Display Message
    if (stringMsg != '') {
        alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n' + stringMsg);
    }

    //Is Year of manufacture above 1994
//    if (document.getElementById('txtYearManufacturer').value < 1994) {
//        stringMsg1994 = 'Clients are required to offer some form of security of a 1994 or above on our loans between $500 - $5000, this includes: Motor Vehicle, Truck, Caravan, Jet Ski, Boat, Motor Bike (must be registered) if you don’t have this you can have a second applicant on the application who can offer security on your behalf.';
//        //document.getElementById('txtYearManufacturer').style.backgroundColor = "Red";
//        //validated = false;
//    }
//    //Display Message - 1994
//    if (stringMsg1994 != '') {
//        //alert(stringMsg1994);
//    }

    return validated;

}
function showFewWords(dropdown) {

    //var myindex = dropdown.selectedIndex
    //var SelValue = dropdown.options[myindex].value


    if (document.getElementById("cboDefaulted").selectedIndex == 1 ||
            document.getElementById("cboJudgment").selectedIndex == 1 ||
            document.getElementById("cboBankrupt").selectedIndex == 1) {
        document.getElementById("panelExplain").style.display = '';
    }
    else {
        document.getElementById("panelExplain").style.display = 'none';
    }

    return;
}

function showWhichFinance(dropdown) {

    //var myindex = dropdown.selectedIndex
    //var SelValue = dropdown.options[myindex].value


    if (document.getElementById("cboSecurity").selectedIndex == 1) {
        document.getElementById("panel1").style.display = '';
    }
    else {
        document.getElementById("panel1").style.display = 'none';
    }

    return;
}