function createPlayer(file, playerdiv, width, height, preview, autostart) {
  if (height == false) height = width;
  if (file.search(/\.flv/) != -1 ) { height = Math.round(eval((width*0.75)+20)); };
  if (file.search(/\.mp3/) != -1 ) { height = 20; };
  var p = document.getElementById(playerdiv);
  p.style.display = 'block';
  p.style.marginBottom = '1em';
  var so = new SWFObject('../media/mediaplayer.swf', 'mediaplayer', width, height, '8');
  so.addParam('allowscriptaccess', 'always');
  so.addParam('allowfullscreen', 'true');
  so.addVariable('file', encodeURIComponent(file));
  if (preview != false) so.addVariable('image', encodeURIComponent(preview));
  so.addVariable('width', width);
  so.addVariable('height', height);
  if (autostart) {
    so.addVariable('autostart', 'true');
  } else {
    so.addVariable('autostart', 'false');
  }
  so.addVariable('javascriptid', 'mediaplayer');
  so.addVariable('enablejs', 'true');
  so.write(playerdiv);
}