//
// 12/10/09 Joshua Weinberg
//
//

//quick email address correction: clears the input if the email address is invalid.
// removes spaces in address.
function errorCorrectEmail(email){
	// remove white space
	email.value = (email.value).replace(/\s/g,'');
	
	// regex for well-formed email address.
	var filter=/^.+@.+\..{2,3}$/
	var result = true;
	
	if (!filter.test(email.value)){
		alert("Please enter a valid email address!")
		email.value = '';
		result = false;
	}
	
	return result;
}

// used to automatically jump from one filled INPUT field to the next 
function jumpToNextTeleField(thisField){	
	numOnly(thisField);
	if(thisField.getAttribute('maxlength')==thisField.value.length){
		var next = thisField;
		do
			next=next.nextSibling;
		while(next.nodeName!='INPUT');
		next.focus();
	}
}

// only allow numbers (including period and hyphen) to be typed into form field
function numOnly(oTxt){
	if (!/^[\d\.]+$/.test(oTxt.value) || isNaN(oTxt.value)){
		if (isNaN(oTxt.value*(-1))){
			oTxt.value = oTxt.value.substring(0,oTxt.value.length-1);
		}
	}
}
