function ClearPurchaseForm(){parent.$("#added-to-cart-modal").modal("hide");$('[id*="CustomField"]').each(ClearInput)}function wireUpSelectize(){$(".masked").each(function(){SetupMaskedInput($(this))});$("select.use-selectize-multi").each(function(){ApplySelectionLimits($(this))});$(".selectized.required[name*='CustomField_']").bind("change",ValidateSelect)}(function(){function t(){}function r(n,t){for(var i=n.length;i--;)if(n[i].listener===t)return i;return-1}function i(n){return function(){return this[n].apply(this,arguments)}}var n=t.prototype,u=this,f=u.EventEmitter;n.getListeners=function(n){var r,t,i=this._getEvents();if("object"==typeof n){r={};for(t in i)i.hasOwnProperty(t)&&n.test(t)&&(r[t]=i[t])}else r=i[n]||(i[n]=[]);return r};n.flattenListeners=function(n){for(var i=[],t=0;n.length>t;t+=1)i.push(n[t].listener);return i};n.getListenersAsObject=function(n){var t,i=this.getListeners(n);return i instanceof Array&&(t={},t[n]=i),t||i};n.addListener=function(n,t){var i,u=this.getListenersAsObject(n),f="object"==typeof t;for(i in u)u.hasOwnProperty(i)&&-1===r(u[i],t)&&u[i].push(f?t:{listener:t,once:!1});return this};n.on=i("addListener");n.addOnceListener=function(n,t){return this.addListener(n,{listener:t,once:!0})};n.once=i("addOnceListener");n.defineEvent=function(n){return this.getListeners(n),this};n.defineEvents=function(n){for(var t=0;n.length>t;t+=1)this.defineEvent(n[t]);return this};n.removeListener=function(n,t){var f,i,u=this.getListenersAsObject(n);for(i in u)u.hasOwnProperty(i)&&(f=r(u[i],t),-1!==f&&u[i].splice(f,1));return this};n.off=i("removeListener");n.addListeners=function(n,t){return this.manipulateListeners(!1,n,t)};n.removeListeners=function(n,t){return this.manipulateListeners(!0,n,t)};n.manipulateListeners=function(n,t,i){var r,u,f=n?this.removeListener:this.addListener,e=n?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(r=i.length;r--;)f.call(this,t,i[r]);else for(r in t)t.hasOwnProperty(r)&&(u=t[r])&&("function"==typeof u?f.call(this,r,u):e.call(this,r,u));return this};n.removeEvent=function(n){var t,r=typeof n,i=this._getEvents();if("string"===r)delete i[n];else if("object"===r)for(t in i)i.hasOwnProperty(t)&&n.test(t)&&delete i[t];else delete this._events;return this};n.removeAllListeners=i("removeEvent");n.emitEvent=function(n,t){var i,f,r,e,u=this.getListenersAsObject(n);for(r in u)if(u.hasOwnProperty(r))for(f=u[r].length;f--;)i=u[r][f],i.once===!0&&this.removeListener(n,i.listener),e=i.listener.apply(this,t||[]),e===this._getOnceReturnValue()&&this.removeListener(n,i.listener);return this};n.trigger=i("emitEvent");n.emit=function(n){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(n,t)};n.setOnceReturnValue=function(n){return this._onceReturnValue=n,this};n._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0};n._getEvents=function(){return this._events||(this._events={})};t.noConflict=function(){return u.EventEmitter=f,t};"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return t}):"object"==typeof module&&module.exports?module.exports=t:this.EventEmitter=t}).call(this),function(n){function f(t){var i=n.event;return i.target=i.target||i.srcElement||t,i}var t=document.documentElement,r=function(){},i,u;t.addEventListener?r=function(n,t,i){n.addEventListener(t,i,!1)}:t.attachEvent&&(r=function(n,t,i){n[t+i]=i.handleEvent?function(){var t=f(n);i.handleEvent.call(i,t)}:function(){var t=f(n);i.call(n,t)};n.attachEvent("on"+t,n[t+i])});i=function(){};t.removeEventListener?i=function(n,t,i){n.removeEventListener(t,i,!1)}:t.detachEvent&&(i=function(n,t,i){n.detachEvent("on"+t,n[t+i]);try{delete n[t+i]}catch(r){n[t+i]=void 0}});u={bind:r,unbind:i};"function"==typeof define&&define.amd?define("eventie/eventie",u):n.eventie=u}(this),function(n,t){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(i,r){return t(n,i,r)}):"object"==typeof exports?module.exports=t(n,require("wolfy87-eventemitter"),require("eventie")):n.imagesLoaded=t(n,n.EventEmitter,n.eventie)}(window,function(n,t,i){function s(n,t){for(var i in t)n[i]=t[i];return n}function c(n){return"[object Array]"===v.call(n)}function l(n){var t=[],i,r;if(c(n))t=n;else if("number"==typeof n.length)for(i=0,r=n.length;r>i;i++)t.push(n[i]);else t.push(n);return t}function r(n,t,i){if(!(this instanceof r))return new r(n,t);"string"==typeof n&&(n=document.querySelectorAll(n));this.elements=l(n);this.options=s({},this.options);"function"==typeof t?i=t:s(this.options,t);i&&this.on("always",i);this.getImages();f&&(this.jqDeferred=new f.Deferred);var u=this;setTimeout(function(){u.check()})}function e(n){this.img=n}function u(n){this.src=n;o[n]=this}var f=n.jQuery,h=n.console,a=h!==void 0,v=Object.prototype.toString,o;return r.prototype=new t,r.prototype.options={},r.prototype.getImages=function(){var i,u,n,t,e;for(this.images=[],i=0,u=this.elements.length;u>i;i++)if(n=this.elements[i],"IMG"===n.nodeName&&this.addImage(n),t=n.nodeType,t&&(1===t||9===t||11===t))for(var f=n.querySelectorAll("img"),r=0,o=f.length;o>r;r++)e=f[r],this.addImage(e)},r.prototype.addImage=function(n){var t=new e(n);this.images.push(t)},r.prototype.check=function(){function f(n,r){return t.options.debug&&a&&h.log("confirm",n,r),t.progress(n),u++,u===i&&t.complete(),!0}var t=this,u=0,i=this.images.length,n,r;if(this.hasAnyBroken=!1,!i)return this.complete(),void 0;for(n=0;i>n;n++)r=this.images[n],r.on("confirm",f),r.check()},r.prototype.progress=function(n){this.hasAnyBroken=this.hasAnyBroken||!n.isLoaded;var t=this;setTimeout(function(){t.emit("progress",t,n);t.jqDeferred&&t.jqDeferred.notify&&t.jqDeferred.notify(t,n)})},r.prototype.complete=function(){var t=this.hasAnyBroken?"fail":"done",n;this.isComplete=!0;n=this;setTimeout(function(){if(n.emit(t,n),n.emit("always",n),n.jqDeferred){var i=n.hasAnyBroken?"reject":"resolve";n.jqDeferred[i](n)}})},f&&(f.fn.imagesLoaded=function(n,t){var i=new r(this,n,t);return i.jqDeferred.promise(f(this))}),e.prototype=new t,e.prototype.check=function(){var n=o[this.img.src]||new u(this.img.src),t;if(n.isConfirmed)return this.confirm(n.isLoaded,"cached was confirmed"),void 0;if(this.img.complete&&void 0!==this.img.naturalWidth)return this.confirm(0!==this.img.naturalWidth,"naturalWidth"),void 0;t=this;n.on("confirm",function(n,i){return t.confirm(n.isLoaded,i),!0});n.check()},e.prototype.confirm=function(n,t){this.isLoaded=n;this.emit("confirm",this,t)},o={},u.prototype=new t,u.prototype.check=function(){if(!this.isChecked){var n=new Image;i.bind(n,"load",this);i.bind(n,"error",this);n.src=this.src;this.isChecked=!0}},u.prototype.handleEvent=function(n){var t="on"+n.type;this[t]&&this[t](n)},u.prototype.onload=function(n){this.confirm(!0,"onload");this.unbindProxyEvents(n)},u.prototype.onerror=function(n){this.confirm(!1,"onerror");this.unbindProxyEvents(n)},u.prototype.confirm=function(n,t){this.isConfirmed=!0;this.isLoaded=n;this.emit("confirm",this,t)},u.prototype.unbindProxyEvents=function(n){i.unbind(n.target,"load",this);i.unbind(n.target,"error",this)},r});var noviNs=noviNs||{};(function(n){n.getMaxQty=function(t,i,r,u){var f,e;return i?(f=n.calcQtyRemaining(t,i,r,u),f<0)?(e=t- -f,e<0?0:e):t:t};n.calcQtyRemaining=function(n,t,i,r){if(!t)return 999999;return i-(r+n)};n.isValidQty=function(t,i,r,u){return i?n.calcQtyRemaining(t,i,r,u)>=0:!0}})(noviNs);$(function(){var t=parent.$("#iframe-modal .modal-body").length>0,n;t&&($("body").addClass("in-modal"),n=parent.$("#iframe-modal"),n.find(".modal-body > .loading").remove(),n.find(".modal-title").html($("h1").html()),n.find(".modal-subtitle").length==0&&n.find(".modal-title").after('<h5 class="modal-subtitle">'+$(".subtitle").html()+"<\/h5>"),n.find(".modal-subtitle").html($(".subtitle").html()),$(".header-ribbon").remove());wireUpSelectize();$(".sign-in,.log-in").click(function(){return parent.window.location.href=$(this).attr("href"),!1});$("#quantity").on("keyup change",function(){var n=$(this),i,r,t,f,u;n&&n.length>0&&(i=n.val(),(i===""||isNaN(i))&&n.val(""),r=n.val()===""?-1:parseInt(n.val()),r>=0&&n.val(r));t=n.val()===""?-1:parseInt(n.val());f=t===-1?!0:noviNs.isValidQty(t,noviNs.productVm.hasLimitedQuantity,noviNs.productVm.quantityAvailable,noviNs.productVm.quantitySold);f||(u=noviNs.getMaxQty(t,noviNs.productVm.hasLimitedQuantity,noviNs.productVm.quantityAvailable,noviNs.productVm.quantitySold),ShowCustomAlert("The maximum quantity you can purchase is "+u+"."),n.val(u))});$("form").validate().settings.ignore=":hidden:not([class~=selectized]):not(.tinymce),:hidden > .selectized, .selectize-control .selectize-input input, .ignore";$("#add-to-cart").click(function(){if(!$("#purchase-form").valid())return!1;var n=$("#quantity").length>0&&$("#quantity").val()!==""&&!isNaN(parseInt($("#quantity").val()))&&parseInt($("#quantity").val())>0?$("#quantity").val():1,i=GetCustomFieldValues($("#purchase-form"));return $.ajax({url:addToCartUrl,type:"POST",dataType:"json",data:{productID:productID,quantity:n,customFieldValues:i},success:function(n){var r=t?parent.$(".items-in-cart"):$(".items-in-cart"),u=t?parent.$(".cart"):$(".cart"),i;r.html(n);u.removeClass("hide");i=$("#added-to-cart-modal");t?(parent.$("body").append(i),parent.$("#added-to-cart-modal").modal(),parent.$("#iframe-modal").modal("hide")):i.modal()},error:function(){alert("There was a problem adding this item to your cart.  Please try again later.")}}),!1});$("#contact-offline").click(function(){return $(".contact-box").slideToggle(),$(".contact-box").is(":visible")&&$("html,body").stop().animate({scrollTop:$(".contact-box").offset().top}),!1});$("#contact-form").submit(function(){var t=$(this),n;return t.valid()?(n=t.find(".btn[type=submit]"),n.addClass("hide"),n.before('<span class="saving"><span class="novicon novicon-spinner novicon-spin"><\/span>Saving...<\/span>'),n.parent().find(".alert").remove(),$.ajax({url:t.attr("action"),type:"POST",dataType:"json",data:$(this).serialize(),success:function(i){i.Status!="OK"?(n.parent().prepend('<div class="alert alert-danger"><span class="novicon novicon-warning"><\/span>'+i.Errors+"<\/div>"),t.find(".saving").remove(),n.removeClass("hide")):($("#contact-success").removeClass("hide"),$(".contact-box").remove())},error:function(i){n.parents(".buttons").prepend('<div class="alert alert-danger"><span class="novicon novicon-warning"><\/span>'+i.responseText+"<\/div>");t.find(".saving").remove();n.removeClass("hide")}}),!1):!1})})