
function passValid(pwd) {
	pwdreg=/^\w{5,15}$/;
	if (pwdreg.exec(pwd)) 
	{
		pwdreg = /^.*\d.*$/;
		return(pwdreg.exec(pwd));
	} else {
		return false;
	}
}
function isMInitial(strMInitial)
{
	minitial=/^\w{0,1}$/;
	return(minitial.exec(strMInitial));
	}

function isDifferent(astring,bstring) {
	if (astring == bstring) return true;
	return false;
}

function socialValid(social) {
	socialreg=/^\d{3}([\s\-])?\d{2}\1?\d{4}$/;
	return(socialreg.exec(social));
}

function umnValid(strID) {
	umnreg=/^\d{7}[0-1][0-9][0-3][0-9][1-2][90][0-9][0-9]$/;
	return(umnreg.exec(strID));
}

function emailValid(email) {
	emailreg=/^([A-Za-z0-9_\-\.\'])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	///^[^@]+@[^@\.].+\.[^@\.]{2,4}$/i
	return(emailreg.exec(email));
}

function streetValid(street) {
	streetreg=/\d+\s+\w+\s+\w+/i;
	return(streetreg.exec(street));
}

//matches 5 digit, 5 + 4 digit and Canadian codes
function zipValid(zip) {
	zipreg=/^(\d{5}-\d{4}|\d{5})$|^([a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d)$/ ;
	return(zipreg.exec(zip));
}

function phoneValid(phonefield) {
	phonereg=/(\d{3})[\s\.\-](\d{3})[\s\.\-](\d{4})/;
	phonetest=phonereg.exec(phonefield.value);
	phonefield.value="(" + RegExp.$1 + ") " + RegExp.$2 + "-" + RegExp.$3;
	return(phonetest);
}

function stateValid(state) {
	statereg=/^[A-Z]{2}$/;
	return(statereg.exec(state));	
}

function nameValid(namestring) {
	namereg=/^[A-Z]./;
	return(namereg.exec(namestring));
}

function isEmpty(notnullstring) {
	emptyreg=/^\S/;
	return(emptyreg.exec(notnullstring));
}

function monthValid(date) {
	memreg=/^\d{1,2}$/;
	return(memreg.exec(date));
}

function yearValid(year) {
	memreg=/^\d{4}$/;
	return(memreg.exec(year));
}

function isSelected(list) {
	if (list.options.selectedIndex != 0) return true;
	return false;
}

function isChecked(box) {
	if(box.checked) return true;
	return false;
}

function setFocus(){
	document.forms[0].elements[0].focus();
}

function stepsValid(steps) {
	stepsreg=/^\d{1,5}$/;
	return(stepsreg.exec(steps));
}

function ssn4Valid(ssn) {
	ssnreg=/^\d{4}$/;
	return(ssnreg.exec(ssn));
}

function num3Valid(num) {
	numreg=/^\d{3}$/;
	return(numreg.exec(num));
}

function VCValid(num) {
	vcreg=/^\d{3,4}$/;
	return(vcreg.exec(num));
}

function isAmericanExpress(cc){
  firstdig = cc.substring(0,1);
  seconddig = cc.substring(1,2);
  if ((cc.length == 15) && (firstdig == 3) &&
      ((seconddig == 4) || (seconddig == 7)))
    return isCreditCard(cc);
  return false;
}

function isMasterCard(cc){
  firstdig = cc.substring(0,1);
  seconddig = cc.substring(1,2);
  if ((cc.length == 16) && (firstdig == 5) &&
      ((seconddig >= 1) && (seconddig <= 5)))
    return isCreditCard(cc);
  return false;
}

function isVisa(cc){
  if (((cc.length == 16) || (cc.length == 13)) &&
      (cc.substring(0,1) == 4))
    return isCreditCard(cc);
  return false;
}

function isDiscover(cc){
  first4digs = cc.substring(0,4);
  if ((cc.length == 16) && (first4digs == "6011"))
    return isCreditCard(cc);
  return false;
}

function isCreditCard(st) {
  // Encoding only works on cards with less than 19 digits
 // if (st.length > 19)
//    return (false);
//
//  sum = 0; mul = 1; l = st.length;
//  for (i = 0; i < l; i++) {
//    digit = st.substring(l-i-1,l-i);
//    tproduct = parseInt(digit ,10)*mul;
//    if (tproduct >= 10)
//      sum += (tproduct % 10) + 1;
//    else
//      sum += tproduct;
//    if (mul == 1)
//      mul++;
//    else
//      mul--;
//  }
// Uncomment the following line to help create credit card numbers
// 1. Create a dummy number with a 0 as the last digit
// 2. Examine the sum written out
// 3. Replace the last digit with the difference between the sum and
//    the next multiple of 10.

//  document.writeln("<BR>Sum      = ",sum,"<BR>");
//  alert("Sum      = " + sum);

 // if ((sum % 10) == 0)
    return (true);
 // else
  //  return (false);

}

function weightZeroValid(weight) {
	weightreg=/^\d{1,3}$/;
	return(weightreg.exec(weight));
}

function weightValid(weight) {
	if (weight.length>0)
	{
		weightreg=/^\d{2,3}$/;
		return(weightreg.exec(weight));
	} else {
		return true;
	}
//	if (weight<=601)
//	{
//		return true;
//	} else {
//		return false
//	};
}

function checkRadios(radioGroup) {
	whatButton = -1;
	for (i=0; i<radioGroup.length; i++) {
		if (radioGroup[i].checked) {
			whatButton = i;
		}
	}
		if (whatButton == -1) {
			return false;
		}
	return true;
}
function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

