function getFullUri(n){return window.location.host=="localhost"&&(n="/SimpleOfficeProducts"+n),n}function addToCart(n,t){return $.ajax({type:"POST",url:getFullUri("/Checkout/AddToCart/"),dataType:"json",data:{productCode:n,quantity:t},success:function(n){$("#cartQty").text(n.TotalCartQty);window.location.replace(getFullUri("/Checkout/"))}}),!1}function updateCart(){var n=[];$(".product").each(function(){var t=$(this).find("span:first").data("itemcode"),i=$(this).find(".quantity input").val(),r=$(this).find(".legsizedropdown").val();n.push({ItemCode:t,Qty:i,LegSize:r})});var t=$("#discountcode").val(),i={Items:n,PostCode:2e3,DiscountCode:t};return $.ajax({type:"POST",url:getFullUri("/Checkout/UpdateCart/"),contentType:"application/json",data:JSON.stringify(i),success:function(n){n.RenderedPartialViewUpdate.length>0&&($("#orderitemscontainer").empty(),$("#orderitemscontainer").append(n.RenderedPartialViewUpdate));$("#cartQty").text(n.ReturnObject.TotalCartQty);$("#cartFreight").text("$"+n.ReturnObject.Freight.toFixed(2));$("#cartSubTotal").text("$"+n.ReturnObject.SubTotal.toFixed(2));$("#cartTotal").text("$"+n.ReturnObject.Total.toFixed(2));$("#cartFreight").text().length==5?$(".freight span:first").css("padding-right","7px"):$(".freight span:first").css("padding-right","0")}}),!1}function PaypalPay(){updateCart();$(this).addClass("disableButton");$("#loading").show();var n=$("#refCode").val();$.get(getFullUri("/Checkout/Pay?RefCode="+n))}function GetOrders(n){var t=$("#lookbackdays").val(),i=getFullUri("/Admin/GetOrders?adminKey="+n+"&lookBackDays="+t);window.location.replace(i)}function removeItem(n){var t=$(n).closest(".product");t.find(".quantity input").val(0);updateCart()}function displayLargeImage(n){var t=n.split("/"),r=n.replace(t[t.length-1],""),i=r+"../highRes/_"+t[t.length-1];return i=i.replace(".png",".jpg"),$.fancybox(i),!1}function displayImage(n){return $.fancybox(n),!1}function sendMail(){return[].push({}),$.ajax({type:"POST",url:getFullUri("/Contactus/SendContact/"),dataType:"json",data:{Name:$("#name").val(),EmailAddress:$("#mail").val(),Message:$("#msg").val()},success:function(n){alert(n.Message)}}),!1}function scrollToBottom(){$("html, body").animate({scrollTop:$(document).height()},"slow")}function addFeedback(){var i=$("#username").val(),r=$("#emailAddress").val(),u=$("#comment").val(),n=$("#starRating").data("val"),t=$("#products").find(":selected").data("itemcode");return t===undefined||t=="Select a product"?(alert("Please select a product"),!1):i.length==0?(alert("Please enter username"),!1):r.length==0?(alert("Please enter email"),!1):u.length==0?(alert("Please enter comment"),!1):n===undefined||n==0?(alert("Please select a rating"),!1):($.ajax({type:"POST",url:getFullUri("/Feedback/AddFeedback/"),dataType:"json",data:{UserName:$("#username").val(),EmailAddress:$("#emailAddress").val(),Feedback:$("#comment").val(),Stars:$("#starRating").data("val"),ProductCode:$("#products").find(":selected").data("itemcode"),Product:null},success:function(){window.location.replace(getFullUri("/Feedback/"))}}),!1)}function initSlider(){max=Math.max.apply(null,$(".item-description").map(function(){return $(this).height()}));$(".item-description").height(max);max=Math.max.apply(null,$(".item, .control").map(function(){return $(this).height()}));console.log(max);$(".item, .control").height(max);$(".slider .control").click(function(){var t=$(this).parents(".slider"),i=+t.find(".slider-wrap").css("margin-left").match(/-?\d+/),u=+t.find(".slider-wrap .item").length,r=280,n,f;i%r==0&&($(this).hasClass("left")?(n=i+r,n>0&&(n=i,t.find(".slider-wrap").css("margin-left",i-r).prepend(t.find(".slider-wrap .item:last-child")))):(n=i-r,n<=-1*(u-3)*r&&(n=i,t.find(".slider-wrap").css("margin-left",i+r).append(t.find(".slider-wrap .item:first-child")))),+t.find(".slider-wrap").animate({"margin-left":n},500),f=-1*n/r)});$(".product input").on("keyup",function(){var t=$(this).closest(".product"),i=+t.find(".element-price").html().replace("$",""),n=+$(this).val()*i;t.find(".total-price").html("$"+n);n=0;$(".product").each(function(){n+=+$(this).find(".total-price").html().replace("$","")});$(".total span").html("$"+n)});$(".product input:first").trigger("keyup")}(function(n,t,i){function y(n){var t={},r=/^jQuery\d+$/;return i.each(n.attributes,function(n,i){i.specified&&!r.test(i.name)&&(t[i.name]=i.value)}),t}function e(n,t){var u=this,r=i(u);if(u.value==r.attr("placeholder")&&r.hasClass("placeholder"))if(r.data("placeholder-password")){if(r=r.hide().next().show().attr("id",r.removeAttr("id").data("placeholder-id")),n===!0)return r[0].value=t;r.focus()}else u.value="",r.removeClass("placeholder"),u==v()&&u.select()}function s(){var t,r=this,n=i(r),u=this.id;if(r.value==""){if(r.type=="password"){if(!n.data("placeholder-textinput")){try{t=n.clone().attr({type:"text"})}catch(f){t=i("<input>").attr(i.extend(y(this),{type:"text"}))}t.removeAttr("name").data({"placeholder-password":n,"placeholder-id":u}).bind("focus.placeholder",e);n.data({"placeholder-textinput":t,"placeholder-id":u}).before(t)}n=n.removeAttr("id").hide().prev().attr("id",u).show()}n.addClass("placeholder");n[0].value=n.attr("placeholder")}else n.removeClass("placeholder")}function v(){try{return t.activeElement}catch(n){}}var h=Object.prototype.toString.call(n.operamini)=="[object OperaMini]",f="placeholder"in t.createElement("input")&&!h,o="placeholder"in t.createElement("textarea")&&!h,c=i.fn,l=i.valHooks,a=i.propHooks,u,r;f&&o?(r=c.placeholder=function(){return this},r.input=r.textarea=!0):(r=c.placeholder=function(){var n=this;return n.filter((f?"textarea":":input")+"[placeholder]").not(".placeholder").bind({"focus.placeholder":e,"blur.placeholder":s}).data("placeholder-enabled",!0).trigger("blur.placeholder"),n},r.input=f,r.textarea=o,u={get:function(n){var t=i(n),r=t.data("placeholder-password");return r?r[0].value:t.data("placeholder-enabled")&&t.hasClass("placeholder")?"":n.value},set:function(n,t){var r=i(n),u=r.data("placeholder-password");return u?u[0].value=t:r.data("placeholder-enabled")?(t==""?(n.value=t,n!=v()&&s.call(n)):r.hasClass("placeholder")?e.call(n,!0,t)||(n.value=t):n.value=t,r):n.value=t}},f||(l.input=u,a.value=u),o||(l.textarea=u,a.value=u),i(function(){i(t).delegate("form","submit.placeholder",function(){var n=i(".placeholder",this).each(e);setTimeout(function(){n.each(s)},10)})}),i(n).bind("beforeunload.placeholder",function(){i(".placeholder").each(function(){this.value=""})}))})(this,document,jQuery),function(n){n.fn.starRating=function(t){return this.each(function(){var r=n(this),i,f,u;for(r.append("<ul />"),i=n(this).children("ul"),f=0;f<r.data("rating-max");f++)i.append("<li>");$ratingFieldItem=i.children();u=0;$ratingFieldItem.on({click:function(){n(this).index()+1!=u?(u=n(this).index()+1,r.attr("data-val",u),n("li:lt("+(n(this).index()+1)+")",i).addClass("active"),n("li:gt("+n(this).index()+")",i).removeClass("active")):(n(this).parent().children("li").removeClass("active"),r.attr("data-val",null),u=0)},mouseenter:function(){n("li:lt("+(n(this).index()+1)+")",i).addClass("hover");n("li:gt("+n(this).index()+")",i).removeClass("hover")},mouseleave:function(){n(this).parent().children("li:gt("+n(this).index()+")").removeClass("hover")}});i.on({mouseleave:function(){$ratingFieldItem.removeClass("hover")}});if(t.minus){r.prepend("<span class='less'><\/span>");n("span.less",r).on("click",function(){n("li.active:last",i).removeClass("active")})}})}}(jQuery)