//<script language="Javascript1.3">
var pbb_levels = new Array();
var pbb_semi_levels = new Array();
var pbb_ann_levels = new Array();
var cds_levels = new Array();
var cds_semi_levels = new Array();
var cds_ann_levels = new Array();
var levels_price = new Array();
var levels_name = new Array();

var num_ab = 0;
var num_pb = 0;
var level_type = "";
var new_month_level = null;
var new_semi_level = null;
var new_ann_level = null;
var new_mem_level = null;
var new_pay_level = null;

pbb_levels[1] = "BronzeMonth";
pbb_levels[2] = "SingleMonth";
pbb_levels[4] = "SilverMonth";
pbb_levels[6] = "GoldMonth";
pbb_levels[9] = "DiamonMonth";
pbb_levels[12] = "PlatinMonth";
pbb_levels[15] = "Book15Month";

pbb_semi_levels[1] = "BronzeSemi";
pbb_semi_levels[2] = "SingleSemi";
pbb_semi_levels[4] = "SilverSemi";
pbb_semi_levels[6] = "GoldSemi";
pbb_semi_levels[9] = "DiamonSemi";
pbb_semi_levels[12] = "PlatinSemi";
pbb_semi_levels[15] = "Book15Semi";

pbb_ann_levels[1] = "BronzePlus";
pbb_ann_levels[2] = "SinglePlus";
pbb_ann_levels[4] = "SilverPlus";
pbb_ann_levels[6] = "GoldPlus";
pbb_ann_levels[9] = "DiamonPlus";
pbb_ann_levels[12] = "PlatinPlus";
pbb_ann_levels[15] = "Book15Plus";

cds_levels[1] = "CD1Month";
cds_levels[2] = "CD2Month";
cds_levels[3] = "CD3Month";
cds_levels[4] = "CD4Month";
cds_levels[5] = "CD5Month";
cds_levels[6] = "CD6Month";

cds_semi_levels[1] = "CD1Semi";
cds_semi_levels[2] = "CD2Semi";
cds_semi_levels[3] = "CD3Semi";
cds_semi_levels[4] = "CD4Semi";
cds_semi_levels[5] = "CD5Semi";
cds_semi_levels[6] = "CD6Semi";

cds_ann_levels[1] = "CD1Plus";
cds_ann_levels[2] = "CD2Plus";
cds_ann_levels[3] = "CD3Plus";
cds_ann_levels[4] = "CD4Plus";
cds_ann_levels[5] = "CD5Plus";
cds_ann_levels[6] = "CD6Plus";

levels_price['SingleMonth'] = 14.49;
levels_price['BronzeMonth'] = 10.99;
levels_price['SilverMonth'] = 17.99;
levels_price['GoldMonth'] = 24.99;
levels_price['PlatinMonth'] = 40.99;
levels_price['DiamonMonth'] = 32.99;
levels_price['Book15Month'] = 50.99;
levels_price['Kid2Month'] = 13.99;
levels_price['Kid4Month'] = 16.99;
levels_price['Kid6Month'] = 23.99;
levels_price['CD1Month'] = 22.49;
levels_price['CD2Month'] = 27.49;
levels_price['CD3Month'] = 37.99;
levels_price['CD4Month'] = 47.99;
levels_price['CD5Month'] = 59.99;
levels_price['CD6Month'] = 70.99;

levels_price['BronzePlus'] = 129.99;
levels_price['SinglePlus'] = 168.99;
levels_price['SilverPlus'] = 200.99;
levels_price['GoldPlus'] = 287.99;
levels_price['PlatinPlus'] = 471.99;
levels_price['BronzeSemi'] = 64.99;
levels_price['SingleSemi'] = 84.99;
levels_price['SilverSemi'] = 100.99;
levels_price['GoldSemi'] = 145.99;
levels_price['PlatinSemi'] = 238.99;
levels_price['DiamonSemi'] = 191.99;
levels_price['DiamonPlus'] = 379.99;
levels_price['Book15Plus'] = 586.99;
levels_price['Book15Semi'] = 296.90;
levels_price['CD1Semi'] = 129.49;
levels_price['CD1Plus'] = 254.49;
levels_price['CD2Semi'] = 159.49;
levels_price['CD2Plus'] = 318.49;
levels_price['CD3Semi'] = 222.49;
levels_price['CD3Plus'] = 439.49;
levels_price['CD4Semi'] = 279.49;
levels_price['CD4Plus'] = 555.49;
levels_price['CD5Semi'] = 349.49;
levels_price['CD5Plus'] = 694.49;
levels_price['CD6Semi'] = 413.49;
levels_price['CD6Plus'] = 822.49;


levels_name['BronzeMonth'] = "Paperback Books<br />2 at-a-time<br /><a style='cursor: pointer; color: rgb(0, 51, 153); text-decoration: underline; font-size: 10pt; font-weight:normal' href='javascript:myRequest.queuePost(\"/include/single.php\", \"null=null\", \"float_div\");'>Single, 2 book order</a>";
levels_name['SingleMonth'] =  "Paperback Books<br />2 at-a-time<br /><a style='cursor: pointer; color: rgb(0, 51, 153); text-decoration: underline; font-size: 10pt; font-weight:normal' href='javascript:myRequest.queuePost(\"/include/orders.php\", \"null=null\", \"float_div\");'>Two, 1 book orders</a>";
levels_name['SilverMonth'] =  "Paperback Books<br />4 at-a-time<br /><a style='cursor: pointer; color: rgb(0, 51, 153); text-decoration: underline; font-size: 10pt; font-weight:normal' href='javascript:myRequest.queuePost(\"/include/orders.php\", \"null=null\", \"float_div\");'>Two, 2 book orders</a>";
levels_name['GoldMonth'] =  "Paperback Books<br />6 at-a-time<br /><a style='cursor: pointer; color: rgb(0, 51, 153); text-decoration: underline; font-size: 10pt; font-weight:normal' href='javascript:myRequest.queuePost(\"/include/orders.php\", \"null=null\", \"float_div\");'>Three, 2 book orders</a>";
levels_name['PlatinMonth'] =  "Paperback Books<br />12 at-a-time<br /><a style='cursor: pointer; color: rgb(0, 51, 153); text-decoration: underline; font-size: 10pt; font-weight:normal' href='javascript:myRequest.queuePost(\"/include/orders.php\", \"null=null\", \"float_div\");'>Four, 3 book orders</a>";
levels_name['DiamonMonth'] =  "Paperback Books<br />9 at-a-time<br /><a style='cursor: pointer; color: rgb(0, 51, 153); text-decoration: underline; font-size: 10pt; font-weight:normal' href='javascript:myRequest.queuePost(\"/include/orders.php\", \"null=null\", \"float_div\");'>Three, 3 book orders</a>";
levels_name['Book15Month'] =  "Paperback Books<br />15 at-a-time<br /><a style='cursor: pointer; color: rgb(0, 51, 153); text-decoration: underline; font-size: 10pt; font-weight:normal' href='javascript:myRequest.queuePost(\"/include/orders.php\", \"null=null\", \"float_div\");'>Five, 3 book orders</a>";

levels_name['CD1Month'] =  "CD &amp; MP3-CD Audiobooks<br />1 at-a-time";
levels_name['CD2Month'] = "CD &amp; MP3-CD Audiobooks<br />2 at-a-time";
levels_name['CD3Month'] = "CD &amp; MP3-CD Audiobooks<br />3 at-a-time";
levels_name['CD4Month'] = "CD &amp; MP3-CD Audiobooks<br />4 at-a-time";
levels_name['CD5Month'] = "CD &amp; MP3-CD Audiobooks<br />5 at-a-time";
levels_name['CD6Month'] = "CD &amp; MP3-CD Audiobooks<br />6 at-a-time";

levels_name['BronzeSemi'] = levels_name['BronzeMonth'];
levels_name['BronzePlus'] = levels_name['BronzeMonth'];
levels_name['SingleSemi'] = levels_name['SingleMonth'];
levels_name['SinglePlus'] = levels_name['SingleMonth'];
levels_name['SilverSemi'] = levels_name['SilverMonth'];
levels_name['SilverPlus'] = levels_name['SilverMonth'];
levels_name['GoldSemi'] = levels_name['GoldMonth'];
levels_name['GoldPlus'] = levels_name['GoldMonth'];
levels_name['PlatinSemi'] = levels_name['PlatinMonth'];
levels_name['PlatinPlus'] = levels_name['PlatinMonth'];
levels_name['DiamonSemi'] = levels_name['DiamonMonth'];
levels_name['DiamonPlus'] = levels_name['DiamonMonth'];
levels_name['Book15Semi'] = levels_name['Book15Month'];
levels_name['Book15Plus'] = levels_name['Book15Month'];

levels_name['CD1Semi'] = levels_name['CD1Month'];
levels_name['CD1Plus'] = levels_name['CD1Month'];
levels_name['CD2Semi'] = levels_name['CD2Month'];
levels_name['CD2Plus'] = levels_name['CD2Month'];
levels_name['CD3Semi'] = levels_name['CD3Month'];
levels_name['CD3Plus'] = levels_name['CD3Month'];
levels_name['CD4Semi'] = levels_name['CD4Month'];
levels_name['CD4Plus'] = levels_name['CD4Month'];
levels_name['CD5Semi'] = levels_name['CD5Month'];
levels_name['CD5Plus'] = levels_name['CD5Month'];
levels_name['CD6Semi'] = levels_name['CD6Month'];
levels_name['CD6Plus'] = levels_name['CD6Month'];

function check_level()
{
	if(!new_mem_level)
	{
		window.alert("You have not selected a membership level. Please select the number of books you'd like to have out at a time, then select 'Join Now'");
		return false;
	}
	return true;
}
function changePrice(ab_pb, num_books)
{
	if(ab_pb == "books")
	{
		// reset variables
		new_month_level = null;
		new_semi_level = null;
		new_ann_level = null;
		new_mem_level = null;
		
		document.getElementById('pbb_null').checked = true;
		document.getElementById('cds_null').checked = true;

		//document.getElementById('pb_plan_img').src = '/images/choose_books2.gif';
		//document.getElementById('pb_learn_more').href = 'http://www.booksfree.com/how_it_works.shtml';
		//document.getElementById('pb_plan_img').setAttribute('alt', "Paperback Book Memberships");
	
		document.getElementById('ab_choices').style.display = 'none';
		document.getElementById('pb_choices').style.display = 'block';
		document.getElementById('join_form').action = 'https://www.booksfree.com/cgi-ssl/join1.cgi';
		level_type = "pb";

	}	
	else if(ab_pb == "cds")
	{
		// reset variables
		new_month_level = null;
		new_semi_level = null;
		new_ann_level = null;
		new_mem_level = null;

		document.getElementById('pbb_null').checked = true;
		document.getElementById('cds_null').checked = true;
		
		//document.getElementById('ab_plan_img').src = '/images/choose_cds2.gif';
		//document.getElementById('ab_learn_more').href = 'http://www.booksfree.com/how_it_works.shtml';
		//document.getElementById('ab_plan_img').setAttribute('alt', "Books-On-Cd Memberships");
		
		document.getElementById('ab_choices').style.display = 'block';
		document.getElementById('pb_choices').style.display = 'none';
		document.getElementById('join_form').action = 'https://www.booksfree.com/cgi-ssl/cd_join1.cgi';
		level_type = "ab";
	}

	if(level_type == "pb" && ab_pb == "pb")
	{
		new_month_level = pbb_levels[num_books];
		new_semi_level = pbb_semi_levels[num_books];
		new_ann_level = pbb_ann_levels[num_books];
		changePrice('pay',new_pay_level);
	}
	else if(level_type == "ab" && ab_pb == "ab")
	{
		new_month_level = cds_levels[num_books];
		new_semi_level = cds_semi_levels[num_books];
		new_ann_level = cds_ann_levels[num_books];
		changePrice('pay',new_pay_level);
	}
	// they are choosing a payment type
	else if(ab_pb == "pay")
	{	
		new_pay_level = num_books;
		
		if(num_books == 1)
		{
			new_mem_level = new_month_level;
			new_level_price_time = "Month";
			
			for(var lvkey in pbb_levels)
			{
				document.getElementById('pbb_'+lvkey+'_price').innerHTML = '$'+levels_price[pbb_levels[lvkey]];
			}
			for(var lvkey in cds_levels)
			{
				document.getElementById('cds_'+lvkey+'_price').innerHTML = '$'+levels_price[cds_levels[lvkey]];
			}
		}
		else if(num_books == 6)
		{
			new_mem_level = new_semi_level;
			new_level_price_time = "6 Months";
			for(var lvkey in pbb_semi_levels)
			{
				document.getElementById('pbb_'+lvkey+'_price').innerHTML = '$'+levels_price[pbb_semi_levels[lvkey]];
			}
			for(var lvkey in cds_semi_levels)
			{
				document.getElementById('cds_'+lvkey+'_price').innerHTML = '$'+levels_price[cds_semi_levels[lvkey]];
			}
		}
		else if(num_books == 12)
		{
			new_mem_level = new_ann_level;
			new_level_price_time = "Year";
			for(var lvkey in pbb_ann_levels)
			{
				document.getElementById('pbb_'+lvkey+'_price').innerHTML = '$'+levels_price[pbb_ann_levels[lvkey]];
			}
			for(var lvkey in cds_ann_levels)
			{
				document.getElementById('cds_'+lvkey+'_price').innerHTML = '$'+levels_price[cds_ann_levels[lvkey]];
			}
		}
		

	}

	if(new_mem_level)
	{
		document.getElementById('mem_level').value = new_mem_level;
	}
}

//</script>
