$(function(){var B=[];var H=false;var I=0;var G=0;var D=false;var F=0;var C=true;var A=function(){if(!H){return }I=0;G=0;D=false;F=0;C=true;$(B).each(function(K){var L=this;if(!L.flat_shipping_rate){I+=L.price_for_user}else{G+=L.flat_shipping_rate}if(L.is_shipping_tbd){D=true}$(L.options).each(function(M){L.options_price=parseInt(L.subform.find("input[id='product_option_value_secret_data_"+this.val()+"']:first").val());if(isNaN(L.options_price)){L.options_price=0}});F+=(L.price_for_user+L.options_price)*L.quantity});C=(!D&&G==0);$order_totals_container=$("#product_order_form_totals");$order_totals_container.html("");$(B).each(function(M){var N=this;if(parseInt(N.quantity)>0){var K=B[M]["standard_ship_time"]=="1"?"day":"days";var P=B[M]["standard_ship_time"]!=""?("Ships in "+B[M]["standard_ship_time"]+" "+K+"<br />"):"";var O="";if(B[M]["flat_shipping_rate"]>0){O=" + "+$.numberToCurrency(N.flat_shipping_rate)+" shipping"}else{if(B[M]["is_shipping_tbd"]){O=' (<a class="form_tips" title="Shipping cost TBD|This item does not qualify for free/flat shipping. We will notify you of exact shipping once we have reviewed the order. WE NEVER CHARGE YOUR CREDIT CARD UNTIL YOUR ITEM HAS SHIPPED and you will be asked to confirm the shipping charges before the item is shipped and your card is charged.">shipping cost TBD</a>)'}else{O=' (<a class="form_tips" title="Free/flat shipping|These items in conjunction with other items in your order will be charged a flat fee based on the order total. FREE SHIPPING FOR ORDERS OVER $50. Shipping costs will be displayed when you add these items to your shopping cart. Even if your order contains some TBD shipping items you will still recieve free/flat shipping based on the order total minus the TBD shipping items.">free/flat shipping prices</a>)'}}var L="";if(N.price_for_user!=N.price_retail_web){L=" (Retail: "+$.numberToCurrency(N.price_retail_web)+")"}$order_totals_container.html($order_totals_container.html()+"<div>"+N.quantity+" x "+N.title+" @ "+$.numberToCurrency(N.price_for_user+N.options_price)+L+'<br /><span class="small quiet"><em>'+O+" "+P+"</em></span></div>")}});var J=C?"These items qualify for free/flat shipping prices":"<!--shipping calculation-->";$order_totals_container.html($order_totals_container.html()+'<div class="product_order_form_totals_subtotal">Subtotal: <strong>'+$.numberToCurrency(F)+'</strong><br /><span class="small quiet"><em>'+J+"</em></span></div>")};var E=function(J,K){if(K){K=K.split("|");B[J]["price_retail_web"]=K[0]?parseFloat(K[0]):0,B[J]["price_retail_web_without_sale"]=K[1]?parseFloat(K[1]):0,B[J]["price_for_user"]=K[2]?parseFloat(K[2]):0,B[J]["standard_ship_time"]=K[3],B[J]["flat_shipping_rate"]=K[4]?parseFloat(K[4]):null,B[J]["is_shipping_tbd"]=K[5]=="true"}};$(".product_order_form").each(function(K){var N=$(this);B[K]={title:"",price_retail_web:0,price_retail_web_without_sale:0,price_for_user:0,standard_ship_time:"",flat_shipping_rate:0,is_shipping_tbd:false,quantity:0,options:[],options_price:0,subform:N};var L=N.find("input[id*='quantity']:first");L.bind("change keyup",function(){B[K]["quantity"]=this.value;A()});L.trigger("change");var M=N.find(":input[id$='_product_line_item_id']:first");M.bind("change",function(){if(this.type=="hidden"){B[K]["title"]=this.title}else{B[K]["title"]=$("option:selected:first",this).attr("title")}secret_data=N.find("input[id='product_line_item_secret_data_"+this.value+"']:first").val();E(K,secret_data);A()});M.trigger("change");var J=N.find(":input[id$='_option_value_id']");J.each(function(O){var P=$(this);B[K]["options"].push(P);if(this.type!="hidden"){P.bind("change",function(){A()})}})});H=true;A()});
