var Cart={};Cart.addItem=function(b,c){var a=Cart.sendItem(b,c)};Cart.sendItem=function(c){var a=c.serialize({hash:false,submit:false});var b={parameters:a,onSuccess:Cart.itemAddOK,onFailure:Cart.itemAddFailed};Cart.Funcs.ajaxRequest("/catalog/add-item",b)};Cart.Funcs={ajaxRequest:function(a,b){new Ajax.Request(a,b)},redirect:function(a){window.location=a},reload:function(){window.location.reload()},alert:function(a){alert(a)}};Cart.itemAddOK=function(c){if(!c.responseJSON){var b;if(c.responseText){b=c.responseText.stripTags()}else{b=Object.inspect($H(c))}jsError(b);Cart.Funcs.alert("Internal error.  Webmaster notified.");return}var a=c.responseJSON;Cart.logEvent(a);Cart.showCart();Cart.updateCartDisplay(a);Cart.notifyCustomer(a);Cart.Funcs.redirect("/catalog/cart")};Cart.itemAddFailed=function(a){alert("Add-item failed: "+a.status)};Cart.updateCartDisplay=function(a){Cart.updateItemCount(a.itemCount);Cart.updateTotalCost(a.totalCost)};Cart.notifyCustomer=function(a){};Cart.startPage=function(){Cart.getStats()};Cart.getStats=function(){var a={onSuccess:Cart.gotStats,onFailure:Cart.failedStats};new Ajax.Request("/catalog/cart/get-stats",a)};Cart.showCart=function(){$("cart-slot").show()};Cart.removeItem=function(a){Cart.doRemoveAction(a)};Cart.empty=function(){if(confirm("Really throw away cart contents?")){Cart.doRemoveAction("all")}};Cart.doRemoveAction=function(a){var b={method:"get",onSuccess:Cart.removeOk,onFailure:Cart.removeFailed};if(a=="all"){b.parameters={all:1}}else{b.parameters={uid:a}}new Cart.Funcs.ajaxRequest("/catalog/cart/remove-item",b)};Cart.removeFailed=function(a){jsError("Cart.empty failure: "+a.responseText+"\n"+a.statusText);alert("Internal error: webmaster notified")};Cart.removeOk=function(a){Cart.Funcs.reload()};Cart.gotStats=function(a){var b=a.responseJSON;Cart.showCart();Cart.updateItemCount(b.itemCount);Cart.updateTotalCost(b.totalCost)};Cart.updateItemCount=function(a){$("item-count").down("span").update(a)};Cart.updateTotalCost=function(a){$("item-total").down("span").update(a)};Cart.failedStats=function(a){};Cart.logEvent=function(a){if(_gaq.push){_gaq.push(["_trackEvent","product",a.action,a.label,a.num])}};
