var jsItemAddonsArray = new Array();
var jsAddonsAva = new Array();
var selectedAddons = new Array();
var selectedAvas = new Array();
var selectedAdditionalField = new Array();
var itm_price = "52.13";
itm_price = "45.00";
var currentDays;
if (!jsAddonsAva[3506]) jsAddonsAva[3506] = Array();
function changeAddons (dd) {
var strpos1 = strpos (dd.name, "[");
var strpos2 = strpos (dd.name, "]");
var showWarn;
var iagId;
var iaoId;
iagId = dd.name.substring(strpos1+1, strpos2);
iaoId = dd.options[dd.selectedIndex].value;
setPrice (iagId,iaoId);
showAddonPrice (iagId,iaoId);
showAddonPicture (iagId,iaoId);
showAddonText (iagId,iaoId);
showAddonAdditionalField(iagId,iaoId);
setAva (iagId,iaoId);
showFloater();
}
function showAddonPrice (iagId,iaoId) {
var id = 'addonPrice_'+ iagId;
var price = parseFloat(jsItemAddonsArray[iagId][iaoId]["price"]);
if (jsItemAddonsArray[iagId][iaoId]["price"]*1 > 0) {
document.getElementById(id).value = price.toFixed(2)+" €";
document.getElementById(id+"_div").innerHTML = price.toFixed(2)+" €";
}
else {
document.getElementById(id).value = "";
document.getElementById(id+"_div").innerHTML = "";
}
}
function showAddonPicture (iagId,iaoId) {
var picture = 'pictureItemAddon_'+ iagId;
if (this.document.images[picture]) this.document.images[picture].src = jsItemAddonsArray[iagId][iaoId]["picture"];
}
function showAddonText (iagId,iaoId) {
var id = 'addonText_'+ iagId;
var text = jsItemAddonsArray[iagId][iaoId]["text"];
document.getElementById(id).innerHTML = text;
}
function showAddonAdditionalField (iagId,iaoId) {
var id = 'addonAdditionalField_'+ iagId;
var divId = 'addonAdditionalFieldText_'+ iagId;
var divId2 = 'addonAdditionalFieldText2_'+ iagId;
var text = jsItemAddonsArray[iagId][iaoId]["additionalFieldText"];
var wrapper = '#aAFWrapper_'+ iagId;
if (text == undefined) {
if (document.getElementById(id) != null) {
document.getElementById(id).value = "";
document.getElementById(id).style.visibility = 'hidden';
document.getElementById(divId).style.display = 'none';
document.getElementById(divId2).style.display = 'none';
$(wrapper).css('display', 'none');
}
}
else {
document.getElementById(divId).style.display = 'inline';
document.getElementById(divId2).style.display = 'inline';
document.getElementById(divId).innerHTML = text;
document.getElementById(id).style.visibility = 'visible';
$(wrapper).css('display', 'block');
}
}
function setPrice (iagId,iaoId) {
var actualPrice;
var variantPrice;
var price;
selectedAddons[iagId] = jsItemAddonsArray[iagId][iaoId]["price"]*1;
variantPrice = 0;
for (iag in selectedAddons){
price = parseFloat(selectedAddons[iag]);
variantPrice = variantPrice + price;
}
actualPrice = variantPrice + parseFloat(itm_price);
if (actualPrice != itm_price) $("#price").html("Preis inkl. Artikelvarianten & Zubehör: " + actualPrice.toFixed(2)+" €");
else $("#price").html("");
$("#priceFloater").html(actualPrice.toFixed(2)+" €");
}
function setAva (iagId,iaoId) {
var selectedDays = parseInt(0);
if(jsAddonsAva[iagId]== null) return true;
selectedAvas[iagId] = iaoId;
for (iagId in selectedAvas){
iaoId = selectedAvas[iagId];
if (selectedDays <= parseInt(jsAddonsAva[iagId][iaoId]["avaDays"])){
selectedDays = parseInt(jsAddonsAva[iagId][iaoId]["avaDays"]);
selectedIagId = iagId;
selectedIaoId = iaoId;
}
}
if (selectedDays == 0) {
var token = "defaultIaoId_" + iagId;
var defIaoId = this.document.form1.elements[token].value
document.getElementById('avaText').innerHTML = this.document.form1.defaultText.value;
document.getElementById('avaText2').innerHTML = this.document.form1.defaultText.value;
document.getElementById('avaText3').innerHTML = this.document.form1.defaultText.value;
this.document.form1.actualDays.value = jsAddonsAva[iagId][defIaoId]["avaDays"];
$("#avaWarn").html("").hide();
$("#avaWarn2").html("").hide();
}
else if (this.document.form1.defaultDays.value < selectedDays) {
document.getElementById('avaText').innerHTML = jsAddonsAva[selectedIagId][selectedIaoId]["avaText"];
document.getElementById('avaText2').innerHTML = jsAddonsAva[selectedIagId][selectedIaoId]["avaText"];
document.getElementById('avaText3').innerHTML = jsAddonsAva[selectedIagId][selectedIaoId]["avaText"];
this.document.form1.actualDays.value = jsAddonsAva[selectedIagId][selectedIaoId]["avaDays"];
$("#avaWarn").html("Achtung die Versandzeit wurde geändert").show();
$("#avaWarn2").html("Achtung die Versandzeit wurde geändert").show();
}
else if (this.document.form1.defaultDays.value == selectedDays) {
document.getElementById('avaText').innerHTML = jsAddonsAva[selectedIagId][selectedIaoId]["avaText"];
document.getElementById('avaText2').innerHTML = jsAddonsAva[selectedIagId][selectedIaoId]["avaText"];
document.getElementById('avaText3').innerHTML = jsAddonsAva[selectedIagId][selectedIaoId]["avaText"];
this.document.form1.actualDays.value = jsAddonsAva[selectedIagId][selectedIaoId]["avaDays"];
$("#avaWarn").html("").hide();
$("#avaWarn2").html("").hide();
}
else {
$("#avaWarn").html("").hide();
$("#avaWarn2").html("").hide();
document.getElementById('avaText').innerHTML = this.document.form1.defaultText.value;
document.getElementById('avaText2').innerHTML = this.document.form1.defaultText.value;
document.getElementById('avaText3').innerHTML = this.document.form1.defaultText.value;
}
}
function strpos(str, ch) {
for (var i = 0; i < str.length; i++) {
if (str.substring(i, i+1) == ch) return i;
}
}
function showFloater() {
document.getElementById('divItemFloater').style.display = "block";
}
function toggleFloatersize() {
if (document.getElementById('divItemFloaterContent').style.display == "block") {
document.getElementById('divItemFloaterContent').style.display = "none";
$("#floaterButton").html('');
}
else {
document.getElementById('divItemFloaterContent').style.display = "block";
$("#floaterButton").html('');
}
}