// Pop-Up Embedder <Script> by David Battino, www.batmosphere.com
// Version 2006-05-31  
// OK to use if this notice is included
   
function BatmoAudioPop(filedesc,filepath,WindowNumber) 
{

// Get Operating System 
var isWin = navigator.userAgent.toLowerCase().indexOf("windows") != -1
if (isWin) {
    // Use MIME type = "application/x-mplayer2";
	visitorOS="Windows";
} else {
    // Use MIME type = "audio/mpeg"; // or audio/x-wav or audio/x-ms-wma, etc.
	visitorOS="Other";
}

// Get the MIME type of the audio file from its extension (for non-Windows browsers)
var mimeType = "audio/mpeg"; // assume MP3/M3U
var objTypeTag = "application/x-mplayer2"; // The Windows MIME type to load the WMP plug-in in Firefox, etc.

var theExtension = filepath.substr(filepath.lastIndexOf('.')+1, 3); // truncates .aiff to aif
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"};
// Add additional MIME types as desired

if (visitorOS != "Windows") { 
objTypeTag = mimeType; // audio/mpeg, audio/x-wav, audio/x-ms-wma, etc.
};

    PlayerWin = window.open('',WindowNumber,'width=280,height=110,resizable=1,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0');
      // additions: width=320,height=217,top=0,left=0,screenX=0,screenY=0,
    PlayerWin.focus();
	PlayerWin.document.write("<!DOCTYPE HTML PUBLIC '-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN' "); 
	PlayerWin.document.writeln("'http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd'>");
    PlayerWin.document.write("<html><head><title>" + filedesc + "<\/title>");
	PlayerWin.document.writeln("<meta http-equiv='content-type' content='text\/html;charset=iso-8859-15'><\/head>");
    PlayerWin.document.write("<body style='margin:0px; padding:0px; border:0px; background-color:#000000; font-size:10pt; color:#AAAAAA;'>");
	PlayerWin.document.write("<div align='center'>"); 
    // PlayerWin.document.writeln("<center>");
    // PlayerWin.document.writeln("<h4 style='font-size:1em; font-family:Tahoma,sans-serif; font-weight:normal; margin:0px; padding:4px; line-height:1.2em'>" + filedesc + "<\/h4><br>");
    PlayerWin.document.writeln("<object width='280' height='70' border='0' style='width:280px; background-color:#000000; margin:0px; padding:0px; border:none;'>");
    PlayerWin.document.writeln("<param name='src' value='" +  filepath + "'>");
    PlayerWin.document.writeln("<param name='type' value='" + objTypeTag + "'>");
    PlayerWin.document.writeln("<param name='autostart' value='1'>");
    PlayerWin.document.writeln("<param name='showcontrols' value='1'>"); 
    PlayerWin.document.writeln("<param name='showstatusbar' value='1'>");
    PlayerWin.document.writeln("<embed src ='" + filepath + "' type='" + objTypeTag + "' autoplay='true' width='280' height='69' controller='1' showstatusbar='1' bgcolor='#9999ff' kioskmode='true'>");
    PlayerWin.document.writeln("<\/embed><\/object>");
    PlayerWin.document.write("<form style='margin:0px; padding:8px; border:0px;' action='./downloads/dl.php' method='post'>");
	PlayerWin.document.write("<input type='hidden' name='f' value='"+ filepath.substr(filepath.lastIndexOf('/')+1) +"'>");	
	PlayerWin.document.write("<input style='font-size:0.8em; width:120px;' type='submit' value='Datei herunterladen'>&nbsp;&nbsp;");
    PlayerWin.document.writeln("<input style='font-size:0.8em; width:120px;' type='button' value='Player schließen' onclick='javascript:window.close();'><\/form>");
    // PlayerWin.document.writeln("</center>");
	PlayerWin.document.writeln("<\/div><\/body><\/html>");

    PlayerWin.document.close(); // "Finalizes" new window
}
