function isDate(str){
  ar = str.split("/");
  if (ar.length != 3)
    return false;
  if (!(ar[0] >= 1 && ar[0] <= 12))
    return false;
  if (!(ar[1] >= 1 && ar[1] <= 31))
    return false;
  if (!(ar[2] >= 1000 && ar[2] <= 9999))
    return false;
  return true;
}

function getDateNoNull(str){
  if (isDate(str)){
    ar = str.split("/");
    return new Date(ar[2],ar[0]-1,ar[1]);
  }
  else
    return new Date();
}

function getDate(str){
  if (isDate(str)){
    ar = str.split("/");
    return new Date(ar[2],ar[0]-1,ar[1]);
  }
  else
    return null;
}

function trim(strText) { 
    // this will get rid of leading spaces 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);

    // this will get rid of trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

   return strText;
}
