Moving the duplicate checking
prettyPhoto allows a larger image to popup on click
Write HTML instead of XHTML because of the CDATA it adds to the JS
Final changes before committing to Sakai trunk in https://jira.sakaiproject.org/browse/SAK-26062