/**
 * Check if a postcode or city is entered when the form at the homepage is
 * submitted
 */
function checkLocationsSubmit(sender) {
	/**
	 * Gather the postcode data
	 */
	this.postcode = document.getElementById('find-dealer-postal-code');
	/**
	 * Gather the city data
	 */
	this.city = document.getElementById('find-dealer-locality');
	/**
	 * Check if the postcode field is filled, we assume the user want to search
	 * with that value.
	 * 
	 * The default value is 1234AB, so ignore this value
	 */
	if (this.postcode.value.length > 0 && this.postcode.value != '1234AB') {
		/**
		 * Check if the postcode meets the exceptations
		 */
		this.postcodeValue = this.postcode.value;
		if (this.postcodeValue.match(/^[0-9]{4}[\ ]?[a-zA-Z]{2}$/)) {
			return true;
		} else {
			/**
			 * The postcode is invalid, show an error for the field
			 */
			this.postcode.setAttribute('class', this.postcode.getAttribute('class') + ' wsv-error');
			return false
		}
	}
	/**
	 * If the postcode isn't filled in, check if there is a city entered.
	 *
	 * The default value of the field is PLaatsnaam, so ignore that value
	 */
	if (this.city.value.length > 0 && this.city.value != 'Plaatsnaam') {
		return true;
	}
	/**
	 * If nothing is set, than don't submit and show an error on both fields
	 */
	this.postcode.setAttribute('class', this.postcode.getAttribute('class') + ' wsv-error');
	this.city.setAttribute('class', this.city.getAttribute('class') + ' wsv-error');
	return false;
}
