<!-- 




function CheckLeapYr(aDate) {
	aDate = parseInt(aDate);
	
	if (aDate % 4 == 0)	{
		if (aDate % 100 != 0) {
			return true;
		}	else {
			if(aDate % 400 == 0)
				return true;
			else
				return false;
		}
	}
	
	return false;
}


function isDayorMonthRange(aField, aDayOrMon) { // 0 for day 1 for month
		
		var aValue = aField.value;
		if (aDayOrMon == 0) {
			if ((aValue < 0) || (aValue > 31)) {
				alert("Day is out of range");
				aField.value = "";
				aField.focus();
				return false;
			}
		} else {
			if ((aValue < 0) || (aValue > 12)) {
				alert("Month is out of range");
				aField.value = "";
				aField.focus();				
				return false;
			} 
		}
		
		return true;
}



//Difference in days between 2 dates
function CalulateDiffDays(aForm) {  
  
  if ( isValid(aForm.firstmonth, "Month in first date") &&
		isValid(aForm.secondmonth, "Month in second date") &&
		isValid(aForm.firstday, "Day in first date") &&
		isValid(aForm.secondday, "Day in second date") &&
		isValid(aForm.firstyear, "Year in first date") &&
		isValid(aForm.secondyear, "Year in second date") ) {
		
			// Check for 2000
		// Check for 2 digits
		var aYY1 = aForm.firstyear.value;
		var aYY2 = aForm.secondyear.value;
		var aMM1 = aForm.firstmonth.value;
		var aMM2 = aForm.secondmonth.value;
		var aDD1 = aForm.firstday.value;
		var aDD2 = aForm.secondday.value;
		
		if (!(isDayorMonthRange(aForm.firstday, 0) && isDayorMonthRange(aForm.secondday, 0)
			&& isDayorMonthRange(aForm.firstmonth, 1) && isDayorMonthRange(aForm.secondmonth, 1))) return false;			

		var lDate1 = new Date(aYY1, aMM1, aDD1);
		var lDate2 = new Date(aYY2, aMM2, aDD2);

		var lDiff = lDate2 - lDate1; //unit is milliseconds
		lDiff = Math.round(lDiff/1000/60/60/24); //contains days passed since Year 2000

		var lString = lDiff;

		if (lDiff > 1)
			lString += " days";
		else
			lString += " day";

		aForm.daydiff.value = lString;
  }
}

function setForm(aForm) {
  var lDate2 	= new Date();
  var aMM2 		= lDate2.getMonth() + 1;
  var aDD2 		= lDate2.getDate();  
  var aYY2 		= lDate2.getFullYear();
  var sYear 	= aYY2;

  if (aYY2 > 99 && aYY2 < 2000) {
		aYY2 	= aYY2 - 100;
		sYear = '0' + aYY2;
  }

  aForm.secondmonth.value = aMM2;
  aForm.secondday.value 	= aDD2;
  aForm.secondyear.value 	= sYear;
}


//Percentage and rent calculation
function isBlank(aString) {
	var lString=" ";
	var TempChar;
	var Count;
	var SpacesOnly = 0;
	if (aString.length == 0||aString==""||aString==null)	{
		return(true);
	}

	for (Count=0; Count < aString.length; Count++)	{
		if(aString.charAt(Count) != lString)	{
			return(false);
		}
	}
	
	return(true);
}

function isValid(field, fieldName) {
  var lValue = field.value;
  if(isNaN(field.value) || isBlank(field.value) ) {
		alert("Please enter a numeric value for the field : " + fieldName);
		field.value = "";
		field.focus();
		return false;
  }	

  return true;
}

function stripBad(string) {
  for (var i=0, output='', valid="eE+/*-0123456789.()"; i<string.length; i++)
	 if (valid.indexOf(string.charAt(i)) != -1)
		output += string.charAt(i);
  return output;
}


-->