var CheckboxList,Globals;function ProductOptions(b,a){this.optionData=b;this.selectedMapId=0;
this.optionsContainer=a;this.onChangeOption=null;this.type3MaxItems=null;this.hideOptionWithOneItem=false;
this.readGlobals()}ProductOptions.prototype.readGlobals=function(){if(Globals.productOptions!==undefined){if(Globals.productOptions.type3MaxItems!==undefined){this.type3MaxItems=Globals.productOptions.type3MaxItems
}}if(this.type3MaxItems===null){this.type3MaxItems={defaultCount:2}}};ProductOptions.prototype.init=function(a){if(this.optionData.options.length>0){if(a!==undefined){this.selectedMapId=this.getMapId(a)
}this.setSelectionKeys(this.selectedMapId);this.writeAllOptions();return true}return false
};ProductOptions.prototype.getMapId=function(e){var j,g,f,l,m,k,h,c,a,n,b,d;b=[];
n=0;for(g=0,m=e.length;g<m;g++){h=this.objSearch(this.optionData.options,"name","",e[g].name);
c=this.objSearch(this.optionData.values,"value","",e[g].value,true);if(typeof(c)=="object"){for(j=0,l=c.length;
j<l;j++){if(h!=-1){b.push({optionId:h,valueId:c[j]})}}}else{if(h!=-1&&c!=-1){b.push({optionId:h,valueId:c})
}}}for(g=0,m=this.optionData.mapping.length;g<m;g++){a=this.optionData.mapping[g];
d=0;for(f=0,k=b.length;f<k;f++){if(a[b[f].optionId]==b[f].valueId){d++}}if(d==this.optionData.options.length){n=g;
break}}return n};ProductOptions.prototype.setSelectionKeys=function(c){var b,a;this.selectedMapId=c;
for(b=0,a=this.optionData.options.length;b<a;b++){this.optionData.options[b].id=b;
this.optionData.options[b].selection=this.optionData.mapping[c][b]}};ProductOptions.prototype.readOptionItems=function(g){var h,f,d,k,l,j,a,b,c,m,e;
b=[];m=[];for(h=0,k=g;h<k;h++){b.push(this.optionData.mapping[this.selectedMapId][h])
}for(f=0,l=this.optionData.mapping.length;f<l;f++){a=this.optionData.mapping[f];c=0;
for(d=0,j=b.length;d<j;d++){if(a[d]==b[d]){c++}}if(c==b.length){e={id:a[g],data:this.optionData.values[a[g]],selected:this.optionData.options[g].selection==a[g],productId:a[a.length-1]};
if(this.objSearch(m,"id","id",a[g])==-1){m.push(e)}}}return m};ProductOptions.prototype.changeSelection=function(g,j,b){var f,e,i,h,a,c,d;
if(b===undefined){b=this.optionData.options.length}if(b<1){return false}if(g!==null&&j!==null){this.optionData.options[g].selection=j
}c=null;for(f=0,i=this.optionData.mapping.length;f<i;f++){a=this.optionData.mapping[f];
d=0;for(e=0,h=b;e<h;e++){if(this.optionData.options[e].selection==a[e]){d++}}if(d==b){c=f;
this.setSelectionKeys(c);break}}if(c===null){this.changeSelection(null,null,b-1)}};
ProductOptions.prototype.writeAllOptions=function(d){var c,a,b;b=(d===undefined)?0:d+1;
for(c=b,a=this.optionData.options.length;c<a;c++){this.writeOption(this.optionData.options[c],this.readOptionItems(c))
}};ProductOptions.prototype.getAllOptionItems=function(){var c,b,a;a=[];for(c=0,b=this.optionData.options.length;
c<b;c++){a.push(this.readOptionItems(c))}return a};ProductOptions.prototype.writeOption=function(option,items){var i,max,newDiv1,newDiv2,newDiv3,newDiv4,newH2,newP,newUl,newLi,newSpan,newVar,oldOption,selectedItem,newSelect,newOption,type3MaxItems,clearDiv,newStyleHelperDiv1,newStyleHelperDiv2,newStyleHelperDiv3;
oldOption=document.getElementById("option"+option.id);if(oldOption!==null){this.optionsContainer.removeChild(oldOption)
}option.newType=option.type;if(option.type==3){type3MaxItems=eval("this.type3MaxItems.productCount"+this.getCurrentProductId());
if(type3MaxItems===undefined){type3MaxItems=eval("this.type3MaxItems.optionCount"+option.name);
if(type3MaxItems===undefined){type3MaxItems=this.type3MaxItems.defaultCount}}option.newType=items.length>type3MaxItems?2:1
}if(this.hideOptionWithOneItem&&items.length==1){option.newType=0}switch(option.newType){case 0:break;
case 2:newDiv1=document.createElement("div");newDiv1.className="option option-"+option.name+" option-"+option.name+"-itemsqty-"+items.length+" comboBoxOption";
newDiv1.id="option"+option.id;newDiv1.optionItems=[];newH2=document.createElement("h2");
newH2.appendChild(document.createTextNode(option.title));newUl=document.createElement("ul");
newUl.id="productOptions-"+option.name;newUl.className="checkboxlist";newLi=document.createElement("li");
newLi.className="pOption-"+option.name+"-"+items[0].data.value;newDiv2=document.createElement("div");
newDiv2.className="radioselect checked";newDiv2.style.cursor="default";newLi.appendChild(newDiv2);
newDiv3=document.createElement("div");newDiv3.className="img";newDiv2.appendChild(newDiv3);
newSelect=document.createElement("select");newSelect.className="select";newSelect.size=1;
for(i=0,max=items.length;i<max;i++){newDiv1.optionItems.push(items[i].id);newOption=document.createElement("option");
newOption.className="pOption-"+option.name+"-"+items[i].data.value;newOption.value=items[i].id;
newOption.selected=items[i].selected;newOption.appendChild(document.createTextNode(items[i].data.title));
newSelect.appendChild(newOption)}newSelect.cbOption=option;newSelect.origObj=this;
newSelect.onchange=this.optionChangeHandler;newDiv2.appendChild(newSelect);newUl.appendChild(newLi);
newDiv4=document.createElement("div");newDiv4.className="previewImg";newDiv1.appendChild(newH2);
newDiv1.appendChild(newUl);newDiv1.appendChild(newDiv4);this.optionsContainer.appendChild(newDiv1);
break;default:case 1:newDiv1=document.createElement("div");newDiv1.className="option option-"+option.name+" option-"+option.name+"-itemsqty-"+items.length+" radioSelectOption";
newDiv1.id="option"+option.id;newDiv1.optionItems=[];newH2=document.createElement("h2");
newH2.appendChild(document.createTextNode(option.title));newP=document.createElement("p");
newP.className="optionDescription";newP.appendChild(document.createTextNode(option.description));
newUl=document.createElement("ul");newUl.id="productOptions-"+option.name;newUl.className="checkboxlist";
for(i=0,max=items.length;i<max;i++){if(items[i].selected){selectedItem=items[i].id
}newDiv1.optionItems.push(items[i].id);newLi=document.createElement("li");newLi.className="pOption-"+option.name+"-"+items[i].data.value;
newVar=document.createElement("var");newVar.appendChild(document.createTextNode(items[i].id));
newLi.appendChild(newVar);newDiv2=document.createElement("div");newDiv2.className="radioselect";
newLi.appendChild(newDiv2);newDiv3=document.createElement("div");newDiv3.className="point";
newDiv2.appendChild(newDiv3);newDiv3=document.createElement("div");newDiv3.className="img";
newDiv2.appendChild(newDiv3);newDiv3=document.createElement("div");newDiv3.className="txt";
newDiv3.appendChild(document.createTextNode(items[i].data.title));newDiv3.appendChild(document.createElement("br"));
newSpan=document.createElement("span");newSpan.className="optionValueDescription";
newSpan.appendChild(document.createTextNode(items[i].data.description));newDiv3.appendChild(newSpan);
newDiv2.appendChild(newDiv3);newUl.appendChild(newLi)}clearDiv=document.createElement("div");
clearDiv.style.clear="both";newStyleHelperDiv1=document.createElement("div");newStyleHelperDiv1.className="option-styleHelper-1";
newStyleHelperDiv2=document.createElement("div");newStyleHelperDiv2.className="option-styleHelper-2";
newStyleHelperDiv3=document.createElement("div");newStyleHelperDiv3.className="option-styleHelper-3";
newStyleHelperDiv3.appendChild(newH2);newStyleHelperDiv3.appendChild(newP);newStyleHelperDiv3.appendChild(newUl);
newStyleHelperDiv3.appendChild(clearDiv);newStyleHelperDiv2.appendChild(newStyleHelperDiv3);
newStyleHelperDiv1.appendChild(newStyleHelperDiv2);newDiv1.appendChild(newStyleHelperDiv1);
this.optionsContainer.appendChild(newDiv1);option.checkBoxList=new CheckboxList("productOptions-"+option.name);
option.checkBoxList.checkBoxClassName="radioselect";option.checkBoxList.useStyleClass=true;
option.checkBoxList.styleClassOn="checked";option.checkBoxList.styleClassOff="";option.checkBoxList.multipleSelection=false;
option.checkBoxList.minSelectedItems=1;option.checkBoxList.init();option.checkBoxList.setCheckedBoxByValue(selectedItem!==undefined?selectedItem:items[0].id);
option.checkBoxList.cbOption=option;option.checkBoxList.origObj=this;option.checkBoxList.onchange=this.optionChangeHandler;
break}};ProductOptions.prototype.optionChangeHandler=function(b,d,e,c){var a;if(typeof(b)=="undefined"){b=undefined
}if(this.origObj){return this.origObj.optionChangeHandler(b,this,this.origObj,this.cbOption)
}a=this.selectedMapId;switch(c.newType){case 1:this.changeSelection(c.id,c.checkBoxList.getValuesFromCheckedBoxes()[0]);
break;case 2:this.changeSelection(c.id,d.value);break}this.writeAllOptions(c.id);
if(this.onChangeOption!==null){this.onChangeOption(c,this.selectedMapId,a)}};ProductOptions.prototype.getCurrentProductId=function(){var a;
a=this.optionData.mapping[this.selectedMapId];return a[a.length-1]};ProductOptions.prototype.getCurrentOptionValues=function(){var d,b,e,a,c;
a=[];e=this.optionData.mapping[this.selectedMapId];for(d=0,b=this.optionData.options.length;
d<b;d++){c={name:this.optionData.options[d].name,value:this.optionData.values[e[d]].value};
a.push(c)}return a};ProductOptions.prototype.objSearch=function(obj,checkKey,resultKey,value,fullSearch){var oSi,oSmax,results;
results=[];if(fullSearch===undefined){fullSearch=false}for(oSi=0,oSmax=obj.length;
oSi<oSmax;oSi++){if(obj[oSi][checkKey]==value){if(fullSearch){results.push((resultKey!=="")?obj[oSi][resultKey]:oSi)
}else{return(resultKey!=="")?eval("obj[oSi]."+resultKey):oSi}}}if(fullSearch&&results.length){return results
}return -1};ProductOptions.prototype.setMapId=function(c){var b,a;this.setSelectionKeys(c);
for(b=0,a=this.optionData.options.length;b<a;b++){this.writeOption(this.optionData.options[b],this.readOptionItems(b))
}};