var CloseBut1 = new Image(); var CloseBut2 = new Image(); var plusImg = new Image(); var minusImg = new Image(); CloseBut1.src = "/proimages/closeButton.gif"; CloseBut2.src = "/proimages/closeButton.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 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 = 'Warenkorb ist leer.'; cartTbl.deleteRow(1); cartTbl.deleteRow(1); cartTbl.deleteRow(1); cartTbl.deleteRow(1); }else if(cartTbl.tBodies[0].rows.length > 1) { var statusObj = cartTbl.tBodies[0].rows[0].cells[1]; statusObj.colSpan = 6; statusObj.innerHTML = ' '; statusObj.style.textAlign = 'right'; statusObj.style.paddingRight = '10px'; //statusObj.style.cssFloat = '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 = 7; 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 = 6; totalCellObj.innerHTML = 'Gesamt:'; totalCellObj.className = 'crtTotal'; var totalCellObj = totalRowObj.insertCell(totalRowObj.cells.length); totalCellObj.className = 'crtTotal'; var dummyRows = maxRows; }else{ var totalCellObj = cartTbl.tBodies[0].rows[(maxRows-3)].cells[1]; var dummyRows = (maxRows-3); } var cntProd = 0; for(var i=2; i<(dummyRows); i++) { var curCell = cartTbl.tBodies[0].rows[i]; var prodIdArr = curCell.id.split('_'); prodId = prodIdArr[prodIdArr.length - 1]; var curStr = parseFloat(document.getElementById('price_' + prodId).innerHTML) * parseFloat(document.getElementById('qtyx_image_' + prodId).value); totalCur += parseFloat(curStr); cntProd = parseFloat(cntProd) + parseFloat(document.getElementById('qtyx_image_' + prodId).value); } totalCellObj.innerHTML = flyObj.currency + number_format(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 = 7; 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 = 7; totalCellObj.style.paddingRight = "10px"; totalCellObj.style.paddingTop = "2px"; totalCellObj.style.paddingBottom = "2px"; totalCellObj.style.textAlign = "right"; totalCellObj.innerHTML = '
'; totalCellObj.className = 'cellpad'; var totalCellObj = totalRowObj.insertCell(totalRowObj.cells.length); }else { var totalCellObj = totalRowObj.cells[1]; totalCellObj.innerHTML = ''; } var tot_item = cntProd; var str_mesg = ""; if(tot_item == 1){ str_mesg = tot_item+' Produkt im '; }else if(tot_item == 0){ str_mesg = ' Keine Produkte im '; }else{ str_mesg = tot_item+' Produkte im '; } document.getElementById('total_items').innerHTML = str_mesg ; document.getElementById('total_cart_amount').innerHTML = number_format(totalCur,2); if(totalCur > 0){ document.getElementById('totalDiv').style.visibility = 'visible'; document.getElementById('totalDiv').style.display = 'block'; }else if(totalCur <= 0){ document.getElementById('totalDiv').style.visibility = 'hidden'; document.getElementById('totalDiv').style.display = 'none'; } }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 = 'Warenkorb ist leer.'; } } 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 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 = 'crtSize'; var minusObj = prodObj.insertCell(prodObj.cells.length); minusObj.id = 'minus_' + flyId; minusObj.className = 'crtPlus'; minusImgObj = document.createElement('IMG'); minusImgObj.id = 'minusx_' + flyId; 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.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; // var spilletedProdSize = prodSizeObj.innerHTML.split(' '); // alert(spilletedProdSize); // if(spilletedProdSize[0].length > 0){ // productSize = 'Größe:' + spilletedProdSize; // } // prodSizeObj.innerHTML = productSize; qtyTextObj.value = qty; prodPriceObj.innerHTML = flyObj.currency + number_format(parseFloat(parseInt(qty, 10) * parseFloat(productPriceObj.innerHTML, 10), 10),2); 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 = this.flyObj.currency + number_format(parseFloat(this.price * this.qty),2); 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.qty--; qty = this.qty; document.getElementById(this.qtyId).value = this.qty; document.getElementById(this.priceId).innerHTML = this.flyObj.currency + number_format(parseFloat(this.price * this.qty),2); 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 if(this.qty>1) { this.qty--; qty = this.qty; document.getElementById(this.qtyId).value = this.qty; document.getElementById(this.priceId).innerHTML = this.flyObj.currency + number_format(parseFloat(this.price * this.qty),2); 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 selArr = document.getElementsByName('size_val'); for(var i=0;i=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 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 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 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.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; var qty = (parseFloat(qtyTextObj.value)) ? parseFloat(parseFloat(qtyTextObj.value) + 1) : 1; prodPriceObj.innerHTML = flyObj.currency + number_format(parseFloat(parseFloat(qty) * parseFloat(productPriceObj.innerHTML)),2); 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 = this.flyObj.currency + number_format(parseFloat(this.price * this.qty),2); 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 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.qty--; qty = this.qty; document.getElementById(this.qtyId).value = this.qty; document.getElementById(this.priceId).innerHTML = this.flyObj.currency + number_format(parseFloat(this.price * this.qty),2); 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 if (this.qty>1){ this.qty--; qty = this.qty; document.getElementById(this.qtyId).value = this.qty; document.getElementById(this.priceId).innerHTML = this.flyObj.currency + number_format(parseFloat(this.price * this.qty),2); 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{ flyObj = fnVars['obj']; var flyingObj = document.getElementById(flyObj.dummyId); } flyingObj.parentNode.removeChild(flyingObj); 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_val_' + prodId); var priceobj = document.getElementById('price_amt_' + 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.gotoFunction = "CalcTotal"; ajaxVar.AjaxPostSQL(); } function remOrderCart(Obj, prodId) { var qtyTxtobj = document.getElementById('qty_val_' + prodId); var priceobj = document.getElementById('price_amt_' + prodId); var qty = Number(qtyTxtobj.innerHTML); if (qty==1) { qty--; qtyTxtobj.innerHTML = 0; var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'decItem'; ajaxVar.vars["args"] = prodId; 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.gotoFunction = "CalcTotal"; ajaxVar.AjaxPostSQL(); } } function CalcTotal(data, fnVars){ var ajaxVar = new ajaxVars(); ajaxVar.phpFile = "/orderCalc.php"; ajaxVar.vars['action'] = 'runFunction'; ajaxVar.gotoFunction = "OrderTotal"; ajaxVar.AjaxPostSQL(); } function OrderTotal(data, fnVars) { var rowArr = data.split("#**#"); var total = 0; val = 0; for (var i=0; i<(rowArr.length - 1); i++) { var colArr = rowArr[i].split("|||"); if (colArr[0].length>0 && colArr[2]>0) { var qty = Number(document.getElementById('qty_val_' + colArr[0]).innerHTML); document.getElementById('totl_price_' + colArr[0]).innerHTML = number_format(parseFloat(0 * qty) + parseFloat(colArr[1] * qty),2); total += parseFloat(0 * qty) + parseFloat(colArr[1] * qty); }else{ if(document.getElementById('qty_val_' + colArr[0])){ var qty = Number(document.getElementById('qty_val_' + colArr[0]).innerHTML); document.getElementById('totl_price_' + colArr[0]).innerHTML = "0.00"; } } document.getElementById('totl_price_' + colArr[0]).innerHTML = format_number(document.getElementById('totl_price_' + colArr[0]).innerHTML,2,',',' '); val++; } var PArr = data.split("#||#"); if(total >0){ document.getElementById('tot_ex_gift').value = parseFloat(total) + parseFloat(document.getElementById('shipCost').innerHTML); } if(total>0){ document.getElementById('totalBfrShipping').value = format_number(total,2,',',' ') total = parseFloat(total) + parseFloat(document.getElementById('shipCost').innerHTML); } if (total>0) { document.getElementById('final_total').innerHTML = number_format(total,2); document.getElementById('odForm').style.visibility = 'visible'; document.getElementById('odForm').style.display = 'block'; }else{ document.getElementById('final_total').innerHTML = '0.00'; document.getElementById('odForm').style.visibility = 'hidden'; document.getElementById('odForm').style.display = 'none'; } document.getElementById('final_total').innerHTML = format_number(document.getElementById('final_total').innerHTML,2,',',' '); } 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]; }