
var Tools = new Tools();

function Tools() {
	this.clearTextField = function(obj, strDefault) {
		if (obj.value == strDefault) obj.value = '';
	}

	this.restoreTextField = function(obj, strDefault) {
		if (obj.value == '') obj.value = strDefault;
	}

	this.getElement = function(strElementId) {
		if (document.getElementById) {
			return document.getElementById(strElementId);
		} else if (document.layers) {
			// ### check document.images too
			return document.layers[strElementId];
		}
	}

	this.setStyle = function(obj, strProperty, value) {
		if (obj.style) obj.style[strProperty] = value;
		else obj[strProperty] = value;
	}

	this.isPostcode = function(v_objPostcodeField) {
		var postcode = v_objPostcodeField.value.toUpperCase();
		if (window.RegExp) {
			var re = new RegExp("^[A-Z]{1,2}[0-9][0-9]? ?[0-9][A-Z]{2}$");
			if (re.test(postcode)) {
				return true;
			} else {
				v_objPostcodeField.focus();
				v_objPostcodeField.select();
				alert('Please enter a valid British postcode, e.g. BA1 2PW');
				return false;
			}
		} else {
			if (postcode.indexOf(' ') >= 0 && (postcode.length > 7)) {
				return true;
			} else {
				alert('Please enter a valid British postcode, e.g. BA1 2PW');
				v_objPostcodeField.focus();
				v_objPostcodeField.select();
				return false;
			}
		}
	}

}