Array.prototype.remove=function(c,a){var b=this.slice((a||c)+1||this.length);this.length=c<0?this.length+c:c;return this.push.apply(this,b)};function setCookie(e,a,b,c,d,f){document.cookie=e+"="+escape(a)+((b)?"; expires="+b.toGMTString():"")+((c)?"; path="+c:"")+((d)?"; domain="+d:"")+((f)?"; secure":"")}function getCookie(e){var c=document.cookie;var a=e+"=";var d=c.indexOf("; "+a);if(d===-1){d=c.indexOf(a);if(d!==0){return null}}else{d+=2}var b=document.cookie.indexOf(";",d);if(b===-1){b=c.length}return unescape(c.substring(d+a.length,b))}function deleteCookie(c,b,a){if(getCookie(c)){document.cookie=c+"="+((b)?"; path="+b:"")+((a)?"; domain="+a:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT"}}$.fn.clearField=function(){return this.focus(function(){log($(this).attr("id"),this,this.value+" "+this.defaultValue);if(this.value===this.defaultValue){this.value=""}}).blur(function(){if(!this.value.length){this.value=this.defaultValue}})};if(!this.JSON){this.JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}());var verification={validateEmail:function(b){var a=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;return a.test(b)}};window.log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){console.log(Array.prototype.slice.call(arguments))}};(function(a){var b=a.write;a.write=function(c){log("document.write(): ",arguments);if(/docwriteregexwhitelist/.test(c)){b.apply(a,arguments)}}})(document);(function($){$.extend($,{clearwatermarks:function(){$("[wmwrap='true']").find("input,textarea").watermark({remove:true})},addwatermarks:function(){$("[watermark]").each(function(num,el){$(el).watermark($(el).attr("watermark"))})},watermark:function(o){o.el=$(o.el);if(o.remove){if(o.el.parent().attr("wmwrap")=="true"){o.el.parent().replaceWith(o.el)}}else{if(o.el.parent().attr("wmwrap")!="true"){o.el=o.el.wrap("<span wmwrap='true' style='position:relative;' class='watermarkHolder' />");var l=$("<label/>");if(o.html){l.html(o.html)}if(o.cls){l.addClass(o.cls)}if(o.css){l.css(o.css)}l.css({position:"absolute",left:"0",top:"0",display:"inline",cursor:"text"});if(o.el.is("TEXTAREA")){if($.browser.msie){l.css("width",o.el.width())}if($.browser.mozilla||$.browser.safari){l.css("top","")}}if(!o.cls&&!o.css){l.css("color","#ccc")}var focus=function(){l.hide()};var blur=function(){if(!o.el.val()){l.show()}else{l.hide()}};var click=function(){o.el.focus()};if(o.inherit){if(typeof o.inherit=="string"){l.css(o.inherit,o.el.css(o.inherit))}else{for(var x=0;x<o.inherit.length;x++){l.css(o.inherit[x],o.el.css(o.inherit[x]))}}}o.el.focus(focus).blur(blur);l.click(click);o.el.before(l);if(o.el.val()){l.hide()}}}return o.el}});$.fn.watermark=function(o){return this.each(function(){if(typeof(o)=="string"){try{o=eval("("+o+")")}catch(ex){o={html:o}}}o.el=this;return $.watermark(o)})}})(jQuery);$().ready(function(){$.addwatermarks()});var cart={init:function(){cart.addEvents();cart.getCart()},addEvents:function(){$("#AddToCart").live("click",function(){cart.addToCart()});$("#continue").live("click",function(){cart.checkCart()});$("#Continue").live("click",function(){return $("#form1").validate({rules:{ctl00$MainContent$BillToName:"required",ctl00$MainContent$BillToEmail:{required:true,email:true},ctl00$MainContent$BillToAddress1:"required",ctl00$MainContent$BillToCity:"required",ctl00$MainContent$BillToRegion:"required",ctl00$MainContent$BillToPhoneNumber:"required",ctl00$MainContent$CCType:"required",ctl00$MainContent$CCNumber:"required",ctl00$MainContent$CID:"required",ctl00$MainContent$ShipToName:"required",ctl00$MainContent$ShipToEmail:{required:true,email:true},ctl00$MainContent$ShipToAddress1:"required",ctl00$MainContent$ShipToCity:"required",ctl00$MainContent$ShipToRegion:"required",ctl00$MainContent$ShipToPhoneNumber:"required"},messages:{ctl00$MainContent$BillToName:"Enter your billing name",ctl00$MainContent$BillToEmail:{required:"Please enter a valid email address for billing",minlength:"Please enter your email address for billing"},ctl00$MainContent$BillToAddress1:"Please enter your billing street address",ctl00$MainContent$BillToCity:"Please enter your billing city",ctl00$MainContent$BillToRegion:"Please enter your billing state/region",ctl00$MainContent$BillToPhoneNumber:"Please enter your billing phone number",ctl00$MainContent$CCType:"Please select your credit card type",ctl00$MainContent$CCNumber:"Please enter your credit card number",ctl00$MainContent$CID:"Please enter your credit card security code",ctl00$MainContent$ShipToName:"Enter your shipping name",ctl00$MainContent$ShipToEmail:{required:"Please enter a valid email address for shipping",minlength:"Please enter your email address for shipping"},ctl00$MainContent$ShipToAddress1:"Please enter your shipping street address",ctl00$MainContent$ShipToCity:"Please enter your shipping city",ctl00$MainContent$ShipToRegion:"Please enter your shipping state/region",ctl00$MainContent$ShipToPhoneNumber:"Please enter your shipping phone number"}})})},addBillingEvents:function(){$("#SameAsBillTo").change(function(){cart.populateShipTo()});$(".country").autocomplete({minChars:2,source:countries});$(".region").autocomplete({minChars:1,source:regions})},populateShipTo:function(){if($("#SameAsBillTo").is(":checked")){$("#ShipToName").val($("#BillToName").val());$("#ShipToEmail").val($("#BillToEmail").val());$("#ShipToAddress1").val($("#BillToAddress1").val());$("#ShipToAddress2").val($("#BillToAddress2").val());$("#ShipToCity").val($("#BillToCity").val());$("#ShipToRegion").val($("#BillToRegion").val());$("#ShipToPostalCode").val($("#BillToPostalCode").val());$("#ShipToCountry").val($("#BillToCountry").val());$("#ShipToPhoneNumber").val($("#BillToPhoneNumber").val())}else{$("#ShipToName").val("");$("#ShipToEmail").val("");$("#ShipToAddress1").val("");$("#ShipToAddress2").val("");$("#ShipToCity").val("");$("#ShipToRegion").val("");$("#ShipToPostalCode").val("");$("#ShipToCountry").val("");$("#ShipToPhoneNumber").val("")}},addToCart:function(){$.ajax({type:"POST",url:"/webservices/products.asmx/AddToCart",data:"{'itemKey':"+$("#ItemKey").val()+", 'qty':"+$("#Qty").val()+"}",contentType:"application/json; charset=utf-8",dataType:"json",beforeSend:function(){$("#loader").removeClass("hidden")},success:function(a){if(a.hasOwnProperty("d")){cart.displayMessage(a.d)}else{cart.displayMessage(a)}},error:function(a,b,c){$("#loader").addClass("hidden");log(a.responseText)}})},displayMessage:function(a){var b="";$("#loader").addClass("hidden");$("#added").removeClass("hidden");if(a.Success){$("#added").addClass("information");cart.getCart()}else{$("#added").addClass("error")}b="<li>"+a.Message+"</li>";$("#added").append(b)},getCart:function(){$.ajax({type:"POST",url:"/webservices/products.asmx/GetCartView",data:"{}",contentType:"application/json; charset=utf-8",dataType:"json",beforeSend:function(){$("#loader").removeClass("hidden")},success:function(a){if(a.hasOwnProperty("d")){cart.updateCartView(a.d)}else{cart.updateCartView(a)}},error:function(a,b,c){$("#loader").addClass("hidden");log(a.responseText)}})},updateCartView:function(a){$("#cartQty").html(a.ItemCount);if(a.ShowCheckout){$("#Checkout").show()}else{$("#Checkout").hide()}},getCartItems:function(){$.ajax({type:"POST",url:"/webservices/products.asmx/GetCartItems",data:"{}",contentType:"application/json; charset=utf-8",dataType:"json",beforeSend:function(){$("#loader").removeClass("hidden")},success:function(a){if(a.hasOwnProperty("d")){cart.populateCartItems(a.d)}else{cart.populateCartItems(a)}},error:function(a,b,c){$("#loader").addClass("hidden");log(a.responseText)}})},populateCartItems:function(e){var c="",d=0,a,b,g,f;$("#items tbody tr").remove();$("#loader").addClass("hidden");if(e.length!==0){if(e.length>0){for(a=0;a<e.length;a++){if(a%2===0){c+='<tr class="even">'}else{c+='<tr class="odd">'}b=parseFloat(e[a].Price);g=parseFloat(e[a].Qty);f=b*g;d+=f;c+='<td><a href="/shop/'+e[a].Slug+'" title="'+e[a].PartNumber+'">'+e[a].PartNumber+"</a></td>";c+="<td>"+e[a].Name+"</td>";c+='<td class="price tableAlignRight">$'+b.toFixed(2)+"</td>";c+='<td><input type="text" class="qty field50" value="'+g+'" /></td>';c+='<td class="extPrice">$'+f.toFixed(2)+"</td>";c+='<td><a href="#" rel="'+e[a].PartNumber+'" class="update"><img src="/webresources/images/icons/arrow_refresh_small.png" alt="Update" /></a> <a href="#" rel="'+e[a].PartNumber+'" class="remove"><img src="/webresources/images/icons/delete.png" alt="Remove" /></a></td>';c+="</tr>"}c+='<tr class="totals">';c+='<td colspan="3">&nbsp;</td>';c+="<td><strong>Sub Total</strong></td>";c+="<td><strong>$"+d.toFixed(2)+"</strong></td>";c+="<td></td>";c+="</tr>";$("#items tbody").append(c);$("a.update").live("click",function(){var h=$(this).parent().siblings().find('input[type="text"]').val();cart.updateCartItem($(this).attr("rel"),h)});$("a.remove").live("click",function(){cart.updateCartItem($(this).attr("rel"),0)});$(".qty").blur(function(){var i=parseFloat($(this).parent().siblings(".price").html().replace("$",""));var j=parseFloat($(this).val());var k=i*j;$(this).parent().siblings(".extPrice").html("$"+k.toFixed(2));var h=$(this).parent().siblings().find("a.update").attr("rel");cart.updateCartItem(h,j)})}else{$(".information").append("<li>No result was returned for the partSearch term entered.</li>");$(".information").removeClass("hidden")}}},updateCartItem:function(b,a){$.ajax({type:"POST",url:"/webservices/products.asmx/UpdateCart",data:"{'partNumber':'"+b+"', 'qty':'"+a+"'}",contentType:"application/json; charset=utf-8",dataType:"json",beforeSend:function(){$("#loader").removeClass("hidden")},success:function(c){if(c.hasOwnProperty("d")){if(c.d){cart.getCartItems()}}else{if(c){cart.getCartItems()}}},error:function(c,d,e){$("#loader").addClass("hidden");log(c.responseText)}})},checkCart:function(){window.location="/cart/billing.aspx"}};
