function fieldData(id, errorName) {
	this.id = id;
	this.errorName = errorName;
}

function validate(fields) {
	var msg = "Please fill out the following field";
	var problems = '';
	var count = 0;
	for (i in fields) {
		element = document.getElementById(fields[i].id);
		if (trim(element.value) == '') {
			problems += fields[i].errorName + "\n";
			count++;
		}
	}
	if (count > 0) {
		if (count > 1) {
			msg += "s";
		}
		msg += ":\n" + problems;
		alert(msg);
		return false;
	}
	return true;
}

function trim(str) {
   return str.replace(/^\s*|\s*$/g,"");
}