/* Dynamic Price 1.5.1 Written by All Web Promotion, Inc. allwebpromotion.com */
(function(a){a.awpDynamicPricing=function(o){var f={currency:"$",removeOptionPrices:false,priceSel:".price-hidden-value",salePriceSel:".sale-price-hidden-value",itemParentSel:".itemform form",itemPriceSel:".price .value, .price-bold .value",itemSalePriceSel:".sale-price .value, .sale-price-bold .value",sectionParentSel:"#contents-table td",sectionPriceSel:".price .value, .price-bold .value",sectionSalePriceSel:".sale-price .value, .sale-price-bold .value",optionAllSel:'select,input[type="checkbox"],input[type="radio"]',optionChangeSel:"select",optionClickSel:'input[type="checkbox"],input[type="radio"]',optionSelectSel:"select",optionCheckboxSel:'input[type="checkbox"]',optionRadioSel:'input[type="radio"]',quantitySel:".quantity-input",extendedPriceSel:".total-price .value",priceSaveAmountSel:".price-save .price",priceSavePercentSel:".price-save .percent",hidePriceTime:200,showPriceTime:400};var e=a.extend({},f,o);var h=/\$\d+\.\d{2}/;var i=/\([\+|\-](.*)\)/;var c=/\((.*)\)/;function n(p,r){var q;for(q=0;q<p.length;q++){if(p[q]===r){return true;}}return false;}function d(p){p=p.match(c);if(p){p=p[1];p=p.replace("$","");p=parseFloat(p);p=isNaN(p)?0:p;}else{p=0;}return p;}function l(u,r,x,A){if(!u){return false;}var q,z,p,y,t,w,s;var v=0;a(u).find(e.optionSelectSel).each(function(){if(a(this).attr("name")){var B=a(this).val();v=v+d(B);}});a(u).find(e.optionCheckboxSel).each(function(){if(a(this).attr("name")){var B;if(a(this).is(":checked")){B=a(this).attr("value");v=v+d(B);}}});s=[];a(u).find(e.optionRadioSel).each(function(){var B=a(this).attr("name");if(!n(s,B)){s.push(B);}});a(s).each(function(C,B){if(a(this).attr("name")){var D=a(u).find('input[name="'+B+'"]:checked').val();v=v+d(D);}});if(x){q=(r=="section")?e.sectionPriceSel:e.itemPriceSel;z=parseFloat(x)+parseFloat(v);m(u,q,z);}if(A){q=(r=="section")?e.sectionSalePriceSel:e.itemSalePriceSel;p=parseFloat(A)+parseFloat(v);m(u,q,p);}if(e.quantitySel&&a(e.quantitySel,u).size()>0){t=parseFloat(a(e.quantitySel,u).val());t=t?t:0;t=(t<0)?0:t;}else{t=1;}y=p?p:z;y=y*t;m(u,e.extendedPriceSel,y);if(x&&A){w=b(z-p);a(e.priceSaveAmountSel,u).text(w);w=k(z,p);a(e.priceSavePercentSel,u).text(w);}}function j(p,r){var q=a(p).find(r).eq(0).val();if(!q){return 0;}var q=parseFloat(q.replace(/\$/,"").replace(/\,/,""));return isNaN(q)?0:q;}function m(p,t,r){if(!t){return;}var q=b(r),s=a(p).find(t);if(q==s.text()){return;}s.animate({opacity:"toggle"},e.hidePriceTime,function(){a(this).text(q).animate({opacity:"toggle"},e.hidePriceTime,function(){});});}function b(q){var p=new Number(q);return e.currency+p.toFixed(2);}function k(q,p){return(Math.round((q-p)/q*100))+"%";}function g(p){if(!e.removeOptionPrices){return;}a(e.optionAllSel,p).each(function(){var r,q;if(this.tagName.toLowerCase()=="select"){a("option",this).each(function(){var s=a(this).text();if(!s){s=a(this).val();}a(this).text(a.trim(s.replace(i,"")));});}else{if(a(this).attr("type")=="radio"){q=a(this).siblings(".radio-option-label");r=q.text();q.text(a.trim(r.replace(i,"")));}else{if(a(this).attr("type")=="checkbox"){}}}});}a(e.itemParentSel).each(function(){var t,p=this,r="item",q=j(p,e.priceSel),s=j(p,e.salePriceSel);a(e.optionChangeSel,p).change(function(){l(p,r,q,s);});a(e.optionClickSel,p).click(function(){l(p,r,q,s);});if(e.quantitySel){a(e.quantitySel,p).keyup(function(){l(p,r,q,s);});}g(p);});a(e.sectionParentSel).each(function(){var t,p=this,r="section",q=j(p,e.priceSel),s=j(p,e.salePriceSel);a(e.optionChangeSel,p).change(function(){l(p,r,q,s);});a(e.optionClickSel,p).click(function(){l(p,r,q,s);});if(e.quantitySel){a(e.quantitySel,p).keyup(function(){l(p,r,q,s);});}g(p);});if(e.quantitySel&&e.itemParentSel&&a(e.quantitySel,e.itemParentSel).size()>0){a(e.quantitySel,e.itemParentSel).eq(0).trigger("keyup");}else{a(e.optionAllSel,e.itemParentSel).eq(0).trigger("change click");}if(e.quantitySel&&e.sectionParentSel&&a(e.quantitySel,e.sectionParentSel).size()>0){a(e.quantitySel,e.sectionParentSel).eq(0).trigger("keyup");}else{a(e.optionSel,e.sectionParentSel).eq(0).trigger("change click");}};})(jQuery);

