function get(id) {
	return document.getElementById(id);	
}

function requireText(id, msg) {
	if (get(id).value == "") {
		alert(msg);
		get(id).focus();
		return false;
	}
	return true;
}

function requireDate(id, msg) {
	if (/^((((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9]))))[\-\/\s]?\d{2}(([02468][048])|([13579][26])))|(((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))[\-\/\s]?\d{2}(([02468][1235679])|([13579][01345789]))))(\s(((0?[1-9])|(1[0-2]))\:([0-5][0-9])((\s)|(\:([0-5][0-9])\s))([AM|PM|am|pm]{2,2})))?$/.test(get(id).value)) return true;
	alert(msg);
	get(id).focus();
	return false;
}

function fixUrl(obj) {
	var url = obj.value.toLowerCase();
	
	// Just www.?
	if (url.substr(0, 4) == "www.") {
		url = "http://" + url;
	}
	
	obj.value = url;
}

function checkEmail(id, msg) {
	str = get(id).value;
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)) return true;
	alert(msg);
	return false;
}
