var FoxyDomain = "envision.foxycart.com/";
 
function fc_PreProcess() {
	// do something here before opening the cart... maybe some form error checking?
        // if you don't want the cart to open, say for example if there were some data validation problems you
        // want your customer to fix, then return false from this function instead of true.
	return true;
}
 
function fc_BuildFoxyCart() {
	fc_FoxyCart = "";
	fc_FoxyCart += "<div><table id=\"fc_table\">";
	fc_FoxyCart += "<tr>";
	fc_FoxyCart += "<th>Item</th>";
    // fc_FoxyCart += "<th>Options</th>";
	// fc_FoxyCart += "<th>Code</th>";
	fc_FoxyCart += "<th>Quantity</th>";
	fc_FoxyCart += "<th>Price</th>";
	fc_FoxyCart += "</tr>";
	for (i=0;i<fc_json.products.length;i++) {
		// BEGIN DO NOT EDIT
		fc_BuildFoxyCartRow(fc_json.products[i].name,fc_json.products[i].code,fc_json.products[i].options,fc_json.products[i].quantity,fc_json.products[i].price_each,fc_json.products[i].price);
		// END DO NOT EDIT
	}
	
	var cartTotal = 0;
	var allProducts = '';
	
	for (i=0;i<fc_json.products.length;i++) {
	
		allProducts = allProducts + fc_json.products[i].name + "(" + fc_json.products[i].price_each + ")  --- ";
		//fc_json.products[i].code
		//fc_json.products[i].options
		//fc_json.products[i].quantity
		//
		
		cartTotal = cartTotal + fc_json.products[i].price;
		
	}
	
	fc_FoxyCart += "<tr class='table-footer'><td colspan='3'>Order Total: $" + cartTotal + "</td></tr>";
	
	
	
	fc_FoxyCart += "</table></div>";
	
	
	fc_FoxyCart += "<p style='width: 400px; margin: 8px 0 0 0;'>If buying physical products, a shipping and handling fee of $20.00 will be included on your final invoice which covers the U.S. excluding Alaska and Hawaii.</p>";
	
	
	
	
	fc_FoxyCart += "<form action='' method='post' id='submit-po-area'>";

	fc_FoxyCart += "<input name='products-ordered' type='hidden' value='" + allProducts + "' />";
	
	fc_FoxyCart += "<input name='cart-total' type='hidden' value='" + cartTotal + "' />";
	
	// fc_FoxyCart += "<label for='po_number'>Purchase Order Number: </label>";
	// fc_FoxyCart += "<input name='po_number' type='text' />";
	
	fc_FoxyCart += "<label for='buyerName'>Name: </label>";
	fc_FoxyCart += "<input name='buyerName' class='required' minlength='2' type='text' />";
	
	fc_FoxyCart += "<label for='company'>Company or Organization: </label>";
	fc_FoxyCart += "<input name='company' id='company' type='text' />";
	
	fc_FoxyCart += "<label for='address'>Address:</label>";
	fc_FoxyCart += "<textarea name='address' class='required' minlength='2' id='address'></textarea>";
	
	fc_FoxyCart += "<label for='phone'>Phone: </label>";
	fc_FoxyCart += "<input name='phone' class='required' minlength='10' id='phone' type='text' />";
	
	fc_FoxyCart += "<label for='fax'>Fax: </label>";
	fc_FoxyCart += "<input name='fax' id='fax' type='text' />";
	
	fc_FoxyCart += "<label for='email'>Email Address: </label>";
	fc_FoxyCart += "<input name='email' class='required email' type='text' />";
	
	fc_FoxyCart += "<label for='names'>Student Name(s):<br /><small>(if registering for a class)</small></label>";
	fc_FoxyCart += "<textarea name='names' id='names'></textarea>";
	
	fc_FoxyCart += "<label for='ponum'>PO Number: </label>";
	fc_FoxyCart += "<input name='ponum' id='ponum' type='text' />";
	
	fc_FoxyCart += "<br /><input type='submit' value='Submit Purchase Order' />";
	
	fc_FoxyCart += "</form>"
	
	
	
 
	// fc_FoxyCart is a javascript variable that now holds your shopping cart data
 
	// if you have some products in your cart, why not display it?
	if (fc_json.products.length > 0) {
	
		jQuery("#fc_cart").html(fc_FoxyCart);
		
		jQuery("#submit-po-area").validate();
		
	} else {
		jQuery("#fc_cart").html("");
	}
	
}
 
// This function is called by fc_BuildFoxyCart() for each product in your cart.
// Feel free to edit this function as needed to display each row of your cart.
function fc_BuildFoxyCartRow(fc_name,fc_code,fc_options,fc_quantity,fc_price_each,fc_price) {
	fc_FoxyCart += "<tr>";
	fc_FoxyCart += "<td>" + fc_name + "</td>";
    //	fc_FoxyCart += "<td>" + fc_options + "</td>";
	// fc_FoxyCart += "<td>" + fc_code + "</td>";
	fc_FoxyCart += "<td>" + fc_quantity + "</td>";
	fc_FoxyCart += "<td>$" + fc_price + "<br /><small>($" + fc_price_each + " each)</small></td>";
	fc_FoxyCart += "</tr>";
}