function teaCommerceError(error){alert("Cart Error: \n"+error.responseText);}
function updateMiniCartUI(miniCart,order){miniCart.find("#miniCartTotalPrice").text(order.TotalPriceWithoutFeesFormatted);miniCart.find("#miniCartTotalQuantity").text(order.TotalQuantity);}
function updateProduct(productEle){var variant=productEle.find('select.productVariants').val(),chosenProductId=variant?variant:productEle.attr('productid'),xsltFile=productEle.children('.invokeXSLT').text(),htmlFromServer=TeaCommerce.invokeXSLT(xsltFile,chosenProductId,{umbracoLanguageId:_languageId,async:false});productEle.before(htmlFromServer).remove();}
function updateCartUI(order){jQuery('#totalExVAT .money div').text(order.TotalPriceWithoutFeesWithoutVATFormatted);jQuery('#totalShipping .money div').text(order.Shipping.FeeFormatted);jQuery('#totalPayment .money div').text(order.Payment.FeeFormatted);jQuery('#totalWithoutVAT .money div').text(order.TotalPriceWithoutVATFormatted);jQuery('#totalVAT .money div').text(order.TotalVATWithoutFeesFormatted);jQuery('#totalWithVAT .money div').text(order.TotalPriceWithoutFeesFormatted);jQuery('#cartTotalQuantity').text(order.TotalQuantity);jQuery('#VATPercent').text(order.VATPercent);var cart=jQuery('#cart'),cartClasses=cart.attr('class').split(' '),cartStepClass='';for(i=0;i<cartClasses.length;i++){if(cartClasses[i].indexOf('stepProgress')>-1){cartStepClass=cartClasses[i];break;}}
cart.attr('class',cartStepClass+' '+'items'+order.TotalQuantity);}
function removeOrderLineFromUI(orderlineEle){orderlineEle.remove();}
function updateOrderLineInUI(orderlineEle,orderLine){if(orderLine.Quantity>0){orderlineEle.find('.productQuantity').val(orderLine.Quantity);orderlineEle.find('.productUnitPrice').text(orderLine.UnitPriceFormatted);orderlineEle.find('.productTotalPrice').text(orderLine.TotalPriceFormatted);}else{removeOrderLineFromUI(orderlineEle);}}
function sendCustomerInformation(){var paymentInformation=jQuery("#paymentInformation"),shippingInformation=jQuery("#shippingInformation"),country=paymentInformation.find("#country option:selected");var formObj={company:paymentInformation.find("#company").val(),firstName:paymentInformation.find("#firstName").val(),lastName:paymentInformation.find("#lastName").val(),city:paymentInformation.find("#city").val(),zipCode:paymentInformation.find("#zipCode").val(),streetAddress:paymentInformation.find("#streetAddress").val(),country:country.text(),ISOCountryCode:country.attr("ISOCountryCode"),phone:paymentInformation.find("#phone").val(),email:paymentInformation.find("#email").val(),comments:jQuery("#comments").val(),shipping_firstName:shippingInformation.find("#shippingFirstName").val(),shipping_lastName:shippingInformation.find("#shippingLastName").val(),shipping_streetAddress:shippingInformation.find("#shippingStreetAddress").val(),shipping_zipCode:shippingInformation.find("#shippingZipCode").val(),shipping_city:shippingInformation.find("#shippingCity").val(),shipping_ISOCountryCode:country.attr("ISOCountryCode")};var pageValidateText='';if(formObj.firstName===''){pageValidateText+='\n'+paymentInformation.find("#firstName").prev().text();}
if(formObj.lastName===''){pageValidateText+='\n'+paymentInformation.find("#lastName").prev().text();}
if(formObj.city===''){pageValidateText+='\n'+paymentInformation.find("#city").prev().text();}
if(formObj.zipCode===''){pageValidateText+='\n'+paymentInformation.find("#zipCode").prev().text();}
if(formObj.streetAddress===''){pageValidateText+='\n'+paymentInformation.find("#streetAddress").prev().text();}
if(formObj.phone===''){pageValidateText+='\n'+paymentInformation.find("#phone").prev().text();}
if(formObj.email===''){pageValidateText+='\n'+paymentInformation.find("#email").prev().text();}
if(pageValidateText!=''){pageValidateText='Remember to fill out'+pageValidateText;alert(pageValidateText);return false;}
TeaCommerce.setCurrentCountry(paymentInformation.find('#country').val(),{async:false});TeaCommerce.updateOrderProperties(formObj,{async:false});return true;}
