var stringExp = /\S+/				// matches one or more non-whitespace characters
										// use to ensure that a field is not blank
var textExp = /^[ \w\-\,\.\!\?]+$/			// matches one or more letters, numbers, spaces, hyphens or underscores
										// use for business names, street addresses, etc.
var charExp = /^[ a-zA-Z\-\,\.\&]+$/		// matches one or more letters or hyphens
										// use for proper names
var dateExp = /^\d{2}\/\d{2}\/\d{4}$/		// matches a date in the form mm/dd/yyyy
										// use for dates
var digitExp = /^[\d]+$/			// matches one or more digits
										// use for credit cards, etc.
var digitExpExt = /^[ \d\-]+$/		// mathces one or more digits, spaces or hyphens
										// use for international phone numbers, etc.
var posIntExp = /^[1-9]+\d*$/		// matches one or more digits from 1 to 9 followed by zero or more digits
										// use for positive integers
var usCurrExp = /^\d+\.{0,1}\d{0,2}$/	// matches one or more digits followed by zero or one periods 
											// followed by zero, one or two digits
											// use for US Currency
var usPhoneExp = /^\d{3}\-{1}\d{3}\-{1}\d{4}$/	// mathches a valid US phone number
var passwordExp = /^[a-zA-Z0-9]{4,}$/	// use for passwords with letters and numbers only, four char min
var emailExp = /^[a-zA-Z_0-9\.\-]+@[a-zA-Z_0-9\.\-]+\.[a-z]+$/		// matches a valid email address

var textMsg = "Please enter a valid ";
var selectMsg = "Please select a valid ";

function isValidInput(validExp, obj, invalidMsg)
{
	if (validExp.test(obj.value.toString()) == false)
	{
		window.alert(invalidMsg);
		obj.focus();
		if (obj.type.toString() == "text")
			obj.select();
		return false;
	}
	else
		return true;
}
function isDate(testDate)
{
	var month = testDate.substring(0,2);
	var day = testDate.substring(3,5);
	var year = testDate.substring(6,10);
	
	switch (month)
	{
		case "01":
		case "03":
		case "05":
		case "07":
		case "08":
		case "10":
		case "12":
			if ((day < 1) || (day > 31))
				return false;
			break;
		case "04":
		case "06":
		case "09":
		case "11":
			if ((day < 1) || (day > 30))
				return false;
			break;
		case "02":	
			if ((year % 4) == 0) // leap year
			{
				if ((day < 1) || (day > 29))
					return false;
			}
			else // non-leap year
			{
				if ((day < 1) || (day > 28))
					return false;
			}
			break;
		default:
			return false;
	}
	return true;
}
function datePos(testDate)
{
	var month = testDate.substring(0,2)-1;
	var day = testDate.substring(3,5);
	var year = testDate.substring(6,10);			
	var now = new Date();
	var today = new Date(now.getYear(), now.getMonth(), now.getDate());
	var date = new Date(year, month, day);
	
	if (date < today)
		return -1;
	else if (date > today)
		return 1;
	else
		return 0;
}
function dateCompare(testDate1, testDate2)
{
	var date1 = new Date(testDate1.substring(6,10), 
							testDate1.substring(0,2)-1, 
							testDate1.substring(3,5));
	var date2 = new Date(testDate2.substring(6,10), 
							testDate2.substring(0,2)-1, 
							testDate2.substring(3,5));
	if (date2 < date1)
		return -1;
	else if (date2 > date1)
		return 1;
	else
		return 0;
}

function popUp(url, name, height, width)
{
	var top = (screen.height / 2) - (height / 2);
	var left = (screen.width / 2) - (width / 2);
	window.open(url, name, "height=" + height + ",width=" + width + ",top=" + top + ",left=" + left);
	return true;
}