	// ---------------------------------------------------------
	// * Checks whether date is a valid date
	// * Returns 'true' if valid, 'false' if not valid
	// * Needs the date's day, month, year
	// * Assumes the year is a leap year
	// ---------------------------------------------------------
	function checkDate(current_day, current_month, current_year)
	{
		var flg_valid;
		var flg_leapyear;
		// if all blank, ok
		if (current_day == '' && current_month == '' && current_year == '') {/*alert('all blank');*/return true;}
		// if any but not all blank, bad
		if (current_day == '' || current_month == '' || current_year == '') {/*alert('some blank');*/return false;}
		// now assume ok unless discovered otherwise
		flg_valid = true;
		if (current_month == 2)
		{
		flg_leapyear = checkLeapYear(current_year)
		if (flg_leapyear == true)
		{
			if (current_day > 29)
			{
			flg_valid = false;
			//alert('leap year but still too big');
			}
		}
		else
		{
			if (current_day > 28)
			{
			flg_valid = false;
			//alert('not leap year too big');
			}
		}
		}
		else if (current_month == 4 || current_month == 6 || current_month == 9 || current_month == 11)
		{
		if (current_day > 30)
		{
			flg_valid = false;
			//alert('30 mth too big');
		}
		}
		return flg_valid;
	}

	// ---------------------------------------------------------
	// * Checks whether a year is a leap year
	// * Returns 'true' if valid, 'false' if not valid
	// * Needs  year as a 4 digit number
	// ---------------------------------------------------------
	function checkLeapYear(current_year)
	{
		var isLeapYear = false;
		if (current_year%4 == 0)
		{
		isLeapYear = true;
		if (current_year%100 == 0)
		{
			isLeapYear = false;
			if (current_year%400 == 0)
			{
			isLeapYear = true;
			}
			else
			{
			isLeapYear = false;
			}
		}
		else
		{
			isLeapYear = true;
		} 
		}
		else
		{
		isLeapYear = false;
		}
		return isLeapYear;
	}

	// ---------------------------------------------------------
	// * Trim leading and trailing spaces
	// ---------------------------------------------------------
  	function trim(strText)
				
	{ 				
			// this will get rid of leading spaces
			while(strText.substring(0, 1) == ' ')
			{
			strText = strText.substring(1, strText.length);
			}

		
			// this will get rid of trailing spaces
			while(strText.substring(strText.length - 1, strText.length) == ' ')
			{
			strText = strText.substring(0, strText.length - 1);
			}

			return(strText);
	}

	function chk(obj)
	{
		var pI = "";
		for(var propertyName in obj)
		{
			if(propertyName != "innerHTML" & propertyName != "innerText" & propertyName != "outerHTML" & propertyName != "outerText")
				pI += propertyName + " = " + obj[propertyName] + " : ";
		}
		alert(pI);
	}  
