function setupTimeslots(){var ajaxRunning=false;var orderVal=$('#cal-order-value').text();var noTimeSlot=$('#free-del-avail').length>0?'true':'false',tsDate=$('#delivery-preview p:first'),forFreeDel=$('#for-free-del'),slotDelCharge=$('#slot-del-charge');$('#delivery-preview').data('empty',$('#delivery-preview').hasClass('empty'));if($('#no-free-del-avail').length){var noTimeSlot=$('#free-del-avail').is(':visible');}
if($('#no-free-del-avail').length){var noTimeSlot=$('#no-free-del-avail').is(':visible');}
$('#t-delivery-timeslot a').hover(function(e)
{var tdString=$(this).attr('id').split("-"),delString=$(this).attr('rel').split("-"),amount=delString[0]/100,threshold=delString[1]/100;var dateString=new Date(tdString[3],tdString[4]-1,tdString[5]);var delCharge=amount==0?'FREE':'£'+amount.toFixed(2);tsDate.data('oldHtml',tsDate.html()).html(''+dateString.format("dddd")+'
'+dateString.format("dd mmm")+'
'+tdString[1]+':00 - '+tdString[2]+':00');if(noTimeSlot){$('#free-del-avail').hide();$('#for-free-del').show();$('#no-free-del-avail').hide();$('#slot-del-charge').show();}
$('#delivery-preview').removeClass('empty');forFreeDel.data('div0Visible',forFreeDel.find('div:eq(0)').is(':visible'));forFreeDel.data('div1Visible',forFreeDel.find('div:eq(1)').is(':visible'));var toSpend=(delString[1]-orderVal)/100;var thresholdAmount=toSpend<=0?'£0':'£'+toSpend.toFixed(2);forFreeDel.data('delCharge',forFreeDel.find('div:eq(1) p:eq(0) span').text());forFreeDel.find('div:eq(1) p:eq(0) span').text(delCharge);forFreeDel.data('thresholdAmount',forFreeDel.find('div:eq(1) p:eq(1) span').text());forFreeDel.find('div:eq(1) p:eq(1) span').text(thresholdAmount);slotDelCharge.data('delCharge',slotDelCharge.find('div:eq(0) p:eq(0) span').text());slotDelCharge.find('div:eq(0) p:eq(0) span').text(delCharge);if(amount==0){$('#for-free-del').addClass('free');$('#for-free-del').find('> div:eq(0)').show();$('#for-free-del').find('> div:eq(1)').hide();}else{$('#for-free-del').removeClass('free');$('#for-free-del').find('> div:eq(0)').hide();$('#for-free-del').find('> div:eq(1)').show();}
slotDelCharge.find('> div:eq(0)').show();},function(){if(noTimeSlot){$('#free-del-avail').show();$('#for-free-del').hide();$('#no-free-del-avail').show();slotDelCharge.hide();}
if($('#delivery-preview').data('empty')==true){$('#delivery-preview').addClass('empty');}
tsDate.html(tsDate.data('oldHtml'));forFreeDel.find('div:eq(1) p:eq(0) span').text(forFreeDel.data('delCharge'));forFreeDel.find('div:eq(1) p:eq(1) span').text(forFreeDel.data('thresholdAmount'));if(forFreeDel.data('div0Visible')==true){forFreeDel.find('div:eq(0)').show();forFreeDel.find('div:eq(1)').hide();forFreeDel.addClass('free');}
if(forFreeDel.data('div1Visible')){forFreeDel.find('div:eq(0)').hide();forFreeDel.find('div:eq(1)').show();forFreeDel.removeClass('free');}});$('table#t-delivery-timeslot td').find('div:last').css({border:'none'});$('.unavailable, .cutoff').each(function(){var offset=($(this).height()/2)-7,newHeight=($(this).height()-offset);$(this).css({paddingTop:offset,height:newHeight});});$('#cboxLoadedContent #popup-pagination li a').live('click',function(){if(ajaxRunning==false){ajaxRunning=true;$.fn.colorbox({scrolling:false,href:$(this).attr('href'),transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){ajaxRunning=false;setupTimeslots();}});}
return false;});}
function checkCookies()
{if(document.cookie.search(/cfm-test=/i)==-1){document.cookie="cfm-test=cfm-test; path=/";}
if(document.cookie.search(/cfm-test=/i)==-1){alert("You need to enable cookies in your browser in order to use the basket");return false;}else{return true;}}
function buildBasketRow(item,unit)
{var basketRow='
';return basketRow;} function buildFullBasketRow(item,unit) {var basketRow='
';return basketRow;}
$(document).ready(function(){$('a.payment-declined').live('click',function(e){$.fn.colorbox({scrolling:false,href:"/account/payment-declined",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});return false;});$('#info-free-delivery').click(function(e){e.preventDefault();});$('#info-free-delivery').qtip({content:{text:'If you add extra goods to the value shown in green to your basket you will qualify for free delivery. Any third party courier/shipping charges will still apply.'},position:{my:'bottom right',at:'top center'},style:{classes:'ui-tooltip-blue ui-tooltip-shadow ui-tooltip-rounded'}});$('#info-third-party-carriage').click(function(e){e.preventDefault();$.fn.colorbox({scrolling:false,href:"/delivery/third-party",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('#info-delivery').click(function(e){e.preventDefault();$.fn.colorbox({scrolling:false,href:"/delivery/info",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('.deposit-info').live('click',function(e){e.preventDefault();$.fn.colorbox({scrolling:false,href:$(this).attr('href'),transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('#guide-price-modal').live('click',function(e){e.preventDefault();$.fn.colorbox({scrolling:false,href:"/basket/guide-price-info",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('#key-unconfirmed a, #key-confirmed a, #key-processing a, #key-delivered a, #key-holiday a').click(function(e){e.preventDefault();var id=$(this).parent().attr('id');$.fn.colorbox({scrolling:false,href:"/account/"+id,transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('.basket-checkout-order').click(function(e){e.preventDefault();var href=$(this).attr('href'),existing=0;params={'format':'json'};$.getJSON(href,params,function(data){if(data.success){$.fn.colorbox({scrolling:false,href:"/basket/checkout-modal/",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,overlayClose:false,onLoad:function(){$('#cboxClose').remove();},onComplete:function(){$('#modal-third-party-carriage').qtip({content:{text:'The third party carriage charge is the cost of shipping to Scilly via the Steamship Company, the charge shown is the minimum charge for up to 10kg; for details of our current charging structure please view our delivery help section. If you have a Steamship account that you would like to use please email us the account number or contact our customer care team on 01326 371951. Please note free delivery does not apply to this third party charge.'},position:{my:'bottom center',at:'top center'},style:{classes:'ui-tooltip-blue ui-tooltip-shadow ui-tooltip-rounded'}});$('#modal-guide-price').qtip({content:{text:"The price shown in your shopping basket is a guide price only. The actual price you are charged can vary slightly from this guide price (up or down) this is because you may have ordered fresh goods such as fruit, vegetables, cheese or fresh meat that will be priced according to their precise weight. Also if a product is not available and you have opted to receive substitutions, we will send you a product that closely matches your original choice but that may have a slightly different price.
When you receive your order you may return a product and receive a full refund if you consider the difference between the guide price on our website and the charged price is unacceptable or that the product substituted is an unacceptable alternative to the one you ordered. We hope to minimise the number of substitutions and any difference between the guide price and the actual price you pay."},position:{my:'left center',at:'right center'},style:{classes:'ui-tooltip-blue ui-tooltip-shadow ui-tooltip-rounded'}});$('#modal-min-delivery-charge').qtip({content:{text:'The delivery charge shown applies to your postcode for the timeslot you have chosen, this charge covers the cost of packing and delivering your order. The total in green shows the amount extra you need to spend to qualify for free delivery.'},position:{my:'bottom center',at:'top center'},style:{classes:'ui-tooltip-blue ui-tooltip-shadow ui-tooltip-rounded'}});$('#modal-min-delivery-charge-ooc').qtip({content:{text:'Please note: a packaging and delivery charge applies to your postcode as follows: -
Monday to Friday - £11.00 for the first 15kg and 35p for each additional kg.
Saturday - £23.00 for the first 15kg and 35p for each additional kg.
The calculated charges will be added at the time of dispatch, the minimum charge is shown in the basket for guidance only.'},position:{my:'bottom center',at:'top center'},style:{classes:'ui-tooltip-blue ui-tooltip-shadow ui-tooltip-rounded'}});$('#modal-info-free-delivery').qtip({content:{text:'If you add extra goods to the value shown in green to your basket you will qualify for free delivery. Any third party courier/shipping charges will still apply.'},position:{my:'bottom center',at:'top center'},style:{classes:'ui-tooltip-blue ui-tooltip-shadow ui-tooltip-rounded'}});$('a.basket-confirm-order-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();return false;});}});}else{window.location.reload();}});});$('.holiday-info').click(function(e){e.preventDefault();$.fn.colorbox({scrolling:false,href:"/holiday/info",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('#confirm-order-msg-help').click(function(e){e.preventDefault();$.fn.colorbox({scrolling:false,href:"/basket/cutoff-info",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('a.voucher-info').click(function(e){e.preventDefault();$.fn.colorbox({scrolling:false,href:"/basket/voucher-info",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('#start-msgs').cycle({fx:'fade',timeout:'4000'});$('#li-newsletter a').click(function(e){e.preventDefault();$.fn.colorbox({scrolling:false,href:"/newsletter",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#popup-newsletter form').live('submit',function(e){e.preventDefault();var first_name=$('input[name="first_name"]',this).val(),last_name=$('input[name="last_name"]',this).val(),email=$('input[name="email"]',this).val(),postcode=$('input[name="postcode"]',this).val(),pattern=/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;if(email==''||email=='email@domain.com'){alert('Please enter an email address');return false;}
else if(!pattern.test(email)){alert('Please enter an valid email address');return false;}
if(email==''||email=='email@domain.com'){alert('Please enter an email address');return false;}
if(first_name==''){alert('Please enter your first name');return false;}
if(last_name==''){alert('Please enter your last name');return false;}
if(postcode==''){alert('Please enter your postcode');return false;}
var url='/newsletter';var params={format:'json',first_name:first_name,last_name:last_name,email:email,postcode:postcode};$.ajax({type:"POST",url:url,data:params,success:function(data){if(data.success){$('#popup-newsletter form').fadeOut('slow',function(){$('#intro-msg').text('Signup complete, thank you!');$.fn.colorbox.resize();});}else if(data.failure){alert('failure');}}});});$('#modal-close').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});if($('#standing-order-options :radio:checked').val()==1){$('#recurring-freq-wrap').show();}else{$('#recurring-freq-wrap').hide();}
$('#standing-order-options :radio').click(function(){var frequency=$('#recurring-freq option:selected').val();if($(this).val()==1){$('#recurring-freq-wrap').show();$("#recurring-freq option[value=1]").attr('selected','selected');}else{$('#recurring-freq-wrap').hide();}
$.ajax({type:"GET",url:"/basket/switch-so/"+$(this).val()+'/'+frequency+'?format=json'});});$('#recurring-freq').change(function(e){var frequency=$('#recurring-freq option:selected').val();$.ajax({type:"GET",url:"/basket/switch-so/"+$('#standing-order-options :radio:checked').val()+'/'+frequency+'?format=json'});});$('#edit-options li .left').each(function(){});$('.page-home #content ul.nav-sub li:last').addClass('last');$('#slideshow ul').cycle({fx:'fade',timeout:'7000'});$('#print-page').click(function(e){e.preventDefault();window.print();});$('div.ss-product-row').find('.ss-product-item:last').addClass('last');$('#fp-reasons div.fp-more').hide();$('#fp-reasons .fp-tell-me-more').click(function(e){e.preventDefault();if($(this).parent().siblings("div.fp-more").is(':hidden')){$(this).parent().siblings("div.fp-more").slideDown();$(this).hide();}else{$(this).parent().siblings("div.fp-more").slideUp();}});$('ul.sf-menu').superfish({delay:200});$('.product-image-wrap, .basket-img').hover(function(){$(this).find('.product-availability').fadeOut();},function(){$(this).find('.product-availability').fadeIn();});$('#credit-balance a').click(function(e){e.preventDefault();$.fn.colorbox({scrolling:false,href:"/account/credit-balance",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-close').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('li#cta-video a').click(function(e){e.preventDefault();$.fn.colorbox({scrolling:false,href:"/index/video/",transition:"elastic",opacity:0.8,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){}});});$('.set-quantity input:radio:checked').next('label').css({fontWeight:'bold'});$('.set-quantity input:radio').click(function(e){$(this).parent().find('label').css({fontWeight:'normal'});$(this).next('label').css({fontWeight:'bold'});});if($('textarea#delivery_notes').length){var dn_text_area_box=$('textarea#delivery_notes').val();var dn_max_numb_of_words=200;var dn_main=dn_text_area_box.length*100;var dn_value=(dn_main/dn_max_numb_of_words);var dn_count=dn_max_numb_of_words-dn_text_area_box.length;$('#progressbar').css('background-color','#552a73');$('#count').html(dn_count);$('#progressbar').animate({'width':dn_value+'%'},1);}
$('textarea#delivery_notes').keyup(function(){var text_area_box=$(this).val();var max_numb_of_words=200;var main=text_area_box.length*100;var value=(main/max_numb_of_words);var count=max_numb_of_words-text_area_box.length;if(text_area_box.length<=max_numb_of_words)
{$('#progressbar').css('background-color','#552a73');$('#count').html(count);$('#progressbar').animate({'width':value+'%'},1);}
else
{$("#progressbar").css("background-color","#b30707");$("textarea#delivery_notes").val(text_area_box.substr(0,max_numb_of_words));}
return false;});$('#age-wrap').hide();$('#advert').cycle({fx:'fade',timeout:'7000'});$('#keep-up-to-date form').live('submit',function(e){e.preventDefault();var email=$('input[name="sb-email"]',this).val(),pattern=/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;if(email==''||email=='email@domain.com'){alert('Please enter an email address');return false;}
else if(!pattern.test(email)){alert('Please enter an valid email address');return false;}
$('#keep-up-to-date form').find('div').append('
');$('#keep-up-to-date form').find("#sb-newsletter-submit").hide();var url='/newsletter';var params={format:'json',email:email};$.ajax({type:"POST",url:url,data:params,success:function(data){if(data.success){$('#keep-up-to-date form').find('div').animate({opacity:0},1000,null,function(){$(this).hide();$('#keep-up-to-date form').find('div').after('
Successfully subscribed
');$('#keep-up-to-date form').find('strong').css({opacity:0}).animate({opacity:1});});$('#keep-up-to-date form').find('img.loading').animate({opacity:0},1500);}else if(data.failure){$('#keep-up-to-date form').find('span').animate({opacity:0},1000,null,function(){$(this).hide();$('#keep-up-to-date form').find('div').append('
There was an issue, please try again.
');$('#keep-up-to-date form').find('strong').css({opacity:0}).animate({opacity:1});});$('#keep-up-to-date form').find('img.loading').animate({opacity:0},1500);}}});});$('#newsletter form').live('submit',function(e){e.preventDefault();var email=$('input[name="email"]',this).val(),pattern=/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;if(email==''||email=='email@domain.com'){alert('Please enter an email address');return false;}
else if(!pattern.test(email)){alert('Please enter an valid email address');return false;}
$('#newsletter form').find('div').append('
');$('#newsletter form').find("#newsletter-submit").hide();var url='/newsletter';var params={format:'json',email:email};$.ajax({type:"POST",url:url,data:params,success:function(data){if(data.success){$('#newsletter form').find('span').animate({opacity:0},1000,null,function(){$(this).hide();$('#newsletter form').find('div').append('
Successfully subscribed
');$('#newsletter form').find('strong').css({opacity:0}).animate({opacity:1});});$('#newsletter form').find('img.loading').animate({opacity:0},1500);}else if(data.failure){$('#newsletter form').find('span').animate({opacity:0},1000,null,function(){$(this).hide();$('#newsletter form').find('div').append('
There was an issue, please try again.
');$('#newsletter form').find('strong').css({opacity:0}).animate({opacity:1});});$('#newsletter form').find('img.loading').animate({opacity:0},1500);}}});});$('#dietary_other_text').parent().hide();$('#dietary_other').click(function(){if($('#dietary_other').attr("checked")){$('#dietary_other_text').parent().show();}else{$('#dietary_other_text').parent().hide();}});if($('#dietary_other').attr("checked")){$('#dietary_other_text').parent().show();}else{$('#dietary_other_text').parent().hide();} $('.year-links > ul').hide();$('.year-links > a').click(function(e){e.preventDefault();if($(this).next('ul').is(':hidden')){$(this).next('ul').slideDown();}else{$(this).next('ul').slideUp();}});$('body.page-blog ul.nav-sub li#what-we-do-what-we-do').removeClass('selected');$('body.page-blog ul.nav-sub li#what-we-do-blog').addClass('selected');$('.faq-answer').hide();$('.faq-question').click(function(e){e.preventDefault();$('.faq-question').parent().removeClass('active');$(this).parent().addClass('active');if($(this).siblings(".faq-answer").is(':hidden')){$(this).siblings(".faq-answer").slideDown();$(this).addClass('active');}else{$(this).siblings(".faq-answer").slideUp();$(this).removeClass('active');}});$('#popup-check-postcode').live('submit',function(e){e.preventDefault();var url='/postcode/check';var params={format:'json'};var postcode=$('input[name="postcode"]',this).val();params['postcode']=postcode;$.ajax({type:"POST",url:url,data:params,success:function(data){if(data.success){$.fn.colorbox({scrolling:false,href:"/postcode/modal-success/postcode/"+escape(data.postcode)+'prev/'+escape(data.previousUrl),transition:"none",opacity:0.2,initialWidth:"45",initialHeight:"20",onComplete:function(){$('#postcode-success-postcode').html(postcode);$('.btn-let-me-shop').click(function(e){e.preventDefault();$.fn.colorbox.close();});},onClosed:function(){window.location.reload();}});}else if(data.failure){$.fn.colorbox({scrolling:false,href:"/postcode/modal-failure/"+escape(data.postcode),transition:"none",opacity:0.2,initialWidth:"45",initialHeight:"20"});}else{$.fn.colorbox.resize();$('#popup-check-postcode input[name="postcode"]').parent().find('.errors').remove();$('#popup-check-postcode input[name="postcode"]').parent().append(getErrorHtml(data['postcode'],'postcode'));$.fn.colorbox.resize();}}});});$('.holiday-edit').click(function(e){e.preventDefault();$.fn.colorbox({scrolling:false,href:$(this).parent().attr('href'),transition:"none",opacity:0.2,initialWidth:"45",initialHeight:"20",onComplete:function(){var startData=$('#frm-cal-start').val(),tmpDate=startData.split("-"),dateLabel=new Date(tmpDate[0],tmpDate[1]-1,tmpDate[2]);$('#cal-start a#date-'+startData).addClass('selected');$('#booking-msg .left strong').text(dateLabel.format("ddd dd mmmm yyyy"));var endData=$('#frm-cal-end').val(),tmpDate=endData.split("-"),dateLabel=new Date(tmpDate[0],tmpDate[1]-1,tmpDate[2]);$('#cal-end a#date-'+endData).addClass('selected');$('#booking-msg .right strong').text(dateLabel.format("ddd dd mmmm yyyy"));$('#btn-holiday-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});$('#frm-book-holiday').submit(function(e){e.preventDefault();var startData=$('#frm-cal-start').val(),endData=$('#frm-cal-end').val(),holidayId=$('#frm-hol-id').val();if(startData==""||endData==""){alert("You must select a start and end date for your holiday break.");}else{var dataString='start='+startData+'&end='+endData+'&id='+holidayId+'&format=json';$.ajax({type:"POST",url:"/holiday/book",data:dataString,success:function(html){if(!html.success){alert(html.msg);}else{$.fn.colorbox({scrolling:false,href:"/holiday/success/",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,overlayClose:false,onComplete:function(){$('#btn-continue').click(function(e){e.preventDefault();$.fn.colorbox.close();window.location.reload();});}});}}});}});}});});$('#setup-delivery-holiday').click(function(e){e.preventDefault();$.fn.colorbox({scrolling:false,href:"/holiday/new/",transition:"none",opacity:0.2,initialWidth:"45",initialHeight:"20",onComplete:function(){$('#btn-holiday-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});$('#frm-book-holiday').submit(function(e){e.preventDefault();var startData=$('#frm-cal-start').val(),endData=$('#frm-cal-end').val();if(startData==""||endData==""){alert("You must select a start and end date for your holiday break.");}else{var dataString='start='+startData+'&end='+endData+'&format=json';$.ajax({type:"POST",url:"/holiday/book",data:dataString,success:function(html){if(!html.success){alert(html.msg);}else{$.fn.colorbox({scrolling:false,href:"/holiday/success/",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,overlayClose:false,onComplete:function(){$('#btn-continue').click(function(e){e.preventDefault();$.fn.colorbox.close();window.location.reload();});}});}}});}});}});});var startData=$('#frm-cal-start').val();$('#cal-start a#date-'+startData).addClass('selected');var endData=$('#frm-cal-end').val();$('#cal-end a#date-'+endData).addClass('selected');$('.calPrev').live('click',function(e){e.preventDefault();$(this).parent().parent().parent().load($(this).attr('href'),function(){var startData=$('#frm-cal-start').val();$('#cal-start a#date-'+startData).addClass('selected');var endData=$('#frm-cal-end').val();$('#cal-end a#date-'+endData).addClass('selected');});});$('.calNext').live('click',function(e){e.preventDefault();$(this).parent().parent().parent().load($(this).attr('href'),function(){var startData=$('#frm-cal-start').val();$('#cal-start a#date-'+startData).addClass('selected');var endData=$('#frm-cal-end').val();$('#cal-end a#date-'+endData).addClass('selected');});});$('.calendar a').live('click',function(e){e.preventDefault();var href=$(this).attr('href');$(this).parents('.calendar').find('a').removeClass('selected');$(this).addClass('selected');if($(this).parents('.calendar').attr('id')=='hol-cal-start'){var urlParts=href.split("/");var datePart=urlParts[urlParts.length-1];$('#frm-cal-start').val(datePart.substr(6));var tmpDate=datePart.substr(6).split("-"),dateLabel=new Date(tmpDate[0],tmpDate[1]-1,tmpDate[2]);$('#booking-msg .left .hol-date').text(dateLabel.format("ddd dd mmm yyyy"));}else{var urlParts=href.split("/");var datePart=urlParts[urlParts.length-1];$('#frm-cal-end').val(datePart.substr(6));var tmpDate=datePart.substr(6).split("-"),dateLabel=new Date(tmpDate[0],tmpDate[1]-1,tmpDate[2]);$('#booking-msg .right .hol-date').text(dateLabel.format("ddd dd mmm yyyy"));}});$('#existing-orders tr').live('mouseover mouseout',function(event){if($(this).find('td').attr('id')!='no-orders'){if(event.type=='mouseover'){$(this).find('td').addClass('hover');var href=$(this).find('a').attr('href');$(this).click(function(e){window.location=href;});}else{$(this).find('td').removeClass('hover');}}});$('ul#edit-options li:last').addClass('last');if($('.alert-inner').text()=='Please book a delivery slot'){$('#btn-order-date').addClass('error');} if($('.alert-inner').text().substr(0,10)=='Your order'){$('#basket-guide-price').addClass('error');} $('#back-to-orders-editing').live('click',function(e){e.preventDefault();var href=$(this).attr('href');$.fn.colorbox({scrolling:false,href:"/basket/back-confirm",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-confirm').click(function(e){window.location.href=href;});$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('.address-item').live('click',function(e){e.preventDefault();$('.address-item').removeClass('selected');$(this).addClass('selected');$('#address-id').val($(this).attr('id').substr(8));$('.delivery-select-notice').html('Selected delivery address: '+$(this).find('span.postcode').text()+'');});$('#btn-edit-postcode').click(function(e){e.preventDefault();$.fn.colorbox({scrolling:false,href:"/basket/select-address",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#btn-confirm-delivery-address').click(function(e){e.preventDefault();var addressId=$('form input[name=address-id]').val(),dataString='address-id='+addressId;$.ajax({type:"POST",url:"/basket/select-address",data:dataString,success:function(html){window.location.reload();$.fn.colorbox.close();}});});$('.btn-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('#order-history-date-control.upcoming li#date-next a').live('click',function(e){e.preventDefault();var params={'format':'json'};$.getJSON($(this).attr('href'),params,function(data){if(data.success){$('.order-date').html(data.date);if($('#order-history-date-control li#date-previous a').length<1){$('#order-history-date-control li#date-previous').html('< Previous month');} $('#order-history-date-control li#date-previous a').attr('href','/account/month-range/'+data.prev_month);$('#order-history-date-control li#date-next a').attr('href','/account/month-range/'+data.next_month);$('#my-orders-table tbody').html(null);$('#my-orders-table tbody').append('
loading...
');$('#my-orders-table tbody').load('/account/month-orders/'+data.ws+'/upcoming');}else{window.location.reload();}});});$('#order-history-date-control.upcoming li#date-previous a').live('click',function(e){e.preventDefault();var params={'format':'json'};$.getJSON($(this).attr('href'),params,function(data){if(data.success){$('.order-date').html(data.date);$('#order-history-date-control li#date-previous a').attr('href','/account/month-range/'+data.prev_month);$('#order-history-date-control li#date-next a').attr('href','/account/month-range/'+data.next_month);if(-1==data.month){$('#order-history-date-control li#date-previous').html('< Previous month');} $('#my-orders-table tbody').html(null);$('#my-orders-table tbody').append('
loading...
');$('#my-orders-table tbody').load('/account/month-orders/'+data.ws);}else{window.location.reload();}});});$('#order-history-date-control.previous li#date-next a').live('click',function(e){e.preventDefault();var params={'format':'json'};$.getJSON($(this).attr('href'),params,function(data){if(data.success){$('.order-date').html(data.date);$('#order-history-date-control li#date-previous a').attr('href','/account/month-range/'+data.prev_month+'/previous');$('#order-history-date-control li#date-next a').attr('href','/account/month-range/'+data.next_month+'/previous');if(1==data.month){$('#order-history-date-control li#date-next').html('Next month >');} $('#my-orders-table tbody').html(null);$('#my-orders-table tbody').append('
loading...
');$('#my-orders-table tbody').load('/account/month-orders/'+data.ws+'/previous');}else{window.location.reload();}});});$('#order-history-date-control.previous li#date-previous a').live('click',function(e){e.preventDefault();var params={'format':'json'};$.getJSON($(this).attr('href'),params,function(data){if(data.success){$('.order-date').html(data.date);if($('#order-history-date-control li#date-next a').length<1){$('#order-history-date-control li#date-next').html('Next month >');} $('#order-history-date-control li#date-previous a').attr('href','/account/month-range/'+data.prev_month+'/previous');$('#order-history-date-control li#date-next a').attr('href','/account/month-range/'+data.next_month+'/previous');$('#my-orders-table tbody').html(null);$('#my-orders-table tbody').append('
loading...
');$('#my-orders-table tbody').load('/account/month-orders/'+data.ws+'/previous');}else{window.location.reload();}});});if($('#my-orders div.alert.success').length>0){$('#my-orders div.alert.success').delay(5000).slideUp('slow');} $('.modal-product').live('click',function(e){e.preventDefault();var stockRef=$(this).attr('href').substr(14);$.fn.colorbox({href:"/modal/product/"+stockRef,transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,scrolling:false,onComplete:function(){$('#cboxClose').addClass('product-preview-close');$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('.bb-link').click(function(e){e.preventDefault();var parts=$(this).attr('id').split('-');var productId=parts[1],objectId=parts[2];$.fn.colorbox({href:"/modal/bulk-buy/"+productId+'/'+objectId,transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,scrolling:false,onComplete:function(){$('#modal-confirm').click(function(e){window.location.href=href;});$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('#sup-image-list li:first').addClass('selected');$('#sup-image-list li a:not([id^="sup-video"])').click(function(e){e.preventDefault();$('#sup-video-wrap').hide().remove();$('#sup-asset-wrap img').show();$('#sup-image-list li').removeClass('selected');$(this).parent().addClass('selected');$('#sup-asset-wrap img').attr('src',$(this).attr('href'));});$('#sup-image-list li a#sup-video').click(function(e){e.preventDefault();$('#sup-image-list li').removeClass('selected');$(this).parent().addClass('selected');if($('#sup-video-wrap').length<1){$('#sup-asset-wrap').append('
');}
$('#sup-asset-wrap img').hide();swfobject.embedSWF('/swf/video-player.swf',"sup-video-wrap","430","310","9.0.0",false,flashvars,params,attributes);});if($('#suppliers-inner').length>0){$('#suppliers-inner').cycle({timeout:0,fx:'fade',next:'.s-next',prev:'.s-previous',after:updateBrandLink});}
function updateBrandLink(){$('#brand-more').attr('href','/suppliers/detail/'+$(this).attr('id').substr(6));}
$('#password-block').hide();$('#security-block').hide();$('#switch-security-block a').click(function(e){e.preventDefault();$(this).hide();$('#security-block').show();});$('#switch-password-block a').click(function(e){e.preventDefault();$(this).hide();$('#password-block').show();});if($('#password-block').find('ul.errors').length>0){$('#switch-password-block').hide();$('#password-block').show();}
if($('#security-block').find('ul.errors').length>0){$('#switch-security-block').hide();$('#security-block').show();}
$('#btn-edit-contact-details').click(function(e){e.preventDefault();$('#contact-summary').hide();$('#account-content').show();});if($('#contact-summary').length>0){var url=new String(window.location);if(url.substr(-4)=='edit'){$('#contact-summary').hide();$('#account-content').show();}else{$('#contact-summary').show();$('#account-content').hide();}}
if($.browser.webkit){}
$('#dob-why').click(function(e){e.preventDefault();});$('#dob-why').hover(function(){$('#age-wrap').css({left:0}).stop(true,true).animate({opacity:"show",left:"375"},"slow");},function(){$('#age-wrap').animate({opacity:"hide",left:'325'},"slow").css({left:'325'});});$('#t-delivery-timeslot td a').live('click',function(e){e.preventDefault();var slotInfo=$(this).attr('id');$.getJSON(baseUrl+"basket/check-restricted-dates/"+slotInfo+'?format=json',false,function(data){if(data.success==false){$.fn.colorbox({scrolling:false,href:"/basket/date-restricted",transition:"elastic",opacity:0.2,initialWidth:"45",initialHeight:"20",onComplete:function(){$('#popup-intro p span#delStart').html(data.start);$('#popup-intro p span#delEnd').html(data.end);$('#modal-cancel').click(function(e){e.preventDefault();window.location.reload();});$.fn.colorbox.resize();}});}
if(data.success){$.fn.colorbox({href:"/delivery/timeslot-confirm/"+slotInfo,transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,scrolling:false,onComplete:function(){$('#want-free-delivery').qtip({content:{text:'Free delivery is available to your postcode for order values over the amount shown. Our handy basket calculator shows you how much more you need to spend to qualify for free delivery. Please note minimum value for free delivery can vary by timeslot and postcode. Any third party courier/shipping charges will still apply.'},position:{my:'bottom right',at:'top center'},style:{classes:'ui-tooltip-blue ui-tooltip-shadow ui-tooltip-rounded'}});$('#modal-third-party-carriage').qtip({content:{text:'The third party carriage charge is the cost of shipping to Scilly via the Steamship Company, the charge shown is the minimum charge for up to 10kg; for details of our current charging structure please view our delivery help section. If you have a Steamship account that you would like to use please email us the account number or contact our customer care team on 01326 371951. Please note free delivery does not apply to this third party charge.'},position:{my:'bottom center',at:'top center'},style:{classes:'ui-tooltip-blue ui-tooltip-shadow ui-tooltip-rounded'}});$('#modal-guide-price').qtip({content:{text:"The price shown in your shopping basket is a guide price only. The actual price you are charged can vary slightly from this guide price (up or down) this is because you may have ordered fresh goods such as fruit, vegetables, cheese or fresh meat that will be priced according to their precise weight. Also if a product is not available and you have opted to receive substitutions, we will send you a product that closely matches your original choice but that may have a slightly different price.
When you receive your order you may return a product and receive a full refund if you consider the difference between the guide price on our website and the charged price is unacceptable or that the product substituted is an unacceptable alternative to the one you ordered. We hope to minimise the number of substitutions and any difference between the guide price and the actual price you pay."},position:{my:'bottom center',at:'top center'},style:{classes:'ui-tooltip-blue ui-tooltip-shadow ui-tooltip-rounded'}});$('#modal-min-delivery-charge').qtip({content:{text:'The delivery charge shown applies to your postcode for the timeslot you have chosen, this charge covers the cost of packing and delivering your order. The total in green shows the amount extra you need to spend to qualify for free delivery.'},position:{my:'bottom center',at:'top center'},style:{classes:'ui-tooltip-blue ui-tooltip-shadow ui-tooltip-rounded'}});$('#modal-info-free-delivery').qtip({content:{text:'If you add extra goods to the value shown in green to your basket you will qualify for free delivery. Any third party courier/shipping charges will still apply.'},position:{my:'bottom center',at:'top center'},style:{classes:'ui-tooltip-blue ui-tooltip-shadow ui-tooltip-rounded'}});$('#frm-book-delivery').live('submit',function(e){e.preventDefault();var url='/delivery/calendar';var params={format:'json',timeslot:$('#frm-book-delivery input[name=timeslot]').val()};$.ajax({type:"POST",url:url,data:params,success:function(data){if(!data.confirm){window.location.reload();}else{var href="/basket/confirm/"+data.orderId;params={'format':'json'};$.getJSON(href,params,function(data){if(data.success){$.fn.colorbox({scrolling:false,href:"/basket/order-confirmation/"+data.orderId,transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,overlayClose:false,onComplete:function(){$('#btn-continue').click(function(e){e.preventDefault();$.fn.colorbox.close();window.location.reload();});}});}else{window.location.reload();}});}}});});}});}});});$('#timeslot-actions a.btn-cancel').live('click',function(e){e.preventDefault();$.fn.colorbox.close();});$('ul.errors').parent().find('input').addClass('error');$('ul.errors').parent().find('select').parent().find('span').addClass('error');$('ul.errors').parent().find('textarea').addClass('error');$('ul.errors').parent().find('select').change(function(each){if($(this).val()!=''){$(this).parent().find('span').removeClass('error');}else{$(this).parent().find('span').addClass('error');}});function mycarousel_initCallback(){$('.product-carousel ').each(function(){var currentTallest=0;$(this).children().each(function(i){if($(this).height()>currentTallest){currentTallest=$(this).height();}});if($.browser.msie&&$.browser.version==6.0){$(this).children().css({'height':currentTallest+10});}
$(this).children().css({'min-height':currentTallest+10});});}
var checking=null;function checkAgreementStatus()
{params={'format':'json'};$.getJSON(baseUrl+"register/agreement?format=json",params,function(data){if(data.success){$('#register-content h2').text('Payment agreement successful!').removeClass('loading');$('#register-content p:not([id^="agreement-id"])').prepend('
Payment Agreement id: '+data.agreementId+'
');$('#register-next ul li.back').html('Start shopping');endCheck();}});} function startCheck() {checking=window.setInterval(checkAgreementStatus,5000);} function endCheck() {window.clearInterval(checking);checking=null;} $('input.error, textarea.error').focus(function(){$(this).removeClass('error');});$('form#payment-setup').submit(function(e){$('#account-content h2').text('Awaiting payment agreement confirmation...').addClass('loading');$('#account-content p').text("Once you have completed the FuturePay agreement this page will update automatically and display your agreement number and you will be able to continue shopping. Please remember without a FuturePay agreement in place you will not be able to pay for your order. If you close the FuturePay window before setting up an agreement you can re-open it from the 'Payment Summary' area on your 'My account' page.");$('#register-next ul li.next input').fadeOut('slow');$('#account-payment-content').hide();$('#register-next ul li.back').text('Please wait...');startCheck();checkAgreementStatus();});$('.btn-remove-address').live('click',function(e){e.preventDefault();var href=$(this).attr('href');$.fn.colorbox({scrolling:false,href:"/account/delete-confirm",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-confirm').click(function(e){window.location.href=href;});$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('.holiday-cancel').live('click',function(e){e.preventDefault();var href=$(this).attr('href');$.fn.colorbox({scrolling:false,href:"/holiday/delete-confirm",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-confirm').click(function(e){window.location.href=href;});$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('.basket-confirm-recurring-order').live('click',function(e){e.preventDefault();var href=$(this).attr('href');$.fn.colorbox({scrolling:false,href:"/basket/so-edit-confirm",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-edit-one').click(function(e){e.preventDefault();var itemId=href.substr(16),params={'format':'json'};$.getJSON(href,params,function(data){if(data.success){$.fn.colorbox({scrolling:false,href:"/basket/order-confirmation/"+data.orderId+"/1",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,overlayClose:false,onComplete:function(){$('#btn-continue').click(function(e){e.preventDefault();$.fn.colorbox.close();window.location.reload();});},onClosed:function(){window.location.reload();}});}else{alert('There was an issue, please try again...');}});});$('#modal-edit-all').click(function(e){e.preventDefault();var itemId=href.substr(16),params={'format':'json'};$.getJSON(href+'/all',params,function(data){if(data.success){$.fn.colorbox({scrolling:false,href:"/basket/order-confirmation/"+data.orderId+"/1",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,overlayClose:false,onComplete:function(){$('#btn-continue').click(function(e){e.preventDefault();$.fn.colorbox.close();window.location.reload();});},onClosed:function(){window.location.reload();}});}else{alert('There was an issue, please try again...');}});});}});});$('#btn-delete, .order-cancel').live('click',function(e){e.preventDefault();var href=$(this).attr('href');var cancelId=href.substr(15);$.fn.colorbox({scrolling:false,href:"/basket/delete-confirm/id/"+cancelId,transition:"elastic",opacity:0.2,initialWidth:"42",initialHeight:"42",speed:100,onComplete:function(){$('#modal-confirm').click(function(e){e.preventDefault();var cancelId=href.substr(15),params={'format':'json'};$.getJSON(baseUrl+"basket/cancel/"+cancelId,params,function(data){if(data.success){window.location.reload();}else{alert('There was an issue cancelling, please try again...');}});$.fn.colorbox.close();});$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});$('#modal-holiday').click(function(e){$('#setup-delivery-holiday').click();});}});});$('a#basket-switch').live('click',function(e){e.preventDefault();var orderId=$(this).parents().filter('.basket-order').attr('id').substr(13),datePreviousTmp=$('#date-previous a').attr('href').substr(14);var datePrevious=new Date(datePreviousTmp);var newDateTmp=new Date(datePrevious.getTime()+604800000),theDate=newDateTmp.getFullYear()+'-'+(newDateTmp.getMonth()+1)+'-'+newDateTmp.getDate();var params={'format':'json'};$.getJSON('/basket/switch/'+orderId,params,function(data){if(data.success){$.each(data.orderItems,function(index,value){$('#product-'+value.id).animate({backgroundColor:'#eff8e7'},'slow',function(){$(this).addClass('active');});$('#product-'+value.id+' .in-basket').html('This product is in your basket');});$('#my-orders #orders').html(null).append('
loading...
').load('/basket/order-range/'+theDate);}else{alert('Please confirm any open orders before editing another order.');}});});$('#order-date-control li#date-previous a').click(function(e){e.preventDefault();var params={'format':'json'};$.getJSON($(this).attr('href'),params,function(data){if(data.success){$('#order-date-control p').html(data.this_week_start+data.this_week_end);$('#order-date-control li#date-previous a').attr('href','/basket/range/'+data.prev_week_start);$('#order-date-control li#date-next a').attr('href','/basket/range/'+data.next_week_start);$('#my-orders #orders table tbody').html(null);$('#my-orders #orders table tbody').append('
');$('#my-orders #orders table tbody').load('/basket/order-range/'+data.ws);}else{window.location.reload();}});});$('#order-date-control li#date-next a').click(function(e){e.preventDefault();var params={'format':'json'};$.getJSON($(this).attr('href'),params,function(data){if(data.success){$('#order-date-control p').html(data.this_week_start+data.this_week_end);$('#order-date-control li#date-previous a').attr('href','/basket/range/'+data.prev_week_start);$('#order-date-control li#date-next a').attr('href','/basket/range/'+data.next_week_start);$('#my-orders #orders table tbody').html(null);$('#my-orders #orders table tbody').append('
');$('#my-orders #orders table tbody').load('/basket/order-range/'+data.ws);}else{window.location.reload();}});});$('#btn-order-date, .basket-calendar a, #btn-timeslot-choose, #step1-delivery-slot, #btn-change-delivery-slot').live('click',function(e){e.preventDefault();$.fn.colorbox({scrolling:false,href:"/delivery/calendar",transition:"elastic",opacity:0.2,initialWidth:"45",initialHeight:"20",speed:100,onComplete:function(){setupTimeslots();}});});$('#btn-standing-order').live('click',function(e){e.preventDefault();var orderId=$(this).parents().filter('.basket-order').attr('id').substr(13);$.fn.colorbox({scrolling:false,href:"/basket/so-modal/"+orderId,transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-confirm').click(function(e){e.preventDefault();var name=$('form#frm-so-name input[name=name]').val(),dataString='name='+name+'&id='+orderId;$.ajax({type:"POST",url:"/basket/so-modal/"+orderId,data:dataString,success:function(html){window.location.reload();}});});$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('#btn-save-voucher').live('click',function(e){$('#basket-voucher').submit();return false;});$('#btn-edit-order-notes').live('click',function(e){e.preventDefault();var orderId=$(this).parents().filter('.basket-order').attr('id').substr(13);$.fn.colorbox({scrolling:false,href:"/basket/notes-modal/"+orderId,transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){if($('textarea#order-notes').length){var dn_text_area_box=$('textarea#order-notes').val();var dn_max_numb_of_words=200;var dn_main=dn_text_area_box.length*100;var dn_value=(dn_main/dn_max_numb_of_words);var dn_count=dn_max_numb_of_words-dn_text_area_box.length;$('#progressbar').css('background-color','#552a73');$('#count').html(dn_count);$('#progressbar').animate({'width':dn_value+'%'},1);} $('textarea#order-notes').keyup(function(){var text_area_box=$(this).val();var max_numb_of_words=200;var main=text_area_box.length*100;var value=(main/max_numb_of_words);var count=max_numb_of_words-text_area_box.length;if(text_area_box.length<=max_numb_of_words) {$('#progressbar').css('background-color','#552a73');$('#count').html(count);$('#progressbar').animate({'width':value+'%'},1);} else {$("#progressbar").css("background-color","#b30707");$("textarea#order-notes").val(text_area_box.substr(0,max_numb_of_words));} return false;});$('#modal-confirm').click(function(e){e.preventDefault();var notes=$('form #order-notes').val(),name=$('form #order-name').val(),dataString='order-name='+encodeURIComponent(name)+'&order-notes='+encodeURIComponent(notes)+'&id='+orderId;$.ajax({type:"POST",url:"/basket/notes-modal/"+orderId,data:dataString,success:function(html){window.location.reload();}});});$('#modal-cancel').click(function(e){e.preventDefault();$.ajax({type:"GET",url:"/basket/remove-notes/"+orderId,success:function(html){window.location.reload();}});});}});});$('.basket-checout-order').live('click',function(e){e.preventDefault();alert('checkout clicked!');});$('.basket-confirm-order, .basket-confirm-existing-order').live('click',function(e){e.preventDefault();var type='/';if(('input[name=update-type]').length){type+=$('input[name=update-type]:checked').val();} var href=$(this).attr('href'),existing=0;if($(this).attr('class')=='basket-confirm-existing-order'){existing=1;} params={'format':'json'};$.getJSON(href+type,params,function(data){if(data.success){$.fn.colorbox({scrolling:false,href:"/basket/order-confirmation/"+data.orderId+"/"+existing,transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,overlayClose:false,onComplete:function(){$('#btn-continue').click(function(e){e.preventDefault();$.fn.colorbox.close();window.location.reload();});}});}else{window.location.reload();}});});$('#btn-cancel').live('click',function(e){e.preventDefault();var href=$(this).attr('href');$.fn.colorbox({scrolling:false,href:"/basket/delete-confirm",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-confirm').click(function(e){e.preventDefault();var cancelId=href.substr(15),params={'format':'json'};$.getJSON(baseUrl+"/basket/cancel/"+cancelId,params,function(data){if(data.success){window.location.reload();}else{alert('There was an issue cancelling, please try again...');}});$.fn.colorbox.close();});$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('#bl-so-delete').live('click',function(e){e.preventDefault();var href=$(this).attr('href');$.fn.colorbox({scrolling:false,href:"/basket/so-delete-confirm",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-delete-one').click(function(e){e.preventDefault();var cancelId=href.substr(15),params={'format':'json'};$.getJSON("/basket/delete/"+cancelId,params,function(data){if(data.success){window.location.reload();}else{alert('There was an issue cancelling, please try again...');}});});$('#modal-delete-all').click(function(e){e.preventDefault();var cancelId=href.substr(15),params={'format':'json'};$.getJSON("/basket/delete/"+cancelId+'/all',params,function(data){if(data.success){window.location.reload();}else{alert('There was an issue cancelling, please try again...');}});});}});});$('#bl-delete').live('click',function(e){e.preventDefault();var href=$(this).attr('href');$.fn.colorbox({scrolling:false,href:"/basket/delete-confirm",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-confirm').click(function(e){e.preventDefault();var cancelId=href.substr(15),params={'format':'json'};$.getJSON("/basket/delete/"+cancelId,params,function(data){if(data.success){window.location.reload();}else{alert('There was an issue cancelling, please try again...');}});$.fn.colorbox.close();});$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('#btn-cancel-changes').live('click',function(e){e.preventDefault();var href=$(this).attr('href');var params={'format':'json'};$.fn.colorbox({scrolling:false,href:"/basket/delete-changes-confirm",transition:"elastic",opacity:0.2,initialWidth:"20",initialHeight:"20",speed:100,onComplete:function(){$('#modal-confirm').click(function(e){e.preventDefault();$.fn.colorbox.close();$.getJSON(href,params,function(data){if(data.success){window.location.reload();}else{alert('Please confirm your open order before editing another order.');}});});$('#modal-cancel').click(function(e){e.preventDefault();$.fn.colorbox.close();});}});});$('form input#search').val($('form input#search').attr('title'));$('form input#search').focus(function(){$(this).val("");});$('form input#search').blur(function(){if($(this).val().length<1){$('form input#search').val($('form input#search').attr('title'));}});$('#search-box #submit').click(function(){if($('form input#search').val()==$('form input#search').attr('title')){$('form input#search').val("");}});$('form input#post-code').val($('form input#post-code').attr('title'));$('form input#post-code').focus(function(){$(this).val("");});$('form input#post-code').blur(function(){if($(this).val().length<1){$('form input#post-code').val($('form input#post-code').attr('title'));}});$('.read-more-info').click(function(e){e.preventDefault();if($("#product-readmore").is(":hidden")){$('#product-readmore').slideDown('slow');}else{$('#product-readmore').slideUp('slow');}});$('ul.pagination').find('> .pagination-nbrs:last').addClass('last');var baseUrl=$('base').attr('href');$(".product-carousel").jcarousel({wrap:'circular',scroll:1,initCallback:mycarousel_initCallback});function getErrorHtml(formErrors,id) {var o='
';return o;} $('form#side-postcode-check').submit(function(e){e.preventDefault();var url='/postcode/check';var params={format:'json'};var postcode=$('input[name="postcode"]',this).val();params['postcode']=postcode;$.ajax({type:"POST",url:url,data:params,success:function(data){if(data.success){$.fn.colorbox({scrolling:false,href:"/postcode/modal-success/postcode/"+escape(data.postcode)+'prev/'+escape(data.previousUrl),transition:"none",opacity:0.2,initialWidth:"45",initialHeight:"20",onComplete:function(){$('#postcode-success-postcode').html(postcode);$('.btn-let-me-shop').click(function(e){e.preventDefault();$.fn.colorbox.close();});},onClosed:function(){window.location.reload();}});}else if(data.failure){$.fn.colorbox({scrolling:false,href:"/postcode/modal-failure/"+escape(data.postcode),transition:"none",opacity:0.2,initialWidth:"45",initialHeight:"20"});}else{$('input[name="postcode"]').parent().find('.errors').remove();$('input[name="postcode"]').parent().append(getErrorHtml(data['postcode'],'postcode'));}}});});function updateVoucher(voucher){if(voucher.has_voucher_message){$('#voucher-message').text(voucher.message);$('#voucher-message').show();}else{$('#voucher-message').text(voucher.message);$('#voucher-message').show();} $('#basket-voucher-saving span').text(voucher.value);if(voucher.applied){$('#basket-voucher-saving').show();}else{$('#basket-voucher-saving').hide();}} function addToBasket(url,params,product,elem,unit,modal){$.getJSON(url,params,function(data){if(data.success){if(modal){window.location.reload();}else{if($('#basket-order-'+data.orderId).length<1){window.location.reload();}else{if(data.hasDepositOrRestrictedProducts){$('li#basket-so').hide();$('#bm-name-notes').addClass('last');$('#standing-order-options :radio[value=0]').attr('checked','checked');}else{$('li#basket-so').show();$('#bm-name-notes').removeClass('last');} $('#confirm-order-msg p span, #sml-order-cutoff strong').text(data.cuffOffDateMsg);$('#order-date-control p').html('< Back to my orders');$('#basket-mini tbody').load('/basket/order-items/'+data.orderId,function(){$('tr#order-item-'+product+' td, tr#order-item-'+product+'-deposit td').css({backgroundColor:'#eff8e7'});$('#basket-guide-price span').text(data.guidePrice);$('#basket-guide-total span').text(data.guideTotal);if(data.toSpend){$('#basket-threshold-total').html('For free delivery spend: '+data.toSpend+' ?');$('#basket-threshold-total, #basket-guide-total, #basket-delivery').show();}else{$('#basket-delivery').hide();if(data.additionalDeliveryCharge==0){$('#basket-guide-total').hide();} $('#basket-threshold-total').html('Free delivery on this order ?').addClass('free');} if(data.voucher.has_voucher){updateVoucher(data.voucher);} $('tr#order-item-'+product+' td, tr#order-item-'+product+'-deposit td').delay(3000).animate({backgroundColor:'#ffffff'},'slow',function(){$(this).css({backgroundColor:'#ffffff'});});});if($(elem).parents().filter('.shop-item').hasClass('detail')){var url='/basket/product-row/'+product+'/'+data.unit+'/detail .shop-item > *';}else{var url='/basket/product-row/'+product+'/'+data.unit+'/listing/y .shop-item > *';} $(elem).parents().filter('.shop-item').load(url,function(){$(this).css({}).addClass('active');$(".product-carousel").jcarousel({wrap:'circular',scroll:1,initCallback:mycarousel_initCallback});});}}}else{if(data.msg=='step-1'){$.fn.colorbox({scrolling:false,href:"/basket/delivery-confirm",transition:"elastic",opacity:0.2,initialWidth:"45",initialHeight:"20",onComplete:function(){$('#modal-cancel').click(function(e){e.preventDefault();window.location.reload();});},onClosed:function(){window.location.reload();}});}else if(data.msg=='login'){$.fn.colorbox({scrolling:false,href:"/login-modal",transition:"elastic",opacity:0.2,initialWidth:"45",initialHeight:"20"});}else if(data.msg=='min-age'){$.fn.colorbox({scrolling:false,href:"/customer/dob",transition:"elastic",opacity:0.2,initialWidth:"45",initialHeight:"20",onComplete:function(){$('.popup-intro p span').html(data.age);}});}else if(data.msg=='min-qty'){$.fn.colorbox({scrolling:false,href:"/basket/min-qty",transition:"elastic",opacity:0.2,initialWidth:"45",initialHeight:"20",onComplete:function(){$('#popup-intro p span#modal-qty').html(data.min);$('#popup-intro p span#modal-unit').html(data.unit);$('#modal-confirm').click(function(e){e.preventDefault();$.fn.colorbox.close();});$.fn.colorbox.resize();}});}else if(data.msg=='cut-off'){$.fn.colorbox({scrolling:false,href:"/basket/cut-off",transition:"elastic",opacity:0.2,initialWidth:"45",initialHeight:"20",onComplete:function(){$('#popup-intro p span#modal-time').html(data.cutoffTime);$('#modal-confirm').click(function(e){e.preventDefault();$.fn.colorbox.close();});$.fn.colorbox.resize();}});}else if(data.msg=='date-restricted'){$.fn.colorbox({scrolling:false,href:"/basket/date-restricted",transition:"elastic",opacity:0.2,initialWidth:"45",initialHeight:"20",onComplete:function(){$('#popup-intro p span#delStart').html(data.start);$('#popup-intro p span#delEnd').html(data.end);$('#modal-cancel').click(function(e){e.preventDefault();window.location.reload();});$.fn.colorbox.resize();}});}else if(data.msg=='restricted-recurring'){$.fn.colorbox({scrolling:false,href:"/basket/restricted-recurring",transition:"elastic",opacity:0.2,initialWidth:"45",initialHeight:"20",onComplete:function(){$('#modal-cancel').click(function(e){e.preventDefault();window.location.reload();});$.fn.colorbox.resize();}});}else{alert('There was a problem when adding to the basket, please try again');}}});} $('form.basketAdd').live('submit',function(e){e.preventDefault();if(checkCookies()){var product=$('input[name="product"]',this).val(),unit=$('input:hidden[name="unit"]',this).val(),qty=$('input[name="qty"]',this).val(),elem=$(this),modal=false;if($('input:hidden[name="unit"]',this).length<1){unit=$('input:radio:checked[name="unit"]',this).val();} var params={'format':'json','product':product,'unit':unit,'qty':qty};if($(this).attr('id')=='modal-basket-add'){modal=true;} addToBasket(baseUrl+"basket/add",params,product,elem,unit,modal);}});$('.basket-decrement').live('click',function(e){e.preventDefault();if($('#basket-mini').length<1){var basketMini=false;var basketTable=$('#tbl-basket tbody');}else{var basketMini=true;var basketTable=$('#basket-mini tbody');} if(checkCookies()){var itemId=$(this).parent().parent().attr('id').substr(11);var params={'format':'json'};$.getJSON(baseUrl+"basket/decrement/"+itemId,params,function(data){if(data.success){if(data.hasDepositOrRestrictedProducts){$('li#basket-so').hide();$('#bm-name-notes').addClass('last');}else{$('li#basket-so').show();$('#bm-name-notes').removeClass('last');} $('#order-date-control p').html('< Back to my orders');$('#basket-guide-price span').text(data.guidePrice);$('#basket-guide-total span').text(data.guideTotal);if(data.toSpend){$('#basket-delivery').html('Min delivery charge: ?').removeClass('free');$('#basket-delivery span:eq(0)').text(data.deliveryCharge);$('#basket-threshold-total').html('For free delivery spend: '+data.toSpend+' ?');$('#basket-threshold-total, #basket-guide-tota, #basket-delivery').show();}else{$('#basket-delivery').hide();if(data.additionalDeliveryCharge==0){$('#basket-guide-total').hide();} $('#basket-threshold-total').html('Free delivery on this order ?').addClass('free');} if(data.voucher.has_voucher){updateVoucher(data.voucher);} if(false===data.exists){$('#confirm-order-msg p span, #sml-order-cutoff strong').text(data.cuffOffDateMsg);$('#product-'+itemId+' .in-basket').fadeOut('slow');$('#product-'+itemId+' .have-you-tried').fadeOut('slow');$('#product-'+itemId).animate({backgroundColor:'#ffffff'},'slow',function(){if($(this).hasClass('detail')){url='/basket/product-row/'+itemId+'/detail .shop-item > *';}else{url='/basket/product-row/'+itemId+' .shop-item > *';} $(this).load(url,function(){$(this).removeClass('active');$(this).css({backgroundColor:null});});});$('tr#order-item-'+itemId+', tr#order-item-'+itemId+'-deposit').fadeOut('slow',function(){$('tr#order-item-'+itemId).remove();if(data.orderItems.length==0){$('#basket-mini tbody').append('
');$('#basket-mini tbody td').fadeIn();}});}else{$.each(data.orderItems,function(i,item){if(item.id==itemId){var unit=item.unit===0?'kg':'';$('tr#order-item-'+itemId).find('div.order-quantity').html(''+item.qty+' '+unit);$('tr#order-item-'+itemId).find('td.price').html(item.price);}});$('tr#order-item-'+itemId+', tr#order-item-'+itemId+'-deposit').find('td').css({backgroundColor:'#eff8e7'});$('tr#order-item-'+itemId+', tr#order-item-'+itemId+'-deposit').find('td').delay(3000).animate({backgroundColor:'#ffffff'},'slow',function(){$(this).css({backgroundColor:'#ffffff'});});}}else{alert('There was a problem when adjusting the basket, please try again');}});}});$('.basket-increment').live('click',function(e){e.preventDefault();if(checkCookies()){var itemId=$(this).parent().parent().attr('id').substr(11);var params={'format':'json'};$.getJSON(baseUrl+"basket/increment/"+itemId,params,function(data){if(data.success){$('#order-date-control p').html('< Back to my orders');$('tr#order-item-'+itemId+', tr#order-item-'+itemId+'-deposit').find('> td').css({backgroundColor:'#eff8e7'});$('#basket-guide-price span').text(data.guidePrice);$('#basket-guide-total span').text(data.guideTotal);if(data.toSpend){$('#basket-delivery').html('Min delivery charge: ?').removeClass('free');$('#basket-delivery span:eq(0)').text(data.deliveryCharge);$('#basket-threshold-total').html('For free delivery spend: '+data.toSpend+' ?');$('#basket-threshold-total, #basket-guide-total, #basket-delivery').show();}else{$('#basket-delivery').hide();if(data.additionalDeliveryCharge==0){$('#basket-guide-total').hide();} $('#basket-threshold-total').html('Free delivery on this order ?').addClass('free');} if(data.voucher.has_voucher){updateVoucher(data.voucher);} $('tr#order-item-'+itemId+', tr#order-item-'+itemId+'-deposit').find('> td').delay(3000).animate({backgroundColor:'#ffffff'},'slow',function(){$(this).css({backgroundColor:'#ffffff'});});$.each(data.orderItems,function(i,item){if(item.id==itemId){var unit=item.unit===0?'kg':'';$('tr#order-item-'+itemId).find('div.order-quantity').html(''+item.qty+' '+unit);$('tr#order-item-'+itemId).find('td.price').html(item.price);}});}else{alert('There was a problem when adjusting the basket, please try again');}});}});$('.basket-item-remove').live('click',function(e){e.preventDefault();if($('#basket-mini').length<1){var basketMini=false;var basketTable=$('#tbl-basket tbody');}else{var basketMini=true;var basketTable=$('#basket-mini tbody');} if(checkCookies()){var itemId=$(this).parent().parent().attr('id').substr(11),url='';var params={'format':'json'};$.getJSON(baseUrl+"basket/remove/"+itemId,params,function(data){if(data.success){$('#confirm-order-msg p span, #sml-order-cutoff strong').text(data.cuffOffDateMsg);if(data.hasDepositOrRestrictedProducts){$('li#basket-so').hide();$('#bm-name-notes').addClass('last');}else{$('li#basket-so').show();$('#bm-name-notes').removeClass('last');} $('#product-'+itemId+' .in-basket').fadeOut('slow');$('#product-'+itemId+' .have-you-tried').fadeOut('slow');$('#product-'+itemId).animate({backgroundColor:'#ffffff'},'slow',function(){if($(this).hasClass('detail')){url='/basket/product-row/'+itemId+'/detail .shop-item > *';}else{url='/basket/product-row/'+itemId+' .shop-item > *';} $(this).load(url,function(){$(this).removeClass('active');$(this).css({backgroundColor:null});});});$('#order-date-control p').html('< Back to my orders');$('tr#order-item-'+itemId+', tr#order-item-'+itemId+'-deposit').fadeOut('slow',function(){$('#basket-guide-price span').text(data.guidePrice);$('#basket-guide-total span').text(data.guideTotal);if(data.toSpend){$('#basket-delivery').html('Min delivery charge: ?').removeClass('free');$('#basket-delivery span:eq(0)').text(data.deliveryCharge);$('#basket-threshold-total').html('For free delivery spend: '+data.toSpend+' ?');$('#basket-threshold-total, #basket-guide-total, #basket-delivery').show();}else{$('#basket-delivery').hide();if(data.additionalDeliveryCharge==0){$('#basket-guide-total').hide();} $('##basket-threshold-total').html('Free delivery on this order ?').addClass('free');} if(data.voucher.has_voucher){updateVoucher(data.voucher);}});}else{alert('There was a problem removing the item from the basket, please try again');}});}});$("ul#shop-items li a.product-image img").lazyload({effect:"fadeIn",placeholder:"images/thumb_loading.gif"});$('.favourite-add').live('click',function(e){e.preventDefault();var itemId=$(this).attr('id').substr(14),elem=$(this);var params={'format':'json'};$.getJSON(baseUrl+"favourites/add/"+itemId,params,function(data){if(data.success){elem.after('Remove from favourites').remove();}else{alert('There was a problem adding the product to favourites, please try again');}});});$('.favourite-remove').live('click',function(e){e.preventDefault();var itemId=$(this).attr('id').substr(17),elem=$(this);var params={'format':'json'};$.getJSON(baseUrl+"favourites/remove/"+itemId,params,function(data){if(data.success){if($('#shop-items.fav-items li#product-'+itemId).length>0){$('#shop-items.fav-items li#product-'+itemId).fadeOut('slow',function(){});}else{elem.after('Add to your favourites').remove();}}else{alert('There was a problem removing the product to favourites, please try again');}});});});