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