﻿function AudioPop(filedesc,filepath,WindowNumber){
  var isWin = navigator.userAgent.toLowerCase().indexOf("windows") != -1
  if (isWin) {
  	visitorOS="Windows";
  } else {
  	visitorOS="Other";
  }
  var mimeType = "audio/mpeg";
  var objTypeTag = "application/x-mplayer2";
  var theExtension = filepath.substr(filepath.lastIndexOf('.')+1, 3);
  if (theExtension.toLowerCase() == "wav") { mimeType = "audio/x-wav"};
  if (theExtension.toLowerCase() == "aif") { mimeType = "audio/x-aiff"};
  if (theExtension.toLowerCase() == "wma") { mimeType = "audio/x-ms-wma"};
  if (theExtension.toLowerCase() == "mid") { mimeType = "audio/mid"};
  if (visitorOS != "Windows") {objTypeTag = MimeType;};
  var winl = (screen.width - 320) / 2;
  var wint = (screen.height - 217) / 2;
  PlayerWin = window.open('',WindowNumber,'width=320,height=217,top='+wint+',left='+winl+',screenX=0,screenY=0');
  PlayerWin.focus();
  PlayerWin.document.write("<html><head><title>" + filedesc + "</title><link rel='stylesheet' type='text/css' href='http://www.saintnicodemos.org/css/nicodemos.css' /></head>");
  PlayerWin.document.write("<body class='playerBody'");
  PlayerWin.document.write("<div align='center'>");
  PlayerWin.document.write("<b class='playerTitle'>" + filedesc + "</b><br />");
  PlayerWin.document.write("<object width='280' height='69'>");
  PlayerWin.document.write("<param name='src' value='" +  filepath + "'>");
  PlayerWin.document.write("<param name='type' value='" + objTypeTag + "'>");
  PlayerWin.document.write("<param name='autostart' value='1'>");
  PlayerWin.document.write("<param name='showcontrols' value='1'>");
  PlayerWin.document.write("<param name='showstatusbar' value='1'>");
  PlayerWin.document.write("<embed src ='" + filepath + "' type='" + objTypeTag + "' autoplay='true' autostart='true' width='280' height='69' controller='1' showstatusbar='1' bgcolor='#9999ff' kioskmode='true'>");
  PlayerWin.document.write("</embed></object></div>");
  PlayerWin.document.write("<div align='center'><a class='playerDownloadLink' href='" + filepath +"'>Download this file</a>&nbsp;<span class='playerHelp'>(right-click or Control-click)</span></div><br />");
  PlayerWin.document.write("<form><div align='center'><input type='button' value='Close this window' onclick='javascript:window.close();'></div></form>");
  PlayerWin.document.write("</body></html>");
  PlayerWin.document.close();
}