/*
 * Copyright 2010 Hen's Teeth Network. All rights reserved.
 *
 * JS for use site-wise in every page
 */

function updateMiniCart()
{
	 $.ajax({
	 type: "POST",
	 url: "/cgi-bin/commerce.cgi",
	 async: false,
	 dataType: "json",
	 data: {display: "action", template: "PDGCommTemplates/HTN/MiniCartJSON.html"},
	 dataFilter: function(data, type) {
	 // remove the last comma from the list
		return data.slice(0, data.length-2) + "]}";
		
	 },
	 success: display_mini_cart,
	 error:  display_mini_cart
	});
}

function display_mini_cart(data)
{
	var itemcount = 0;
	var subtototal = 0;
	
	itemcount = data.minicart[0].itemcount;
	subtotal =  data.minicart[0].subtotal;
	
	$('#miniSubtotal').html(subtotal);
	$('#miniItemcount').html(itemcount);
	$('#miniCart').show();
	
	$('#bminiSubtotal').html(subtotal);
	$('#bminiItemcount').html(itemcount);
	$('#bminiCart').show();
}


// On Document Ready, Do these things:
$(function()
{
	updateMiniCart();		   
});

$(document).ready(function() {
	$(".breadcrumbs").children('a:first').attr('href','/cgi-bin/commerce.cgi?listcategories');
	$(".breadcrumbs").children('a:first').html('Home');
});

