function onDateType(element, content)
{
	var szNumeric = "0123456789/";
	var i = 0;
	var temp;
	for (i=0; i<element.value.length; i++) 
	{
		temp = "" + element.value.substring(i, i+1);
		if (szNumeric.indexOf(temp) == "-1") 
		{
			temp = "" + element.value.substring(0, i);
			element.value = temp;
			return false;
		}
		if( i != 2 && i != 5 && temp == "/" )
		{
			temp = "" + element.value.substring(0, i);
			element.value = temp;
			return false;
		}
	}

	if( content.length == 2 )
	{
		var szMonth;
		szMonth = element.value.substr(0,2);
		//szMonth = element.value.substr(3,2);
		if( szMonth > 12 || szMonth == 0 )
		{
			alert("Ilegal month");
			element.value = "";
			return true;
		}
		element.value = content + "/";
	}

	if( content.length == 5 )
	{
		var szDay;
		szDay = element.value.substr(3,2);
		//szDay = element.value.substr(0,2);
		if( szDay > 31 || szDay == 0  )
		{
			alert("Ilegal Day.");
			temp = element.value.substr(0, 3);
			element.value = temp;			
			return true;
		}
		element.value = content + "/"
	}
	
		
	if( content.length == 10 )
	{
		var szYear;
		szYear = element.value.substr(6, 4);
		var szNow = new Date();
		
		
		if( szYear < szNow.getFullYear() )
		{
			alert("Ilegal year!");
			alert( szYear + " " + szNow.getFullYear() );
			temp = element.value.substr(0,6);
			element.value = temp;
		}
	}
	return true;
}
function OnDateExit(element, content)
{
	if( content.length < 10 && content.length > 6 )
	{
		var szYear;
		szYear = element.value.substr(6, 4)
		if( szYear < 1900 )
		{
			alert("Ilegal year!");
			alert( szYear);
			temp = element.value.substr(0,6);
			element.value = temp;
			
		}
	}
}



//------------------------------------------------------------------------------------


<!-- helper script that uses the calendar -->
calendar = null; // remember the calendar object so that we reuse
                     // it and avoid creating another
var MINUTE = 60 * 1000;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;
var WEEK = 7 * DAY;

// This function gets called when an end-user clicks on some date
function selected(cal, date) {
  cal.sel.value = date; // just update the value of the input field
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks the "Close" (X) button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
  cal.hide();			// hide the calendar

  // don't check mousedown on document anymore (used to be able to hide the
  // calendar when someone clicks outside it, see the showCalendar function).
  Calendar.removeEvent(document, "mousedown", checkCalendar);
}

// This gets called when the user presses a mouse button anywhere in the
// document, if the calendar is shown.  If the click was outside the open
// calendar this function closes it.
function checkCalendar(ev) {
  var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
  for (; el != null; el = el.parentNode)
    // FIXME: allow end-user to click some link without closing the
    // calendar.  Good to see real-time stylesheet change :)
    if (el == calendar.element || el.tagName == "A") break;
  if (el == null) {
    // calls closeHandler which should hide the calendar.
    calendar.callCloseHandler(); Calendar.stopEvent(ev);
  }
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(id, dateFormat) {
  var el = document.getElementById(id);
  if (calendar != null) {
    // we already have one created, so just update it.
    calendar.hide();		// hide the existing calendar
    calendar.parseDate(el.value); // set it to a new date
  } else {
    // first-time call, create the calendar
    var cal = new Calendar(true, null, selected, closeHandler);
    calendar = cal;		// remember the calendar in the global
    cal.setRange(2007, 2010);	// min/max year allowed
    cal.setDateFormat(dateFormat);
    calendar.create();		// create a popup calendar
    
  }
  calendar.sel = el;		// inform it about the input field in use
  calendar.showAtElement(el);	// show the calendar next to the input field

  // catch mousedown on the document
  Calendar.addEvent(document, "mousedown", checkCalendar);
  return false;
}
function flatSelected(cal, date) {
 // var el = document.getElementById("preview");
 //el.innerHTML = date;
 document.getElementById("delDate").value = date;
}
function isDisabled(date) {
  var today = new Date();
  return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
}
/*


function Today22()
{
	var locTime = new Date();
	var dCurMonth = locTime.getMonth();
	var dCurDayOfMonth = locTime.getDate();
	var dCurYear = locTime.getFullYear();
	var szTime = dCurDayOfMonth + '/'+ dCurMonth + '/' +dCurYear;
	document.getElementById("distributeDate").value =  szTime;//DateFormat.getDateInstance().format(locTime);
}*/

