function reserveStore(){$("span.reservationOption  a").click(function(b){b.preventDefault();$("td.reserveSelect span .active").removeClass("active");var c=this.id;var a=c.replace("option","radioCheck");$("."+a).attr("checked",true);$(this).addClass("active").parent().addClass("active");return false})}function show_unavailable_products(){if(($("#unavailable_products").length>0)&&($("#unavaliable_message").length>0)){var h=$("#unavailable_products");var c=$("#unavaliable_message");$("body").append('<div class="map_overlay"></div>').append('<div id="unavailable_popup">&nbsp;</div>');var g=$("#unavailable_popup");c.clone().prependTo(g);var a=$(window).width()/2-g.width()/2;var e=$("div#mainCont").position().top+134;var b=$("div.map_overlay");b.css({height:$(document).height(),width:$(document).width(),opacity:0.7});h.clone().appendTo(g);if($.browser.msie&&$.browser.version==6){$("#unavailable_popup #unavailable_products td.imageCell").each(function(){var j=$(this);var k=j.children().height();var i=j.children().width();if(k==0){j.children("span").css({width:76,height:115})}})}g.css({left:a,top:e});$("#unavailable_popup #unavailable_products").prepend('<span class="close"></span>');f()}function d(){if($.browser.msie&&$.browser.version==6){$("#ie6_overlay_block").hide()}g.hide("fast",function(){b.hide()})}function f(){if($.browser.msie&&$.browser.version==6){if($("ie6_overlay_block").length>0){$("#ie6_overlay_block").show()}else{$("body").prepend("<iframe id='ie6_overlay_block' frameBorder='0' src='/pws/blank.html'></iframe>")}var i=$("#ie6_overlay_block");i.css({display:"block",opacity:0,"z-index":"10",position:"absolute",top:"0px",left:"0px",width:$(document).width(),height:$(document).height()})}b.show("fast",function(){g.show()})}$("span.close").click(function(){d()});$(".map_overlay").click(function(){d()}).css("cursor","pointer");$("#unavailable_link a").click(function(){f()})}function vipRemoveExpiryDate(){var a=$("select#cardType"),d=$("div#paymentExpiry"),e=$("div#cardStartDate"),c=$("div#cardSecurityNumber"),b=$("div#cardIssueNumber");function f(){d.css("display","none");e.css("display","none");c.css("display","none");b.css("display","none")}if(a.length>0){if(a.val()==="OASIS"){f()}a.change(function(){if($(this).val()==="OASIS"){f()}else{d.css("display","block");e.css("display","block");c.css("display","block");b.css("display","block")}})}}function setupBillingAddressBehavior(){_lastSelectedBillingAddress=$("div#_"+$("select#customerAddressID").val());_lastSelectedBillingAddress.fadeIn();$("select#customerAddressID").change(function(){var b=_lastSelectedBillingAddress;var a=$("#_"+$(this).val());_lastSelectedBillingAddress=a;b.hide();a.show()})}function preloadCheckoutImages(){var b=$("p#deliverToOther img");$.each(b,function(){$(this).preload({find:"_0.jpg",replace:"_Open.jpg"})})}function handleDeliveryForm(){$("p#deliverToOther img").unbind("click");window.deliveryAddress=true}function launchPayPal(a){window.open(a,"name","height=500,width=530")}$(document).ready(function(){if($("body.selectstorePage").length>0){view_store_details()}if(($(".customerdetailsPage").length>0)||($(".paymentdetailslayout").length>0)){show_unavailable_products()}preloadCheckoutImages();$("select#shippingOptions").change(function(){$(this).parents("form").submit()});if($(".in_warehouse").length>0&&$(".delivery_price","#delivery_sfs").length>0){$(".delivery_price","#delivery_sfs").html($(".delivery_price","#delivery_sfs").html().replace(/\d\.\d\d/i,"0.00"))}$("select#titlefield").change(function(){if($(this).val()==="Other"){$("div#otherTitleField").slideDown()}else{$("div#otherTitleField").slideUp()}});$("span#addANewAddress").click(function(){$("form#createNewDeliveryAddress").slideDown();$("select#countryList").removeAttr("disabled");$(this).fadeTo(500,0.3).css("cursor","default")});var b="none";var a="none";if($("select#customerAddressID").length>0){if($("select#customerAddressID option:selected").length>0){b=$("select#customerAddressID option:selected").html();a=$("select#customerAddressID option:selected").attr("value")}else{b=$("select#customerAddressID option:first").html();a=$("select#customerAddressID option:first").attr("value")}}if(b!="none"){$("div#selectedBilling address").html(b.replace(/, /g,"<br/>"));$("select#customerAddressID").change(function(){b=$("select#customerAddressID option:selected").html();$("div#selectedBilling address").html(b.replace(/, /g,"<br/>"));var c=$("a#editBillingAddress").attr("href");editBillingLinkAddressId=c.split(a);var e=$("select#customerAddressID option:selected").attr("value");var d=editBillingLinkAddressId[0]+e+editBillingLinkAddressId[1];$("a#editBillingAddress").attr("href",d);a=e})}$.each($("a.addressEdit"),function(){var d=$(this);var c=d.attr("href");d.click(function(e){e.stopPropagation();e.preventDefault();window.location=c+"&billingAddress="+$("select#customerAddressID").val()});d.css("visibility","visible")});setupBillingAddressBehavior();vipRemoveExpiryDate();reserveStore();if($(".paymentdetailsPage").length>0){initaliseGiftCards()}});function initaliseGiftCards(){var a=$("#gift_card_form")||"";if(a.length>0){$(".card_no_input").keyup(function(c){var b=parseInt($(this).attr("id").split("_")[2])+1;autoTab($(this),$("#card_no_"+b))});if($("#gift_card_page_scroll").length>0){$.scrollTo("#gift_card",800)}$(".no_script_input_remove").remove();$("#gift_card_explain").contentPopup({topOffset:694,leftOffset:40,elementToAjax:"#gift_card_pin_msg"});$("#gift_card_form").submit(function(){if(validateGiftCard()){$("#gift_card_overlay").removeClass("hide");$(this).ajaxSubmit({success:giftCardSuccess})}return false});$("#gift_card_form_redeem").submit(function(){var b=false;if(validateRedeemAmount()){$("#gift_card_overlay").removeClass("hide");b=true}return b})}}function isInteger(b){var a=/^\s*\d+\s*$/;return String(b).search(a)!=-1}function validateGiftCard(){var d=true,b="",c="",e,a;e=$("#card_no");a=$("#card_pin_no");$("#gift_card_ajax_error").html("");$(".gc_error").remove();$(".gc_error_pin").remove();b=$("#card_no_1").val()+""+$("#card_no_2").val()+""+$("#card_no_3").val()+""+$("#card_no_4").val();if((b.length==19)&&(isInteger(b))){e.val(b)}else{e.before('<span class="gc_error">Please enter a valid Gift Card Number</span>');d=false}c=a.val();if((c.length!=4)||(!isInteger(c))){$("#gift_check_submit").after('<span class="gc_error_pin">Please enter a valid PIN number</span>');d=false}return d}function validateRedeemAmount(){var f=true,e,d,c="",b=0,a=0;$(".gc_error_redeem").remove();e=$("#gift_amount").val();d=$("#gift_amount_decimal").val();if(d.length===0){d="00"}c=""+e+"."+d;c=c.replace(",","");if(isInteger(e)&&isInteger(d)){b=parseFloat(c);a=parseFloat($("#redeem_basket_total").val());if(b<=a){$("#informedAmount").val(c)}else{$("#gift_redeem_submit").after('<span class="gc_error_redeem">The amount to redeem exceeds the order value.</span>');f=false}}else{$("#gift_redeem_submit").after('<span class="gc_error_redeem">Please enter a valid amount to redeem.</span>');f=false}return f}function giftCardSuccess(f,g,h,c){var e=$(f),d=e.find("#gift_card_errors").html()||"",b="",a="";$("#gift_card_overlay").addClass("hide");if(d.length===0){b=e.find("#gift_card_balance_amount").text();$("#gift_card_balance").removeClass("hide");$("#gift_card_balance_amount").html(b);if(parseFloat(b)>0){$("#gift_card_redeem").removeClass("hide");a=e.find("#gift_card_redeem_pound").text();a=a.replace(",","");$("#gift_amount").val(a);$("#gift_amount_decimal").val(e.find("#gift_card_redeem_pence").text());$("#redeem_basket_total").val(e.find("#basket_value").text());$("#redeem_card_no").val($("#card_no").val());$("#redeem_pin_no").val($("#card_pin_no").val());$("#redeemed_to_card_no").addClass("hide");$("#redeemed_text").addClass("hide")}}else{$("#gift_card_ajax_error").html(d);$("#gift_card_balance").addClass("hide")}}function autoTab(a,b){if(a.val().length==a.attr("maxlength")){b.focus()}}jQuery.fn.submitSfsShipping=function(){var a={id:"#chooseShipping",form:$("#chooseShipping"),input:document.getElementById("chooseShipping").shippingOption,container:$("#chooseShipping"),overlay:$('<div class="sfsOverlay"></div>'),overlayContent:$('<p class="sfsOverlayText">Updating...</p>'),totalsSectionId:".totalsBox"};a.form.css({position:"relative"});a.overlayContent.css({"font-size":"12px","font-weight":"bold","margin-top":"15px","text-align":"center"});a.overlay.css({left:"0px",top:"0px",width:a.container.outerWidth()+"px",height:a.container.outerHeight()+"px",background:"#FFF",opacity:"0.7",position:"absolute"});a.overlay.append(a.overlayContent);a.container.prepend(a.overlay);if(a.input.length>0){a.input[0].checked=true}else{a.input.checked=true}var b=a.form.serialize();$.ajax({type:"POST",url:"ShippingOptions.ice",data:b,success:function(c){$new=$('<div id="hiddenUpdatedOptions">'+c+"</div>");$formContent=$(a.id,$new);$totals=$(a.totalsSectionId,$new);a.form.html($formContent.html());$(a.totalsSectionId).html($totals.html())}})};
