function isEmpty (str) { 
  if ((str==null)||(str.length==0)) return true; 
  else return(false); 
} 

function isDigit(s) { 
  var patrn=/^[0-9]{1,20}$/; 
  if (!patrn.exec(s)) return false 
  return true 
} 

function isBetween (val, lo, hi) { 
  if ((val < lo) || (val > hi)) { return(false); } 
  else { return(true); } 
} 

function isInt (theStr) { 
  var flag = true; 
  if (isEmpty(theStr)) { flag=false; } 
  else 
  { for (var i=0; i<theStr.length; i++) { 
   if (isDigit(theStr.substring(i,i+1)) == false) { 
   flag = false; break; 
  } 
 } 
 } 
 return(flag); 
} 

function isDate (theStr) { 
  var the1st = theStr.indexOf('-'); 
  var the2nd = theStr.lastIndexOf('-'); 

  if (the1st == the2nd) { return(false); } 
  else { 
    var y = theStr.substring(0,the1st); 
    var m = theStr.substring(the1st+1,the2nd); 
    var d = theStr.substring(the2nd+1,theStr.length); 
    var maxDays = 31; 

    if (isInt(m)==false || isInt(d)==false || isInt(y)==false) { 
      return(false); } 
    else if (y.length < 4) { return(false); } 
    else if (!isBetween (m, 1, 12)) { return(false); } 
    else if (m==4 || m==6 || m==9 || m==11) maxDays = 30; 
    else if (m==2) { 
      if (y % 4 > 0) maxDays = 28; 
      else if (y % 100 == 0 && y % 400 > 0) maxDays = 28; 
      else maxDays = 29; 
    } 
    
    if (isBetween(d, 1, maxDays) == false) { return(false); } 
    else { return(true); } 
    } 
} 
function isEmail (theStr) { 
  var atIndex = theStr.indexOf('@'); 
  var dotIndex = theStr.indexOf('.', atIndex); 
  var flag = true; 
  theSub = theStr.substring(0, dotIndex+1) 

  if ((atIndex < 1)||(atIndex != theStr.lastIndexOf('@'))||(dotIndex < atIndex + 2)||(theStr.length <= theSub.length)) 
  { return(false); } 
  else { return(true); } 
} 

function back()
{ history.go(-1);}
