var smallCartVisible=0;var strTimeOutId;$(document).ready(function() {$("#store_small_cart_toggle_btn").click(function() {if(smallCartVisible==0) {open_small_cart();return false;} else {close_small_cart();return false;}});$("#store_small_cart_container").bind("click mouseover",function(){clearTimeout(strTimeOutId);});});function position_small_cart() {var pos=$("#store_small_cart_toggle_btn").offset();var eWidth=$("#store_small_cart_toggle_btn").outerWidth();var mWidth=$("#store_small_cart_container").outerWidth();var left=(pos.left+90+eWidth-mWidth)+"px";var top=24+pos.top+"px";$("#store_small_cart_container").css({zIndex:5000});} function open_small_cart() {clearTimeout(strTimeOutId);position_small_cart();$("#store_small_cart_container").hide().slideDown("slow");smallCartVisible=1;} function close_small_cart() {clearTimeout(strTimeOutId);$("#store_small_cart_container").fadeOut('slow');smallCartVisible=0;} function update_small_cart(objAjaxRequest) {arrRequest=objAjaxRequest.responseText.split('","");eval(strJS);toggle_loading_div(false);document.getElementById('store_small_cart_container').innerHTML=arrRequest[0];clearTimeout(strTimeOutId);strTimeOutId=setTimeout(close_small_cart,7000);$("#header-bar-cart-total").html(fltTotalPrice);$("#header-bar-cart-items").html(intTotalQty+' Items:');if(typeof(check_auto_reorder_frequency)!='undefined'){check_auto_reorder_frequency();}} function toggle_loading_div(boolTurnLoadingDivOn) {if(boolTurnLoadingDivOn) {document.getElementById('store_small_cart_main').style.display="none";document.getElementById('store_small_cart_main_loading').style.display="block";} else {document.getElementById('store_small_cart_main').style.display="block";document.getElementById('store_small_cart_main_loading').style.display="none";}} function prepare_cart_display(strPageURI,boolScrollCartToBt) {toggle_loading_div(true);if(boolScrollCartToBt==true) {document.location.href=strPageURI+'#header-shopping-cart-no-scroll';$("#store_small_cart_container").addClass('mini_cart_no_scroll');document.getElementById('store_small_cart_container').style.position='fixed';document.getElementById('store_small_cart_container').style.top='20px';document.getElementById('store_small_cart_container').style.left='50%';document.getElementById('store_small_cart_container').style.margin='0 0 0 -230px';document.getElementById('store_small_cart_container').style.display='block';smallCartVisible=1;} else {document.location.href='/'+strPageURI+'#header-shopping-cart';document.getElementById('store_small_cart_container').style.display='block';smallCartVisible=1;}} function remove_from_cart_ajax(strURL) {toggle_loading_div(true);send_ajax_request('update_small_cart',strURL,'POST','',true,true);if(typeof(check_auto_reorder_frequency)!='undefined'){check_auto_reorder_frequency();}} function clear_cart_ajax(strURL) {send_ajax_request('update_small_cart','cart-ajax;cart,clear_cart.html','POST','',true,true);} function update_cart_ajax(strURL) {i=0;strQuantities='';do {intQty=$('#cart_item_qty_'+i).val();if(typeof(intQty)!='undefined') {strQuantities=strQuantities+'&cart_item_qty_'+i+'='+intQty;} if($('input[name="cart_item_auto_order_'+i+'"]').length>0) {if($('input[name="cart_item_auto_order_'+i+'"]:checked').length>0) intRecurring=1;else intRecurring=0;strQuantities=strQuantities+'&cart_item_auto_order_'+i+'='+intRecurring;} i++;} while(intQty);if(typeof($('#auto_reorder_frequency')).val()!='undefined') {strQuantities=strQuantities+'&auto_reorder_frequency='+$('#auto_reorder_frequency').val();} toggle_loading_div(true);send_ajax_request('update_small_cart',strURL+'?'+strQuantities,'POST','',true,true);} function add_to_cart_ajax(strProdSKU,strProdId,boolScrollCartToBt,intQty) {prepare_cart_display(arrGlobals['page_uri'],boolScrollCartToBt);if(typeof(intQty)==="undefined") intQty=document.getElementById('qty_'+strProdId).value;send_ajax_request('update_small_cart',arrGlobals['site_url']+arrGlobals['link_pre']+'cart-ajax;cart,add_to_cart,'+strProdSKU+','+intQty+arrGlobals['link_post'],'POST','',true,true);return false;} function toggle_reorder_frequency() {intReorderCount=$("#store_small_cart_main input[name^='cart_item_auto_order_']:checked").length;if(intReorderCount<1) {if(document.getElementById('auto_reorder_frequency')) {$('#auto_reorder_frequency').attr("disabled",true);$('#autoreorderfrequency_div').hide();}} else {$('#autoreorderfrequency_div').show();$('#auto_reorder_frequency').removeAttr("disabled");}}