var cols = 3;
var guides = [ 'restroom','matrimony','office','holiday','pirate','zombie' ]
var paypal_biz = 'johnzo@sff.net';
var num_tour_pages =22; 

var guides = {
	'restroom': {
		'display_name': 'Restrooms',
		'icon': 'restroom-icon.png',
		'paypal_item_name': 'Comfort Guide - Restrooms',
		'paypal_amount': '2.99',
		'tour_page': '1'
	},

	'matrimony': {
		'display_name': 'Matrimony',
		'icon': 'matrimony-icon.png',
		'paypal_item_name': 'Comfort Guide - Matrimony',
		'paypal_amount': '2.99',
		'tour_page': '4',
		'extra_linky_text': 'Personalize',
		'extra_linky_onclick': 'show_tour_page(20)'
	},

	'office': {
		'display_name': 'Office',
		'icon': 'office-icon.png',
		'paypal_item_name': 'Comfort Guide - Office',
		'paypal_amount': '2.99',
		'tour_page': '7'
	},

	'holiday': {
		'display_name': 'Holidays',
		'icon': 'holiday-icon.png',
		'paypal_item_name': 'Comfort Guide - Holidays',
		'paypal_amount': '2.99',
		'tour_page': '10',
		'extra_linky_text': 'Greeting Cards',
		'extra_linky_onclick': 'show_tour_page(21)'
	},

	'pirate': {
		'display_name': 'Pirates',
		'icon': 'pirate-icon.png',
		'paypal_item_name': 'Comfort Guide - Pirates',
		'paypal_amount': '2.99',
		'tour_page': '13'
	},

 	'zombie': {
		'display_name': 'Zombies',
		'icon': 'zombie-icon.png',
		'paypal_item_name': 'Comfort Guide - Zombies',
		'paypal_amount': '2.99',
		'tour_page': '16'
	}

};

function show_tour_page(p) {
	hide_entire_tour();
	document.getElementById(p).style.display="block";
}

function hide_entire_tour() {
	document.getElementById('spinner').style.display="none";
	for( var p=0; p < num_tour_pages; p++ ) {
		document.getElementById(p).style.display="none";
	}
}

function make_icon_table() {

	var i = 0;
	var g;

	document.write('<table class="icons">');

	for ( g in guides ) {

		if (i % cols == 0 ) { 
			if ( i > 0 ) { 
				document.write('</tr>');
			}
			document.write('<tr>');
		} 

		i++;

		// add to cart

		document.write('<td class="icon" onClick="show_tour_page(\'' + guides[g].tour_page + '\');" >');
		document.write('<IMG class="icon" src ="images/icons/' + guides[g].icon + '" >');
		document.write('<P class="iconlabel">' + guides[g].display_name + '</P>');
		document.write('<form class="paypal" target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">');
		document.write('<input class="paypal" type="image" src="http://www.paypal.com/en_US/i/btn/btn_cart_SM.gif" border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!">');
		document.write('<input type="hidden" name="add" value="1"><input type="hidden" name="cmd" value="_cart">');
		document.write('<input type="hidden" name="currency_code" value="USD"><input type="hidden" name="lc" value="US",input type="hidden" name="bn" value="PP-ShopCartBF">');
		document.write('<input type="hidden" name="item_name" value="'+ guides[g].paypal_item_name +'">');
		document.write('<input type="hidden" name="amount" value="' + guides[g].paypal_amount + '">');
		document.write('<input type="hidden" name="business" value="' + paypal_biz + '">');
		document.write('<input type="hidden" name="no_shipping" value="2">');
		document.write('</form>');

		//if ( ( guides[g].extra_linky_text != null ) && ( guides[g].extra_linky_onclick != null )) { 
		//	document.write('<P class="linky" onClick="' + guides[g].extra_linky_onclick + '">' + guides[g].extra_linky_text+ '</P>');
		//}

		// buy now!

		//document.write('<form class="paypal" 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="business" value="' + paypal_biz + '">');
		//document.write('<input class="paypal" type="image" src="https://www.paypal.com/en_US/i/btn/view_cart_02.gif" border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!">');
		//document.write('<input type="hidden" name="display" value="1">');
		//document.write('</form>');

		document.write('</td>');

	}

	if ( ! ( i % cols == 0 ) ) {
		document.write('</tr>');
	}
	
	document.write('</table>');

}


