<img src="/icons/{.switch|%item-name%|;|upload|uploadicon.gif|icons|iconsicon.gif|folder.gif.}" border="0">
no javascript is needed
I suggest you to use the next template code:
in your ICONS folder you can put icons files named
file extension : mp3.gif, exe.gif, ... ; if the file exist for a specific extension then it replace the default icon %item-icon%
folder name : uploadicon.gif, iconsicon.gif, ... ; if the file exist for a specific name then it replace the default icon /icons/folder.gif
you have not to update the future template but just to put the correct GIF in the folder /icons/
[file=folder=link]
<tr><td>
{.if|{.get|can delete.}{.and|{.get|can access.}|{.get|can archive item.}.}| <input type='checkbox' name='selection' value="%item-url%"> .}
{.if|{.get|is new.}|<span class='flag'> NEW </span>.}
{.if not|{.get|can access.}|<img src='/~img_lock'>.}
<a href="%item-url%">
[+file]
<img src="{.if|{.filesize|/icons/%item-ext%.gif.}| /icons/%item-ext%.gif | %item-icon% .}" border="0">
[+folder]
<img src="{.if|{.filesize|/icons/%item-name%icon.gif.}| /icons/%item-name%icon.gif | /icons/folder.gif .}" border="0">
[+link]
<img src="%item-icon%">
[+file=+folder=+link]
%item-name%</a>
{.if| {.?search.} |{:<div class='item-folder'>{.!item folder.} {.breadcrumbs|{:<a href="%bread-url%">%bread-name%/</a>:}|from={.count substring|/|%folder%.}/breadcrumbs.}:} .}
{.if| %item-comment% | <div class='comment'>%item-comment%</div> .}
[+file]
<td align='right'>%item-size%<td align='right'>%item-modified%<td align='right'>%item-dl-count%
[+folder]
<td align='center'><i>folder</i><td align='right'>%item-modified%<td align='right'>%item-dl-count%
[+link]
<td colspan='3' align='center'><i>link</i>