function getInventoryByOrder(n,t){var i,r;if(t.Items&&t.Items.length>0)for(i=0;i<t.Items.length;i++)if(r=t.Items[i],r.Name===n)return r;return undefined}function delitem(n){$.cookie(n,null);$("#"+n).remove();$("#cartitems").children().length==0&&$("#cart").hide()}function addfield(n){return $("#"+n).val().toString().replace("|","")+"|"}function addradio(n){return $("input[name="+n+"]:checked").val()+"|"}function addcheckbox(n){return $("#"+n).is(":checked").toString()+"|"}function ClearFields(){$("#firstname").val("").removeClass("invalidinput").addClass("validinput");$("#lastname").val("").removeClass("invalidinput").addClass("validinput");$("input:checkbox").removeAttr("checked");$("#insurance").prop("checked",!0);$("select").val("");$("#ability").removeClass("invalidinput").addClass("validinput");$("input[name=stance][value=Regular]").prop("checked",!0);$("input[name=gender][value=male]").prop("checked",!0);$("#shoesize").html($("#shoesizeM").html());$("#validationmsg").css({visibility:"hidden"});$(".stance-display").hide()}function CheckFields(){var i=!0,t,n;for($(".clearField").each(function(){var n=$(this);n.val()==""||n.val().replace(" ","")==n.attr("id")?(n.removeClass("validinput").addClass("invalidinput"),i=!1):n.removeClass("invalidinput").addClass("validinput")}),t=["ability","age","height","weight","shoesize"],n=0;n<t.length;n++)$("#"+t[n]).val()==""?($("#"+t[n]).removeClass("validinput").addClass("invalidinput"),i=!1):$("#"+t[n]).removeClass("invalidinput").addClass("validinput");return i||$("#validationmsg").css({visibility:"visible"}),i}function DoScroll(){var n=menuYloc+$(document).scrollTop()+"px";$("#cart").animate({top:n},{duration:500,queue:!1})}function OpenAddItem(n){itemcnt>0&&$(".modal-title").text("You won't be going it alone. Great!");itemcnt>1&&$(".modal-title").text("A group of you...  even more fun!");$("#packagetype").val(n);$("#myModal").modal({show:!0,backdrop:"static"});$("#packagetype").val().indexOf("SB")>=0?$(".stance-display").show():$(".stance-display").hide();$("#packagetype").val().indexOf("JNR")>0?$("#shoesize").html($("#shoesizeJ").html()):$("#shoesize").html($("#shoesizeM").html())}function AddItem(){var n,t;$.cookie("example2",["foo,1","foo2"]);n=GetAllCookies();for(t in n)alert(t+" : "+n[t]+"\r")}function GetAllCookies(){var r={},i,t,n;if(document.cookie&&document.cookie!="")for(i=document.cookie.split(";"),t=0;t<i.length;t++)n=i[t].split("="),n[0]=n[0].replace(/^ /,""),r[decodeURIComponent(n[0])]=decodeURIComponent(n[1]);return r}jQuery.extend({Guid:{Set:function(){var n;return arguments.length==1&&(n=this.IsValid(arguments[0])?arguments[0]:this.Empty()),$(this).data("value",n),n},Empty:function(){return"00000000-0000-0000-0000-000000000000"},IsEmpty:function(n){return n==this.Empty()||typeof n=="undefined"||n==null||n==""},IsValid:function(n){return rGx=new RegExp("\\b(?:[A-F0-9]{8})(?:-[A-F0-9]{4}){3}-(?:[A-F0-9]{12})\\b"),rGx.exec(n)!=null},New:function(){var t,i,r,n;if(arguments.length==1&&this.IsValid(arguments[0]))return $(this).data("value",arguments[0]),value=arguments[0];for(t=[],r=new RegExp("[2345]"),n=0;n<8;n++)i=((1+Math.random())*65536|0).toString(16).substring(1),r.exec(n.toString())!=null&&(n==3&&(i="6"+i.substr(1,3)),t.push("-")),t.push(i.toUpperCase());return value=t.join(""),$(this).data("value",value),value},Value:function(){if($(this).data("value"))return $(this).data("value");var n=this.New();return $(this).data("value",n),n}}})();var menuYloc=0,itemcnt=0;$(document).ready(function(){var r=GetAllCookies(),t=0,n,i;for(n in r)n.substring(0,4)=="item"&&(t++,i=r[n],$("#cartitems").append("<span id='"+n+"'>"+(t==1?"":"&nbsp;&nbsp;")+i.substring(0,i.indexOf("|"))+" <img class='delbtn' src='images/del.gif' onclick=delitem('"+n+"')><\/span> "));t>0&&($("#cart").show(),$(window).scroll(function(){DoScroll()}),DoScroll());$(".insurance").tooltip();$(".shoes").tooltip();$("#additem").click(function(){var t,i,n;CheckFields()&&(itemcnt++,$("#myModal").modal("hide"),$("#showEssentialsDiv").show(),$("#essentialsDiv").hide(),t=$.Guid.New(),i=$("#firstname").val(),i=i.split(" ").join("&nbsp;"),$("#cartitems").append("<span id='item"+t+"'>"+($("#cartitems").text()==""?"":"&nbsp;&nbsp;")+i+" <img class='delbtn' src='images/del.gif' onclick=delitem('item"+t+"')><\/span> "),$("#packagetype").val().indexOf("SK")>=0,n="",n+=addfield("firstname"),n+=addfield("lastname"),n+=addfield("packagetype"),n+=addfield("ability"),n+=$("#packagetype").val().indexOf("SB")>=0?addradio("stance"):"|",n+=addradio("gender"),n+=addfield("height"),n+=addfield("weight"),n+=addfield("age"),n+=addfield("shoesize"),$("input:checkbox").each(function(){var t=$(this),i=t.data("code"),r=t.data("name"),u=t.data("cost");i?t.is(":checked")&&(n+=r+"~"+u+"~"+i+"|"):n+=this.checked+"|"}),$.cookie("item"+t,n),$("#cart").is(":visible")||($("#cart").show(),$(window).scroll(function(){DoScroll()}),DoScroll()),ClearFields())});$("#canceladd").click(function(){ClearFields();$("#myModal").modal("hide");$("#showEssentialsDiv").show();$("#essentialsDiv").hide()});$("input[type=radio][name=gender]").change(function(){$("#packagetype").val().indexOf("JNR")>0?$("#shoesize").html($("#shoesizeJ").html()):this.value=="male"?$("#shoesize").html($("#shoesizeM").html()):this.value=="female"&&$("#shoesize").html($("#shoesizeF").html())});$("#packagetype").change(function(){this.value.indexOf("JNR")>0?$("#shoesize").html($("#shoesizeJ").html()):$('[name="gender"]:checked').val()=="male"?$("#shoesize").html($("#shoesizeM").html()):$('[name="gender"]:checked').val()=="female"&&$("#shoesize").html($("#shoesizeF").html());this.value.indexOf("SB")>=0?$(".stance-display").show():$(".stance-display").hide()});$("#showEssentials").click(function(){var n=$(this);n.button("loading");$("#showEssentialsDiv").hide();$("#essentialsDiv").show();n.button("reset")});$("#myModal").on("shown.bs.modal",function(){$("#firstname").focus()})})