function objValidate(arrFields) {
	this.arrFields = new Array();
	this.addField = function(type, id, msg) {
		this.arrFields.push({type:type, id:id, msg:msg});
	}
	this.validate = function() {
		// Set up the array of validation types (carry out a Trim at the same time)...
		var regexes = {text:	/^\s*([\s\S]+)$/i,
					   digit:	/^\s*(\d+)\s*$/i,
					   email:	/^\s*([\w\d\.\-]+@[\w\d\.\-]+\.(com|uk|fr|dk|eu|net|org|info|biz|edu))\s*$/i,
					   phone:	/^\s*([\d\(\)\+\s]+)\s*$/i};
		
		for (var i = 0; i < this.arrFields.length; i++) {
			var objField	= this.arrFields[i];
			var objEl		= document.getElementById(objField.id);
			var arrResult	= regexes[objField.type].exec(objEl.value);
			if (arrResult != null && arrResult.length > 0) {
				objEl.value = arrResult[1];
			} else {
				//alert("Validation failed:-\n" + "Field ID = " + objField.id + "\n" + "Field type = " + objField.type + "\n" + "Field value = " + objEl.value);
				alert("Please enter a valid value for the " + objField.msg);
				objEl.focus();
				return false;
			}
		}
		return true;
	}
}


function objLabelTips(tips) {
	this.tips = new Object();
	this.addTip = function(forEl, tip) {
		this.tips[forEl] = tip;
	}
	this.showTips = function() {
		// Load up all the labels...
		var labels = document.getElementsByTagName("label");
		// Read through the labels & lookup the tips...
		for (var i = 0; i < labels.length; i++) {
			var label = labels.item(i);
			var forEl = label.getAttribute("for");
			var tip = this.tips[forEl];
			if (tip != undefined) {
				// Wrap the Label's first child (text element) in an anchor
				var a = document.createElement("a");
				a.href			= "javascript:void(0);";
				a.onmouseover	= new Function("return overlib(\"" + tip + "\");");
				a.onmouseout	= function() {return nd();};
				a.appendChild(label.replaceChild(a, label.firstChild));
			}
		}
	}
}
