Split up file decider JS

Split up the JavaScript to decide what file it is and what to view it
in. Currently there's only <iframe> and <img> available, but everything
is in place and ready for additional viewers.