
function verifyFundAccountFormat(iInput) {
	// Variables
	var match = null ;
	var patterns = new Array(3) ;
	var displayAccount = '' ;

	// Get the patterns
	patterns[0] = /^\s*(\d{3})\s*[\-\.]?\s*(\d{2})\s*[\-\.]?\s*(\d{2})\s*$/ ;
	patterns[1] = /^\s*(\d{3})\s*[\-\.]?\s*(\d{2})\s*[\-\.]?\s*(\d{2})\s*[\-\.]?\s*(\d{2})\s*[\-\.]?\s*(\d{4})\s*$/ ;
	patterns[2] = /^\s*$/ ;

	for (var i = 0 ; !match && i < patterns.length ; i++) {
		match = patterns[i].exec(iInput.value) ;
	}

	if (match) {
		for (var i = 1 ; i < match.length ; i++) {
			displayAccount += ((displayAccount.length == 0) ? '' : '-' ) + match[i] ;
		}
		if (displayAccount.length == 0) displayAccount = '' ;
		iInput.value = displayAccount ;
		return 0 ;
	} else {
		alert('"' + iInput.value + '" is not a valid ISU Intramural, please use one of the formats below:    \r\n###-##-##\r\nor\r\n###-##-##-##-####') ;
		iInput.value = '' ;
	}

	return -1 ;
}
function verifyCurrencyFormat(iInput) {
	var value = iInput.value ;

	function clean(str) {
		var result = '' ;
		var ch ;
		var precision = -1 ;

		// Method to clean up the money string...
		for (var i = 0 ; i < str.length ; i++) {
			if ((ch = str.charAt(i)).search(/[\d\.-]/) == 0) {
				result += ch ;
				if (ch == '.') {
					precision = 0 ;
				} else if (precision >= 0) {
					precision++ ;
				}
			}
		}
		for (var i = precision ; i < 2 ; i++) {
			if (i < 0) {
				result += '.' ;
			} else {
				result += '0' ;
			}
		}
		return result ;
	}

	// Look for the format: (-)#,###(.##)
	var matches = value.match(/\s*\$?-?\s*\d{1,3}(,\d{3})*(\.\d{0,2})?\s*/) ;
	if (matches) {
		if (matches[0].length == value.length) {
			iInput.value = '$' + clean(value) ;
			return 0 ;
		}
	}

	// Look for the format: (-)#(.##)? (no commas)
	matches = value.match(/\s*\$?-?\s*\d+(\.\d{0,2})?\s*/) ;
	if (matches) {
		if (matches[0].length == value.length) {
			iInput.value = '$' + clean(value) ;
			return 0 ;
		}
	}

	// Look for the format: (-)(#)?.## (no commas)
	matches = value.match(/\s*\$?-?\s*\.\d{1,2}\s*/) ;
	if (matches) {
		if (matches[0].length == value.length) {
			iInput.value = '$' + clean(value) ;
			return 0 ;
		}
	}

	// Look for the empty value
	matches = value.match(/\s*/) ;
	if (matches[0].length == value.length) {
		iInput.value = '' ;
		return 0 ;
	}

	alert('"' + iInput.value + '" is not a monetary amount.') ;
	iInput.value = '' ;
}

