var itemdisplaytype=0;function basketnote(c){var b="basketnote",a=$sj(b);a.t&&clearTimeout(a.t);a.t=null;a.innerHTML=c;if(c!=""){$sjShow(b);a.t=setTimeout(function(){basketnote("");$sjHide(b)},8e3)}}function getproducts(a){var g="ajaxWait",f="btmmsgmotoring",e="topmsgmotoring",d="topmsgaccessories",c="sjfincalc",b="productcategory";if(a==null||a==""){alert("ProgCat3Id invalid");return}basketnote("");$sjShow(b);$sjHTML("shoppingPageTitle",page_title_suffix);$sjHTML(b,"loading...");$sjShow("producttopmsg");$sjHide("producttopbasket");switch(a.toString()){case "9036":itemdisplaytype=2;$sjVisible(c);$sjHide(d);$sjShow(e);$sjShow(f);fincalcinit();break;case "9043":itemdisplaytype=1;$sjHidden(c);$sjHide(e);$sjHide(f);$sjShow(d);break;default:itemdisplaytype=typeof customItemDisplayType=="undefined"?0:customItemDisplayType}$sjHTML("divout","");try{sjAjax.load("serviceshopping.asmx/getproducts",'{"prodcat3id":"'+a+'","key":"'+websvs_key+'","allocenc":"'+alloc+'"}',getproducts_loaded);$sjShow(g)}catch(h){alert("Error occurred calling Ajax: "+h);$sjHide(g)}logimg(11,"prodcat3:"+a);return false}function htmlrep(a){return a.replace(/~\(/g,"<").replace(/~\)/g,">")}function getproducts_loaded(k,j){var h="sjfincalc",i="shopSideBasket",e="</div>";$sjHide("ajaxWait");if(k!=200){alert("Error ocurred: "+k+"\r\n\r\n"+j);return}var c="",d=sjAjax.jsonDotNet(j);$sjHTML("productcategory",d.category);for(var b=d.items,l=b.length,a=0;a<l;a++){var f=b[a].f,g=b[a].g;c+='<div class="item"><div class="left"><div><img '+(b[a].b=="noproduct.gif"?"":'class="magnify" onmouseover="sjbigimg.show(this)" onmouseout="sjbigimg.hide(this)" ')+'src="shared/product/'+b[a].b+'" border="0" alt="" width="100" height="100"/></div><h2>'+b[a].c+"</h2><h5>"+b[a].d+"</h5>"+e+'<div class="right"><h4>'+b[a].e+"</h4>"+(f==""&&g==""?"":"<h5>"+f+(f!=""&&g!=""?" - ":"")+g+"</h5>")+'<div class="fab">'+htmlrep(b[a].h)+e;if(itemdisplaytype==0)if(b[a].i=="N")c+='<div class="cart">Call <strong>'+clientPhone+"</strong></div>";else c+='<div class="cart"><a class="btn20" href="#" onclick="return addtobasket(\''+b[a].a+"')\"><span>add to basket</span></a></div>";else if(itemdisplaytype==2)c+='<div class="cart"><a class="btn20" href="#" onclick="return docarfin(\''+b[a].e+"','"+b[a].c+"', this)\"><span>calculate payments</span></a></div>";c+=e+e}$sjHTML("divout",c);switch(itemdisplaytype){case 0:if(d.baskethtml!=null&&d.baskethtml!=""){$sjShow(i);$sjHTML("shopSideBasketContent",d.baskethtml)}else $sjHide(i);break;case 1:$sjHide(h);break;case 2:$sjShow(h);fincalcresetpos()}}function getbasketpage(){var a="ajaxWait";sjDialogBox.hideDialog();$sjHide("producttopmsg");$sjHide("producttopbasket");$sjHTML("divout","");$sjHide("productcategory");$sjHTML("shoppingPageTitle","Basket");try{sjAjax.load("serviceshopping.asmx/getbasketpage",'{"key":"'+websvs_key+'"}',getbasketpage_loaded);$sjShow(a)}catch(b){alert("Error occurred calling Ajax: "+b);$sjHide(a)}return false}function getbasketpage_loaded(j,i){var d="</div>",f="producttopbasket",g="shopSideBasket";$sjHide("ajaxWait");if(j!=200){alert("Error ocurred: "+j+"\r\n\r\n"+i);return}var h="",c=sjAjax.jsonDotNet(i);if(c.baskethtml!=null&&c.baskethtml!=""){$sjShow(g);$sjHTML("shopSideBasketContent",c.baskethtml)}else $sjHide(g);var e=c.isloggedin;$sjShow(f);if(c.grandtotalqty==0)$sjHTML(f,'<div class="formmsg"><h5>Note:</h5><ul><li>There are no items in your basket</li></ul></div>');else $sjHTML(f,(c.grandtotalqty==0?"":'<div style="float:right"><a class="'+(e?"btn24":"btn24Disabled")+'" title="'+(e?"Continue to Checkout":"Please login to Checkout")+'" href="'+(e?"shoppingcheckout.aspx":"javascript:alert('Please login to Checkout')")+'"><span><b>Checkout</b></span></a></div>')+'<h3 class="color1">'+c.grandtotalqty+" item"+(c.grandtotalqty==1?"":"s")+' in your basket</h3><h3 style="margin:3px 0 5px">Total: '+c.grandtotal+"</h3>"+(e?"":'<div style="text-align:right"><i>N.B. <b>Please login first to Checkout!</b></i></div>'));for(var b=c.items,e=b.length,a=0;a<e;a++)h+='<div class="item"><div class="left"><div><img '+(b[a].b=="noproduct.gif"?"":'class="magnify" onmouseover="sjbigimg.show(this)" onmouseout="sjbigimg.hide(this)" ')+'src="shared/product/'+b[a].b+'" border="0" alt="" width="100" height="100"/></div><h2>'+b[a].c+"</h2><h5>"+b[a].d+"</h5><h3>Total: "+b[a].ItemTotal+"</h3>"+d+'<div class="right"><h4>'+b[a].e+"</h4><h5>"+b[a].f+" - "+b[a].g+'2</h5><div class="fab">'+b[a].h+d+'<div class="basketbutton"><span>'+b[a].Qty+" item"+(b[a].Qty==1?"":"s")+'</span><input type="button" title="Increase Quantity" class="btnplus" onclick="changebasketqty(\'Add\',\''+b[a].a+"')\" />"+(b[a].Qty==1?'<input type="button" disabled="disabled" title="" class="btnminusdis" onclick="return false" />':'<input type="button" title="Decrease Quantity" class="btnminus" onclick="changebasketqty(\'Sub\',\''+b[a].a+"')\" />")+"<div><a href=\"#\" onclick=\"return changebasketqty('Del','"+b[a].a+"')\">Remove</a></div>"+d+d+d;$sjHTML("divout",h);logimg(11,"basket")}function changebasketqty(b,d){var a="ajaxWait";try{if(b=="Del")if(!confirm("Are you sure you wish to remove this product from your basket?"))return;$sj("divout","");$sjShow(a);sjAjax.load("serviceshopping.asmx/changebasketqty",'{"thecmd":"'+b+'","productid":"'+d+'","key":"'+websvs_key+'"}',changebasketqty_loaded)}catch(c){alert("Error occurred calling Ajax: "+c);$sjHide(a)}return false}function changebasketqty_loaded(b,a){$sjHide("ajaxWait");if(b!=200){alert("Error ocurred: "+b+"\r\n\r\n"+a);return}var d="",c=sjAjax.jsonDotNet(a);basketnote(c);getbasketpage()}function addtobasket(c){var a="ajaxWait";try{sjAjax.load("serviceshopping.asmx/addtobasket",'{"productid":"'+c+'","key":"'+websvs_key+'","allocenc":"'+alloc+'"}',addtobasket_loaded);$sjShow(a);sjDialogBox.showDialog("ADDING ITEM TO SHOPPING BASKET","<h3>Please Wait</h3>","prompt",false)}catch(b){sjDialogBox.hideDialog();alert("Error occurred calling Ajax: "+b);$sjHide(a)}return false}function addtobasket_loaded(e,d){var b="shopSideBasket";$sjHide("ajaxWait");if(e!=200){sjDialogBox.hideDialog();alert("Error ocurred: "+e+"\r\n\r\n"+d);return}var c=sjAjax.jsonDotNet(d);if(!c)return;var a=c.split("~",2);if(a[1]!=""){$sjShow(b);$sjHTML("shopSideBasketContent",a[1])}else $sjHide(b);var f="<h3>The following item was added to your shopping basket:</h3><p>"+a[0]+'</p><div class="floatcontainer"><input type="button" id="dlgclosebutton" class="btn140x24" onclick="sjDialogBox.hideDialog()" value="Continue Shopping" style="float:left"><input type="button" id="dlggetbasketpage" class="btn140x24" onclick="getbasketpage()" value="View Basket / Checkout" style="float:right" ></div>';sjDialogBox.showDialog("ADDED ITEM TO SHOPPING BASKET",f,"prompt")}
