
function checkInteger( strVal ) {
  var re  = /(^-?\d\d*$)/;

  //check for integer characters
  return re.test(strValue);
}

function trimBoth(strVal) {

	var re = /^(\s*)([\W\w]*)(\b\s*$)/;

	// check for leading & trailing spaces

	if (re.test(strVal)) {
		strVal = strVal.replace(re, '$2');
	}
	return strVal;
}

function isEmpty(inputStr) {

	inputStr = trimBoth(inputStr);
	if (inputStr==null || inputStr=="") {
		return true;
	}
	return false;
}

function checkEmail(varEmail) {
	var re  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]){2,4}$/;
//	var re=/^.+@.+\..{2,4}$/
	
	if (isEmpty(varEmail.value) ==  true){
		alert("Email : E-Mail address is missing.");
		varEmail.focus();
		return false;
	} else if (!re.test(varEmail.value)) {
		alert("Email : Please input a complete and valid email address.\n");
		varEmail.focus();
		return false;	
	}
	return true
}

function checkPhone(varPhone, tObject) {
	var re = /\(?\d{3}\)?\d{3}-\d{4}/;

	varPhone = trimBoth(varPhone);
	if (!re.test(varPhone)) {
		alert("Phone : Please input a valid phone number");
		tObject.focus();
		return false;	
	}
	return true;
}

function checkZip(varZip) {

	var re = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
	
	if (!re.test(varZip.value)) {
		alert("ZIP : Please input a valid zip code");
		varZip.focus();
		return false;
	}
	return true;
}
function checkCredit(varCredit) {
	var re = /\d{15}/;

	if (!re.test(varCredit.value)) {
		alert("CreditCard : Please input a valid creditcard number");
		varCredit.focus();
		return false;
	}
	return true;
}
