function asm_create_cookie(name,value,expires,path,domain,secure){var today=new Date();today.setTime(today.getTime());if(expires){expires=expires*1000*60*60*24}var expires_date=new Date(today.getTime()+(expires));document.cookie=name+"="+escape(value)+((expires)?";expires="+expires_date.toGMTString():"")+((path)?";path="+path:"")+((domain)?";domain="+domain:"")+((secure)?";secure":"")}function asm_read_cookie(check_name){var i,x,y,ARRcookies=document.cookie.split(';');for(i=0;i0)){for(i=0;i(');tmp_method_name_display=tmp_method_name_display.replace(')',')');results=results+'
';results=results+'
';results=results+' ';results=results+'
';results=results+'
';if((shipping_methods.shipping_rates[i].price=='0.00')&&(asm_fake_standard_rate>0)&&(tmp_method_name_display.toLowerCase().indexOf('call us')!=-1)&&(tmp_method_name_display.toLowerCase().indexOf('quote')==-1))results=results+'
$'+asm_fake_standard_rate+'CALL US
';else if((shipping_methods.shipping_rates[i].price=='0.00')&&(asm_fake_standard_rate>0)&&(tmp_method_name_display.toLowerCase().indexOf('call us')==-1)&&(tmp_method_name_display.toLowerCase().indexOf('quote')!=-1))results=results+'
$'+asm_fake_standard_rate+'QUOTE
';else if((shipping_methods.shipping_rates[i].price=='0.00')&&(asm_fake_standard_rate>0)&&(tmp_method_name_display.toLowerCase().indexOf('call us')==-1)&&(tmp_method_name_display.toLowerCase().indexOf('quote')==-1))results=results+'
$'+asm_fake_standard_rate+'FREE
';else if((shipping_methods.shipping_rates[i].price=='0.00')&&(tmp_method_name_display.toLowerCase().indexOf('call us')!=-1)&&(tmp_method_name_display.toLowerCase().indexOf('quote')==-1))results=results+'
CALL US
';else if((shipping_methods.shipping_rates[i].price=='0.00')&&(tmp_method_name_display.toLowerCase().indexOf('call us')==-1)&&(tmp_method_name_display.toLowerCase().indexOf('quote')!=-1))results=results+'
QUOTE
';else if((shipping_methods.shipping_rates[i].price=='0.00')&&(tmp_method_name_display.toLowerCase().indexOf('call us')==-1)&&(tmp_method_name_display.toLowerCase().indexOf('quote')==-1))results=results+'
FREE
';else results=results+'
$'+shipping_methods.shipping_rates[i].price+'
';results=results+'
'+tmp_method_name_display+'
';results=results+'
';results=results+'
';results=results+'
'}}}document.getElementById('asm-shipping-methods-list').innerHTML=results;if(selected_number!='')asm_select_shipping_methods(selected_number,shipping_methods.shipping_rates.length);else asm_select_shipping_methods(1,shipping_methods.shipping_rates.length);document.getElementById('asm-mini-cart').style.opacity='1';if(document.getElementById('asm-ship-to-city-state'))document.getElementById('asm-ship-to-city-state').style.display='block';if(document.getElementById('asm-ship-to-zip'))document.getElementById('asm-ship-to-zip').style.display='block';if(document.getElementById('asm-ship-to-force-zip'))document.getElementById('asm-ship-to-force-zip').style.display='none';if(document.getElementById('asm-force-zip-apply'))document.getElementById('asm-force-zip-apply').innerHTML='Apply';window.asm_shipping_calculation_flag=false}function asm_mini_cart_shipping(zip,state,country){var shipping_rates;var xhr=new XMLHttpRequest();xhr.onreadystatechange=function(){if(xhr.readyState===4){shipping_rates=xhr.response;var tmp_shipping_methods_check=JSON.parse(shipping_rates);if(shipping_rates=='{"error":["This cart does not require shipping"]}'){asm_alt_cart('empty')}else if((shipping_rates=='{"shipping_rates":[]}')||(typeof tmp_shipping_methods_check.shipping_rates=='undefined')){asm_alt_cart('error')}else{if(shipping_rates=='')console.log('CHECK!');asm_parse_mini_cart_methods(shipping_rates)}}};xhr.open('GET','/cart/shipping_rates.json?shipping_address[zip]='+zip+'&shipping_address[country]='+country+'&shipping_address[province]='+state,true);xhr.send()}function asm_search_standard_rate_value(){for(const[key,value]of Object.entries(standard_rates)){if(parseFloat(key)<=parseFloat(asm_cart_weight_lb)){asm_fake_standard_rate=value}else if(parseFloat(key)>parseFloat(asm_cart_weight_lb)){break}}}function asm_add_insurance_item(variant_id){jQuery.ajax({url:'/cart/add.js',type:'post',dataType:'json',data:{items:[{id:''+variant_id+'',quantity:1}]},success:function(){window.location='/cart'},error:function(){console.log('ASM debug error - adding product ID '+variant_id);asm_ajax_counter=asm_ajax_counter+1;if(asm_ajax_counter<10)asm_add_insurance_item(variant_id)},})}function asm_remove_insurance_item(variant_id){jQuery.ajax({url:'/cart/update.js',type:'post',dataType:'json',data:'updates['+variant_id+']=0',success:function(){window.location='/cart'},error:function(){console.log('ASM debug error - removing product ID '+variant_id);asm_ajax_counter=asm_ajax_counter+1;if(asm_ajax_counter<10)asm_remove_insurance_item(variant_id)},})}function asm_update_insurance_item(old_variant_id,new_variant_id){jQuery.ajax({url:'/cart/update.js',type:'post',dataType:'json',data:'updates['+old_variant_id+']=0',success:function(){jQuery.ajax({url:'/cart/add.js',type:'post',dataType:'json',data:{items:[{id:''+new_variant_id+'',quantity:1}]},success:function(){window.location='/cart'},})},error:function(){console.log('ASM debug error - updating product ID '+new_variant_id+' instead of product ID '+old_variant_id);asm_ajax_counter=asm_ajax_counter+1;if(asm_ajax_counter<10)asm_update_insurance_item(old_variant_id,new_variant_id)},})}function asm_read_cart_data(){var cart_data;var xhr=new XMLHttpRequest();xhr.onreadystatechange=function(){if(xhr.readyState===4){cart_data=JSON.parse(xhr.response);console.log(cart_data);asm_cart_subtotal=cart_data.total_price/100;asm_cart_subtotal=asm_cart_subtotal.toFixed(2);asm_cart_subtotal_visual=asm_cart_subtotal.replace(/\B(?=(\d{3})+(?!\d))/g,',');if(asm_cart_subtotal>0){if(document.getElementById('asm-subtotal-rate'))document.getElementById('asm-subtotal-rate').innerHTML='$'+asm_cart_subtotal_visual;if(cart_data.items){var asm_insurance_product_found=false;for(i=0;i0)){asm_create_insurance_item(asm_existing_insurance_variant_id)}else{}document.getElementById('asm-insurance-cost').innerHTML='$'+asm_insurance;document.getElementById('asm-insurance-option').style.display='block'}}if(auto_calc==false)asm_force_change_zip()}};xhr.open('GET','/cart.js',true);xhr.send()}function asm_create_insurance_item(old_variant_id){var jsel=document.createElement('SCRIPT');jsel.type='text/javascript';jsel.src='https://www.advancedshippingmanager.com/clients/calcs/shopify_cart/minicart/asm_mini_cart.php?si='+Shopify.shop.replace('.myshopify.com','')+'&add_insurance=true&price='+asm_insurance+'&ov='+old_variant_id;document.getElementById('asm-mini-cart').appendChild(jsel)}function asm_toggle_rate(){var tmp_total=document.getElementById('asm-total-rate').innerHTML;if(document.getElementById('asm-toggle-insurance').checked==false){asm_remove_insurance_item(asm_existing_insurance_variant_id)}else if(document.getElementById('asm-toggle-insurance').checked==true){asm_create_insurance_item()}}function asm_mini_cart_activate_enter(evt){evt=(evt)?evt:event;var charCode=(evt.charCode)?evt.charCode:((evt.which)?evt.which:evt.keyCode);if(charCode==13){asm_ship_recalc();return false}else{return true}}function asm_ship_recalc(){window.asm_shipping_calculation_flag=true;if(document.getElementById('asm-force-zip')){auto_calc=true;var asm_zip_code=document.getElementById('asm-force-zip').value;if(asm_zip_code!=''){if(document.getElementById('asm-force-zip-apply'))document.getElementById('asm-force-zip-apply').innerHTML='Calculating...';var jsel=document.createElement('SCRIPT');jsel.type='text/javascript';jsel.src='https://www.advancedshippingmanager.com/clients/calcs/shopify_cart/minicart/asm_mini_cart.php?zip_lookup='+asm_zip_code+'&si='+Shopify.shop.replace('.myshopify.com','');document.getElementById('asm-mini-cart').appendChild(jsel)}}}function asm_change_zip_code(){if(document.getElementById('asm-ship-to-change')){if(document.getElementById('asm-ship-to-change').innerHTML=='CHANGE')document.getElementById('asm-ship-to-change').innerHTML='CLOSE';else document.getElementById('asm-ship-to-change').innerHTML='CHANGE'}if(document.getElementById('asm-ship-to-city-state')){if(document.getElementById('asm-ship-to-city-state').style.display=='block')document.getElementById('asm-ship-to-city-state').style.display='none';else document.getElementById('asm-ship-to-city-state').style.display='block'}if(document.getElementById('asm-ship-to-zip')){if(document.getElementById('asm-ship-to-zip').style.display=='block')document.getElementById('asm-ship-to-zip').style.display='none';else document.getElementById('asm-ship-to-zip').style.display='block'}if(document.getElementById('asm-ship-to-force-zip')){if(document.getElementById('asm-ship-to-force-zip').style.display=='none')document.getElementById('asm-ship-to-force-zip').style.display='block';else document.getElementById('asm-ship-to-force-zip').style.display='none'}}function asm_force_change_zip(){if(document.getElementById('asm-total-rate'))document.getElementById('asm-total-rate').innerHTML='$'+asm_cart_subtotal;if(document.getElementById('asm-mini-cart'))document.getElementById('asm-mini-cart').style.opacity='1';if(document.getElementById('asm-ship-to-city-state'))document.getElementById('asm-ship-to-city-state').style.display='block';if(document.getElementById('asm-ship-to-zip'))document.getElementById('asm-ship-to-zip').style.display='block';if(document.getElementById('asm-ship-to-force-zip'))document.getElementById('asm-ship-to-force-zip').style.display='none';if(document.getElementById('asm-force-zip-apply'))document.getElementById('asm-force-zip-apply').innerHTML='Apply';asm_change_zip_code()}function asm_set_geo_values(city,state,zip,country){var asm_geo_data=city+'~'+state+'~'+zip+'~'+country;sessionStorage.setItem('ASM-Geo-Data',asm_geo_data);if(document.getElementById('asm-ship-to-change'))document.getElementById('asm-ship-to-change').innerHTML='CHANGE';if(document.getElementById('asm-ship-to-city-state'))document.getElementById('asm-ship-to-city-state').innerHTML=city+', '+state;if(document.getElementById('asm-ship-to-zip'))document.getElementById('asm-ship-to-zip').innerHTML='('+zip+')';if(document.getElementById('asm-force-zip'))document.getElementById('asm-force-zip').value=zip;if(auto_calc==true)asm_mini_cart_shipping(zip,state,country)}function asm_geo_location(){if(auto_calc==false){if(document.getElementById('asm-shipping-methods-list'))document.getElementById('asm-shipping-methods-list').innerHTML='';if(document.getElementById('asm-shipping-rate'))document.getElementById('asm-shipping-rate').innerHTML='TBD'}if(sessionStorage.getItem('ASM-Geo-Data')){var asm_geo_data=sessionStorage.getItem('ASM-Geo-Data');var asm_geo_exploded=asm_geo_data.split('~');var city=asm_geo_exploded[0];var state=asm_geo_exploded[1];var zip=asm_geo_exploded[2];var country=asm_geo_exploded[3];asm_set_geo_values(city,state,zip,country)}else{var jsel=document.createElement('SCRIPT');jsel.type='text/javascript';jsel.src='https://www.advancedshippingmanager.com/clients/calcs/shopify_cart/minicart/asm_mini_cart.php?si='+Shopify.shop.replace('.myshopify.com','');document.getElementById('asm-mini-cart').appendChild(jsel)}}function asm_add_event(obj,evType,fn){if(obj.addEventListener){obj.addEventListener(evType,fn,false);return true}else if(obj.attachEvent){var r=obj.attachEvent('on'+evType,fn);return r}else{return false}}function asm_read_checkout_shipping_methods(){var checked_input=false;var form_tags=document.body.getElementsByTagName('form');for(i=0;i