function isDate(dtStr){
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strMonth=dtStr.substring(0,pos1);
	var strDay=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){
		alert("Форматът на датата трябва да бъде : mm/dd/yyyy");
		return false;
	}
	if (strMonth.length < 1 || month < 1 || month > 12){
		alert("Моля, въведете валиден месец !");
		return false;
	}
	if (strDay.length < 1 || day < 1 || day > 31 || (month==2 && day > daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Моля, въведете валиден ден !");
		return false;
	}
	if (strYear.length != 4 || year==0 || year < minYear || year > maxYear){
		alert("Моля, въведете 4 цифрена година между "+minYear+" и "+maxYear);
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Моля, въведете валидна дата !");
		return false;
	}
return true;
}

function ValidateForm(){
	var dt=document.ex_form.months.value+"/"+document.ex_form.days.value+"/"+document.ex_form.years.value;
	if (isDate(dt)==false){
		return false;
	}
    document.ex_form.submit();
 }


