// Validate the form where the user selects a city, year, and password
function ValidateFirstForm(f) {
	today = new Date();
	currentyear = today.getYear();
	if (currentyear < 1000) currentyear += 1900;
	if ((f.year.value < 1900) || (f.year.value > currentyear)) {
		alert ('The year value entered is invalid.  The year must be between 1900 and ' + currentyear + ' (the current year, according to your computer clock)');
		return false;
	}
}

function isDouble(value) {
	if (value=="") return true;
	var i = 0;
	var ncommas = 0;
	for (i = 0; i < value.length; i++) {
		if ((value.charAt(i) < '0' || value.charAt(i) > '9') && (value.charAt(i) != '.') && (value.charAt(i) != ',')) {
			return false;
		}
		if ((value.charAt(i) == '.') || (value.charAt(i) == ',')) ncommas++;
	}
	if (ncommas > 1) { return false; }
	return true;
}

function ValidateData(f) {
	var i;
	var ok;
	for (i=0; i<f.length; i++) {
		var e = f.elements[i];
		if ((e.v_datatype == 'd') && (!isDouble(e.value))) {
			alert ('The field "' + e.v_Title + '" contains an invalid value.  It must be only a number.  Use a single "." or "," to indicate the decimal point.  Do not use a space or comma as a thousands-separator.');
			e.focus();
			return false;
		}
	}
}
