function highlightField(inputField) {
	eval ("document.policymask." + inputField + ".select()");
	eval ("document.policymask." + inputField + ".select()");
}

function check_Contents(elem, sValidChars) {
	var checkOK = sValidChars;
	var checkStr = elem.value;
	var allValid = true;

	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;
		}
	}
	return (allValid);
}

function check_entered(elem) {
	// alert ("check_entered "+ elem.value.length);
    if (elem.value.length < 1) {
		return (false);
	}
	return (true);
}

function check_Number(elem) {
	// alert ("check_Number");
	var checkOK = "0123456789";
	if (check_Contents (elem, checkOK) == false) {
		return error(elem,"Please enter a valid number without spaces in this field.");
	}
	return (true);
}

function error(elem, msg) {
	alert (msg);
	elem.focus();
	elem.select();
	return (false);
}

function check_MMDDYYYYY(elem) {
	var checkOK = "0123456789/";
	var Remove = "/";
	var allValid = true;
	var sClean = new String;
                
	var Today = new Date;
	var Month = Today.getMonth();
	var Year = Today.getYear();
                
	if ( ! check_Contents (elem, checkOK) == true) {
		return error (elem, "Wrong character: please enter a valid date of the form 'MM/DD/YYYY' in this field.");
	}                 
	sClean = elem.value;
	if (sClean.length == 9) {
		// pad leading zero if omitted
		sClean = "0" + sClean;
	}
	if (sClean.length != 10) {
		return error (elem, "Wrong length: please enter a valid date of the form 'MM/DD/YYYY' in this field.");
	}
	if (sClean.substring(0,2) > 12 || sClean.substring(0,2) <= 0) {
		return error (elem, "Wrong month: please enter a valid date of the form 'MM/DD/YYYY' in this field.");
	}
	if (sClean.substring(3,5) > 31 || sClean.substring(3,5) <= 0) {
		return error (elem, "Wrong day: please enter a valid date of the form 'MM/DD/YYYY' in this field.");
	}
	if (sClean.substring(6,10) < 1990) {
		return error (elem, "Wrong year: please enter a valid date of the form 'MM/DD/YYYY' in this field.");
	}
	return (true);
}
