function isNumeric(num) {
	var numEx=/^[0-9]+$/;
	if(num.match(numEx)){
		return true;
	}
	return false;
}

function isPhoneNo(num) {
	if(num.length<6) {
		return false;
	} else {
		var phoneEx=/^[0-9A-Z\+, \(\)-]+$/;
		if(num.match(phoneEx)){
			return true;
		}
	}
	return false;
}

function isAlpha(text) {
	var alphaEx=/^[a-zA-Z\s]+$/;
	if(text.match(alphaEx)){
		return true;
	}
	return false;
}

function checkRadioArray(radioButtons) {
	for(var i=0; i <radioButtons.length; i++) {
		if(radioButtons[i].checked) {
			return true;
		}
	}
	return false;
}

function checkEmail(email) {
	var emailEx=/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/;
	if(email.match(emailEx)) {
		return true;
	}
	return false;
}

function checkLength(text, min, max){
	min = min || 1;
	max = max || 10000;
	if (text.length < min || text.length > max) {
		return false;
	}
	return true;
}

function checkTextArea(textArea, max){
 	var numChars, chopped, message;
 	if (textArea.value.length > max) {
	 	numChars = textArea.value.length;
	 	chopped = textArea.value.substr(0, max);
	 	message = "You typed " + numChars + " characters.\n";
	 	message += "The limit is " + max + ".";
	 	message += "Your entry will be shortened to:\n\n" + chopped;
	 	alert(message);
	 	textArea.value = chopped;
	}
	/*if (textArea.value.length < 2) {
	 	alert("Please leave a comment.");
	}*/
}

function reportErrors(errors) {
	var msg="There were some problems... \n";
	var numError;
	for(var i=0; i <errors.length; i++) {
		numError=i+1;
		msg+="\n"+numError+". "+errors[i];
	}
	alert(msg);
}
