var current_taxes=[],product_thumbnail=document.getElementById("product_thumbnail"),availObj=document.getElementById("product_avail");
function check_options(){var b=[],e=false,a=false;for(var c in taxes)b[c]=taxes[c][0];price=default_price;for(var d in variants)if(variants[d][1].length!=0){a=d;for(var f in variants[d][1])if(getPOValue(f)!=variants[d][1][f]){a=false;break}if(a)break}if(a){price=variants[a][0][0];orig_price=variants[a][0][4];avail=variants[a][0][1];if(variants[a][3]){product_wholesale=[];for(c in variants[a][3]){var g=modi_price(variants[a][3][c][2],cloneObject(variants[a][3][c][3]),variants[a][3][c][4]);product_wholesale[c]=
[variants[a][3][c][0],variants[a][3][c][1],g[0],[]];for(f in g[1])product_wholesale[c][3][f]=g[1][f]}e=true}for(c in b)if(variants[a][2][c])b[c]=parseFloat(variants[a][2][c]);product_thumbnail||(product_thumbnail=document.getElementById("product_thumbnail"));if(product_thumbnail)if(variants[a][0][2].src&&variants[a][0][2].width>0&&variants[a][0][2].height>0){if(product_thumbnail.src!=variants[a][0][2].src){product_thumbnail.src=variants[a][0][2].src;product_thumbnail.width=variants[a][0][2].width;
product_thumbnail.height=variants[a][0][2].height}}else if(document.getElementById("product_thumbnail").src!=product_image.src){product_thumbnail.src=product_image.src;if(product_image.width>0&&product_image.height>0){product_thumbnail.width=product_image.width;product_thumbnail.height=product_image.height}}if(document.getElementById("product_weight"))document.getElementById("product_weight").innerHTML=price_format(variants[a][0][3]);if(document.getElementById("product_weight_box"))document.getElementById("product_weight_box").style.display=
parseFloat(variants[a][0][3])>0?"":"none";if(document.getElementById("product_code"))document.getElementById("product_code").innerHTML=variants[a][0][5]}if(pconf_price>0)price=pconf_price;g=modi_price(price,b,orig_price);price=g[0];b=g[1];if(!a){product_wholesale=[];for(c in _product_wholesale){g=modi_price(_product_wholesale[c][2],_product_wholesale[c][3].slice(0),_product_wholesale[c][4]);product_wholesale[c]=[_product_wholesale[c][0],_product_wholesale[c][1],g[0],g[1]]}e=true}for(c in b){if(document.getElementById("tax_"+
c))document.getElementById("tax_"+c).innerHTML=currency_symbol+price_format(b[c]<0?0:b[c]);current_taxes[c]=b[c]}e&&rebuild_wholesale();if(document.getElementById("product_price"))document.getElementById("product_price").innerHTML=currency_symbol+price_format(price<0?0:price);if(alter_currency_rate>0&&alter_currency_symbol!=""&&document.getElementById("product_alt_price")){d=price*alter_currency_rate;document.getElementById("product_alt_price").innerHTML="("+alter_currency_symbol+" "+price_format(d<
0?0:d)+")"}if(document.getElementById("save_percent")&&document.getElementById("save_percent_box")&&list_price>0&&dynamic_save_money_enabled){d=Math.round(100-price/list_price*100);if(d>0){document.getElementById("save_percent_box").style.display="";document.getElementById("save_percent").innerHTML=d}else{document.getElementById("save_percent_box").style.display="none";document.getElementById("save_percent").innerHTML="0"}}if(document.getElementById("product_avail_txt"))if(avail>0)document.getElementById("product_avail_txt").innerHTML=
substitute(txt_items_available,"items",a?avail:product_avail);else document.getElementById("product_avail_txt").innerHTML=lbl_no_items_available;if(mq>0&&avail>mq+min_avail||is_unlimit)avail=mq+min_avail-1;avail=avail>mq?mq:avail;a=min_avail;availObj||(availObj=document.getElementById("product_avail"));if(availObj&&availObj.tagName.toUpperCase()=="SELECT"){if(!isNaN(min_avail)&&!isNaN(avail)){a=-1;if(availObj.options[0])a=availObj.options[0].value;if(a==min_avail){if(avail-min_avail+1!=availObj.options.length)if(availObj.options.length>
avail){a=availObj.options.length;for(d=avail<0?0:avail;d<a;d++)availObj.options[availObj.options.length-1]=null}else{a=availObj.options.length;for(d=a+1;d<=avail;d++)availObj.options[a++]=new Option(d,d)}}else{for(;availObj.options.length>0;)availObj.options[0]=null;a=0;for(d=min_avail;d<=avail;d++)availObj.options[a++]=new Option(d,d)}if(availObj.options.length==0||min_avail>avail)availObj.options[0]=new Option(txt_out_of_stock,0)}a=availObj.options[availObj.selectedIndex].value}else if(availObj&&
availObj.tagName.toUpperCase()=="INPUT"&&availObj.type.toUpperCase()=="TEXT"){if(!isNaN(min_avail)&&!isNaN(avail)){availObj.minQuantity=min_avail;availObj.maxQuantity=avail}a=availObj.value}check_wholesale(a);alert_msg=="Y"&&min_avail>avail&&alert(txt_out_of_stock);a=check_exceptions();!a&&alert_msg=="Y"&&alert(exception_msg);if(document.getElementById("exception_msg"))document.getElementById("exception_msg").innerHTML=a?"":exception_msg_html+"<br /><br />";return true}
function modi_price(b,e,a){var c=round(b,2);for(var d in modifiers){var f=getPOValue(d);if(f&&modifiers[d][f]){f=modifiers[d][f];c+=parseFloat(f[1]=="$"?f[0]:b*f[0]/100);for(var g in e)if(f[2][g])e[g]+=parseFloat(f[1]=="$"?f[2][g]:a*f[2][g]/100)}}return[c,e]}function check_exceptions(){if(!exceptions)return true;for(var b in exceptions)if(!isNaN(b)){var e=true;for(var a in exceptions[b]){var c=getPOValue(a);if(!c)return true;if(c!=exceptions[b][a]){e=false;break}}if(e)return false}return true}
function rebuild_wholesale(){var b=document.getElementById("wl_table");if(!b)return false;if(!product_wholesale||product_wholesale.length==0){b.innerHTML="";return false}var e="",a=0;for(var c in product_wholesale)if(product_wholesale[c][0]!=0){if(a==0)e+='<br /><table cellpadding="2" cellspacing="2"><tr class="TableHead"><td align="right"><b>'+lbl_quantity+":&nbsp;</b></td>";e+="<td>"+product_wholesale[c][0];if(c==product_wholesale.length-1)e+="+";else if(product_wholesale[c][0]<product_wholesale[c][1])e+=
"-"+product_wholesale[c][1];e+="&nbsp;"+(product_wholesale[c][0]==1?lbl_item:lbl_items)+"</td>";a++}if(a==0)return false;a="";if(taxes.length>0)for(c in taxes)if(current_taxes[c]>0)a+=substitute(lbl_including_tax,"tax",taxes[c][1])+"<br />";e+='</tr><tr bgcolor="#EEEEEE"><td align="right"><b>'+lbl_price+(a.length>0?"*":"")+":&nbsp;</b></td>";for(c in product_wholesale)if(product_wholesale[c][0]!=0)e+="<td>"+price_format(product_wholesale[c][2]<0?0:product_wholesale[c][2])+"</td>";e+="</tr></table>";
if(a.length>0)e+='<br /><table><tr><td class="FormButton" valign="top"><b>*'+txt_note+':</b>&nbsp;</td><td nowrap="nowrap" valign="top">'+a+"</td></tr></table>";e+="<br />";b.innerHTML=e;return true}
function check_wholesale(b){if(product_wholesale.length==0)return true;for(var e=current_taxes.slice(0),a=price,c=false,d=0;d<product_wholesale.length;d++){if(product_wholesale[d][0]<=b&&(product_wholesale[d][1]>=b||product_wholesale[d][1]==0)){a=product_wholesale[d][2];e=product_wholesale[d][3].slice(0);c=true}if(document.getElementById("wp"+d)){c=price-default_price+product_wholesale[d][2];document.getElementById("wp"+d).innerHTML=currency_symbol+price_format(c<0?0:c)}}if(document.getElementById("product_price"))document.getElementById("product_price").innerHTML=
currency_symbol+price_format(a<0?0:a);if(alter_currency_rate>0&&alter_currency_symbol!=""&&document.getElementById("product_alt_price")){b=a*alter_currency_rate;document.getElementById("product_alt_price").innerHTML="("+alter_currency_symbol+" "+price_format(b<0?0:b)+")"}if(document.getElementById("save_percent")&&document.getElementById("save_percent_box")&&list_price>0&&dynamic_save_money_enabled){a=Math.round(100-(a<0?0:a)/list_price*100);if(a>0){document.getElementById("save_percent_box").style.display=
"";document.getElementById("save_percent").innerHTML=a}else{document.getElementById("save_percent_box").style.display="none";document.getElementById("save_percent").innerHTML="0"}}for(d in taxes)if(document.getElementById("tax_"+d)&&e[d]&&current_taxes[d])document.getElementById("tax_"+d).innerHTML=currency_symbol+price_format(e[d]<0?0:e[d]);return true}
function check_quantity_input_box(b){if(isNaN(b.minQuantity))b.minQuantity=min_avail;if(isNaN(b.maxQuantity))b.maxQuantit=avail;if(!isNaN(b.minQuantity)&&!isNaN(b.maxQuantity)){var e=parseInt(b.value);if(isNaN(e)){alert(substitute(lbl_product_quantity_type_error,"min",b.minQuantity,"max",b.maxQuantity));return false}if(e<b.minQuantity){alert(substitute(lbl_product_minquantity_error,"min",b.minQuantity));return false}if(e>b.maxQuantity){alert(substitute(lbl_product_maxquantity_error,"max",b.maxQuantity));
return false}check_wholesale(b.value)}return true}function getPOValue(b){if(!document.getElementById("po"+b)||document.getElementById("po"+b).tagName.toUpperCase()!="SELECT")return false;return document.getElementById("po"+b).options[document.getElementById("po"+b).selectedIndex].value}function product_option(b){if(!isNaN(b))return document.getElementById("po"+b);if(!names)return false;for(var e in names)if(names[e].class_name==b)return document.getElementById("po"+e);return false}
function product_option_value(b){var e=product_option(b);if(!e)return false;if(e.type!="select-one")return e.value;b=parseInt(e.id.substr(2));e=parseInt(e.options[e.selectedIndex].value);if(names[b]&&names[b].options[e])return names[b].options[e];return false};