// General purpose routines


	// Change spaces into %20
	function ConvertSpacesToCode(str) {
		var s, i, l;

		s = '';
		l = str.length;
		for (i = 0; i<l; i++) {
			s += (str.charAt(i) == ' ') ? '%20' : str.charAt(i);
			}
		return s;
		}


// Support optional display of additional detailed information

	// Generate toggle details block buttons
	function GenerateToggleDetailsBlockButtons(name) {
		document.write('<span class="detailsLink">\n');
		document.write('	<span id="' + name + 'Details' + '" onclick="javascript: ToggleDetailsBlockDisplay(\'' + name + '\');">Details...</span>\n');
		document.write('	<span id="' + name + 'Less' + '" onclick="javascript: ToggleDetailsBlockDisplay(\'' + name + '\');" style="display:none">Less...</span>\n');
		document.write('</span>\n');
		}


	// Toggle details block display with Details... and Less...
	// Requires 3 elements: <... ID="xxxDetails" onclick="javascript: ToggleDetailsBlockDisplay('xxx');">...</...>
	//						<... ID="xxxLess" onclick="javascript: ToggleDetailsBlockDisplay('xxx'); style="display: none">...</...>
	//						<... ID="xxxDetailsBlock" style="display: none;">...</...>
	function ToggleDetailsBlockDisplay(name) {
		var element;

		element = document.getElementById(name + 'Details');			// Get first element
		if (element.style.display == 'none') {							// Element is hidden...
			element.style.display = '';									// Show first element
			element = document.getElementById(name + 'Less');			// Get second element
			element.style.display = 'none';								// Hide second element
			element = document.getElementById(name + 'DetailsBlock');	// Get third element
			element.style.display = 'none';								// Hide third element

			}
		else {															// Element is showing...
			element.style.display = 'none';								// Hide first element
			element = document.getElementById(name + 'Less');			// Get second element
			element.style.display = '';									// Show second element
			element = document.getElementById(name + 'DetailsBlock');	// Get third element
			element.style.display = '';									// Show third element
			}
		}


// Generate "Add to Cart" button

	function AddToCartButton(buttonNumber,itemNumber,itemName,itemDescription,amount,returnUrl) {
		document.write('<form name="AddToCartButton">\n');
		document.write('<table class="buttonListTable">\n');
		document.write(' <tr>\n');
		document.write('  <td>\n');
		document.write('   <input type="button" \n');
		document.write('    id="AddButton' + buttonNumber + '" \n');
		if (buttonNumber == 0) {
			document.write('    value="Out of stock" \n');
			document.write('    disabled="1" \n');
			}
		else {
			document.write('    value="Add to Cart" \n');
			}
		document.write('    onclick="javascript: window.location = \'');
		document.write('https://www.paypal.com/cgi-bin/webscr?cmd=_cart');
		document.write('&business=4C953D4G39FXE');
		document.write('&lc=US');
		document.write('&item_number=' + itemNumber);
		document.write('&item_name=' + ConvertSpacesToCode(itemName));
		document.write('&on0=Description');
		document.write('&os0=' + ConvertSpacesToCode(itemDescription));
		document.write('&amount=' + amount + '%2e00');
		document.write('&currency_code=USD');
		document.write('&cn=Special%20instructions');
		document.write('&no_shipping=2');
		document.write('&undefined_quantity=1');
		document.write('&add=1');
		document.write('&bn=PP%2dShopCartBF%3abtn_cart_LG%2egif%3aNonHosted');
		document.write('&shopping_url=' + returnUrl);
		document.write('\';"');
		document.write('    />\n');
		document.write('  </td>\n');
		document.write('  <td class ="buttonDescription">\n');
		document.write(itemDescription + ': $' + amount + '.00\n');
		document.write('  </td>\n');
		document.write(' </tr>\n');
		document.write('</table>\n');
		document.write('</form>\n');
		}
