/*
<input type="text" name="Email" size="20" onChange="emailvalidation(this,'The E-mail is not valid');">

<form onsubmit="return formvalidation(this)">
<form onsubmit="return formvalidation(this)">
function formvalidation(thisform)
{
with (thisform)
{
if (emailvalidation(Email,"Illegal E-mail")==false) {Email.focus(); return false;};
if (valuevalidation(Value,0,5,"Value MUST be in the range 0-5")==false) {Value.focus(); return false;};
if (digitvalidation(Digits,3,4,"You MUST enter 3 or 4 integer digits","I")==false) {Digits.focus(); return false;};
if (emptyvalidation(Whatever,"The textfield is empty")==false) {Whatever.focus(); return false;};
}
} 

*/
function validateEmail(entered, alertbox) {
	// E-mail Validation by Henrik Petersen / NetKontoret
	// Explained at www.echoecho.com/jsforms.htm
	// Please do not remove this line and the two lines above.
	with (entered) {
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		lastpos=value.length-1;
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) {
			if (alertbox) {
				alert(alertbox);
			}
			return false;
		} else {
			return true;
		}
	}
}
function validateValue(entered, min, max, alertbox, datatype) {
	// Value Validation by Henrik Petersen / NetKontoret
	// Explained at www.echoecho.com/jsforms.htm
	// Please do not remove this line and the two lines above.
	with (entered) {
		checkvalue=parseFloat(value);
		if (datatype) {
			smalldatatype=datatype.toLowerCase();
			if (smalldatatype.charAt(0)=="i") {
				checkvalue=parseInt(value);
			}
		}
		if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue) {
			if (alertbox!="") {alert(alertbox);} return false;
		} else {
			return true;
		}
	}
}
function validateEmpty(entered, alertbox) {
	// Emptyfield Validation by Henrik Petersen / NetKontoret
	// Explained at www.echoecho.com/jsforms.htm
	// Please do not remove this line and the two lines above.
	with (entered) {
		if (value==null || value=="") {
			if (alertbox!="") {
				alert(alertbox);
			}
			return false;
		} else {
			return true;
		}
	}
}
function validateDigit(entered, min, max, alertbox, datatype) {
	// Digit Validation by Henrik Petersen / NetKontoret
	// Explained at www.echoecho.com/jsforms.htm
	// Please do not remove this line and the two lines above.
	with (entered) {
		checkvalue=parseFloat(value);
		if (datatype) {
			smalldatatype=datatype.toLowerCase();
			if (smalldatatype.charAt(0)=="i") {
				checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {
					checkvalue=checkvalue+1;
				}
			}
		}
		if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue) {
			if (alertbox!="") {alert(alertbox);} return false;
		} else {
			return true;
		}
	}
}
function validateDate(entered, alertbox) {
	// Date Validation by Jason Sisk
	// This is a crude string match, and does not validate the actual date.
	// If you need something stronger, go fishin' on the web.
	var dateRegex = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
	var dateEntered = entered.value;
	if (!dateEntered.match(dateRegex)) {
		if (alertbox) {
			alert(alertbox);
		}
		return false;
	} else {
		return true;
	}
}