
// *************************************************************************************************
// BacksideOfLove.com audio-handling routines
// (presumes that BOL_inventory.js is loaded)
// *************************************************************************************************

var audio_ON = 00;

var audio_URL_prefix        = (backside_base_URL() + 'audio/');

var audio_instructions_URL  = (audio_URL_prefix + 'audio_instructions.html');

var audio_player_width  = '300';
var audio_player_height = '55';

///////////////////////////////////////////////////////////////
// is there an audio excerpt available?
function is_audio_excerpt_available (ID) {
	aea_b = 00;
	aea_i = find_item (ID, ID_idx);
	if (aea_i > 01)
		if (items[aea_i][audio_excerpts_idx] != "")
			aea_b = 01;
	if (!audio_ON)
		aea_b = 00;
	return aea_b;
} // function audio_excerpt_available


///////////////////////////////////////////////////////////////
// is an audio URL is set for the item?
function is_audiobook_available (ID) {
	aea_b = 00;
	aea_i = find_item (ID, ID_idx);
	if (aea_i > 01)
		if (items[aea_i][audio_URL_idx] != "")
			aea_b = 01;
	return aea_b;
} // function audio_excerpt_available


////////////////////////////////////////////////////////
// take ID and gender, return the URL of that audio excerpt HTML file
function make_audio_excerpt_URL (ID, gender) {
	maeu_s = (backside_base_URL() + 'readery/' + ID + '/audio/' + ID + '_excerpt_' + gender + '.html');
	return maeu_s;
} // make_audio_exerpt_URL


////////////////////////////////////////////////////////
// take ID and gender, return the URL of that audio excerpt SWF file
function make_audio_excerpt_SWF (ID, gender) {
	maeu_s = (backside_base_URL() + 'readery/' + ID + '/audio/' + ID + '_excerpt_' + gender + '.swf');
	return maeu_s;
} // make_audio_exerpt_URL


////////////////////////////////////////
function audio_instructions () {
	document_window (backside_base_URL() + 'audio/audio_instructions.html');
} // function audio_instructions


////////////////////////////////////////
function audio_excerpt_controls (ID) {
	if (debug) 	document.write ('Inside AUDIO_EXCERPT_CONTROLS');
	audio_excerpt_controls_i = find_item (ID, ID_idx);
	if (debug) document.write (audio_excerpt_controls_i);

//	if (AUDIO_ONLINE) {
	if (01) {
		if (audio_excerpt_controls_i > -1) {
			if (items[audio_excerpt_controls_i][audio_excerpts_idx] > 00) {
				document.write ('  <img src="' + backside_base_URL() + 'audio/BOL_audio_controls.jpg"  width="100" height="146" border="0" usemap="#BOL_audio_controls_map" />  ');
				document.write ('  <map name="BOL_audio_controls_map" id="BOL_audio_controls_map">  ');
				document.write ('  <area shape="circle" coords="49,102,14" href="javascript:audio_instructions()" alt="Audio excerpt help" />  ');
				document.write ('  <area shape="poly" coords="34,107,31,97,20,92,9,95,2,104,1,114,1,128,1,139,6,141,16,142,24,141,30,141,36,140,36,124,37,116,33,107" href="javascript:open_audio_excerpt(\'' + ID + '\', \'F\');" alt="Listen to female read excerpts" />  ');
				document.write ('  <area shape="poly" coords="91,134,95,121,96,102,95,93,84,92,75,93,66,100,64,107,59,113,54,119,49,122,48,131,51,136,58,139,68,141,78,141,88,141,91,134" href="javascript:open_audio_excerpt(\'' + ID + '\', \'M\');" alt="Listen to male read excerpts" />  ');
				document.write ('  <area shape="rect" coords="1,0,98,89" href="javascript:audio_instructions()" alt="Click for help with audio excerpts" />  ');
				document.write ('  </map>  ');
			}  // if there are excerpts
		} // if item found
	} // if audio_online
} // audio_excerpt_controls



///////////////////////////////////////////
// launch the audio of an item's excerpt
var excerpt_audio_win = 0;
function open_audio_excerpt (item_ID, gender) {
 	var audio_swf_URL = make_audio_excerpt_URL (item_ID, gender);
	var width="500";
	var height="300";
	var left = (screen.width/2) - width/2;
	var top = (screen.height/2) - height/2;
	var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
	
	if(excerpt_audio_win)  {
	    if(!excerpt_audio_win.closed) excerpt_audio_win.close();
	}	

	i = find_item (item_ID, ID_idx);
	if (i > -1) {
				
		// var excerpt_audio_win = window.open(audio_swf_URL,"msgWindow", styleStr);
		var excerpt_audio_win = window.open('',"msgWindow", styleStr);
				
		excerpt_audio_win.document.write ('  <html xmlns="http://www.w3.org/1999/xhtml">  ');
		excerpt_audio_win.document.write ('  <head>  ');
		excerpt_audio_win.document.write ('  <title>' + items[i][title_idx] + '</title>  ');
		excerpt_audio_win.document.write ('  <style type="text/css">  ');
		excerpt_audio_win.document.write ('  <!--  ');
		excerpt_audio_win.document.write ('  body {  ');
		excerpt_audio_win.document.write ('  	background-color: #000000;  ');
		excerpt_audio_win.document.write ('  	margin-left: 0px;  ');
		excerpt_audio_win.document.write ('  	margin-top: 0px;  ');
		excerpt_audio_win.document.write ('  	margin-right: 0px;  ');
		excerpt_audio_win.document.write ('  	margin-bottom: 0px;  ');
		excerpt_audio_win.document.write ('  	}  ');
		excerpt_audio_win.document.write ('  	-->  ');
		excerpt_audio_win.document.write ('  	</style>		  ');
		
		excerpt_audio_win.document.write ('  	<link rel="SHORTCUT ICON" href="http://backsideoflove.com/images/favicon.ico" />  ');

		excerpt_audio_win.document.write ('  	<link rel="stylesheet" type="text/css" href="../backside.css" />  ');

		excerpt_audio_win.document.write ('  	<script language="javascript" src="../js/backside.js">  ');
		excerpt_audio_win.document.write ('  	</script>  ');

		excerpt_audio_win.document.write ('  	<script language="javascript" src="BOL_inventory.js">  ');
		excerpt_audio_win.document.write ('  	</script>  ');
		
		
		
		excerpt_audio_win.document.write ('  </head>  ');

		excerpt_audio_win.document.write ('  <body>  ');
		excerpt_audio_win.document.write ( backside_base_URL() + 'readery/' + ID + '/audio/' + ID + '_excerpt_' + gender + '.swf');
		excerpt_audio_win.document.write ('  	<table width="550" height="300" border="1" cellpadding="0" cellspacing="0" bordercolor="#808080" bgcolor="#330000">  ');
		excerpt_audio_win.document.write ('  		<tr>  ');
		excerpt_audio_win.document.write ('  			<td align="center" valign="middle" class="main_content">  ');
	
		excerpt_audio_win.document.write (		'<b>' + items[i][title_idx] + '</b><br />by ' + items[i][title_idx] + '<br /><br />');

		excerpt_audio_win.document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"  ');
		excerpt_audio_win.document.write ('		codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"  ');
		excerpt_audio_win.document.write ('		width="504" height="82" id="BacksideAudioExcerpt" align="middle">  ');
		excerpt_audio_win.document.write ('	<param name="movie" value="' + backside_base_URL() + 'readery/' + ID + '/audio/' + ID + '_excerpt_' + gender + '.swf"/>  ');
		excerpt_audio_win.document.write ('	<param name="quality" value="high" />  ');
		excerpt_audio_win.document.write ('	<param name="scale" value="noscale" />  ');
		excerpt_audio_win.document.write ('	<param name="salign" value="lt" />  ');
		excerpt_audio_win.document.write ('	<param name="bgcolor" value="#ffffff" />  ');
		excerpt_audio_win.document.write ('	<embed src="' + backside_base_URL() + 'readery/' + ID + '/audio/' + ID + '_excerpt_' + gender + '.swf" quality="high" bgcolor="#ffffff" width="504" height="82"  ');
		excerpt_audio_win.document.write ('		name="CoffeeCup" scale="noscale" salign="lt" align="middle" type="application/x-shockwave-flash"  ');
		excerpt_audio_win.document.write ('		pluginspage="http://www.macromedia.com/go/getflashplayer" />  ');
		excerpt_audio_win.document.write ('</object>  ');


		excerpt_audio_win.document.write ('				</td>  ');
		excerpt_audio_win.document.write ('			</tr>  ');
		excerpt_audio_win.document.write ('		</table>  ');
		excerpt_audio_win.document.write ('	</body>  ');
		excerpt_audio_win.document.write ('	</html>  ');

	} // if found

} // open_audio_excerpt

//////////////////////////////
// END audio routines
/////////////////////////////////////////////////////////////////////////////



