
//===============================================================================================================================
//
// 03/02/2007: Half through including DIRECT_DL_URL field for free items.
// 	- index created, updated REGISTER_ITEM, so ITEM[I][direct_DL_idx] contains valid URL if it's available for direct download.
//	- display of buy buttons in catalog entry and summary entry must check for "HTTP:" in DIRECT_DL_URL - if found, 
//		include link to it instead of usual Shopping Cart download button -- *but must include "print" version button, right??**
//
//===============================================================================================================================

if (debug) debug_report ('INSIDE BOL_INVENTORY');

var items_max       = 50;
var fields_max      = 14;
var number_of_items = 00;
var this_ID         = 00;

var readery_URL_prefix      = (backside_base_URL() + "readery/");

var LuLu_prefix      = "http://www.lulu.com/content/";
var DL_prefix        = "http://www.lulu.com/content/";
var print_prefix     = "http://www.lulu.com/content/";

var thumbnail_suffix = "_thumb.jpg";
var excerpts_suffix = "_excerpts.html";
var main_image_suffix = "";

var audio_prompt_s     = "podcast! (MP3 <i>book-on-tape</i>)";
var download_prompt_s  = "download e-book";
var excerpt_prompt_s   = "free samples";
var excerpt_button_URL = (backside_base_URL() + 'images/button_excerpts.gif');

var anthology_keyword = "anthology";
var novella_keyword = "novella";
var shortstory_keyword = "short-story";


///////////////////////////////////////
var ID_idx             = 00;
var title_idx          = 01;
var pages_idx          = 02;
var series_idx         = 03;
var DL_price_idx       = 04;
var print_price_idx    = 05;
var DL_URL_idx         = 06;
var print_URL_idx      = 07;
var descript_short_idx = 08;
var category_idx       = 09;
var subcategory_idx    = 10;
var author_idx         = 11;
var author_email_idx   = 12;
var content_keys_idx   = 13;
var type_idx           = 14; 
var audio_excerpts_idx = 15; 
var audio_URL_idx      = 16; 
var descript_long_idx  = 17; 
var direct_DL_idx      = 18;

var show_descript       = 01;
var dont_show_descript  = 00;
var show_thumbnail      = 01;
var dont_show_thumbnail = 00;
var show_keys           = 01;
var dont_show_keys      = 00;

var carolyns_name = "Carolyn Faulkner";
var carolyns_email = "http://backsideoflove.com/contact/contact_carolyn.html";

var UBs_name = "Bobby S.";
var UBs_email = "http://backsideoflove.com/contact/contact_UB.html";

var spanking_category = "Spanking";
var ageplay_category = "Ageplay";

spanking_default_content_keys = "mf dd xx";
ageplay_default_content_keys = "mf dd ds xx ** med water age diaper";


// ================================  ECOMMERCE ROUTINES   =========================================

function output_frontpage_summary (ID, new_tag) {
	oib_i = find_item (ID, ID_idx);
	if (oib_i > -1) {

		document.write ('<a href="readery/display_item.html?' + items[oib_i][ID_idx] + '">');
		document.write (	'<img src="http://backsideoflove.com/readery/' + items[oib_i][ID_idx] + '/' + items[oib_i][ID_idx] + '_thumb.jpg" alt="book cover thumbnail" width="125" height="189" border="0" align="right" />');
		document.write ('</a>');
		if (new_tag) {
			document.write ('<span class="NEW_style">&nbsp;NEW!&nbsp;&nbsp;&nbsp;</span>');			
		}
		else
			document.write ('<img src="images/BulletHandprint.gif" alt="bullet - small red handprint" width="20" height="24" hspace="0" vspace="5" border="0" align="absbottom" /> ');

		document.write ('<a href="readery/display_item.html?' + items[oib_i][ID_idx] + '">');
		document.write (	items[oib_i][title_idx] );
		document.write ('</a>:&nbsp;');
		document.write (items[oib_i][descript_short_idx]);

	} // if
}  // func


// make link directly to ZIP file w/item's title 
function output_direct_download_link (ID) {
	make_download_URL_i = find_item (ID, ID_idx);
	make_download_URL_s = "";
	if (make_download_URL_i > -1) {
		make_download_URL_s = ('<a href="' + readery_URL_prefix + items[make_download_URL_i][ID_idx] + '/' + items[make_download_URL_i][direct_DL_idx] + '">' + items[make_download_URL_i][title_idx] + '</a>');
	}  // if found
	return make_download_URL_s;						
}  // output_free_download_link


function make_download_link (ID) {
	make_download_URL_i = find_item (ID, ID_idx);
	make_download_URL_s = "";
	if (make_download_URL_i > -1) {
		if (PP_on) {  // backside.js
			make_download_URL_s = ('<a target="_blank" href="' + DL_prefix + items[make_download_URL_i][DL_URL_idx] + '">' + download_prompt_s + '</a>');
		} // if PP
		else {
			make_download_URL_s = ('<a target="_blank" href="' + LuLu_prefix + items[make_download_URL_i][DL_URL_idx] + '">' + download_prompt_s + '</a>');
		}  // else not PP
	}  // if found
	return make_download_URL_s;						
} // func


function make_download_URL (ID) {
	make_download_URL_i = find_item (ID, ID_idx);
	make_download_URL_s = "";
	if (make_download_URL_i > -1) 
		make_download_URL_s = (DL_prefix + items[make_download_URL_i][DL_URL_idx]);
	return make_download_URL_s;						
} // func


function make_print_URL (ID) {
	make_print_URL_i = find_item (ID, ID_idx);
	make_print_URL_s = "";
	if (make_print_URL_i > -1)
		make_print_URL_s = (print_prefix + items[make_print_URL_i][print_URL_idx]);
	return make_print_URL_s;
} // func


if (debug) debug_report ('OUTPUT FUNC DEFS OVER');


////////////////////////////////////////////////////////////
// take an ID and output the cart button forms
function display_cart_buttons (ID) {
	oib_i = find_item (ID, ID_idx);

	if (oib_i > -1) {
		document.write ('<table border="1" cellpadding="0" cellspacing="0" width="100%"><tr><td  class="readery_catalog_links" align="center" valign="middle">');
		document.write ('	<?php $aip = $_SERVER["REMOTE_ADDR"]; ?> ');
		document.write ('	<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr/mrb/pal=9QQVZHP6UK9L2" method="post"> ');
		document.write ('		<input type="hidden" name="bn" value="phppixie.com"> ');
		document.write ('		<input type="hidden" name="add" value="1"> ');
		document.write ('		<input type="hidden" name="cmd" value="_cart"> ');
		document.write ('		<input type="hidden" name="page_style" value="backside_main_style">  ');
		document.write ('		<input type="hidden" name="rm" value="1"> ');
		document.write ('		<input type=hidden name=business value=paypal@behavioralartsdisciples.org> ');
		document.write ('		<input type=hidden name=item_name value="' + items[oib_i][title_idx] + ' - download"> ');
		document.write ('		<input type=hidden name=item_number value="' + ID + '"> ');
		document.write ('		<input type=hidden name=amount value=' + items[oib_i][DL_price_idx] + '> ');
		document.write ('		<input type=hidden name=currency_code value=USD> ');
		document.write ('		<input type=hidden name=image_url value=http://backsideoflove.com/images/[BacksideOfLove]_01.gif> ');
		document.write ('		<input type=hidden name=return value=http://backsideoflove.com/clerk/DL_order_okay.html> ');
		document.write ('		<input type=hidden name=cancel_return value=http://backsideoflove.com/clerk/DL_order_cancel.html> ');
		document.write ('		<input type=hidden name=custom value=CART> ');
		document.write ('		<input type=image src=http://backsideoflove.com/clerk/images/button_buy_cart.jpg> ');
		document.write ('		<input type="hidden" name="notify_url" value="http://backsideoflove.com/clerk/downloads/download/pixie.php"> ');
		document.write ('	</form> ');
		document.write ('</td><td align="center" valign="middle">');
		document.write ('	<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> ');
		document.write ('		<input type="hidden" name="cmd" value="_cart"> ');
		document.write ('		<input type="hidden" name="page_style" value="backside_main_style">  ');
		document.write ('		<input type="hidden" name="business2" value="paypal@behavioralartsdisciples.org"> ');
		document.write ('		<input type="image" src="http://backsideoflove.com/clerk/images/button_checkout.jpg" border="0" name="submit" alt="Check out"> ');
		document.write ('		<input type="hidden" name="display" value="1">');
		document.write ('	</form> ');
		document.write ('</td></tr></table>'); 
	} // if 
}  // func


function output_item_buy_links (ID) {
	oib_i = find_item (ID, ID_idx);
	if (oib_i > -1) {

		document.write ('<table align="center" width="1" height="1" border="2" cellpadding="0" cellspacing="0"  style="border-collapse: collapse;" bordercolor="purple"  bgcolor="#330100" >  ');
		document.write ('  	<tr>  ');
		document.write ('  		<td align="left" width="1" valign="top" height="1">');
		document.write ('    		<table width="300" height="1" border="0" cellpadding="0" cellspacing="0"  style="border-collapse: collapse;" bordercolor="red">  ');
		document.write ('  				<tr>  ');
		document.write ('  					<td colspan="2" align="center" valign="middle" height="1" style="font-family: Verdana; color: #808080;">');
		document.write ('						<img src="' + backside_base_URL() + 'images/clerk/buttons_buy_main_images/[InstantDownload].gif" alt="Instant Download heading">');
		document.write ('  					</td>  ');
		document.write ('  				</tr>  ');
		document.write ('  				<tr>  ');
		document.write ('  					<td width="50%"  height="1"  align="center" valign="middle">  ');
		
 		if (items[oib_i][DL_price_idx] > 00) {  // if this isn't free...
		
			if (PP_on) {  // backside.js
				document.write ('						<?php $aip = $_SERVER["REMOTE_ADDR"]; ?> ');
				document.write ('						<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr/mrb/pal=9QQVZHP6UK9L2" method="post"> ');
				document.write ('							<input type="hidden" name="bn" value="phppixie.com"> ');
				document.write ('							<input type="hidden" name="add" value="1"> ');
				document.write ('							<input type="hidden" name="cmd" value="_cart"> ');
				document.write ('							<input type="hidden" name="page_style" value="backside_main_style">  ');
				document.write ('							<input type="hidden" name="rm" value="1"> ');
				document.write ('							<input type=hidden name=business value=paypal@behavioralartsdisciples.org> ');
				document.write ('							<input type=hidden name=item_name value="' + items[oib_i][title_idx] + ' - download"> ');
				document.write ('							<input type=hidden name=item_number value="' + ID + '"> ');
				document.write ('							<input type=hidden name=amount value=' + items[oib_i][DL_price_idx] + '> ');
				document.write ('							<input type=hidden name=currency_code value=USD> ');
				document.write ('							<input type=hidden name=image_url value=http://backsideoflove.com/images/[BacksideOfLove]_01.gif> ');
				document.write ('							<input type=hidden name=return value=http://backsideoflove.com/clerk/DL_order_okay.html> ');
				document.write ('							<input type=hidden name=cancel_return value=http://backsideoflove.com/clerk/DL_order_cancel.html> ');
				document.write ('							<input type=hidden name=custom value=CART> ');
				document.write ('							<input type=image src="' + backside_base_URL() + 'images/clerk/buttons_buy_main_images/buttons_buy_main_add_to_cart.jpg" name="submit" alt="Add this download to your cart"     > ');
				document.write ('							<input type="hidden" name="notify_url" value="http://backsideoflove.com/clerk/downloads/download/pixie.php"> ');
				document.write ('						</form> ');
			}  // if PP_on
			
			else {  // don't use PP
				//-------------------------------------------------------------------
				// make link directly to this item on LuLu if we're not using PP
				//-------------------------------------------------------------------
				document.write ('						<a href="' + LuLu_prefix + items[oib_i][DL_URL_idx] + '"><img src="' + backside_base_URL() + 'images/clerk/buttons_buy_main_images/buttons_buy_main_add_to_cart.jpg" alt="Add this download to your cart" border="0"></a> ');
			}  // else PP off
		} // if price > 00
		else {  // since it's free, provide direct DL link
			output_item_direct_download_link (oib_i);
		}  // else it was free

		document.write ('					</td>  ');
		document.write ('  					<td width="50%"  height="1"  align="center" valign="middle">  ');
		
		if (PP_on) {  // backside.js
			document.write ('						<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> ');
			document.write ('							<input type="hidden" name="cmd" value="_cart"> ');
			document.write ('							<input type="hidden" name="page_style" value="backside_main_style">  ');
			document.write ('							<input type="hidden" name="business2" value="paypal@behavioralartsdisciples.org"> ');
			document.write ('							<input type="image" src="' + backside_base_URL() + 'images/clerk/buttons_buy_main_images/buttons_buy_main_check_out.jpg" border="0" name="submit" alt="Check out"> ');
			document.write ('							<input type="hidden" name="display" value="1">');
			document.write ('						</form> ');
		}  // if PP_on
		else {
			document.write ('						<img src="' + backside_base_URL() + 'images/clerk/buttons_buy_main_images/buttons_buy_main_check_out.jpg" border="0" alt="Check out"> ');
		}  // else PP off
		
		document.write ('					</td>  ');
		document.write ('  				</tr>  ');
		document.write ('  				<tr>  ');
		document.write ('  					<td colspan="2" height="1">  ');
		document.write ('							<img src="' + backside_base_URL() + 'images/pixel_purple_light.gif" width="90%" height="3" align="center">  ');
		document.write ('  					</td>  ');
		document.write ('  				</tr>  ');
		document.write ('  				<tr>  ');
		document.write ('  					<td colspan="2" height="1" align="center" valign="top" style="font-family:Verdana; font-size: 9pt; color:#808080;" >  ');
		document.write ('						(or click here to have a printed version shipped to you)<br />');
		document.write ('						<a target="_blank" href="' + print_prefix + items[oib_i][print_URL_idx] + '" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'order_printed_copy\',\'\',\'buttons_buy_main_images/buttons_buy_main_print_over.jpg\',1)">  ');
		document.write ('							<img src="' + backside_base_URL() + 'images/clerk/buttons_buy_main_images/buttons_buy_main_print.jpg" alt="Order a printed copy of this book" width="225" height="49" border="0" />  ');
		document.write ('						</a>  ');
		document.write ('					</td>  ');
		document.write ('				</tr>  ');
          document.write ('			</table>  ');  // inner
		document.write ('		</td>');
		document.write ('		<td align="center" valign="middle" > ');		
		document.write (			make_excerpts_link_vertical (ID));
		document.write ('			<br /><br />');
		document.write ('			<img src="' + backside_base_URL() + '/audio/audio_icon.jpg" alt="(audio excerpts Coming Soon!)">');
								// REM -- AUDIO_EXCERPT CONTROLS HAS A TABLE-DISPLAY ERROR!!
								// if (is_audio_excerpt_available (ID)) audio_excerpt_controls (ID);
		document.write ('		</td>  ');
          document.write ('	</tr>  ');
          document.write ('</table>  ');  // outer
	} // if found
} // func


// display link for directly downloading free items
function output_item_direct_download_link (oiddl_i) {
	document.write ('<a href="' + readery_URL_prefix + items[oiddl_i][ID_idx] + '/' + items[oiddl_i][ID_idx] + '.zip"><img border="0" src="' + backside_base_URL() + 'images/clerk/button_download_directly_small_text.gif"></a>');
} // func


function output_item_buy_links_SUMMARY (ID) {
	oib_i = find_item (ID, ID_idx);

	if (oib_i > -1) {
		document.write ('    <table>');
		document.write ('  	<tr>');
		document.write ('  		<td valign="middle">');
		
		// if it isn't a free item...
 		if (items[oib_i][DL_price_idx] > 00) {  // if this isn't free...
			document.write ('			<?php $aip = $_SERVER["REMOTE_ADDR"]; ?> ');
			document.write ('			<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr/mrb/pal=9QQVZHP6UK9L2" method="post"> ');
			document.write ('				<input type="hidden" name="bn" value="phppixie.com"> ');
			document.write ('				<input type="hidden" name="add" value="1"> ');
			document.write ('				<input type="hidden" name="cmd" value="_cart"> ');
			document.write ('				<input type="hidden" name="page_style" value="backside_main_style">  ');
			document.write ('				<input type="hidden" name="rm" value="1"> ');
			document.write ('				<input type=hidden name=business value=paypal@behavioralartsdisciples.org> ');
			document.write ('				<input type=hidden name=item_name value="' + items[oib_i][title_idx] + ' - download"> ');
			document.write ('				<input type=hidden name=item_number value="' + ID + '"> ');
			document.write ('				<input type=hidden name=amount value=' + items[oib_i][DL_price_idx] + '> ');
			document.write ('				<input type=hidden name=currency_code value=USD> ');
			document.write ('				<input type=hidden name=image_url value=http://backsideoflove.com/images/[BacksideOfLove]_01.gif> ');
			document.write ('				<input type=hidden name=return value=http://backsideoflove.com/clerk/DL_order_okay.html> ');
			document.write ('				<input type=hidden name=cancel_return value=http://backsideoflove.com/clerk/DL_order_cancel.html> ');
			document.write ('				<input type=hidden name=custom value=CART> ');
			document.write ('				<input type=image border="1" src="'  + backside_base_URL() + 'images/clerk/button_cart_add_small_text.gif"    name="submit" alt="Add this download to your cart"     > ');
			document.write ('				<input type="hidden" name="notify_url" value="http://backsideoflove.com/clerk/downloads/download/pixie.php"> ');
			document.write ('			</form> ');
		}  // if > 0.00
		else {  // else its free
			output_item_direct_download_link (oib_i);
		}  // else it was free
		document.write ('		</td>  ');
		document.write ('  		<td valign="middle>>  ');
		document.write ('			<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> ');
		document.write ('				<input type="hidden" name="cmd" value="_cart"> ');
		document.write ('				<input type="hidden" name="page_style" value="backside_main_style">  ');
		document.write ('				<input type="hidden" name="business2" value="paypal@behavioralartsdisciples.org"> ');
		document.write ('				<input type="image" src="' + backside_base_URL() + 'images/clerk/button_cart_checkout_small_text.gif" border="0" name="submit" alt="Check out"> ');
		document.write ('				<input type="hidden" name="display" value="1">');
		document.write ('			</form> ');
		document.write ('		</td>  ');
		document.write ('  		<td valign="top">  ');
		document.write ('			<a href="javascript:document_window(\'' + make_excerpts_URL(ID) + '\')"><img src="' + backside_base_URL() + 'images/clerk/button_excerpts_smaller_vertical.gif" border="0"></a>');
//		document.write ('			<a href="javascript:document_window(\'' + make_excerpts_URL(ID) + '\')" target="_blank"><img src="' + backside_base_URL() + 'images/clerk/button_excerpts_smaller_vertical.gif" border="0"></a>');
		document.write ('  		</td>  ');
		document.write ('  	</tr>  ');
        document.write ('  </table>  ');
	} // if 
} // func


// ================================  ECOMMERCE ROUTINES   =========================================


function make_thumb_URL (ID) {
	make_thumb_URL_s = ('<img align="right" border="0" src="' + readery_URL_prefix + ID + '/' + ID + thumbnail_suffix + '">');
	return make_thumb_URL_s;						
} // func


function make_excerpts_link (ID) {
	make_excerpts_URL_s = ('<a target="_blank" href="' + readery_URL_prefix + ID + '/' + ID + '_excerpts.html"><img src="' + backside_base_URL() + 'images/clerk/button_excerpts_small.gif" border="0" alt="Click here for free samples of this piece" align="top"></a>');
	return make_excerpts_URL_s;						
} // func


function make_excerpts_URL (ID) {
	make_excerpts_URL_s = (readery_URL_prefix + ID + '/' + ID + '_excerpts.html');
	return make_excerpts_URL_s;							
} // func


function make_excerpts_link_large (ID) {
	make_excerpts_URL_s = ('<a target="_blank" href="' + readery_URL_prefix + ID + '/' + ID + '_excerpts.html"><img src="' + backside_base_URL() + 'images/clerk/button_excerpts_small.gif" border="0" align="top"  alt="Click here for free samples of this piece" ></a>');
	return make_excerpts_URL_s;						
} // func


function make_excerpts_link_vertical (ID) {
	make_excerpts_URL_url = (readery_URL_prefix + ID + '/' + ID + '_excerpts.html');
	make_excerpts_URL_s = ('javascript:document_window(\'' + make_excerpts_URL_url + '\');');
	make_excerpts_URL_s = ('<a href="' + make_excerpts_URL_s + '"><img src="' + backside_base_URL() + 'images/clerk/button_excerpts_small_vertical.gif" border="0" align="top"  alt="Click here for free samples of this piece" ></a>');
	return make_excerpts_URL_s;						
} // func


function display_image (ID, leftright) {
	di_i = find_item(ID, ID_idx);
	if (di_i > -1) 	di_s = items[di_i][title_idx];
		else di_s = "Backside of Love original spanking stores & adult ageplay stories";
	display_image_s = (readery_URL_prefix + ID + '/' + ID + '.jpg');
	display_image_s = ('<img src="' + display_image_s + '" bder="0" align="' + leftright + '" alt="' + di_s + '">');
	document.write (display_image_s);
} // func


function jump_to_inventory_item (ID) {
	make_main_link_i = find_item (ID, ID_idx);
	if (make_main_link_i > -1)
		document.write ('document.location = "' + readery_URL_prefix + 'display_item.html?' + ID);
	else
		make_main_link_s = '';
} // func


function make_main_link (ID) {
	make_main_link_s = '';
	make_main_link_i = find_item (ID, ID_idx);
	if (make_main_link_i > -1)
		make_main_link_s = ('<a target="_blank" href="' + readery_URL_prefix + 'display_item.html?' + ID + '">' + items[make_main_link_i][01] + '</a>');
	return make_main_link_s;						
} // func


function make_author_link (ID, link_it) {
	make_author_link_i = find_item (ID, ID_idx);
	
	if (make_author_link_i > -1) {
		if (link_it > 00)
			make_author_link_s = ('<a target="_blank" href="' + items[make_author_link_i][author_email_idx] + '">' + items[make_author_link_i][author_idx] + '</a>')
		else
			make_author_link_s = (items[make_author_link_i][author_idx]);
	}
	else
		make_author_link_s = '';
	return make_author_link_s;						
} // func


function cart_checkout () {
		document.write ('			<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> ');
		document.write ('				<input type="hidden" name="cmd" value="_cart"> ');
		document.write ('				<input type="hidden" name="page_style" value="backside_main_style">  ');
		document.write ('				<input type="hidden" name="business2" value="paypal@behavioralartsdisciples.org"> ');
		document.write ('				<input type="image" src="' + backside_base_URL() + 'images/clerk/button_cart_checkout_small.gif" border="0" name="submit" alt="Check out"> ');
		document.write ('				<input type="hidden" name="display" value="1">');
		document.write ('			</form> ');
} // func


function output_catalog_entry (ois_i, should_show_descript, should_show_thumbnail) {
	if (debug) debug_report ('output_catalog_entry<BR>');
	output_i = ois_i;
	output_s = "";
	if (output_i > -1) {
		document.write ('<table border="0" bordercolor="#808080" style="border-collapse:collapse;" cellpadding="0" cellspacing="0" width="100%"><tr>');
		document.write (	'<td valign="middle" align="left" class="readery_catalog">');
		document.write (		'<b><a href="' + readery_URL_prefix + 'display_item.html?' + items[output_i][ID_idx] + '">');
	} // if
	document.write ( items[output_i][title_idx] );
	if (output_i > -1) {
		document.write ('</a></b>');
		if (should_show_descript) {
			document.write (':&nbsp;&nbsp;&nbsp;' + items[output_i][descript_short_idx]);
		} // if should_show_descript
		
		if (items[output_i][pages_idx] != "")
			document.write ('&nbsp;&nbsp;&nbsp;<EM>(' + items[output_i][pages_idx] + '&nbsp;pages)</EM>');
		
		output_item_buy_links_SUMMARY (items[output_i][ID_idx]);

 		if (should_show_thumbnail) {
			document.write ('</td><td width="1" align="right" valign="middle">');
			document.write ( '<a href="' + readery_URL_prefix + 'display_item.html?' + items[output_i][ID_idx] + '">' + make_thumb_URL (items[output_i][ID_idx]) + '</a>');
		} // if

		document.write (		'</td>');
		document.write (	'</tr>');
		document.write (	'<tr>');
		document.write (		'<td colspan="2" height="35" align="center" valign="middle">');
		document.write (			'<img src="http://backsideoflove.com/images/pixel_darkpurple.gif" width="90%" height="3">');
		document.write (		'</td>');
		document.write (	'</tr>');
		document.write ('</table>');
	}	// if
} // func


function output_items (target_s, target_idx, should_show_descripts, should_show_thumbnail) {
	found_i = -1;
	if (debug) debug_report ('OUTPUT_ITEMS - target = "' + target_s + '"   target_idx = "' + target_idx + '"<BR>');
    for (find_i = 0; find_i < number_of_items; find_i++) {
         if (items[find_i][target_idx] == target_s) 
              output_catalog_entry (find_i, should_show_descripts, should_show_thumbnail);
	}
} // func


function summarize_items (target_s, target_idx) {
	found_i = -1;
	if (debug) debug_report ('OUTPUT_ITEMS - target = "' + target_s + '"   target_idx = "' + target_idx + '"<BR>');
	for (find_i = 0; find_i < number_of_items; find_i++) {
         if (items[find_i][target_idx] == target_s) { 
			document.write ('*&nbsp;<a href="' + readery_URL_prefix + 'display_item.html?' + items[find_i][ID_idx] + '">' +  items[find_i][title_idx] + '</a><BR />');
		} // if
	} // for
} // func


function output_items_by_author (author, target_s, target_idx, show_descripts, show_thumbnail) {
	found_i = -1;
	if (debug) debug_report ('OUTPUT_ITEMS - target = "' + target_s + '"   target_idx = "' + target_idx + '"<BR>');
	for (find_i = 0; find_i < number_of_items; find_i++) {
		if ((items[find_i][author_idx] == author) && (items[find_i][target_idx] == target_s)) {
			document.write ('<p>');
				output_catalog_entry (find_i, show_descripts, show_thumbnail);
			document.write ('</p>');
		}
	}
} // func


function create_items () {
	if (debug) debug_report ('CREATE_ITEMS<BR>');
	items = new Array(items_max);
	for (i = 0; i < items_max; i++) 
		items[i] = new Array(fields_max);
} // func


function register_item (ID, title, pages, series, DL_price, print_price, DL_URL, print_URL, descript_short, category, subcategory, author, author_email, content_keys, kind, audio_excerpts, audio_URL, descript_long, direct_DL_URL, temp3) {
	if (debug)debug_report ('REGISTER_ITEM = "' + ID + '"');
	number_of_items++;
   	items[number_of_items - 01][ID_idx] = ID;
	items[number_of_items - 01][title_idx] = title;
	items[number_of_items - 01][pages_idx] = pages;
	items[number_of_items - 01][series_idx] = series;
	items[number_of_items - 01][DL_price_idx] = DL_price;
	items[number_of_items - 01][print_price_idx] = print_price;
	items[number_of_items - 01][DL_URL_idx] = DL_URL;     // (w/o the URL prefix)
	items[number_of_items - 01][print_URL_idx] = print_URL;  // (w/o the URL prefix)
	items[number_of_items - 01][descript_short_idx] = descript_short;
	items[number_of_items - 01][category_idx] = category;
	items[number_of_items - 01][subcategory_idx] = subcategory;
	items[number_of_items - 01][author_idx] = author;
	items[number_of_items - 01][author_email_idx] = author_email;
	items[number_of_items - 01][content_keys_idx] = content_keys;
	items[number_of_items - 01][type_idx] = kind;
	items[number_of_items - 01][audio_excerpts_idx] = audio_excerpts;
	items[number_of_items - 01][audio_URL_idx] = audio_URL;
	items[number_of_items - 01][descript_long_idx] = descript_long;
	items[number_of_items - 01][direct_DL_idx] = direct_DL_URL;  // free or not?
}  // func


function find_item (target, idx_to_use) {
	if (debug) debug_report ('FIND_ITEM');
	find_item_found_i = -1;
	if (debug) debug_report ('FIND_ITEM -- target = "' + target + '"  idx = "' + idx_to_use + '"');
	for (find_item_i = 0; find_item_i < number_of_items; find_item_i++)
		if (items[find_item_i][idx_to_use] == target)
			find_item_found_i = find_item_i;
	return find_item_found_i;
} // func


function output_others_like_this (target_ID) {
	document.write ('<table align="center" width="90%" border="0" cellpadding="10" cellspacing="0"><tr>');
	document.write ('<td class="readery_catalog" style="background-color:#000033";>');
	document.write ('<b>Other <em>' + items[find_item(target_ID, ID_idx)][category_idx] + '</em> stories in our catalogue:<br><br></b>');
	output_items (items[find_item(target_ID, ID_idx)][category_idx], category_idx, show_descript, dont_show_thumbnail);  // no thumbs no descripts
	document.write ('</td></tr></table>');
} // func


function offer_more_like_this (category) {
	if (items[ID_i][category_idx] == "Ageplay")
		document.write ('<font color="#FFFFFF" size="2">&nbsp;&nbsp;S\'more </font><a href="' + readery_URL_prefix + 'ageplay/index.html"><em><font color="yellow" size="2">Adult Ageplay</font></em></a><font color="#FFFFFF" size="2"> stories, anyone? :)</font>&nbsp;&nbsp;');
	if (items[ID_i][category_idx] == "Spanking")
		document.write ('<font color="#FFFFFF" size="2">&nbsp;&nbsp;S\'more </font><a href="' + readery_URL_prefix + 'spanking/index.html"><em><font color="yellow" size="2">Adoring Discipline</font></em></a><font color="#FFFFFF" size="2"> stories, anyone? :)</font>&nbsp;&nbsp;');
} // func




create_items ();

// CONTENT KEYS: mf ff fm rl nf dd ds xx ** !! verb med water age diaper
// register_item ("ID", "title", "pages", "series",  "DL price", "print price", "download_URL_suffix",  "print_URL_suffix", 
//		"descript_short", 
//		"category", "subcategory", "author", "author_email", "content_keys",  "type",  "audio_excerpts", "audio_URL", 
//		"descript_long", 
//		"temp2", "temp3");


// load in the actual database - so we can have custom versions of BOL_inventory but just 1 copy of the actual data
document.write ('<SCRIPT LANGUAGE="javascript" type="text/javascript" src="http://backsideoflove.com/readery/BOL_inventory_database.js">');
document.write ('</SCRIPT>');



// END BOL_inventory.js


