From http://stackoverflow.com/questions/190852/how-can-i-get-file-extensions-with-javascript