function isValidDateYMD(txtDate){
	var day, month, year;
	var dateString;
	var indx1, indx2, delimiter;
	dateString=txtDate;
	
	if (dateString.length != 10){return false;}
	if (dateString.indexOf("-") != 4 || dateString.substring(5, dateString.length).indexOf("-") != 2){return false;}
	
	year=dateString.substr(0,4);
	month=dateString.substr(6,2);
	day=dateString.substr(8,2);
	return isValidDate(day, month, year);
	
	
//	==== Work in progress ====
	
//	Extract D, M and Y from value
//		Find the three parts
//			Delimiters can be (space) "-" or "/" or "\"
//				Two of them so find indexes of both
//	indx1=dateString.indexOf("-");
//	if (indx1 > 0){
//		delimiter="-";
//	}else{
//		indx1=dateString.indexOf(" ");
//		if (indx1 > 0){
//			delimiter=" ";
//		}else{
//			indx1=dateString.indexOf("\\");
//			if (indx1 > 0){
//				delimiter="\\";
//			}else{
//				indx1=dateString.indexOf("/");
//				if (indx1 > 0){
//					delimiter="/";
//				}else{
//					return false;
//				}
//			}
//		}
//	}
//	indx2=dateString.substring(indx1 + 1, dateString.length).indexOf(delimiter);
//	if (indx2 <= 0){
//		return false;
//	}else{
//		indx2=indx2 + indx1 + 1;
//	}
//	alert(indx1);
//	alert(indx2);
//	return false;
	
//		Identify which parts are which
//	Reset format to YYYY-MM-DD if necessary
//	Validate date with isValidDate function
//	return true;
}

function isValidDate(day, month, year){
	if (month < 1 || month > 12){return false;}
	if (day < 1 || day > 31){return false;}
	if ((month==4 || month==6 || month==9 || month==11) && day==31){return false;}
	
	if (month == 2)	{ // check for february 29th
	  var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
	  if (day>29 || (day==29 && !isleap)){return false;}
	}
	return true;  // date is valid
}

function StripText(ob){
	var r, re;
	var s = ob.value;
	re = /'|"/gi;
	ob.value = s.replace(re,"");
}

function UpCaseText(ob){
	ob.value=ob.value.toUpperCase();
}

function isValidEmailChars(inStr){
	var emailRegExp = new RegExp("^([A-Za-z0-9])+([A-Za-z0-9_\.\-])+([A-Za-z0-9])+$|^[A-Za-z0-9]{1}|^[A-Za-z0-9]{2}?$");
	return emailRegExp.test(inStr);
}

function isValidEmailAddress(emailAddress){
	var emailRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return (emailRegExp.test(emailAddress));
}

//Check NINO numbers
function regExpNinoIs_valid(field)
{	var myRegExp = /\D{2}\d{6}\D/i;
	return !(myRegExp.test(field));	}
	
