function fnIsValidEmail(sEmailAddr) {
     var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
     var regex = new RegExp(emailReg);
     return regex.test(sEmailAddr);
}
function fnGetRadioValue(objRadio) {
	if ( !(objRadio))
		return false;
	for (var i = 0; i < objRadio.length; i++) {
		if ( objRadio[i].checked == true)
   			return objRadio[i].value;
	}
	if (objRadio.checked == true)
		return objRadio.value;
	return '';
}
function fnIsValidDate (sDateIn) {
	var dateFormat = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
	return sDateIn.match(dateFormat);
}

function fnCalcAge(sDateIn){
  var t, mon, day, year, DD, MM, YY, age;
  var fnDIM = new fnGetDaysInMonth();
  YY   = parseInt(sDateIn.split('/')[2]);	// year of birth (4 digits)
  MM   = parseInt(sDateIn.split('/')[1]);	// month of birth (1-12)
  DD   = parseInt(sDateIn.split('/')[0]);	// date of birth (1-31)
  if (fnDIM[MM] < DD || DD < 1) return -1;
  t    = new Date();	// get current date
  year = t.getFullYear();	// get year of current
  mon  = t.getMonth() + 1;	// get month of current
  day  = t.getDate();	// get date of current
  if (MM == 2 && DD == 29){	// check leap year
 //   if (!(((YY % 4 == 0) && (YY % 100 != 0)) || (YY % 400 == 0))){
 //     alert('The year ' +YY+ ' ends at 28th of '+MM+' month\nPlease check the date.');
 //     return -1;
 //   }
  }
  age = year - YY;
  if ((MM > mon) || (MM == mon && day < DD)) age --;
  return age;
}
function fnGetDaysInMonth(){
  var i = 0;
  this[i++] = 0; // dummy
  this[i++] = 31;
  this[i++] = 29;
  this[i++] = 31;
  this[i++] = 30;
  this[i++] = 31;
  this[i++] = 30;
  this[i++] = 31;
  this[i++] = 31;
  this[i++] = 30;
  this[i++] = 31;
  this[i++] = 30;
  this[i  ] = 31;
  this.length = i;
}