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 = 'Cart is Empty.'; 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 = 7; 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 = 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 = "Total:"; 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 icon_data=""; 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(document.getElementById('iconval_' + prodId).innerHTML != "" ){ // icon_data = "

NB. Some items in your Order Request are subject to additional lead times and
delivery charges. If additional delivery charges apply, you will be contacted to
confirm these prior to your order being processed.
"; // } } 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 = "0px"; totalCellObj.style.paddingTop = "2px"; totalCellObj.style.paddingBottom = "2px"; totalCellObj.style.textAlign = "right"; totalCellObj.innerHTML = '
'; if(icon_data){ totalCellObj.innerHTML += icon_data; } 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 = 'Cart is Empty.'; } } 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 productCodeObj = document.getElementById('code_' + prodId); var producticonObj = document.getElementById('iconval_' + 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 prodCodeObj = prodObj.insertCell(prodObj.cells.length); prodCodeObj.id = 'code_' + flyId; prodCodeObj.className = 'crtName'; prodCodeObj.style.valign = 'top'; 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; //prodCodeObj.innerHTML = productCodeObj.innerHTML +" "+ producticonObj.innerHTML; prodCodeObj.innerHTML = productCodeObj.innerHTML; qtyTextObj.value = qty; if(productPriceObj.innerHTML >0){ prodPriceObj.innerHTML = flyObj.currency + number_format(parseFloat(parseInt(qty, 10) * parseFloat(productPriceObj.innerHTML, 10), 10),2); }else{ prodPriceObj.innerHTML = "Price on application"; } 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.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 = 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 productVat = document.getElementById('vat_' + productId).innerHTML; var productCode = document.getElementById('code_' + productId).innerHTML; var productIcon = document.getElementById('iconval_' + 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]"] = productVat; ajaxVar.vars["args[5]"] = productCode; ajaxVar.vars["args[6]"] = productIcon; 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 productCodeObj = document.getElementById('code_' + productId); var prodIconObj = document.getElementById('iconval_' + 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 prodCodeObj = document.getElementById('code_' + flyObj.flyId); var prodIconObj = document.getElementById('iconval_' + productId); 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 prodCodeObj = prodObj.insertCell(prodObj.cells.length); prodCodeObj.id = 'code_' + flyObj.flyId; prodCodeObj.className = 'crtName'; prodCodeObj.style.valign = 'top'; 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; //prodCodeObj.innerHTML = productCodeObj.innerHTML +" "+ prodIconObj.innerHTML; prodCodeObj.innerHTML = productCodeObj.innerHTML; var qty = (parseFloat(qtyTextObj.value)) ? parseFloat(parseFloat(qtyTextObj.value) + 1) : 1; if(productPriceObj.innerHTML){ prodPriceObj.innerHTML = flyObj.currency + number_format(parseFloat(parseFloat(qty) * parseFloat(productPriceObj.innerHTML)),2); }else{ prodPriceObj.innerHTML = "Price on application"; } 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.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 = 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); } if(datainfo[1]>1){ document.getElementById('open_cart').innerHTML = datainfo[1] +" items in your list"; }else{ document.getElementById('open_cart').innerHTML = datainfo[1] +" item in your list"; } 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_' + prodId); var priceobj = document.getElementById('price_' + 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_' + prodId); var priceobj = document.getElementById('price_' + prodId); var qty = Number(qtyTxtobj.innerHTML); if (qty==1) { var totalRows = document.getElementById('showCart').rows.length; //alert(Obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.rows.length); if(document.getElementById('showCart').rows[totalRows-1].innerHTML.indexOf('Some')>0){ totalRows = totalRows - 2; } if (totalRows==7) { var cartObj = document.getElementById('showCart'); var totllen = cartObj.rows.length; for(var i=1;i"; }else{ Obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.removeChild(Obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode); } var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'delItem'; ajaxVar.vars["args"] = prodId; ajaxVar.gotoFunction = "CalcTotal"; ajaxVar.AjaxPostSQL(); }else{ 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; for (var i=0; i0 && colArr[2]> 0) { var qty = Number(document.getElementById('qty_' + colArr[0]).innerHTML); document.getElementById('price_val_' + colArr[0]).innerHTML = number_format(parseFloat(0 * qty) + parseFloat(colArr[1] * qty),2); total += parseFloat(0 * qty) + parseFloat(colArr[1] * qty); } } if (total>0) { var rowArr1 = data.split("UUU"); var colArrval = rowArr1[1].split("III"); document.getElementById('order_total').innerHTML = colArrval[0]; document.getElementById('vat_total_val').innerHTML = colArrval[1]; document.getElementById('main_val_total').innerHTML = colArrval[2]; document.getElementById('shoppingcost_value').innerHTML = colArrval[3]; }else{ // msg='

Cart is empty currently.

'; // document.getElementById('showCart').innerHTML = msg; document.getElementById('open_cart').innerHTML = "0 item in your list"; document.getElementById('billing_information').innerHTML = ""; } }