function CheckInt(value) {
	if(value != "") {
		var intParsed = parseInt(value);
		var strParsed = new String(intParsed);
		return((! isNaN(intParsed)) && (strParsed.length == value.length));
	}
	else {
		return(true);
	}
}


// Returns true if the specified field contains a valid integer
function CheckIntValue(name, desc) {
	if(CheckInt(document.forms[0][name].value)) {
		return(true);
	}
	else {
		alert(MLSGetTextD("common.illegal_int", "Illegal integer value for") + " \"" + desc + "\" !");
		document.forms[0][name].focus();
		return(false);
	}
}

// Returns true if the specified field is filled with value.
// Otherwise, shows a warning message with the specified
// user-friendly description of the field, moves the focus
// to the field and returns false.
function CheckRequiredField(name, desc) {
	if(document.forms[0][name].value == "") {
		alert(MLSGetTextD("common.missing_value", "Missing value for") + " \"" + desc + "\" !");
		document.forms[0][name].focus();
		return(false);
	}
	else {
		return(true);
	}
}

// Returns true if CheckRequiredField returns true for each name-description
// pair. Input array has the form:
// (name1, desc1, name2, desc2, ..., nameN, descN)
function CheckRequiredFields(arrNamesDescs) {
	var res = true;
	var i;
	for(i = 0; (i < arrNamesDescs.length / 2) && res; ++i) {
		res = CheckRequiredField(arrNamesDescs[2 * i], arrNamesDescs[2 * i + 1]);
	}
	return(res);
}
