var FoxyDomain = "bourgeoiseyewear.foxycart.com/"; // replace this with your store subdomain
jQuery(document).ready(function(){
	function updateBasket(theForm){
		MyFoxyData = jQuery(theForm).serialize(false);
		MyFoxyID = jQuery(theForm).attr('id');
		// if they defined fc_PreProcess(), let them process the form data before we pass it along
		if (typeof(fc_PreProcess) == 'function') { 
			if (!fc_PreProcess(MyFoxyData, MyFoxyID)) {
				return false;
			}
		}
		href="https://" + FoxyDomain + "cart?" + MyFoxyData;
		
		jQuery.getJSON(href + '&output=json&callback=?' + fc_AddSession(), function(data){
			// Update the fc_json object, so other things can access it
			fc_json = data;
			fc_UpdateCart(FoxyDomain);
		});
	}	

	jQuery("input.foxy_submit").click(function(){
		updateBasket(this.parentNode);
		return false;
	});
	
});
function fc_PreProcess(data, id) {
	// 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 = "";
	for (i=0;i<fc_json.products.length;i++) {
		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);

	}
	// 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) {
		// show the cart if it's not already open
		if (jQuery("#slidingTopContent").is(":visible")) {
		}else{
			jQuery("#slidingTopContent").slideToggle("slow", function(){
					jQuery("#slidingTopFooterLeft").html('<img src="http://www.bourgeoiseyewear.com/bourgeoiswp/wp-content/themes/bourgeois/scripts/sliding-basket/images/arrow-up.png" alt="Hide Cart" /> <a href="aaa.htm" onclick="return false;" id="slidingTopTrigger">Hide Cart</a>');
			});
		};	
		// the actual declaration that moves the cart from a jquery variable to actual html
		jQuery("#basketItemsWrap #cart_content").html(fc_FoxyCart);
		
		// wait for a bit and hide the basket again
		jQuery("#slidingTopTrigger").fadeTo(4000, 1, function(){
			jQuery("#slidingTopContent").slideToggle("slow", function(){
					jQuery("#slidingTopFooterLeft").html('<img src="http://www.bourgeoiseyewear.com/bourgeoiswp/wp-content/themes/bourgeois/scripts/sliding-basket/images/arrow-down.png" alt="Show Cart" /> <a href="aaa.htm" onclick="return false;" id="slidingTopTrigger">Show Cart</a>');
			});
		});
	} else {
		//jQuery("#basketItemsWrap #cart_content").html("<tr><td>You have no items in your basket</td></tr>");	// Use this for a default message when empty
		jQuery("#basketItemsWrap #cart_content").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 += "\n<tr>\n";
	fc_FoxyCart += "<td class=\"item-name\">" + fc_name + "</td>\n";
	fc_FoxyCart += "<td class=\"item-qty\">" + fc_quantity + "</td>\n";
//		fc_FoxyCart += "<td class=\"item-price\">" + fc_price.toFixed(2) + "</td>\n";
//      fc_FoxyCart += "<td>" + fc_options + "</td>";
//      fc_FoxyCart += "<td>" + fc_code + "</td>";
//      fc_FoxyCart += "<td>" + fc_price_each + "</td>";
	fc_FoxyCart += "</tr>\n";
}

