var DateUtils = new Object();

DateUtils.dtCh= "/";
DateUtils.minYear=0;
DateUtils.maxYear=2038;

DateUtils.checkDate = function (d, m, y) {
	if (isNaN(parseInt(d)) || isNaN(parseInt(m)) || isNaN(parseInt(y)) ) {
		return false;
	}

    return this.isDate(d+DateUtils.dtCh+m+DateUtils.dtCh+y);
};

	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
DateUtils.daysInFebruary = function (year){
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
};


DateUtils.DaysArray = function (n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
		if (i==2) {this[i] = 29;}
   }
   return this;
};


DateUtils.isDate = function (dtStr){
	var daysInMonth = DateUtils.DaysArray(12);
	var pos1=dtStr.indexOf(DateUtils.dtCh);
	var pos2=dtStr.indexOf(DateUtils.dtCh,pos1+1);
	var strDay=dtStr.substring(0,pos1);
	var strMonth=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1){
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>DateUtils.daysInFebruary(year)) || day > daysInMonth[month]){
		return false;
	}
	if (strYear.length != 4 || year==0 || year<DateUtils.minYear || year>DateUtils.maxYear){
		return false;
	}
	if (dtStr.indexOf(DateUtils.dtCh,pos2+1)!=-1 || TypeUtils.isInteger(TypeUtils.stripCharsInBag(dtStr, DateUtils.dtCh))==false){
		return false;
	}
return true;
};


DateUtils.checkTime = function (h, m) {
	if (h=="" || m=="") {
		return false;
	}

	if (isNaN(h) || isNaN(m)) {
		return false;
	}
	
	if (h>23 || h<0) {
		return false;
	}
	
	if (m>59 || m<0) {
		return false;
	}
	
	return true;
}


