// RestonTech StoreFront
// Copyright (c) 2004 RestonTech, Ltd
// This code is protected by copyright law, duplication is
// expressly prohibited.

// The following routines are part of the RestonTech StoreFront.
// They are intended to be used ONLY with the corresponding
// server-based utilities provided to RestonTech StoreFront
// customers.

// This file holds the data structure that makes up an order, and
// handles the checkout function. Must be used in a frame or window
// that will not change as the visitor goes from page to page.

// Holds all of the to-be-purchased items in an associative array.
// Key = item ID, Value = # of item purchased.
var order = parent.order;

// Mainly serializes the order[] data structure, store_top needs to have
// a form suitable for this use. Data will look like 'key:value\n' repeated.
function checkout() {
//	open("https://secure.restontech.com/store/loading.html","orderframe");
	var temp = "";
	for (i in order) {
		if (order[i] > 0) {
			temp += i + "*" + order[i] + "*";
			} // end if
		} // end for
	if (temp.length < 1) {
		alert("Please make at least one selection before proceeding to checkout.");
		return false;
		}
	cart.order.value = temp.substring(0,temp.length-1);
	cart.submit();
	} // end checkout()

function showcart() {
	var temp = new Array();
	for (i in order) {
		if (order[i] > 0) {
			temp[temp.length] = i;
			} // end if
		} // end for
	if (temp.length < 1) {
		alert("Please make at least one selection before proceeding to checkout.");
		return false;
		}
	var items = temp.join(",");
	var URL = "http://www.americuscd.com/cgi-bin/cart.pl?" + items;
	top.AmericusMain.location.href=URL;
	return false;
	} // end showcart()
