
var theWindow = null;

function fixTitle(theTitle)
{
	if( theTitle.charAt(0)=='-' ) return theTitle.slice(1);
	else return '"' + theTitle + '"';
}

function openAudioWindow(theTitle,theFile,windWidth,windHeight,movWidth,movHeight)
{
	theParms = 'title='+fixTitle(theTitle)+'&movie='+theFile+'&width='+movWidth+'&height='+movHeight;

	w = screen.availWidth, h = screen.availHeight;
	if( w<800 ) W = 800;
	if( h<600 ) h = 600;

	windLeft = (w-windWidth)/2, windTop = (h-windHeight)/2;
	windTop = windTop - (windTop/4);

	// if the window already exists, the open will fail to resize so close it first
	if( theWindow && theWindow.open )
	{
		if( !theWindow.closed ) theWindow.close();
		delete theWindow;
		theWindow = null;
	}

	windName = 'wndMovie';
	theWindow = window.open('audio_popup.html?'+theParms, windName,
		  'width=' + windWidth
		+ ',height=' + windHeight
		+ ',top=' + windTop
		+ ',left=' + windLeft
		+ ',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no');

	return
}

function addAudioFile(theTitle,theFile)
{
	link = "<A CLASS=\"play\" HREF=\"javascript:openAudioWindow('" + theTitle + "','" + theFile + "',360,32,276,0)\">Play</A>";

	str = '<TR>'
		+ '<TD ALIGN="LEFT"><SPAN CLASS="play_name">' + theTitle + '</SPAN></TD>'
		+ '<TD ALIGN="RIGHT">' + link + '</TD>'
		+ '</TR>';

	document.write(str);
}
