function updateCartFromPage(b,c,e){showMainLoading("Updating cart...");var a=$("#priceeach_"+c).html();var d=[{name:"method",value:"bluemelon.products.updatecartentry"}];d.push({name:"cartentryids",value:c});d.push({name:"quantity",value:e});d.push({name:"itemownerid",value:b});$.post("/api/ajax/",d,function(f){$(f).find("rsp").each(function(){if($(this).attr("status")!="ok"){alert("The changes are not saved: "+$(this).attr("errormsg"));hideMainLoading();return}else{warnings=$(this).find("warning");if(warnings.length!=0){var g="";warnings.each(function(){g=g+$(this).text()+"\n"});alert(g)}var h=a*e;$("#itemtotal_"+c).html("$ "+h.toFixed(2));if(e==0){$("#entry_"+c).fadeOut("slow")}updateCartSumaries($(this));updateCartTotals($(this));hideMainLoading()}})})}function changeProduct(a,b){var c="";if(b){c="?cartentryid="+b+"&itemownerid="+a}showQuickPanelPreload(905,"Loading Product panel...");QpRequest=$.get("/snippets/cart/productchanger.qp.seam"+c,function(e,d){if(d!="success"){alert("Product Panel load error : "+$(this).attr("errormsg"));hideQuickPanel();return}$(".quickPanel").html(e);showQuickPanel(905)})}function addProduct(b,c,a){showQuickPanelPreload(905,"Loading Add Product panel...");QpRequest=$.get("/snippets/cart/productselector-item.qp.seam?itemids="+c+"&albumids="+a+"&reloadonclose=true",function(e,d){if(d!="success"){alert("Product Panel load error : "+$(this).attr("errormsg"));hideQuickPanel();return}$(".quickPanel").html(e);showQuickPanel(905)})}function changePosition(a,b){var c="";if(b){c="?itemownerid="+a+"&cartentryid="+b+"&mode=cart"}showQuickPanelPreload(632,"Loading Position panel...");QpRequest=$.get("/snippets/cart/position.qp.seam"+c,function(e,d){if(d!="success"){alert("Position Panel load error : "+$(this).attr("errormsg"));hideQuickPanel();return}$(".quickPanel").html(e);showQuickPanel(632)})}function goBack(a){if(document.referrer.indexOf("http://"+document.domain)==0&&document.referrer!="http://"+document.domain+"/cart/cart.seam"){window.location.replace(document.referrer);return}window.location.replace("http://"+document.domain+"/"+a)}function isInteger(a){return(a.toString().search(/^-?[0-9]+$/)==0)}function incAmount(a,c){var d="#amount-"+c;var b=$(d).val();var e;if(isInteger(b)){b=parseInt(b);e=b+1}else{e=0}$(d).val(e);if(c!="all"){updateCartFromPage(a,c,e)}else{$("#quantity_radio").attr("checked","true")}}function decAmount(a,c){var d="#amount-"+c;var b=$(d).val();var e;if(isInteger(b)){b=parseInt(b);if(b>0){e=b-1}else{e=0}}else{e=0}if(b==e){return}$(d).val(e);if(c!="all"){updateCartFromPage(a,c,e)}else{$("#quantity_radio").attr("checked","true")}}function showBulkPanel(a){showQuickPanelPreload(800,"Loading Bulk panel...");QpRequest=$.get("/snippets/cart/bulk.qp.seam?itemownerid="+a,function(c,b){if(b!="success"){alert("Position Panel load error : "+$(this).attr("errormsg"));hideQuickPanel();return}$(".quickPanel").html(c);showQuickPanel(800)})}function emptyCart(a){showMainLoading("Emptying the Cart...");var b=[{name:"method",value:"bluemelon.products.emptyCart"}];b.push({name:"itemownerid",value:a});$.post("/api/ajax/",b,function(c){$(c).find("rsp").each(function(){if($(this).attr("status")!="ok"){hideMainLoading();alert("The Cart was not emptied: "+$(this).attr("errormsg"));return}else{window.location.replace(unescape(window.location.pathname));return}})})};
