function isValidFileName (str) {
  //need to allow slashes and backslashes since part of file path
  str.trim();
  var startIndex = 0;
  if (str.lastIndexOf('\\') != -1)
    startIndex = str.lastIndexOf('\\') + 1; // windows path
  else if (str.lastIndexOf('/') != -1)
    startIndex = str.lastIndexOf('/') + 1; // unix path
  else
    startIndex = 0;
  var fileName = str.substr(startIndex);
  if (fileName.match(/[^\w_\.\\\/\s\-]/)) {
    alert("Invalid character(s) in file name.  Allowed characters are [a-z], [A-Z], 0-9, ' ', '-', '_' , and  '.'");
    return 0;
  }

  return 1;
}

String.prototype.trim = function() {
 // skip leading and trailing whitespace
 // and return everything in between
  var x=this;
  x=x.replace(/^\s*(.*)/, "$1");
  x=x.replace(/(.*?)\s*$/, "$1");
  return x;
}

