function ale(f){var old=window.onload;if(typeof window.onload!='function'){window.onload=f;}else{window.onload=function(){old();f();}}}function st(e,t){if(e){e.innerText=t;e.textContent=t;}}function gv(o){var a=[];for(var i=0;i<o.length;++i){for(var j=0;o[i]&&j<o[i].length;++j){if(o[i][j].options)a.push(o[i][j].options[o[i][j].selectedIndex].value);else if(o[i][j].checked)a.push(o[i][j].value);else if(o[i][j].length){for(var k=0;o[i][j]&&k<o[i][j].length;++k){if(o[i][j][k].options)a.push(o[i][j][k].options[o[i][j][k].selectedIndex].value);else if(o[i][j][k].checked)a.push(o[i][j][k].value);}}}}return a;}
function sh(e,h){if(e){e.innerHTML=h;e.htmlContent=h;}}
function checkInstallation(showAlert)
{if(typeof showAlert=='undefined')
var showAlert=false;if(typeof sl_elements=='undefined'||typeof sl_validAssignIds=='undefined'||typeof sl_stockInfo=='undefined'||typeof sl_prodCode=='undefined'||typeof sl_totalStock=='undefined'||typeof sl_useStock=='undefined'||typeof sl_showStockLevel=='undefined'||typeof sl_allowOutOfStock=='undefined'||typeof sl_appendCode=='undefined'||typeof sl_appendChar=='undefined'||typeof sl_langInStock=='undefined'||typeof sl_langOutOfStock=='undefined'||typeof sl_langVariantOutOfStock=='undefined'||typeof sl_langVariantNotAvail=='undefined'||typeof sl_langOutOfStockAlert=='undefined'||typeof sl_langNotAvailAlert=='undefined'){return false;}
return true;}
function getIndex(assignIds)
{var index='';for(var i=0;i<sl_validAssignIds.length;++i){for(var j=0;j<assignIds.length;++j){if(sl_validAssignIds[i]==assignIds[j]){if(index.length>0)index+=',';index+=sl_validAssignIds[i];}}}
return index;}
function updateStockLevel()
{if(!checkInstallation()){return;}
var assignIds=[];var stockString='';var outStockString='';var prodCode='';var a=gv(sl_elements);var incompleteSelection=false;for(var i=0;i<a.length;++i){if(a[i].charAt(0)=='0'){a.length=0;incompleteSelection=true;}}
var index=getIndex(a);if(typeof sl_stockInfo[index]!='undefined'){prodCode=sl_stockInfo[index][1];var stockLevel=sl_stockInfo[index][0];}else if(index==''){var stockLevel=sl_totalStock;}
if(sl_useStock&&typeof stockLevel!='undefined'){if(incompleteSelection){stockString=outStockString='';}else if(stockLevel>0){stockString=sl_langInStock;if(sl_showStockLevel)stockString+=': '+stockLevel;outStockString='';$('#add-to-cart-button').show();}else if(sl_totalStock<=0){stockString='';outStockString=sl_langOutOfStock;$('#add-to-cart-button').hide();}else{stockString='';outStockString=sl_langVariantOutOfStock;$('#add-to-cart-button').hide();}}else if(sl_useStock){stockString='';outStockString=sl_langVariantNotAvail;}
var inStockSpan=document.getElementById('inStock');var outOfStockSpan=document.getElementById('outOfStock');var prodCodeSpan=document.getElementById('prodCode');if(sl_useStock){sh(inStockSpan,stockString);sh(outOfStockSpan,outStockString);}
if(prodCode!=''&&sl_appendCode){st(prodCodeSpan,sl_prodCode+sl_appendChar+prodCode);}else if(prodCode!=''&&!sl_appendCode){st(prodCodeSpan,prodCode);}else{st(prodCodeSpan,sl_prodCode);}}
function checkStock()
{if(!checkInstallation(true)){return true;}
var a=gv(sl_elements);var index=getIndex(a);if(typeof sl_stockInfo[index]!='undefined'){stockLevel=sl_stockInfo[index][0];}else if(index==''){stockLevel=sl_totalStock;}
if(typeof stockLevel!='undefined'){if(stockLevel>0){return true;}else if(stockLevel<=0&&!sl_useStock){return true;}else if(stockLevel<=0&&sl_allowOutOfStock){return true;}else if(stockLevel<=0&&!sl_allowOutOfStock){alert(sl_langOutOfStockAlert);return false;}}else{alert(sl_langNotAvailAlert);return false;}}