﻿
function getbc(region,locationID)
{
    if (region.value == 'Other') {
        document.getElementById('otherholder').style.display = '';
        document.getElementById('dealerholder').style.display = 'none';
    }
    else if (region.value == 'Head Office') {
        document.getElementById('otherholder').style.display = 'none';
        document.getElementById('dealerholder').style.display = 'none';
    }
    else {
        document.getElementById('otherholder').style.display = 'none';
        document.getElementById('dealerholder').style.display = '';
        size = locationID.length
        for (x = 0; x < size; x++) {
            locationID.remove(0);
        }

        locationID.length += 1; //add 1 to the length of array
        locationID.options[locationID.length - 1].value = '';
        locationID.options[locationID.length - 1].text = 'Please select...';

        for (x = 0; x < locationcomp.length; x++) {
            if (regioncomp[x] == region.value) {
                locationID.length += 1;
                locationID.options[locationID.length - 1].value = locationcomp[x];
                locationID.options[locationID.length - 1].text = locname[x];
            }
        }
    }
}


function validateData() {

    if (document.forms[0].ContactType.value == '')
	{
	    alert('Please select a Contact Type.');
		document.forms[0].ContactType.focus();
		return false;
	}
	else if (document.forms[0].Dealership.value == '')
	{
	    alert('Please select a Region.');
	    document.forms[0].Dealership.focus();
	    return false;
	}
	else if (document.forms[0].Dealership.value == 'Other' && document.forms[0].OtherDesc.value == '')
	{
	    alert('Please fill in the Other Description.');
	    document.forms[0].OtherDesc.focus();
	    return false;
	}
	else if (document.forms[0].dealerid.value == '' && document.forms[0].Dealership.value != 'Other' && document.forms[0].Dealership.value != 'Head Office')
	{
	    alert('Please select a Dealership.');
		document.forms[0].dealerid.focus();
		return false;
    }
    else if (document.forms[0].Category.value == '')
	{
	    alert('Please select a Category.');
	    document.forms[0].Category.focus();
	    return false;
	}
	else if (document.forms[0].FirstName.value == '')
	{
		alert('Please fill in your First Name.');
		document.forms[0].FirstName.focus();
		return false;
    }
    else if (document.forms[0].Surname.value == '')
	{
	    alert('Please fill in your Surname.');
		document.forms[0].Surname.focus();
		return false;
    }
    else if (document.forms[0].Cell.value == '' || document.forms[0].Cell.value.length < 10)
	{
		alert('Please fill in your 10 digit cell phone number with no spaces, eg: 0821234567.');
		document.forms[0].Cell.focus();
		return false;
    }
    else if (document.forms[0].Office.value == '' || document.forms[0].Office.value.length < 10)
	{
		alert('Please fill in your 10 digit office number, including area code, with no spaces, eg: 0111234567.');
		document.forms[0].Office.focus();
		return false;
    }
    else if (document.forms[0].email.value == '')
	{
		alert('Please fill in your email address.');
		document.forms[0].email.focus();
		return false;
    }
    else
	{
		return true;
	}
}

