/*
 * minishopcart.js
 * requires
 * <script src="/js/yui/yahoo/yahoo-min.js"></script>
 * <script src="/js/yui/event/event-min.js"></script>
 * <script src="/js/yui/connection/connection-min.js"></script>
 */
var shopCartUrl = "/webapp/wcs/stores/servlet/AjaxShopCartView?storeId=301";
function createShopCartBox(shopcart) {
	var items = document.getElementById("mscitems");
	items.appendChild(document.createTextNode(
        shopcart['itemcount'] + " Item(s) in Bag"));
	var subtotal = document.getElementById("mscsubtotal");
    subtotal.appendChild(document.createTextNode(
        "Subtotal: " + shopcart['subtotal']));
}

var fbCallback = 
{
    success:function(o) {
        var shopcart = eval('(' + o.responseText + ')');
        createShopCartBox(shopcart);
    },
    failure:function(o) {
		createShopCartBox({ itemcount:0, subtotal:'$0.00'});
        //alert('failure');
    },
    timeout: 5000
}

YAHOO.util.Event.onAvailable(
	"mscitems", 
	function(e) {
		YAHOO.util.Connect.initHeader("If-Modified-Since", new Date(), true);
		var trans = YAHOO.util.Connect.asyncRequest(
			'GET', 
			shopCartUrl, 
			fbCallback, 
			null);
		
	}, 
	null, 
	false);