function validateDate (strDate) {

   var parsedDate = strDate.split ("/");
   if (parsedDate.length != 3) return false;
   var day, month, year;
   month = parsedDate[0]-1;
   day = parsedDate[1];
   year = parsedDate[2];
   var objDate = new Date (strDate);
   if (month != objDate.getMonth()) return false;
   if (day != objDate.getDate()) return false;
   if (year != objDate.getFullYear()) return false;
	
   return true;}
   
   
function checkYear(strDate) {
	var		parsedDate = strDate.split ("/");
	var		year = parsedDate[2];
	// Check to be sure that the year is the right length
	if (year.length != 4) 
		return false;
	else
		return true;
}

function isNull(val) {
	if (val == null) { return true; }
	return false;
	}

//-------------------------------------------------------------------
// isBlank(value)
//   Returns true if value only contains spaces
//-------------------------------------------------------------------
function isBlank(val) {
	if (val == null) { return true; }
	for (var i=0; i < val.length; i++) {
		if ((val.charAt(i) != ' ') && (val.charAt(i) != "\t") && (val.charAt(i) != "\n")) { return false; }
		}
	return true;
	}


 
function CheckForm () {
	var		todaysDate = new Date();
	var		strbusLicDate = document.forms.form3.businesslicensedate.value;
	var		busLicDate = new Date(strbusLicDate);
	
	// Make sure that there is data in all of the date fields
	if (isNull(strbusLicDate) || isBlank(strbusLicDate)) {
		alert("The Business License Date field must contain a date!");
		document.forms.form3.businesslicensedate.focus();
		return false;
	}

	// Check to be sure the year business license date is a 4 digit year.
	if (checkYear(strbusLicDate) == false) {
		alert("Please enter a 4 digit year in the Business License Date field!");
		document.forms.form3.businesslicensedate.focus();
		return false;
	}
		
	// Make sure that the Business License date is a valid date
	if (validateDate(strbusLicDate) == false) {
		alert("Please enter a valid date in the Business License Date field!");
		document.forms.form3.businesslicensedate.focus();
		return false;
	}

	// Make sure the business license date is before the current date
	
	if (busLicDate > todaysDate) { 
		alert("The Business License Date cannot occur in the future!");	
		return false;
	}
	strbusLicDate = document.forms.form3.taxyeardateUI.value;
	if (strbusLicDate.length == 1) {
		strbusLicDate = "0"+strbusLicDate;
	}
	document.forms.form3.taxyeardate.value=strbusLicDate+"/01/"+todaysDate.getFullYear();
} 