	
	function isEmptyField(thefield, thefieldName) {
		if (thefield.value == "") {
			alert("Please enter a value for the " + thefieldName + " field.");
			thefield.select();
			return(false);
		}
		return(true);
	}

	function validateNumber(field, fieldName, allowDecimals) {
		var errMsg2 = "";
		var checkOK = "0123456789.";
		var checkStr = field.value;
		var allValid = true;
		var decPoints = 0;
		var allNum = "";
		for (i = 0;  i < checkStr.length;  i++) {
			ch = checkStr.charAt(i);
			for (j = 0;  j < checkOK.length;  j++)
				if (ch == checkOK.charAt(j)) break;
				if (j == checkOK.length){
					allValid = false;
					break;
		}
		if (ch == "."){
			allNum += ".";
			decPoints++;
		}else
			allNum += ch;
		}

		if (!allValid){
			alert("Please enter a valid number in the " + fieldName + " field.\n");
			//field.focus();
			field.select();
			return(false);
		}

		if (allowDecimals == 'yes') {
			if (decPoints > 1){
				alert("Please enter no more than one decimal point in the " + fieldName + " field.\n");
				//field.focus();
				field.select();
				return(false);
			}
		}

		if (allowDecimals == 'no') {		
			if (decPoints > 0) {
				alert("Please do not use decimal points in the " + fieldName + " field.\n");  
				//field.focus();
				field.select();
				return(false);
			}	
		}
		return (true);
	}
	
	function checkdate(mydate){
    	var dateArray = new Array(21); // will received parsed output
   	 	for (var i=0; i<dateArray.length; i++)
        	{dateArray[i]=""} // insurance
        	a=mydate.value // document.frm.dat.value
        	i=0; // index for output array
   	 	for (var j=0; j<a.length; j++)
        	{ if ((isNaN(a.charAt(j)))){ // test jth input char
        		i++ // step past possible numerics
        		dateArray[i]= a.charAt(j) // deposit non-numeric separator
        		i++} // step past
    		else { // numeric
        		dateArray[i]=dateArray[i]+a.charAt(j)} // concatenate
        	}

        var err=0

        b = dateArray[0] //a.substring(0, 2) month
        c = dateArray[1] //a.substring(2, 3) '/'
        d = dateArray[2] //a.substring(3, 5) day
        e = dateArray[3] //a.substring(5, 6) '/'
        f = dateArray[4] //a.substring(6, 10) year
        g = dateArray[5] //

		//basic error checking

    	if (isNaN(b)) err=1
    	if (b<1 || b>12) err = 2

    	if (c != '/') err = 3

    	if (isNaN(d)) err=4
    	if (d<1 || d>31) err = 5

    	if (e != '/') err = 6
     
    	if (isNaN(f)) err=7
     
    	if (f<1987 || f>2005) err = 8
    	if (g != '') err=9

		//advanced error checking
     
    	if (b==4 || b==6 || b==9 || b==11){ // months with 30 days
     
    	if (d>30) err=10

    	}

		// february, leap year

    	if (b==2){ // feb

    	var g=parseInt(f/4)
    	if (isNaN(g)) {
        	err=11
    	}

    	if (d>29) err=12

    	if (d==29 && ((f/4)!=parseInt(f/4))) err=13 // test remainder > 0
    	}
    	if (err>0) {alert(mydate.value+' is not a valid date.');
        	return (false);}
    	else {return (true);}
	}	

