﻿// Pop-Up Embedder Script by David Battino, www.batmosphere.com
// Version 2006-05-31  
// OK to use if this notice is included
var WindowNumber = 314 
var newWinOffset = 0 // Position of first pop-up

function BatmoAudioPop(filedesc,filepath,caption,imgpath) 
{

// 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.
};
//resize
var winWidth = 570;
     var rawHeight = 400 + caption.length/7; // calculate window height based on caption length
     var winHeight = Math.round(rawHeight * Math.pow(10,0))/Math.pow(10,0); // round to integer
//end resize
    PlayerWin = window.open('',WindowNumber,'width=570,height=' + winHeight + ' ,top=' + newWinOffset + ' ,left=0,screenX=0,screenY=0,resizable=1,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0');

    PlayerWin.focus();
    PlayerWin.document.write("<html><head><title>" + filedesc + "</title></head>");
    PlayerWin.document.write("<body bgcolor='000000'>"); // specify background img if desired
    PlayerWin.document.write("<div align='left'>");
	PlayerWin.document.write("<img src='" + imgpath + "' id='image1' border='2' alt='" + filedesc + "' width='120px' height='140px'title='" + filedesc + "' />")
    	PlayerWin.document.write("<br />")
	PlayerWin.document.write("<b style ='padding-left:.5em;font-size:18px;font-family:Lucida,sans-serif;line-height:1.6;color:white;'>" + filedesc + "</b><br />");
	PlayerWin.document.writeln("<div style='width: 560px; margin: 0px; padding: 0 1em 0em 0em; text-align:left; background-color: #000;'>")
    PlayerWin.document.write("<object width='560' 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' width='560' height='69' controller='1' showstatusbar='1' bgcolor='#000' kioskmode='true'>");
    PlayerWin.document.write("</embed></object>");

	PlayerWin.document.write("<p style='padding-left: 1em;font-size:12px;font-family:Arial,sans-serif;color:#ddd'>" + caption + "</p>")
    PlayerWin.document.write("<p style='font-size:12px;font-family:Lucida,sans-serif;text-align:center'><a style='color:red;'href='" + filepath +"'>Download Demo</a> <span style='font-size:10px; color:silver;'>(Right-click or Control-click)</span></p>");
    PlayerWin.document.write("<form><div align='center'><input type='button' value='Close this window' onclick='javascript:window.close();'></div></form>");
	PlayerWin.document.write("<p style='margin:0px;padding:0;font-size:14px;font-family:Arial,sans-serif;font-weight:normal;color:#FF0000;font-stretch: narrower'>Word Of Mouth</p>")
   PlayerWin.document.write("<p style='margin:0px;padding:0;font-size:10px;font-family:Arial,sans-serif;font-weight:normal;color:#aaa;padding:0;'>Call (+64) 9 360-1990 or 0800 VOICES</p>")
   PlayerWin.document.write("</div></div></body></html>");

    PlayerWin.document.close(); // "Finalizes" new window
	WindowNumber = WindowNumber + 1 
}
