function handleValidation(element,message) {
	// we check if it already has the error class to prevent multiple messages appearing on the same element
	if (!element.hasClassName('errorField')) {
	
		// the name of the element
		var name = message.substr(0,message.indexOf(' '));
		
		// the actually error message
		var originalMessage = message;
		var message = message.substr(message.indexOf(' '));
		
		// if its a checkbox, don't highlight the element but highlight the text beside it
		if (element.type == "checkbox") {
			var label = $(element).next();
		} else {
			var label = $(element).up(0).previousSiblings()[0].down(0);
		}
		
		// the title we're going to use
		var title = element.title;
		
		// without *
		var titlesub = title.substr(0,title.indexOf('*'))
		
		// the output
		var out = '';
		
		// check the message and output the right title and message combo
		if (name == element.name && title) {
			if (message != "The email address supplied is already registered. Did you forget your login information?" && message.substr(1,8) != "username" && message.substr(0,11) != "The captcha") {
				if (title.indexOf('*') > -1) {
					out = titlesub+" "+message;
				} else {
					out = title+message;
				}
			} else if (message == "The email address supplied is already registered. Did you forget your login information?") {
				out = "The email address supplied is already registered.";
			} else {
				out = titlesub+" "+message;
			}
		} else {
		
			if (message.substr(1,8) === "username" && message.substr(14,6) !== "picked") {
				out = titlesub+" "+message.substr(10);
			} else	if (message.substr(1) === "passwords did not match") {
				out = "P"+message.substr(2);
			} else if (element.type == "checkbox") {
				out = titlesub+message;
			} else {
				out = originalMessage;
			}
		}
		
		// get all the labels in this from
		var labels = element.form.getElementsByTagName('label');
		for(var i=0;i<labels.length;i++) {
			// check all the labels for the one that matches the failed form element
			if (labels[i].htmlFor==element.id) {
				// put the message inside the label
				//if (element.type != "checkbox") {
					labels[i].innerHTML = out;
				//}
				// make the label stand out
				labels[i].addClassName('error');
				// remove the old border-color
				// this fixes an issue when fading out the border
				element.setStyle({'borderColor':''});
				// make the input stand out
				element.addClassName('errorField');
				// scroll the browser to that element.
				labels[i].scrollTo();

			}
		}
	
		// remove the styles from the failed form element and the label
		function removeStyles(t) {
			// search though all the labels again
			for(var i=0;i<labels.length;i++) {
				// find the label that matches the failed form element
				if (labels[i].htmlFor==element.id) {
					// return everything to normal
					labels[i].innerHTML = t;
					labels[i].removeClassName('error');
					element.removeClassName('errorField');
				}
			}
		}

	}

	// we want the element and label to retrun to normal when the user relizes the error.
	element.observe('focus', function(event) {
		removeStyles(title);
	});
}
