function allFieldsCompleted(frm){

	// This function is used to validate that all text
	// fields in a given form contain some value

	for (var i=0; i < frm.elements.length; i++){
		if (frm.elements[i].type == 'text'){
			if (frm.elements[i].value == ''){
				return false;	
			}
		}
	}
	return true

}

function validateEmail(email){
	
	// This function is used to validate a given e-mail 
	// address for the proper syntax
	
	if (email == ""){
		return false;
	}
	badStuff = ";:/,' \"\\";
	for (i=0; i<badStuff.length; i++){
		badCheck = badStuff.charAt(i)
		if (email.indexOf(badCheck,0) != -1){
			return false;
		}
	}
	posOfAtSign = email.indexOf("@",1)
	if (posOfAtSign == -1){
		return false;
	}
	if (email.indexOf("@",posOfAtSign+1) != -1){
		return false;
	}
	posOfPeriod = email.indexOf(".", posOfAtSign)
	if (posOfPeriod == -1){
		return false;
	}
	if (posOfPeriod+2 > email.length){
		return false;
	}
	return true
}

function validatePwd(pwd){
	
	// This function checks passwords for valid characters
	
	if (pwd == ""){
		return false;
	}
	badStuff = ";:/,' ";
	badStuff += '"';
	for (i=0; i<badStuff.length; i++){
		badCheck = badStuff.charAt(i)
		if (pwd.indexOf(badCheck,0) != -1){
			return false;
		}
	}
	return true
}

function isNumeric(inValue){
	
	// This function checks a given value to see if it contains any
	// non-numeric characters
	
	for (i=0; i<inValue.length; i++){
		if ((inValue.charAt(i) != "0") && (!parseFloat(inValue.charAt(i)))){
			return false;
		}
	}
	return true;
}

function validatePhone(phone){
	
	// This function checks a given value to see if is a valid phone number
	
	var phoneMask
	
	phoneMask = '###-###-####'
	
	if (phone.length != phoneMask.length) return false;
	
	for (i=0; i<phone.length; i++){
		if (phoneMask.charAt(i) == "#"){
		// Need a digit here
			if (!parseInt(phone.charAt(i))){
				if (phone.charAt(i)!=0){
					return false;
				}
			}
		}else{
		// Need a mask character here
			if (phoneMask.charAt(i)!=phone.charAt(i)){
				return false;
			}
		}
	}
	return true;
}

