var dt = "";
var num = "";

function validEmail(email) {
	invalidChars = " /:,;"
	for(i = 0; i < invalidChars.length; i++){  // invalid characters?
		badChar = invalidChars.charAt(i)
		if(email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@", 1)   // must be at least one @
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@", atPos + 1) != -1) {  //can only be one @
		return false
	}
	periodPos = email.indexOf(".", atPos)  // and at least one "." after the @
	if (periodPos == -1) {
		return false
	}
	if (periodPos + 3 > email.length) { // must be at least two chars after the "."
		return false 
	}
	return true 
}

function testNumber(textbox) {
	if(textbox.value.length != 0) {
		if(isNaN(textbox.value)) {
			textbox.value = num;
			textbox.focus();
			alert("Numeric required.");
			return(false);
		}
	}
	return(true);
}

function testDate(textbox) {
	var newVal = textbox.value;
	var myDate;
	
	if(textbox.value.length == 0) return;
	
	for(var i = 0; i < newVal.length; i++) {
		if(newVal.charAt(i) == '-')
			newVal = newVal.substring(0, i).concat(' ').concat(newVal.substring(i+1, newVal.length+1));
	}
	
	myDate = new Date(newVal);
	
	if(isNaN(myDate)) {
		textbox.value = dt;
		textbox.focus();
		alert("Valid date required.\n(d-mmm-yyyy)");
	}
}
