//var msg = "Do you prefer to open each audio link in its own player window?\n\n"
//		+ "(Chose 'cancel' if you just want to download files.)\n";

//if (confirm(msg))
//{
	// Look at all links in the document
	for (var i=0; i < document.links.length; i++) //>
	{
		// If the link points to an MP3 file, save the link
		// and replace it with a call to the play() function
		if((document.links[i].href.match(/\.mp3$/i))
		|| (document.links[i].href.match(/\.mid$/i)))
		{
			document.links[i]._href = document.links[i].href;
			document.links[i].href="javascript:play(" + i + ")";
		}
	}
//}

// Play the track associated with the given index
function play(track)
{	
	// Use link text as the title
	var ttl=document.links[track].innerHTML;
	var mp3=document.links[track]._href;

	var w=window.open("", "", "width=230,height=300,resizable=yes,scrollbars=no");
	if(w == null)
	{
		alert("Can't create window!\nPlease make sure that pop-ups are allowed and not blocked.");
		return;
	}
	w.document.open("text/html");
	w.document.write(
		  '<html>\n<head>\n'
		+ '<style>\n'
		+ 'BODY, TD, TH, H1, H2, H3 {font-family:arial}\n'
		+ 'BODY {background-color: #000000;  color: #FFFFDD}\n'
		+ 'A:link    {text-decoration: none; color: #FFFFDD;}\n'
		+ 'A:visited {text-decoration: none; color: #FFFFDD}\n'
		+ 'A:active  {text-decoration: underline;}\n'
		+ 'A:hover   {text-decoration: underline;}\n'
		+ '</style>\n'
		+ '<title>' + ttl + '</title>\n</head>\n'
		+ '<body><center>\n'
		+ '<img src="http://www.chicagogamelan.org/graphics/200batik.jpg" width="200" height="200" border="1" alt="' +  ttl + '"><br>\n'
		+ '<embed src="' + mp3 + '" autostart="true" height="50" width="200" bgcolor="#000000"><br>\n'
		+ '<table><tr><td nowrap align="center">'
		+ '<font class="medium"><a href="' + mp3 + '">' + ttl +  '</a></font><br>\n'
		+ '</td></tr></table>\n'
		+ '</center></body></html>\n'
		);

	w.document.close();
}