function isValidEmail(entered, alertbox) {
// checks for a valid email address
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 inRange(entered, min, max, alertbox, datatype){
// checks a value is in the max and min range specified
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 isEmpty(entered, alertbox){
// checks a value is specified (not empty)
with (entered)
	{
	if (value==null || value=="")
		{if (alertbox!="") {alert(alertbox);} return false;}
	else {return true;}
	}
}

function isStrValue(entered, strValue, alertbox){
// checks a value is specified (not empty)
with (entered)
	{
	if (value==strValue)
		{if (alertbox!="") {alert(alertbox);} return false;}
	else {return true;}
	}
}

function isInteger(entered, alertbox){
// checks for an integer (+ or -)
with (entered)
	{
	if (value!=parseInt(value))
		{if (alertbox!="") {alert(alertbox);} return false;}
	else {return true;}
	}
}

function isFloat(entered, alertbox){
// checks for a decimal 
with (entered)
	{
	if (value!=parseFloat(value))
		{if (alertbox!="") {alert(alertbox);} return false;}
	else {return true;}
	}
}


function isSelected(entered, alertbox, thistype){
// checks for a selected item (mandatory check)
with (entered)
	{
	if (thistype.toLowerCase()=='select')
		{
		if (selectedIndex==-1 || options[selectedIndex].value=="")
			{if (alertbox!="") {alert(alertbox);} return false;}
		else {return true;}
		}
	if (thistype.toLowerCase()=='multiselect')
		{
		if (selectedIndex==-1)
			{if (alertbox!="") {alert(alertbox);} return false;}
		else {return true;}
		}	
	if (thistype.toLowerCase()=='radio' || thistype.toLowerCase()=='checkbox')
		{
		var count=0;
		if (entered.length)
			{
			for (var i=0;i<entered.length;i++)
				{if (entered[i].checked==true){count++;}}
			}
		else
			{
			if (entered.checked==true) {count++;}
			}
		if (count==0)
			{if (alertbox!="") {alert(alertbox);} return false;}
		else {return true;}
		}
	}
}

function deletekey(e) {
    var thekeycode;

    if (document.all) {
        e = window.event;
		var thekeycode = e.keyCode;
    	}
    else
        if (document.layers)
		var thekeycode = e.which;
 	
	// 46 Delete, 8 Backspace
    if (thekeycode  == 46 || thekeycode == 8) {
        if (document.layers){
            return true;}
        else if (document.all){
            //e.returnValue = true;
			return true;}
    	}
	
}

function MaxChars(entered,maxChars,label)
// checks a field has not exceeded max characters (for submission)
{
with (entered)
	{
	var charsover=value.length-maxChars;
	if (charsover > 0)
	//if (value.length > maxChars)
		{
		if (label== null){label=entered.name;}
		var charsoverstring=''
		if (charsover!=0)
			charsoverstring=' (currently ' + charsover + ' character(s) too many)';
		alert('The ' + label + ' can have a maximum of ' + maxChars + ' characters.' + charsoverstring);
		//value = value.substr(0,maxChars);
		return true;
		}
	else 
		{return false;}
	}
}


function MinChars(entered,minChars,label)
// checks a field has not exceeded max characters
{
with (entered)
	{
	var charsunder=minChars-value.length;
	if (charsunder > 0)
	//if (value.length > maxChars)
		{
		if (label== null){label=entered.name;}
		var charsunderstring=''
		if (charsunder>0)
			charsunderstring=' (currently ' + charsunder + ' character(s) too few)';
		alert('The ' + label + ' can have a minimum of ' + minChars + ' characters.' + charsunderstring);return true;
		}
	else 
		{return false;}
	}
}

/*
function validateform(thisform)
{
// This function checks the entire form before it is submitted
// Note: This function needs to be customized to fit your form

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;};
}
}*/
<!-- *** do not change or remove  *** -->
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->

