var CloseBut1 = new Image(); var CloseBut2 = new Image(); var plusImg = new Image(); var minusImg = new Image(); CloseBut1.src = "/proimages/closebtn.gif"; CloseBut2.src = "/proimages/closebtn.gif"; plusImg.src = "/proimages/plus.gif"; minusImg.src = "/proimages/minus.gif"; function startFlying(flyId){ var flyObj = new fly(); flyObj.flyId = flyId; flyObj.stopId = 'cart'; flyObj.dummyref = 'flydummy'; flyObj.dummyId = 'dummy_' + flyId; flyObj.flyStopFn[0] = 'putInSession'; flyStopObj = document.getElementById(flyObj.stopId); flyStopObj.className = 'visibleObj'; document.getElementById('cartCont').style.visibility = 'visible'; flyObj.startFly(); } function format_number(a, b, c, d) { // number_format(number, decimals, comma, formatSeparator) a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b); e = a + ''; f = e.split('.'); if(!f[0]) f[0] = '0'; if(!f[1]) f[1] = ''; if(f[1].length < b){ g = f[1]; for(i = f[1].length + 1; i <= b; i++) { g += '0'; } f[1] = g; } if(d != '' && f[0].length > 3) { h = f[0]; f[0] = ''; for(j = 3; j < h.length; j += 3) { i = h.slice(h.length - j, h.length - j + 3); f[0] = d + i + f[0] + ''; } j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3)); f[0] = j + f[0]; } c = (b <= 0) ? '': c; return f[0] + c + f[1]; } function cartStatus(){ var flyObj = new fly(); var cartTbl = document.getElementById('cart'); var statusObj = cartTbl.tBodies[0].rows[0].cells[0]; if((cartTbl.tBodies[0].rows.length == 5) && (cartTbl.tBodies[0].rows[0].innerHTML.indexOf('order') >=0) ) { cartTbl.tBodies[0].rows[0].cells[1].innerHTML = ''; statusObj.innerHTML = ''; statusObj.style.paddingRight = "10px"; statusObj.style.textAlign = 'right'; statusObj.className = 'crtEmpty'; statusObj.innerHTML = 'Es befinden sich keine Waren im Warenkorb.'; cartTbl.deleteRow(1); cartTbl.deleteRow(1); cartTbl.deleteRow(1); cartTbl.deleteRow(1); }else if(cartTbl.tBodies[0].rows.length > 1) { statusObj.innerHTML = ''; var statusObj = cartTbl.tBodies[0].rows[0].cells[1]; statusObj.colSpan = 8; statusObj.style.paddingRight = "6px"; statusObj.style.paddingTop = "10px"; statusObj.style.paddingleft = "0px"; statusObj.style.paddingBottom = "0px"; statusObj.style.textAlign = "right"; // statusObj.innerHTML = ' '; statusObj.innerHTML = '
   
'; statusObj.style.textAlign = 'right'; if(cartTbl.tBodies[0].rows.length>1) { if (cartTbl.tBodies[0].rows[1].innerHTML.indexOf('hrId1')<0) { var totalRowObj = cartTbl.tBodies[0].insertRow(1); var totalCellObj = totalRowObj.insertCell(totalRowObj.cells.length); totalCellObj.colSpan = 8; // totalCellObj.innerHTML = "
"; totalCellObj.innerHTML = "
"; } } var totalCur = 0; var maxRows = cartTbl.tBodies[0].rows.length; if(cartTbl.tBodies[0].rows[maxRows-1].innerHTML.indexOf('orders.php') < 0) { var totalRowObj = cartTbl.tBodies[0].insertRow((maxRows)); var totalCellObj = totalRowObj.insertCell(totalRowObj.cells.length); totalCellObj.colSpan = 5; totalCellObj.innerHTML = "Summe:"; totalCellObj.className = 'crtTotal'; var totalCellObj = totalRowObj.insertCell(totalRowObj.cells.length); totalCellObj.colSpan = 3; totalCellObj.className = 'crtTotal1'; var dummyRows = maxRows; }else{ var totalCellObj = cartTbl.tBodies[0].rows[(maxRows-3)].cells[1]; var dummyRows = (maxRows-3); } for(var i=2; i<(dummyRows); i++) { var curCell = cartTbl.tBodies[0].rows[i]; var prodIdArr = curCell.id.split('_'); prodId = prodIdArr[prodIdArr.length - 1]; if(document.getElementById('price_' + prodId).innerHTML){ var curStr = parseFloat(document.getElementById('price_' + prodId).innerHTML) * parseFloat(document.getElementById('qtyx_image_' + prodId).value); totalCur += parseFloat(curStr); } } if(dummyRows>2){ document.getElementById('totl_items').innerHTML = dummyRows - 2; } totalCellObj.innerHTML = format_number(totalCur,2,',',' ') +" "+ flyObj.currency; document.getElementById('order_totl_val').innerHTML = format_number(totalCur,2,',',' '); var maxRows = cartTbl.tBodies[0].rows.length; if(cartTbl.tBodies[0].rows[maxRows-1].innerHTML.indexOf('orders.php') < 0) { var totalRowObj = cartTbl.tBodies[0].insertRow(maxRows); var totalCellObj = totalRowObj.insertCell(totalRowObj.cells.length); totalCellObj.colSpan = 8; // totalCellObj.innerHTML = "
"; totalCellObj.innerHTML = "
"; } var maxRows = cartTbl.tBodies[0].rows.length; var totalRowObj = cartTbl.tBodies[0].rows[maxRows - 1]; if(totalRowObj.innerHTML.indexOf('orders.php') < 0 ) { var totalRowObj = cartTbl.tBodies[0].insertRow(maxRows); var totalCellObj = totalRowObj.insertCell(totalRowObj.cells.length); totalCellObj.colSpan = 8; totalCellObj.style.paddingRight = "1px"; totalCellObj.style.paddingTop = "0px"; totalCellObj.style.paddingLeft = "0px"; totalCellObj.style.paddingBottom = "0px"; totalCellObj.style.textAlign = "right"; // totalCellObj.innerHTML = '
'; totalCellObj.innerHTML = '
   
'; // totalCellObj.className = 'cellpad'; var totalCellObj = totalRowObj.insertCell(totalRowObj.cells.length); }else { var totalCellObj = totalRowObj.cells[1]; totalCellObj.innerHTML = ''; } }else{ cartTbl.tBodies[0].rows[0].cells[0].innerHTML = ''; var statusObj = cartTbl.tBodies[0].rows[0].cells[1]; statusObj.innerHTML = ''; statusObj.style.paddingRight = "10px"; statusObj.style.textAlign = 'right'; statusObj.className = 'crtEmpty'; statusObj.innerHTML = 'Es befinden sich keine Waren im Warenkorb.'; } } function addToCart(flyId, qty, prodtype){ var productinfoArr = flyId.split('_'); var prodId = productinfoArr[productinfoArr.length - 1]; var flyObj = new fly(); flyObj.stopId = 'cart'; flyStopObj = document.getElementById(flyObj.stopId); var newCartObjId = 'cart_' + flyId; var productNameObj = document.getElementById('name_' + prodId); var productPriceObj = document.getElementById('price_' + prodId); var productImgObj = document.getElementById('image_' + prodId); var productSizeObj = document.getElementById('size_' + prodId); var productColorObj = document.getElementById('color_' + prodId); var prodObj = flyStopObj.tBodies[0].insertRow(flyStopObj.rows.length); prodObj.id = newCartObjId; prodObj.className = "cartEntry"; var prodImageObj = prodObj.insertCell(prodObj.cells.length); prodImageObj.id = 'image_' + flyId; prodImageObj.className = 'pname'; var prodNameObj = prodObj.insertCell(prodObj.cells.length); prodNameObj.id = 'name_' + flyId; prodNameObj.className = 'crtName'; var prodSizeObj = prodObj.insertCell(prodObj.cells.length); prodSizeObj.id = 'size_' + flyId; prodSizeObj.className = 'crtName'; var prodColorObj = prodObj.insertCell(prodObj.cells.length); prodColorObj.id = 'color_' + flyId; prodColorObj.className = 'crtName'; var minusObj = prodObj.insertCell(prodObj.cells.length); minusObj.id = 'minus_' + flyId; minusObj.className = 'crtPlus'; minusImgObj = document.createElement('IMG'); minusImgObj.id = 'minusx_' + flyId; minusImgObj.style.width = 13; minusImgObj.style.height = 13; minusImgObj.src = minusImg.src; minusObj.appendChild(minusImgObj); var prodQtyObj = prodObj.insertCell(prodObj.cells.length); prodQtyObj.id = 'qty_' + flyId; prodQtyObj.className = 'crtQty'; qtyTextObj = document.createElement('INPUT'); qtyTextObj.id = 'qtyx_' + flyId; qtyTextObj.className = 'crtQtyTxt'; qtyTextObj.maxLength=3; qtyTextObj.readOnly=true; prodQtyObj.appendChild(qtyTextObj); var plusObj = prodObj.insertCell(prodObj.cells.length); plusObj.id = 'plus_' + flyId; plusObj.className = 'crtPlus'; plusImgObj = document.createElement('IMG'); plusImgObj.id = 'plusx_' + flyId; plusImgObj.style.width = 13; plusImgObj.style.height = 13; plusImgObj.src = plusImg.src; plusObj.appendChild(plusImgObj); var prodPriceObj = prodObj.insertCell(prodObj.cells.length); prodPriceObj.id = 'price_' + flyId; prodPriceObj.className = 'crtPrice'; prodImageObj.innerHTML = productImgObj.innerHTML; prodNameObj.innerHTML = productNameObj.innerHTML; prodSizeObj.innerHTML = productSizeObj.innerHTML; prodSizeObj.innerHTML += '
'+productColorObj.innerHTML; // prodColorObj.innerHTML = productColorObj.innerHTML; qtyTextObj.value = qty; //productPriceObj.innerHTML = productPriceObj.innerHTML.replace(',', ''); if(productPriceObj.innerHTML >0){ var testprice = parseFloat(parseInt(qty, 10) * parseFloat(productPriceObj.innerHTML, 10)); prodPriceObj.innerHTML = format_number(parseFloat(parseInt(qty, 10) * parseFloat(productPriceObj.innerHTML, 10), 10),2,',',' ') +" "+ flyObj.currency; } plusImgObj.qtyId = qtyTextObj.id; plusImgObj.qty = 0; plusImgObj.priceId = prodPriceObj.id; plusImgObj.price = productPriceObj.innerHTML; plusImgObj.flyObj = flyObj; plusImgObj.productId = prodId; plusImgObj.onclick = function(e){ var status = true; this.qty = parseFloat(document.getElementById(this.qtyId).value); if(status) { this.qty++; document.getElementById(this.qtyId).value = this.qty; document.getElementById(this.priceId).innerHTML = format_number(parseFloat(this.price * this.qty),2,',',' ') +" "+ this.flyObj.currency ; var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'incItem'; ajaxVar.vars["args"] = this.productId; ajaxVar.gotoFunction = "doNothing"; ajaxVar.AjaxPostSQL(); } }; // to put the delete qty code minusImgObj.qtyId = qtyTextObj.id; minusImgObj.qty = 0; minusImgObj.priceId = prodPriceObj.id; minusImgObj.price = productPriceObj.innerHTML; minusImgObj.flyObj = flyObj; minusImgObj.productId = prodId; minusImgObj.onclick = function(e){ this.qty = parseFloat(document.getElementById(this.qtyId).value); var status = true; if(status) { if(this.qty == 1) { this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode); var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'delItem'; ajaxVar.vars["args"] = this.productId; ajaxVar.gotoFunction = "doNothing"; ajaxVar.AjaxPostSQL(); }else{ this.qty--; qty = this.qty; document.getElementById(this.qtyId).value = this.qty; document.getElementById(this.priceId).innerHTML = format_number(parseFloat(this.price * this.qty),2,',',' ') +" "+this.flyObj.currency; var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'decItem'; ajaxVar.vars["args"] = this.productId; ajaxVar.gotoFunction = "doNothing"; ajaxVar.AjaxPostSQL(); } } }; } function putInSession(flyObj){ var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'addItem'; var productinfoArr = flyObj.flyId.split('_'); var productId = productinfoArr[productinfoArr.length - 1]; var productImage = document.getElementById('image_' + productId).innerHTML; var productName = document.getElementById('name_' + productId).innerHTML; var productPrice = document.getElementById('price_' + productId).innerHTML; var productSize = document.getElementById('size_' + productId).innerHTML; var productColor = document.getElementById('color_' + productId).innerHTML; var productQty = 1; ajaxVar.vars["args[0]"] = productId; ajaxVar.vars["args[1]"] = productName; ajaxVar.vars["args[2]"] = productPrice; ajaxVar.vars["args[3]"] = productQty; ajaxVar.vars["args[4]"] = productSize; ajaxVar.vars["args[5]"] = productColor; ajaxVar.fnVars['obj'] = flyObj; ajaxVar.gotoFunction = "putInCart"; ajaxVar.AjaxPostSQL(); } function doNothing(data, fnVars){ cartStatus(); } function putInCart(data, fnVars){ var datainfo = data.split("####"); if(data == 1 || data.indexOf('done')>=0){ flyObj = fnVars['obj']; clearTimeout(flyObj.flyTime[flyObj.flyId]); var flyObject = document.getElementById(flyObj.flyId); var flyStopObj = document.getElementById(flyObj.stopId); var flyingObj = document.getElementById(flyObj.dummyId); var productinfoArr = flyObj.flyId.split('_'); var productId = productinfoArr[productinfoArr.length - 1]; var productNameObj = document.getElementById('name_' + productId); var productPriceObj = document.getElementById('price_' + productId); var productSizeObj = document.getElementById('size_' + productId); var productColorObj = document.getElementById('color_' + productId); var newCartObjId = 'cart_' + flyObj.flyId; var prodObj = document.getElementById(newCartObjId); if(prodObj) { var prodImageObj = document.getElementById('image_' + flyObj.flyId); var prodNameObj = document.getElementById('name_' + flyObj.flyId); var prodSizeObj = document.getElementById('size_' + flyObj.flyId); var prodColorObj = document.getElementById('color_' + flyObj.flyId); var prodQtyObj = document.getElementById('qty_' + flyObj.flyId); var qtyTextObj = document.getElementById('qtyx_' + flyObj.flyId); var prodPriceObj = document.getElementById('price_' + flyObj.flyId); var plusImgObj = document.getElementById('plusx_' + flyObj.flyId); var minusImgObj = document.getElementById('minusx_' + flyObj.flyId); }else{ var prodObj = flyStopObj.tBodies[0].insertRow((flyStopObj.rows.length == 1) ? flyStopObj.rows.length : flyStopObj.rows.length - 3); prodObj.id = newCartObjId; prodObj.className = "cartEntry"; var prodImageObj = prodObj.insertCell(prodObj.cells.length); prodImageObj.id = 'image_' + flyObj.flyId; prodImageObj.className = 'pname'; var prodNameObj = prodObj.insertCell(prodObj.cells.length); prodNameObj.id = 'name_' + flyObj.flyId; prodNameObj.className = 'crtName'; var prodSizeObj = prodObj.insertCell(prodObj.cells.length); prodSizeObj.id = 'size_' + flyObj.flyId; prodSizeObj.className = 'crtName'; var prodColorObj = prodObj.insertCell(prodObj.cells.length); prodColorObj.id = 'color_' + flyObj.flyId; prodColorObj.className = 'crtName'; var minusObj = prodObj.insertCell(prodObj.cells.length); minusObj.id = 'minus_' + flyObj.flyId; minusObj.className = 'crtPlus'; minusImgObj = document.createElement('IMG'); minusImgObj.id = 'minusx_' + flyObj.flyId; minusImgObj.src = minusImg.src; minusObj.appendChild(minusImgObj); var prodQtyObj = prodObj.insertCell(prodObj.cells.length); prodQtyObj.id = 'qty_' + flyObj.flyId; prodQtyObj.className = 'crtQty'; qtyTextObj = document.createElement('INPUT'); qtyTextObj.id = 'qtyx_' + flyObj.flyId; qtyTextObj.className = 'crtQtyTxt'; qtyTextObj.maxLength=3; qtyTextObj.readOnly=true; prodQtyObj.appendChild(qtyTextObj); var plusObj = prodObj.insertCell(prodObj.cells.length); plusObj.id = 'plus_' + flyObj.flyId; plusObj.className = 'crtPlus'; plusImgObj = document.createElement('IMG'); plusImgObj.id = 'plusx_' + flyObj.flyId; plusImgObj.style.width = 13; plusImgObj.style.height = 13; plusImgObj.src = plusImg.src; plusObj.appendChild(plusImgObj); var prodPriceObj = prodObj.insertCell(prodObj.cells.length); prodPriceObj.id = 'price_' + flyObj.flyId; prodPriceObj.className = 'crtPrice'; } prodImageObj.innerHTML = flyObject.innerHTML; prodNameObj.innerHTML = productNameObj.innerHTML; prodSizeObj.innerHTML = productSizeObj.innerHTML; prodSizeObj.innerHTML +='
'+ productColorObj.innerHTML; // prodColorObj.innerHTML = productColorObj.innerHTML; var qty = (parseFloat(qtyTextObj.value)) ? parseFloat(parseFloat(qtyTextObj.value) + 1) : 1; if(productPriceObj.innerHTML){ productPriceObj.innerHTML = productPriceObj.innerHTML.replace(',', ''); prodPriceObj.innerHTML = format_number(parseFloat(parseFloat(qty) * parseFloat(productPriceObj.innerHTML)),2,',',' ') +" "+flyObj.currency; } plusImgObj.qtyId = qtyTextObj.id; plusImgObj.qty = 0; plusImgObj.priceId = prodPriceObj.id; plusImgObj.price = productPriceObj.innerHTML; plusImgObj.flyObj = flyObj; plusImgObj.productId = productId; plusImgObj.onclick = function(e){ var status = true; this.qty = parseFloat(document.getElementById(this.qtyId).value); if(status) { // this.qty++; // document.getElementById(this.qtyId).value = this.qty; // document.getElementById(this.priceId).innerHTML = format_number(parseFloat(this.price * this.qty),2,',',' ') +" "+ this.flyObj.currency; var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'incItem'; ajaxVar.vars["args"] = this.productId; ajaxVar.fnVars['pobj'] = this; ajaxVar.gotoFunction = "ChkAvailability"; ajaxVar.AjaxPostSQL(); } }; // to put the delete qty code qtyTextObj.value = qty; minusImgObj.qtyId = qtyTextObj.id; minusImgObj.qty = 0; minusImgObj.priceId = prodPriceObj.id; minusImgObj.price = productPriceObj.innerHTML; minusImgObj.flyObj = flyObj; minusImgObj.productId = productId; minusImgObj.onclick = function(e){ this.qty = parseFloat(document.getElementById(this.qtyId).value); var status = true; if(status) { if(this.qty == 1) { this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode); var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'delItem'; ajaxVar.vars["args"] = this.productId; ajaxVar.gotoFunction = "doNothing"; ajaxVar.AjaxPostSQL(); }else{ this.qty--; qty = this.qty; document.getElementById(this.qtyId).value = this.qty; document.getElementById(this.priceId).innerHTML = format_number(parseFloat(this.price * this.qty),2,',',' ') + " "+ this.flyObj.currency; var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'decItem'; ajaxVar.vars["args"] = this.productId; ajaxVar.gotoFunction = "doNothing"; ajaxVar.AjaxPostSQL(); } } }; }else{ var quantity = document.getElementById('qtyx_' + flyObj.flyId); alert('Leider sind nur noch insgesamt ['+quantity.value+'] Teile verfügbar'); flyObj = fnVars['obj']; var flyingObj = document.getElementById(flyObj.dummyId); } flyingObj.parentNode.removeChild(flyingObj); cartStatus(); } function ChkAvailability(data,fnVars){ var plusImgObj=fnVars["pobj"]; if(data=='done'){ plusImgObj.qty++; document.getElementById(plusImgObj.qtyId).value = plusImgObj.qty; document.getElementById(plusImgObj.priceId).innerHTML = format_number(parseFloat(plusImgObj.price * plusImgObj.qty),2,',',' ') +" "+ plusImgObj.flyObj.currency; }else{ alert('Leider sind nur noch insgesamt ['+plusImgObj.qty+'] Teile verfügbar'); } cartStatus(); } function hideCart(btnObj){ var cartObj = document.getElementById('cart'); cartObj.className = 'hiddenObj'; btnObj.onclick = function(e) { showCart(this); } btnObj.innerHTML = 'O'; } function showCart(btnObj){ var cartObj = document.getElementById('cart'); cartObj.className = 'visibleObj'; btnObj.onclick = function(e) { hideCart(this); } btnObj.innerHTML = '_'; } function moveCart(event, id){ divDrag = new drag(); var dragDiv = document.getElementById(id); divDrag.id = id; divDrag.dragObj.zIndex = 0; divDrag.dragStopFn[0] = 'fixCartPosition'; divDrag.dragStart(event); } function addOrderCart(Obj, prodId) { var qtyTxtobj = document.getElementById('qty_' + prodId); var priceobj = document.getElementById('price_val_' + prodId); // var qty = Number(qtyTxtobj.innerHTML); // qty++; // qtyTxtobj.innerHTML = qty; var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'incItem'; ajaxVar.vars["args"] = prodId; ajaxVar.fnVars['txtObj'] = qtyTxtobj; ajaxVar.gotoFunction = "CalcTotal"; ajaxVar.AjaxPostSQL(); } function remOrderCart(Obj, prodId) { var qtyTxtobj = document.getElementById('qty_' + prodId); var priceobj = document.getElementById('price_val_' + prodId); var qty = Number(qtyTxtobj.innerHTML); if (qty==1) { qty--; qtyTxtobj.innerHTML = qty; var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'orderdelItem'; ajaxVar.vars["args"] = prodId; ajaxVar.fnVars['txtObj'] = qtyTxtobj; ajaxVar.fnVars['prevaction'] = 'remove'; ajaxVar.gotoFunction = "CalcTotal"; ajaxVar.AjaxPostSQL(); }else if(qty > 1){ qty--; qtyTxtobj.innerHTML = qty; var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'decItem'; ajaxVar.vars["args"] = prodId; ajaxVar.fnVars['txtObj'] = qtyTxtobj; ajaxVar.fnVars['prevaction'] = 'remove'; ajaxVar.gotoFunction = "CalcTotal"; ajaxVar.AjaxPostSQL(); } // else if(qty==0){ // qtyTxtobj.innerHTML = qty; // var ajaxVar = new ajaxVars(); // ajaxVar.vars['action'] = 'runFunction'; // ajaxVar.vars['class'] = 'cart'; // ajaxVar.vars['func'] = 'decItem'; // ajaxVar.vars["args"] = prodId; // ajaxVar.fnVars['txtObj'] = qtyTxtobj; // ajaxVar.fnVars['prevaction'] = 'remove'; // ajaxVar.gotoFunction = "CalcTotal"; // ajaxVar.AjaxPostSQL(); // // } } function CalcTotal(data, fnVars){ qtyTxtobj=fnVars['txtObj']; var qty = Number(qtyTxtobj.innerHTML); if(fnVars['prevaction']=='remove'){ if(data=='done' || data=='empty'){ qtyTxtobj.innerHTML = qty; var ajaxVar = new ajaxVars(); ajaxVar.phpFile = "/orderCalc.php"; ajaxVar.vars['action'] = 'runFunction'; ajaxVar.gotoFunction = "OrderTotal"; ajaxVar.AjaxPostSQL(); } }else{ if(data=='done'){ qty++; qtyTxtobj.innerHTML = qty; var ajaxVar = new ajaxVars(); ajaxVar.phpFile = "/orderCalc.php"; ajaxVar.vars['action'] = 'runFunction'; ajaxVar.gotoFunction = "OrderTotal"; ajaxVar.AjaxPostSQL(); }else{ alert('Leider sind nur noch insgesamt ['+qty+'] Teile verfügbar'); } } } function OrderTotal(data, fnVars) { var rowArr = data.split("#**#"); var total = 0; val = 0; for (var i=0; i0) { var qty = Number(document.getElementById('qty_' + colArr[0]).innerHTML); var testval = format_number(parseFloat(0 * qty) + parseFloat(colArr[1] * qty),2,',',' '); document.getElementById('price_' + colArr[0]).innerHTML = format_number(parseFloat(0 * qty) + parseFloat(colArr[1] * qty),2,',',' '); total += parseFloat(0 * qty) + parseFloat(colArr[1] * qty); var discount = 0; if(total >= 100.00 && total <= 199.99 ){ discount = (2 * total)/100; }else if(total >= 200.00 && total <= 299.99 ){ discount = (3 * total)/100; }else if(total >= 300.00 && total <= 499.99 ){ discount = (4 * total)/100; }else if(total >= 500.00){ discount = (5 * total)/100; } } val++; } if (total>0 || val>0) { document.getElementById('grandTotal').innerHTML = format_number(total,2,',',' '); document.getElementById('discount').innerHTML = format_number(discount,2,',',' '); if(total > 100){ document.getElementById('rabatt').style.visibility = 'visible'; document.getElementById('rabatt').style.display = 'block'; document.getElementById('rabattVal').style.visibility = 'visible'; document.getElementById('rabattVal').style.display = 'block'; document.getElementById('summeabz').style.visibility = 'visible'; document.getElementById('summeabz').style.display = 'block'; document.getElementById('summeabzVal').style.visibility = 'visible'; document.getElementById('summeabzVal').style.display = 'block'; }else{ document.getElementById('rabatt').style.visibility = 'hidden'; document.getElementById('rabatt').style.display = 'none'; document.getElementById('rabattVal').style.visibility = 'hidden'; document.getElementById('rabattVal').style.display = 'none'; document.getElementById('summeabz').style.visibility = 'hidden'; document.getElementById('summeabz').style.display = 'none'; document.getElementById('summeabzVal').style.visibility = 'hidden'; document.getElementById('summeabzVal').style.display = 'none'; } var totalval = format_number(total,2,',',' '); var discountval = format_number(discount,2,',',' '); var finalval = parseFloat(total) - parseFloat(discount); document.getElementById('totdiscount').innerHTML = format_number(finalval,2,',',' '); if(document.getElementById('s_country').value == 1 ){ calculateshipcost(finalval); }else if(document.getElementById('s_country').value == 2 || document.getElementById('s_country').value == 3 || document.getElementById('s_country').value == 4 || document.getElementById('s_country').value == 5){ var val1 = 0; var val2 = 0; if(document.getElementById('s_country').value == 2){ val1 = 250; val2 = 7.95; }else if(document.getElementById('s_country').value == 3){ val1 = 500; val2 = 10.00; }else if(document.getElementById('s_country').value == 4){ val1 = 500; val2 = 13.50; }else if(document.getElementById('s_country').value == 5){ val1 = 500; val2 = 0.00; } calcfinalAmount(finalval,val1,val2); } }else{ msg='

Es befinden sich keine Waren im Warenkorb.

'; document.getElementById('showCart').innerHTML = msg; document.getElementById('odForm').innerHTML = ''; document.getElementById('mand').innerHTML = ''; } // checkLand(); }