function isDate(s)   {      
  // make sure it is in the expected format   
  if (s.search(/^\d{1,2}[\/|\-|\.|_]\d{1,2}[\/|\-|\.|_]\d{4}/g) != 0)   
    return false;   
  // remove other separators that are not valid with the Date class              
  s = s.replace(/[\-|\.|_]/g, "/");   
  // convert it into a date instance   
  var dt = new Date(Date.parse(s));          
  // check the components of the date   
  // since Date instance automatically rolls over each component   
  var arrDateParts = s.split("/");   
  return (   
          dt.getMonth() == arrDateParts[0]-1 &&   
          dt.getDate() == arrDateParts[1] &&   
          dt.getFullYear() == arrDateParts[2]   
        );             
}   


function getJsDate(s)   {      
  
    // make sure it is in the expected format   
  if (s.search(/^\d{1,2}[\/|\-|\.|_]\d{1,2}[\/|\-|\.|_]\d{4}/g) != 0)   
    return false;   
  // remove other separators that are not valid with the Date class              
  s = s.replace(/[\-|\.|_]/g, "/");   
  // convert it into a date instance   
  var dt = new Date(Date.parse(s));          
  // check the components of the date   
  // since Date instance automatically rolls over each component   
  var arrDateParts = s.split("/");   
  return dt;

  
}     

function getNumDay(d1,d2){
  var one_day=1000*60*60*24

//Calculate difference btw the two dates, and convert to days
  return Math.ceil((d1.getTime()-d2.getTime())/(one_day));

}


function checkEmail(email) {
  var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
  if (!filter.test(email)) {
    return false;
  }
  return true;
}

function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}


