
	function isFilled(elm, minlength, maxlength) {
	    if (elm.value == "" || elm.value == null) return false;
	    if (minlength  != -1) {
	      if (elm.value.length < minlength || elm.value.length > maxlength) return false ;
	    }
	
	    else return true;
	}
	
	function isNumeric(strString) { //  check for valid numeric strings	
		//var strValidChars = "0123456789.-";
		var strValidChars = "0123456789";
		var strChar;
		var blnResult = true;
		if (strString.length == 0) return false;
		//  test strString consists of valid characters listed above
		for (i = 0; i < strString.length && blnResult == true; i++) {
			strChar = strString.charAt(i);
			if (strValidChars.indexOf(strChar) == -1) {
				blnResult = false;
			}
		}
		return blnResult;
	}
	
	// to check the form fields
	function isReady(form) {
		// is FirstName filled?
	    if (isFilled(form.FirstName, -1, 40) == false) {
		    alert("Please enter your first name.");
		    form.FirstName.focus();
		    return false;
	    } else {
			var theFN = form.FirstName.value;
			if (isNumeric(theFN)) {
				alert("Please enter your real first name");
				form.FirstName.focus();
				return false;
			}
		}
		// is TrackingCode filled?
		if ((isFilled(form.TrackingCode, -1, 40) == false) && (isFilled(form.uid, -1, 40) == false)){
		    alert("Either the tracking code or user id must be entered.");
			form.TrackingCode.focus();
			return false;
		}
	    if ((isFilled(form.TrackingCode, -1, 40) == false) && (isFilled(form.uid, -1, 40) == true)){
			var theUid = form.uid.value;
			if (!isNumeric(theUid)) {
				alert("Invalid user id");
				form.uid.focus();
				return false;
			}
		}
	    if ((isFilled(form.TrackingCode, -1, 40) == true) && (isFilled(form.uid, -1, 40) == false)){
			var theTC = form.TrackingCode.value;
			if (isNumeric(theTC)) {
				alert("Invalid TrackingCode");
				form.TrackingCode.focus();
				return false;
			}
		}
		
		return true;
	}
	

	





	
