var Custom="Custom",GoogleCheckout="GoogleCheckout",PayPal="PayPal",Email="Email",AustralianDollar="AUD",AUD="AUD",CanadianDollar="CAD",CAD="CAD",CzechKoruna="CZK",CZK="CZK",DanishKrone="DKK",DKK="DKK",Euro="EUR",EUR="EUR",HongKongDollar="HKD",HKD="HKD",HungarianForint="HUF",HUF="HUF",IsraeliNewSheqel="ILS",ILS="ILS",JapaneseYen="JPY",JPY="JPY",MexicanPeso="MXN",MXN="MXN",NorwegianKrone="NOK",NOK="NOK",NewZealandDollar="NZD",NZD="NZD",PolishZloty="PLN",PLN="PLN",PoundSterling="GBP",GBP="GBP",SingaporeDollar=
"SGD",SGD="SGD",SwedishKrona="SEK",SEK="SEK",SwissFranc="CHF",CHF="CHF",ThaiBaht="THB",THB="THB",USDollar="USD",USD="USD";
function Cart(){var a=this;a.nextId=1;a.Version="2.2";a.Shelf=null;a.items={};a.isLoaded=!1;a.pageIsReady=!1;a.quantity=0;a.total=0;a.taxRate=0;a.taxCost=0;a.shippingFlatRate=0;a.shippingTotalRate=0;a.shippingQuantityRate=0;a.shippingRate=0;a.shippingCost=0;a.currency=USD;a.checkoutTo=PayPal;a.email="";a.merchantId="";a.successUrl=null;a.cancelUrl=null;a.cookieDuration=30;a.storagePrefix="sc_";a.MAX_COOKIE_SIZE=4E3;a.cartHeaders=["Name","Price","Quantity","Total"];a.add=function(c){this.pageIsReady||
(this.initializeView(),this.update());this.isLoaded||(this.load(),this.update());var a=new CartItem;if(!arguments||arguments.length===0)return error("No values passed for item."),null;var d=arguments;c&&typeof c!=="string"&&typeof c!=="number"&&(d=c);a.parseValuesFromArray(d);a.checkQuantityAndPrice();this.hasItem(a)?(d=this.hasItem(a),d.quantity=parseInt(d.quantity,10)+parseInt(a.quantity,10),a=d):this.items[a.id]=a;this.update();return a};a.remove=function(c){var b={};a.each(function(a){a.id!==
c&&(b[a.id]=a)});this.items=b};a.empty=function(){simpleCart.items={};simpleCart.update()};a.find=function(c){if(!c)return null;var b=[];a.each(function(d){fits=!0;a.each(c,function(a,c,b){if(!d[b]||d[b]!=a)fits=!1});fits&&b.push(d)});return b.length===0?null:b};a.each=function(c,b){var d,e=0,g;if(typeof c==="function")var h=c,f=a.items;else if(typeof b==="function")var h=b,f=c;else return;for(d in f)if(typeof f[d]!=="function"){g=h.call(a,f[d],e,d);if(g===!1)break;e++}};a.chunk=function(a,b){typeof b===
"undefined"&&(b=2);return a.match(RegExp(".{1,"+b+"}","g"))||[]};a.checkout=function(){if(simpleCart.quantity===0)error("Cart is empty");else switch(simpleCart.checkoutTo){case PayPal:simpleCart.paypalCheckout();break;case GoogleCheckout:simpleCart.googleCheckout();break;case Email:simpleCart.emailCheckout();break;default:simpleCart.customCheckout()}};a.paypalCheckout=function(){var a=this,b="https://www.paypal.com/cgi-bin/webscr?cmd=_cart&upload=1&business="+a.email+"&currency_code="+a.currency,
d=1,e="",g;a.taxRate&&(b=b+"&tax_cart="+a.currencyStringForPaypalCheckout(a.taxCost));a.each(function(b,f){d=f+1;g="";a.each(b,function(a,c,b){b!=="id"&&b!=="price"&&b!=="quantity"&&b!=="name"&&b!=="shipping"&&(g=g+", "+b+"="+a)});g=g.substring(2);e=e+"&item_name_"+d+"="+b.name+"&item_number_"+d+"="+d+"&quantity_"+d+"="+b.quantity+"&amount_"+d+"="+a.currencyStringForPaypalCheckout(b.price)+"&on0_"+d+"=Options&os0_"+d+"="+g});a.shipping()!==0&&(e=e+"&shipping="+a.currencyStringForPaypalCheckout(a.shippingCost));
a.successUrl&&(e=e+"&return="+a.successUrl);a.cancelUrl&&(e=e+"&cancel_return="+a.cancelUrl);b+=e;window.open(b,"paypal","scrollbars,location,resizable,status")};a.googleCheckout=function(){var a=this;if(a.currency!==USD&&a.currency!==GBP)error("Google Checkout only allows the USD and GBP for currency.");else if(a.merchantId===""||a.merchantId===null||!a.merchantId)error("No merchant Id for google checkout supplied.");else{var b=document.createElement("form"),d=1,e;b.style.display="none";b.method=
"POST";b.action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/"+a.merchantId;b.acceptCharset="utf-8";a.each(function(g,h){d=h+1;b.appendChild(a.createHiddenElement("item_name_"+d,g.name));b.appendChild(a.createHiddenElement("item_quantity_"+d,g.quantity));b.appendChild(a.createHiddenElement("item_price_"+d,g.price));b.appendChild(a.createHiddenElement("item_currency_"+d,a.currency));b.appendChild(a.createHiddenElement("item_tax_rate_"+d,a.taxRate));b.appendChild(a.createHiddenElement("_charset_",
""));e="";a.each(g,function(a,c,b){b!=="id"&&b!=="quantity"&&b!=="price"&&(e=e+", "+b+": "+a)});e=e.substring(1);b.appendChild(a.createHiddenElement("item_description_"+d,e))});a.shipping()!==0&&(b.appendChild(a.createHiddenElement("ship_method_name_1","Shipping")),b.appendChild(a.createHiddenElement("ship_method_price_1",parseFloat(a.shippingCost).toFixed(2))),b.appendChild(a.createHiddenElement("ship_method_currency_1",a.currency)));document.body.appendChild(b);b.submit();document.body.removeChild(b)}};
a.emailCheckout=function(){};a.customCheckout=function(){};a.load=function(){this.items={};this.quantity=this.total=0;if(readCookie(simpleCart.storagePrefix+"simpleCart_chunks")){var a=1*readCookie(simpleCart.storagePrefix+"simpleCart_chunks"),b=[],d="",d="",e=0;if(a>0){for(e=0;e<a;e++)b.push(readCookie(simpleCart.storagePrefix+"simpleCart_"+(1+e)));d=unescape(b.join(""));d=d.split("++")}for(var e=0,g=d.length;e<g;e++)a=d[e].split("||"),b=new CartItem,b.parseValuesFromArray(a)&&(b.checkQuantityAndPrice(),
this.items[b.id]=b)}this.isLoaded=!0};a.save=function(){for(var c="",b=[],b=0,b=1*readCookie(simpleCart.storagePrefix+"simpleCart_chunks"),d=0;d<b;d++)eraseCookie(simpleCart.storagePrefix+"simpleCart_"+d);eraseCookie(simpleCart.storagePrefix+"simpleCart_chunks");a.each(function(a){c=c+"++"+a.print()});for(var b=simpleCart.chunk(c.substring(2),simpleCart.MAX_COOKIE_SIZE),d=0,e=b.length;d<e;d++)createCookie(simpleCart.storagePrefix+"simpleCart_"+(1+d),b[d],a.cookieDuration);createCookie(simpleCart.storagePrefix+
"simpleCart_chunks",""+b.length,a.cookieDuration)};a.initializeView=function(){this.totalOutlets=getElementsByClassName("simpleCart_total");this.quantityOutlets=getElementsByClassName("simpleCart_quantity");this.cartDivs=getElementsByClassName("simpleCart_items");this.taxCostOutlets=getElementsByClassName("simpleCart_taxCost");this.taxRateOutlets=getElementsByClassName("simpleCart_taxRate");this.shippingCostOutlets=getElementsByClassName("simpleCart_shippingCost");this.finalTotalOutlets=getElementsByClassName("simpleCart_finalTotal");
this.addEventToArray(getElementsByClassName("simpleCart_checkout"),simpleCart.checkout,"click");this.addEventToArray(getElementsByClassName("simpleCart_empty"),simpleCart.empty,"click");this.Shelf=new Shelf;this.Shelf.readPage();this.pageIsReady=!0};a.updateView=function(){a.updateViewTotals();a.cartDivs&&a.cartDivs.length>0&&a.updateCartView()};a.updateViewTotals=function(){for(var c=[["quantity","none"],["total","currency"],["shippingCost","currency"],["taxCost","currency"],["taxRate","percentage"],
["finalTotal","currency"]],b=0,d=c.length;b<d;b++)for(var e=c[b][0]+"Outlets",g,h=0,f=a[e].length;h<f;h++){switch(c[b][1]){case "none":g=""+a[c[b][0]];break;case "currency":g=a.valueToCurrencyString(a[c[b][0]]);break;case "percentage":g=a.valueToPercentageString(a[c[b][0]]);break;default:g=""+a[c[b][0]]}a[e][h].innerHTML=""+g}};a.updateCartView=function(){var c=[],b,d,e,g,h,f;d=document.createElement("div");b=0;for(var i=a.cartHeaders.length;b<i;b++){e=document.createElement("div");f=a.cartHeaders[b].split("_");
e.innerHTML=a.print(f[0]);e.className="item"+f[0];for(var j=1,k=f.length;j<k;j++)if(f[j].toLowerCase()=="noheader")e.style.display="none";d.appendChild(e)}d.className="cartHeaders";c[0]=d;a.each(function(b,f){d=document.createElement("div");for(var i=0,j=a.cartHeaders.length;i<j;i++)e=document.createElement("div"),g=a.cartHeaders[i].split("_"),h=a.createCartRow(g,b,h),e.innerHTML=h,e.className="item"+g[0],d.appendChild(e);d.className="itemContainer";c[f+1]=d});b=0;for(f=a.cartDivs.length;b<f;b++)if(i=
a.cartDivs[b],i.childNodes&&i.appendChild){for(;i.childNodes[0];)i.removeChild(i.childNodes[0]);j=0;for(k=c.length;j<k;j++)i.appendChild(c[j])}};a.createCartRow=function(c,b,d){switch(c[0].toLowerCase()){case "total":d=a.valueToCurrencyString(parseFloat(b.price)*parseInt(b.quantity,10));break;case "increment":d=a.valueToLink("+","javascript:;","onclick=\"simpleCart.items['"+b.id+"'].increment();\"");break;case "decrement":d=a.valueToLink("-","javascript:;","onclick=\"simpleCart.items['"+b.id+"'].decrement();\"");
break;case "remove":d=a.valueToLink("Remove","javascript:;","onclick=\"simpleCart.items['"+b.id+"'].remove();\"");break;case "price":d=a.valueToCurrencyString(b[c[0].toLowerCase()]?b[c[0].toLowerCase()]:" ");break;default:d=b[c[0].toLowerCase()]?b[c[0].toLowerCase()]:" "}for(var e=1,g=c.length;e<g;e++)switch(option=c[e].toLowerCase(),option){case "image":case "img":d=a.valueToImageString(d);break;case "input":d=a.valueToTextInput(d,"onchange=\"simpleCart.items['"+b.id+"'].set('"+c[0].toLowerCase()+
"' , this.value);\"");break;case "div":case "span":case "h1":case "h2":case "h3":case "h4":case "p":d=a.valueToElement(option,d,"");break;case "noheader":break;default:error("unkown header option: "+option)}return d};a.addEventToArray=function(a,b,d){for(var e,g=0,h=a.length;g<h;g++)e=a[g],e.addEventListener?e.addEventListener(d,b,!1):e.attachEvent&&e.attachEvent("on"+d,b)};a.createHiddenElement=function(a,b){var d=document.createElement("input");d.type="hidden";d.name=a;d.value=b;return d};a.currencySymbol=
function(){switch(a.currency){case CHF:return"CHF&nbsp;";case CZK:return"CZK&nbsp;";case DKK:return"DKK&nbsp;";case HUF:return"HUF&nbsp;";case NOK:return"NOK&nbsp;";case PLN:return"PLN&nbsp;";case SEK:return"SEK&nbsp;";case JPY:return"&yen;";case EUR:return"&euro;";case GBP:return"&pound;";case CHF:return"CHF&nbsp;";case THB:return"&#3647;";case USD:case CAD:case AUD:case NZD:case HKD:case SGD:return"&#36;";default:return""}};a.currencyStringForPaypalCheckout=function(c){return a.currencySymbol()==
"&#36;"?"$"+parseFloat(c).toFixed(2):""+parseFloat(c).toFixed(2)};a.valueToCurrencyString=function(c){c=parseFloat(c);isNaN(c)&&(c=0);return c.toCurrency(a.currencySymbol())};a.valueToPercentageString=function(a){return parseFloat(100*a)+"%"};a.valueToImageString=function(a){return a.match(/<\s*img.*src\=/)?a:'<img src="'+a+'" />'};a.valueToTextInput=function(a,b){return'<input type="text" value="'+a+'" '+b+" />"};a.valueToLink=function(a,b,d){return'<a href="'+b+'" '+d+" >"+a+"</a>"};a.valueToElement=
function(a,b,d){return"<"+a+" "+d+" > "+b+"</"+a+">"};a.hasItem=function(c){var b,d=!1;a.each(function(e){b=!0;a.each(c,function(a,d,f){f!=="quantity"&&f!=="id"&&c[f]!==e[f]&&(b=!1)});b&&(d=e)});return d};a.ln={en_us:{quantity:"Quantity",price:"Price",total:"Total",decrement:"Decrement",increment:"Increment",remove:"Remove",tax:"Tax",shipping:"Shipping",image:"Image"}};a.language="en_us";a.print=function(a){return this.ln[this.language]&&this.ln[this.language][a.toLowerCase()]?this.ln[this.language][a.toLowerCase()]:
a};a.update=function(){simpleCart.isLoaded||simpleCart.load();simpleCart.pageIsReady||simpleCart.initializeView();a.updateTotals();a.updateView();a.save()};a.updateTotals=function(){a.total=0;a.quantity=0;a.each(function(c){if(c.quantity<1)c.remove();else if(c.quantity!==null&&c.quantity!=="undefined")a.quantity=parseInt(a.quantity,10)+parseInt(c.quantity,10);if(c.price)a.total=parseFloat(a.total)+parseInt(c.quantity,10)*parseFloat(c.price)});a.shippingCost=a.shipping();a.taxCost=parseFloat(a.total)*
a.taxRate;a.finalTotal=a.shippingCost+a.taxCost+a.total};a.shipping=function(){if(parseInt(a.quantity,10)===0)return 0;var c=parseFloat(a.shippingFlatRate)+parseFloat(a.shippingTotalRate)*parseFloat(a.total)+parseFloat(a.shippingQuantityRate)*parseInt(a.quantity,10);a.each(function(a){a.shipping&&(c+=typeof a.shipping=="function"?parseFloat(a.shipping()):parseFloat(a.shipping))});return c};a.initialize=function(){simpleCart.initializeView();simpleCart.load();simpleCart.update()}}
function CartItem(){for(;simpleCart.items["c"+simpleCart.nextId];)simpleCart.nextId++;this.id="c"+simpleCart.nextId}
CartItem.prototype.set=function(a,c){a=a.toLowerCase();typeof this[a]!=="function"&&a!=="id"?(a=="quantity"?(c=c.replace(/[^(\d|\.)]*/gi,""),c=c.replace(/,*/gi,""),c=parseInt(c,10)):a=="price"&&(c=c.replace(/[^(\d|\.)]*/gi,""),c=c.replace(/,*/gi,""),c=parseFloat(c)),typeof c=="number"&&isNaN(c)?error("Improperly formatted input."):(c.match(/\~|\=/)&&error("Special character ~ or = not allowed: "+c),c=c.replace(/\~|\=/g,""),this[a]=c,this.checkQuantityAndPrice())):error("Cannot change "+a+", this is a reserved field.");
simpleCart.update()};CartItem.prototype.increment=function(){this.quantity=parseInt(this.quantity,10)+1;simpleCart.update()};CartItem.prototype.decrement=function(){parseInt(this.quantity,10)<2?this.remove():(this.quantity=parseInt(this.quantity,10)-1,simpleCart.update())};CartItem.prototype.print=function(){var a="";simpleCart.each(this,function(c,b,d){a+=escape(d)+"="+escape(c)+"||"});return a.substring(0,a.length-2)};
CartItem.prototype.checkQuantityAndPrice=function(){if(!this.quantity||this.quantity==null||this.quantity=="undefined")this.quantity=1,error("No quantity for item.");else if(this.quantity=(""+this.quantity).replace(/,*/gi,""),this.quantity=parseInt((""+this.quantity).replace(/[^(\d|\.)]*/gi,""),10),isNaN(this.quantity))error("Quantity is not a number."),this.quantity=1;if(!this.price||this.price==null||this.price=="undefined")this.price=0,error("No price for item or price not properly formatted.");
else if(this.price=(""+this.price).replace(/,*/gi,""),this.price=parseFloat((""+this.price).replace(/[^(\d|\.)]*/gi,"")),isNaN(this.price))error("Price is not a number."),this.price=0};
CartItem.prototype.parseValuesFromArray=function(a){if(a&&a.length&&a.length>0){for(var c=0,b=a.length;c<b;c++){a[c]=a[c].replace(/\|\|/g,"| |");a[c]=a[c].replace(/\+\+/g,"+ +");a[c].match(/\~/)&&error("Special character ~ not allowed: "+a[c]);a[c]=a[c].replace(/\~/g,"");var d=a[c].split("=");if(d.length>1){if(d.length>2)for(var e=2,g=d.length;e<g;e++)d[1]=d[1]+"="+d[e];this[unescape(d[0]).toLowerCase()]=unescape(d[1])}}return!0}else return!1};
CartItem.prototype.remove=function(){simpleCart.remove(this.id);simpleCart.update()};function Shelf(){this.items={}}Shelf.prototype.readPage=function(){this.items={};var a=getElementsByClassName("simpleCart_shelfItem"),c;me=this;for(var b=0,d=a.length;b<d;b++)c=new ShelfItem,me.checkChildren(a[b],c),me.items[c.id]=c};
Shelf.prototype.checkChildren=function(a,c){if(a.childNodes)for(var b=0;a.childNodes[b];b++){var d=a.childNodes[b];if(d.className&&d.className.match(/item_[^ ]+/)){var e=/item_[^ ]+/.exec(d.className)[0].split("_");if(e[1]=="add"||e[1]=="Add"){e=[];e.push(d);var g=simpleCart.Shelf.addToCart(c.id);simpleCart.addEventToArray(e,g,"click");d.id=c.id}else c[e[1]]=d}d.childNodes[0]&&this.checkChildren(d,c)}};Shelf.prototype.empty=function(){this.items={}};
Shelf.prototype.addToCart=function(a){return function(){simpleCart.Shelf.items[a]?simpleCart.Shelf.items[a].addToCart():error("Shelf item with id of "+a+" does not exist.")}};function ShelfItem(){this.id="s"+simpleCart.nextId++}ShelfItem.prototype.remove=function(){simpleCart.Shelf.items[this.id]=null};
ShelfItem.prototype.addToCart=function(){var a=[],c,b;for(b in this)if(typeof this[b]!=="function"&&b!=="id"){c="";switch(b){case "price":if(this[b].value)c=this[b].value;else if(this[b].innerHTML)c=this[b].innerHTML;c=c.replace(/[^(\d|\.)]*/gi,"");c=c.replace(/,*/,"");break;case "image":c=this[b].src;break;default:c=this[b].value?this[b].value:this[b].innerHTML?this[b].innerHTML:this[b].src?this[b].src:this[b]}a.push(b+"="+c)}simpleCart.add(a)};
function createCookie(a,c,b){if(b){var d=new Date;d.setTime(d.getTime()+b*864E5);b="; expires="+d.toGMTString()}else b="";c=c.replace(/\=/g,"~");document.cookie=a+"="+escape(c)+b+"; path=/"}function readCookie(a){a+="=";for(var c=document.cookie.split(";"),b=0;b<c.length;b++){for(var d=c[b];d.charAt(0)==" ";)d=d.substring(1,d.length);if(d.indexOf(a)===0)return unescape(d.substring(a.length,d.length)).replace(/\~/g,"=")}return null}function eraseCookie(a){createCookie(a,"",-1)}
var getElementsByClassName=function(a,c,b){getElementsByClassName=document.getElementsByClassName?function(a,b,c){for(var a=(c||document).getElementsByClassName(a),b=b?RegExp("\\b"+b+"\\b","i"):null,c=[],h,f=0,i=a.length;f<i;f+=1)h=a[f],(!b||b.test(h.nodeName))&&c.push(h);return c}:document.evaluate?function(a,b,c){for(var b=b||"*",c=c||document,h=a.split(" "),f="",i=document.documentElement.namespaceURI==="http://www.w3.org/1999/xhtml"?"http://www.w3.org/1999/xhtml":null,a=[],j,k=0,l=h.length;k<
l;k+=1)f+="[contains(concat(' ', @class, ' '), ' "+h[k]+" ')]";try{j=document.evaluate(".//"+b+f,c,i,0,null)}catch(m){j=document.evaluate(".//"+b+f,c,null,0,null)}for(;b=j.iterateNext();)a.push(b);return a}:function(a,b,c){var b=b||"*",c=c||document,h=a.split(" "),a=[],b=b==="*"&&c.all?c.all:c.getElementsByTagName(b),c=[],f;f=0;for(var i=h.length;f<i;f+=1)a.push(RegExp("(^|\\s)"+h[f]+"(\\s|$)"));for(var i=0,j=b.length;i<j;i+=1){h=b[i];f=!1;for(var k=0,l=a.length;k<l;k+=1)if(f=a[k].test(h.className),
!f)break;f&&c.push(h)}return c};return getElementsByClassName(a,c,b)};String.prototype.reverse=function(){return this.split("").reverse().join("")};Number.prototype.withCommas=function(){for(var a=6,c=parseFloat(this).toFixed(2).toString().reverse();a<c.length;)c=c.substring(0,a)+","+c.substring(a),a+=4;return c.reverse()};Number.prototype.toCurrency=function(a){return(a?a:"$")+this.withCommas()};function error(a){try{console.log(a)}catch(c){}}var simpleCart=new Cart;
typeof jQuery!=="undefined"?$(document).ready(function(){simpleCart.initialize()}):typeof Prototype!=="undefined"?Event.observe(window,"load",function(){simpleCart.initialize()}):window.onload=simpleCart.initialize;
