var CloseBut1 = new Image(); var CloseBut2 = new Image(); var plusImg = new Image(); var plusImgBlink = new Image(); var minusImg = new Image(); var checkoutImg = new Image(); var clearCartImg = new Image(); var cartT; CloseBut1.src = "/proimages/closeButton.gif"; CloseBut2.src = "/proimages/closeButton.gif"; plusImg.src = "/proimages/plus.png"; plusImgBlink.src = "/proimages/plus_blink.gif"; minusImg.src = "/proimages/minus.png"; checkoutImg.src = "/proimages/checkout.gif"; clearCartImg.src = "/proimages/clearcart.gif"; function number_format( number, decimals, dec_point, thousands_sep ) { var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals; var d = dec_point == undefined ? "." : dec_point; var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : ""; var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : ""); } function startFlying(flyId){ var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'returnOrderType'; ajaxVar.vars['flyId'] = flyId; ajaxVar.fnVars['flyId'] = flyId; ajaxVar.gotoFunction = 'thenstartFlying'; ajaxVar.AjaxPostSQL(); } function thenstartFlying(dataArr,fnVars){ if(dataArr == 2){ show_cart_err("Sorry - but you are trying to mix items from our QnE range and our Main Fish Hall in the same basket.
This isn't allowed. Please click here for more information.",15000); return; } var flyObj = new fly(); flyObj.flyId = fnVars['flyId']; flyObj.stopId = 'cart'; flyObj.dummyref = 'flydummy'; flyObj.dummyId = 'dummy_' + fnVars['flyId']; flyObj.flyStopFn[0] = 'putInSession'; flyStopObj = document.getElementById(flyObj.stopId); flyStopObj.className = 'visibleObj'; document.getElementById('cartCont').style.visibility = 'visible'; document.getElementById('cartCont').style.display = 'block'; if(typeof hs != 'undefined') hs.forcedim(); flyObj.startFly(); } function cartStatus(flag){ var flyObj = new fly(); var cartTbl = document.getElementById('cart'); var statusObj = cartTbl.tBodies[0].rows[0].cells[0]; var teaserAmt = document.getElementById('tAmt'); var teaserBox = document.getElementById('spendTeaser'); var qNeDv = document.getElementById('qNeDvid'); if(qNeDv){ qNeDv.style.display = 'none'; } var cartOutTbl = document.getElementById('cartOut'); 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.className = 'crtEmpty'; statusObj.innerHTML = 'Shopping basket is Empty.'; cartTbl.deleteRow(1); cartTbl.deleteRow(1); cartTbl.deleteRow(1); cartTbl.deleteRow(1); }else if(cartTbl.tBodies[0].rows.length > 1) { cartTbl.tBodies[0].rows[0].style.display = 'none'; var statusObj = cartTbl.tBodies[0].rows[0].cells[1]; statusObj.colSpan = 5; statusObj.style.paddingRight = "0px"; statusObj.style.paddingTop = "2px"; statusObj.style.paddingBottom = "2px"; statusObj.style.textAlign = "right"; statusObj.innerHTML = '
'; //cartTbl.tBodies[0].rows[0].cells[0].innerHTML ="
P & D
"; cartTbl.tBodies[0].rows[0].cells[0].innerHTML = "
To adjust quantity use +/- buttons
"; var newDiv = document.getElementById('artcle_no'); //top pNd and other buttons var pNdBnt = cartOutTbl.tBodies[0].rows[0].cells[0]; pNdBnt.style.paddingRight = "10px"; pNdBnt.style.paddingTop = "2px"; pNdBnt.style.paddingBottom = "2px"; pNdBnt.style.textAlign = "right"; //pNdBnt.innerHTML ="
P & D
"; pNdBnt.innerHTML = "
To adjust quantity use +/- buttons
"; var otr2Btns = cartOutTbl.tBodies[0].rows[0].cells[1]; otr2Btns.style.paddingRight = "25px"; otr2Btns.style.paddingTop = "2px"; otr2Btns.style.paddingBottom = "2px"; otr2Btns.style.textAlign = "right"; otr2Btns.innerHTML = '
'; if(flag){ count = cartTbl.tBodies[0].rows.length-1; if(count == -3){ count = 1; } newDiv.innerHTML = count + ((count>1)?" ITEMS ":" ITEM ") + " £0.00 + £0.00 DELIVERY"; }else{ count = cartTbl.tBodies[0].rows.length-5; if(count == -3){ count = 1; } newDiv.innerHTML = count + ((count>1)?" ITEMS ":" ITEM ") + " £0.00 + £0.00 DELIVERY"; } 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 = 6; totalCellObj.style.display = 'none'; totalCellObj.innerHTML = "
"; } //top horizontal line if (cartOutTbl.tBodies[0].rows[1].innerHTML.indexOf('OutHrId1')<0) { var totalRowObj4HR = cartOutTbl.tBodies[0].insertRow(1); var totalCellObj4HR = totalRowObj4HR.insertCell(totalRowObj4HR.cells.length); totalCellObj4HR.colSpan = 2; totalCellObj4HR.style.paddingRight = '30px'; totalCellObj4HR.style.paddingLeft = '30px'; totalCellObj4HR.innerHTML = "
"; } } var totalCur = 0; var maxRows = cartTbl.tBodies[0].rows.length; if(cartTbl.tBodies[0].rows[maxRows-1].innerHTML.indexOf('checkout.gif') < 0) { var totalRowObj = cartTbl.tBodies[0].insertRow((maxRows)); var totalCellObj = totalRowObj.insertCell(totalRowObj.cells.length); totalCellObj.colSpan = 5; totalCellObj.innerHTML = "Total:   "; totalCellObj.style.textAlign = "right"; totalCellObj.className = 'crtTotal'; var totalCellObj = totalRowObj.insertCell(totalRowObj.cells.length); totalCellObj.className = 'crtTotal'; totalCellObj.style.textAlign = "right"; 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]; var priceObjL = document.getElementById('price_' + prodId); var qtyObjL = document.getElementById('qtyx_image_' + prodId); if(priceObjL){ var curStr = parseFloat(priceObjL.innerHTML) * parseFloat(qtyObjL.value); totalCur += parseFloat(curStr); } } totalCellObj.innerHTML = flyObj.currency + number_format(totalCur,2); var tHold = 0; if(teaserAmt){ tHold = 65 - totalCur; teaserAmt.innerHTML = number_format(tHold,2); totCAmtObj = document.getElementById('totCAmt'); if(totCAmtObj) totCAmtObj.innerHTML = number_format(totalCur,2); totDAmtObj = document.getElementById('totDAmt'); if(totDAmtObj) totDAmtObj.innerHTML = number_format(calculateCarriage(totalCur),2); } var maxRows = cartTbl.tBodies[0].rows.length; if(cartTbl.tBodies[0].rows[maxRows-1].innerHTML.indexOf('checkout.gif') < 0) { var totalRowObj = cartTbl.tBodies[0].insertRow(maxRows); var totalCellObj = totalRowObj.insertCell(totalRowObj.cells.length); totalCellObj.colSpan = 6; totalCellObj.style.display = 'none'; totalCellObj.innerHTML = "
"; } // bottom horizontal line var OutmaxRows = cartOutTbl.tBodies[0].rows.length; if (cartOutTbl.tBodies[0].rows[OutmaxRows-1].innerHTML.indexOf('checkout.gif') < 0) { if (cartOutTbl.tBodies[0].rows[OutmaxRows-1].innerHTML.indexOf('OuthrId2')<0) { var totalRowObj4HR = cartOutTbl.tBodies[0].insertRow(OutmaxRows); var totalCellObj4HR = totalRowObj4HR.insertCell(totalRowObj4HR.cells.length); totalCellObj4HR.colSpan = 2; totalCellObj4HR.style.paddingRight = '30px'; totalCellObj4HR.style.paddingLeft = '30px'; totalCellObj4HR.innerHTML = "
 
"; } } var maxRows = cartTbl.tBodies[0].rows.length; var totalRowObj = cartTbl.tBodies[0].rows[maxRows - 1]; if(totalRowObj.innerHTML.indexOf('checkout.gif') < 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 = '
'; totalCellObj.className = 'cellpad'; totalCellObj.style.display = 'none'; //var totalCellObj = totalRowObj.insertCell(totalRowObj.cells.length); }else { var totalCellObj = totalRowObj.cells[1]; } //bottom other 2 buttons var OutMaxRows = cartOutTbl.tBodies[0].rows.length; var OutTotalRowObj = cartOutTbl.tBodies[0].rows[OutMaxRows - 1]; if(OutTotalRowObj.innerHTML.indexOf('checkout.gif') < 0 ) { var OutTotalRowObj = cartOutTbl.tBodies[0].insertRow(OutMaxRows); var OutTotalCellObj = OutTotalRowObj.insertCell(OutTotalRowObj.cells.length); OutTotalCellObj.colSpan =7; OutTotalCellObj.style.paddingRight = "25px"; OutTotalCellObj.style.paddingTop = "2px"; OutTotalCellObj.style.paddingBottom = "2px"; OutTotalCellObj.style.textAlign = "right"; OutTotalCellObj.innerHTML = '
'; OutTotalCellObj.className = 'cellpad'; } hide_cart_err(); if(count<=0){ destroyCart(); } // toggle cart text based on quixkNeasy or normal shopping. toggleCartTxt(tHold); }else{ cartTbl.tBodies[0].rows[0].cells[0].innerHTML = ''; var statusObj = cartTbl.tBodies[0].rows[0].cells[1]; statusObj.innerHTML = ''; statusObj.className = 'crtEmpty'; statusObj.innerHTML = 'Shopping basket is Empty.'; } //alert(''); } function calculateCarriage(fishtotal){ if(fishtotal == 0){ return '0'; } if(fishtotal >= 100){ return '0'; } if(fishtotal >= 65 && fishtotal < 100){ return '5'; } if(fishtotal < 65){ return '10'; } } function toggleCartTxt(tHold){ var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'checkQuickNeasy'; ajaxVar.fnVars['tHold'] = tHold; ajaxVar.gotoFunction = 'toggleCartTxtMsg'; ajaxVar.AjaxPostSQL(); } function toggleCartTxtMsg(dataArr,fnVars){ var hcObj = document.getElementById('headerCheckout'); if(parseInt(dataArr) == 1){ totDAmtObj = document.getElementById('totDAmt'); totDAmtObj.innerHTML = number_format(calculateCarriage(0),2); if(hcObj){ hcObj.href = '/gift-checkout_member-login.html'; } }else{ if(hcObj){ hcObj.href = '/checkout_member-login.html'; } } if(document.getElementById('cartCont').style.visibility == 'visible'){ var tpTxt = document.getElementById('crtTopTxt'); var teaserBox = document.getElementById('spendTeaser'); var qNeDv = document.getElementById('qNeDvid'); var upChkBtn = document.getElementById('upChkbtnId'); var dwnChkBtn = document.getElementById('dwnChkbtnId'); var upChkBtn1 = document.getElementById('crtdwnChkBtnId'); var dwnChkBtn1 = document.getElementById('crtupChkBtnId'); if(dataArr.toString() != 'empty'){ if(parseInt(dataArr) == 1){ // Gift order if(tpTxt){ tpTxt.style.visibility = 'hidden'; tpTxt.style.display = 'none'; } if(teaserBox){ teaserBox.style.visibility = 'hidden'; } if(qNeDv){ qNeDv.style.display = 'block'; } if(upChkBtn){ upChkBtn.onclick = function(e){ location.href='/gift-checkout_member-login.html'; } } if(dwnChkBtn){ dwnChkBtn.onclick = function(e){ location.href='/gift-checkout_member-login.html'; } } if(upChkBtn1){ upChkBtn1.onclick = function(e){ location.href='/gift-checkout_member-login.html'; } } if(dwnChkBtn1){ dwnChkBtn1.onclick = function(e){ location.href='/gift-checkout_member-login.html'; } } } }else{ if(parseInt(fnVars['tHold']) > 0){ if(get_cookie('splashOffer') != 2){ teaserBox.style.visibility = 'visible'; }else{ teaserBox.style.visibility = 'hidden'; } }else{ teaserBox.style.visibility = 'hidden'; } if(tpTxt){ tpTxt.style.visibility = 'visible'; tpTxt.style.display = 'block'; } if(qNeDv){ qNeDv.style.display = 'none'; } if(upChkBtn){ upChkBtn.onclick = function(e){ location.href='/checkout_member-login.html'; } } if(dwnChkBtn){ dwnChkBtn.onclick = function(e){ location.href='/checkout_member-login.html'; } } if(upChkBtn1){ upChkBtn1.onclick = function(e){ location.href='/checkout_member-login.html'; } } if(dwnChkBtn1){ dwnChkBtn1.onclick = function(e){ location.href='/checkout_member-login.html'; } } } } } function destroyCart(){ var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'destroyCart'; ajaxVar.gotoFunction = ""; ajaxVar.AjaxPostSQL(); } 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 productStockObj = document.getElementById('stock_' + 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 minusObj = prodObj.insertCell(prodObj.cells.length); minusObj.id = 'minus_' + flyId; minusObj.className = 'crtPlus curserProp'; minusImgObj = document.createElement('IMG'); minusImgObj.id = 'minusx_' + flyId; minusImgObj.src = minusImg.src; minusObj.appendChild(minusImgObj); minusObj.imgId = minusImgObj.id; 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 curserProp'; plusImgObj = document.createElement('IMG'); plusImgObj.id = 'plusx_' + flyId; plusImgObj.src = plusImg.src; plusObj.appendChild(plusImgObj); plusObj.imgId = plusImgObj.id; var prodPriceObj = prodObj.insertCell(prodObj.cells.length); prodPriceObj.id = 'price_' + flyId; prodPriceObj.className = 'crtPrice'; prodImageObj.innerHTML = "
"+productImgObj.innerHTML+"
"; prodNameObj.innerHTML = productNameObj.innerHTML; 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) { //Function added by amar add_stock(this); } }; // 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) { minus_stock(this); } }; } //Function by amar to add (+) stock on first attampt. function add_stock_1(qty,productId){ //Ajax call to check.. existing stock var ajaxVar = new ajaxVars(); ajaxVar.incModule = 'common'; ajaxVar.vars['action'] = "runFunction"; ajaxVar.vars['func'] = "show_valid_stock"; ajaxVar.vars['nosplit'] = 1; ajaxVar.vars["count_bsk"] = 0; ajaxVar.vars["sess_id"] ='d59b0306887948619194c5558a227604'; ajaxVar.vars["prod_id"] = productId; ajaxVar.gotoFunction = 'doNothing'; ajaxVar.AjaxPostSQL(); } //Function by amar to add (+) stock function add_stock(crObj){ //Ajax call to check.. existing stock var ajaxVar = new ajaxVars(); ajaxVar.incModule = 'common'; ajaxVar.vars['action'] = "runFunction"; ajaxVar.vars['func'] = "show_valid_stock"; ajaxVar.vars['nosplit'] = 1; ajaxVar.vars["count_bsk"] = crObj.qty; ajaxVar.vars["sess_id"] ='d59b0306887948619194c5558a227604'; ajaxVar.vars["prod_id"] = crObj.productId; ajaxVar.fnVars['crObj'] = crObj; ajaxVar.gotoFunction = 'confirm_add_stock'; ajaxVar.AjaxPostSQL(); } function confirm_add_stock(dataArr, fnVars){ var crObj = fnVars['crObj']; if(dataArr == 1){ hide_cart_err(); crObj.qty++; document.getElementById(crObj.qtyId).value = crObj.qty; document.getElementById(crObj.priceId).innerHTML = crObj.flyObj.currency + number_format(parseFloat(crObj.price * crObj.qty),2); var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'incItem'; ajaxVar.vars["args"] = crObj.productId; ajaxVar.gotoFunction = "doNothing"; ajaxVar.AjaxPostSQL(); }else if(dataArr==-9999){ show_cart_err("SSO: cannot add more quantity."); }else{ show_cart_err("Your have ordered all our stock of this code"); } } //Function by amar to add (-) stock function minus_stock(crObj){ //Ajex call to check.. existing stock var ajaxVar = new ajaxVars(); ajaxVar.incModule = 'common'; ajaxVar.vars['action'] = "runFunction"; ajaxVar.vars['func'] = "correct_valid_stock"; ajaxVar.vars['nosplit'] = 1; ajaxVar.vars["prod_id"] = crObj.productId; ajaxVar.vars["sess_id"] ='d59b0306887948619194c5558a227604'; ajaxVar.vars["count_bsk"] = crObj.qty; ajaxVar.fnVars['crObj'] = crObj; ajaxVar.gotoFunction = 'confirm_minus_stock'; ajaxVar.AjaxPostSQL(); } function confirm_minus_stock(dataArr, fnVars){ var crObj=fnVars['crObj']; if(dataArr){ if(crObj.qty == 1) { crObj.parentNode.parentNode.parentNode.removeChild(crObj.parentNode.parentNode); var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'delItem'; ajaxVar.vars["args"] = crObj.productId; ajaxVar.gotoFunction = "doNothing"; ajaxVar.AjaxPostSQL(); }else{ crObj.qty--; qty = crObj.qty; document.getElementById(crObj.qtyId).value = crObj.qty; document.getElementById(crObj.priceId).innerHTML = crObj.flyObj.currency + number_format(parseFloat(crObj.price * crObj.qty),2); var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'decItem'; ajaxVar.vars["args"] = crObj.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 productStock = document.getElementById('stock_' + productId).innerHTML; var productVoucher = eval(document.getElementById('voucherid_' + productId)); var productQty = 1; var productType = ''; ajaxVar.vars["args[0]"] = productId; ajaxVar.vars["args[1]"] = productName; ajaxVar.vars["args[2]"] = productPrice; ajaxVar.vars["args[3]"] = productQty; ajaxVar.vars["args[4]"] = productStock; if(productVoucher){ ajaxVar.vars["args[5]"] = productVoucher.value; } ajaxVar.fnVars['obj'] = flyObj; ajaxVar.fnVars['type'] = productType; ajaxVar.gotoFunction = "putInCart"; ajaxVar.AjaxPostSQL(); } function doNothing(data,fnVars){ cartStatus(0); } function putInCart(data, fnVars){ 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 productStockObj = document.getElementById('stock_' + 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 prodQtyObj = document.getElementById('qty_' + flyObj.flyId); var prodStockObj = document.getElementById('stock_' + 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 minusObj = prodObj.insertCell(prodObj.cells.length); minusObj.id = 'minus_' + flyObj.flyId; minusObj.className = 'crtPlus curserProp'; minusImgObj = document.createElement('IMG'); minusImgObj.id = 'minusx_' + flyObj.flyId; minusImgObj.src = minusImg.src; minusObj.appendChild(minusImgObj); minusObj.imgId = minusImgObj.id; 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 curserProp'; plusImgObj = document.createElement('IMG'); plusImgObj.id = 'plusx_' + flyObj.flyId; plusImgObj.src = plusImgBlink.src; plusObj.appendChild(plusImgObj); plusObj.imgId = plusImgObj.id; var prodPriceObj = prodObj.insertCell(prodObj.cells.length); prodPriceObj.id = 'price_' + flyObj.flyId; prodPriceObj.className = 'crtPrice'; } prodImageObj.innerHTML = "
"+flyObject.innerHTML+"
"; prodNameObj.innerHTML = productNameObj.innerHTML; //prodStockObj.innerHTML = productStockObj.innerHTML; var qty = (parseFloat(qtyTextObj.value)) ? parseFloat(parseFloat(qtyTextObj.value) + 1) : 1; if(qty==1){ add_stock_1(qty,productId); } 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) { add_stock(this); } }; // 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) { minus_stock(this); } }; }else{ flyObj = fnVars['obj']; var flyingObj = document.getElementById(flyObj.dummyId); } flyingObj.parentNode.removeChild(flyingObj); cartStatus(0); close_cart_delay(); } 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.value); qty++; qtyTxtobj.value = 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.value); if (qty==1) { var totalRows = Obj.parentNode.parentNode.parentNode.rows.length; if (totalRows==5) { var cartObj = document.getElementById('shopCart'); cartObj.deleteRow(1); cartObj.deleteRow(1); cartObj.deleteRow(1); var objRow = cartObj.tBodies[0].insertRow(1); objRow.className = 'cartItem'; var objCol = objRow.insertCell(objRow.cells.length); objCol.colSpan = 7; //objCol.style.textAlign = 'left'; objCol.innerHTML = "Shopping basket is Empty."; }else{ Obj.parentNode.parentNode.parentNode.removeChild(Obj.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.value = 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) { var qty = Number(document.getElementById('qty_' + colArr[0]).value); document.getElementById('price_' + colArr[0]).innerHTML = flyObj.currency + number_format(parseFloat(colArr[2] * qty) + parseFloat(colArr[1] * qty),2); total += parseFloat(0 * qty) + parseFloat(colArr[1] * qty); } } if (total>0) { document.getElementById('grandTotal').innerHTML = flyObj.currency + number_format(total,2); }else{ msg='Shopping basket is Empty.'; document.getElementById('showCart').innerHTML = msg; document.getElementById('odForm').innerHTML = ''; document.getElementById('mand').innerHTML = ''; } } function close_cart_click(){ if(document.getElementById('cartCont').style.visibility=='visible'){ close_cart(); } } function close_cart(){ if(typeof hs != 'undefined') hs.undim(); CartOpen=false; document.getElementById('cartCont').style.visibility='hidden'; document.getElementById('cartCont').style.display='none'; } function close_cart_delay(){ clearTimeout(cartT); cartT = setTimeout("close_cart()",12000); } //Function to increment value from checkout for function addToSession(obj){ var flyObj = new fly(); var split_field = obj.id.split('_'); var price_obj = eval(document.getElementById('price_'+split_field[1])); var grandtot_obj = eval(document.getElementById('grandtot')); if(price_obj){ obj.value++; var unitPriceObj = document.getElementById('unitprice_'+split_field[1]); var grandtotvalObj = document.getElementById('grandtotval'); grandtotvalObj.value = grandtotvalObj.value.replace(',', ''); price_obj.innerHTML = flyObj.currency + number_format(parseFloat(unitPriceObj.value) * parseFloat(obj.value),2); grandtot_obj.innerHTML = number_format(parseFloat(grandtotvalObj.value) + parseFloat(unitPriceObj.value),2); grandtotvalObj.value = grandtot_obj.innerHTML; if(split_field[1]){ var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'incItem'; ajaxVar.vars["args"] = split_field[1]; ajaxVar.gotoFunction = "doNothing"; ajaxVar.AjaxPostSQL(); } } } function addfromdetails(prod_id){ var flyObj = new fly(); if(prod_id){ var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'incdetailsItem'; ajaxVar.vars["args"] = prod_id; ajaxVar.gotoFunction = "doNothing"; ajaxVar.AjaxPostSQL(); } } function removefrmSession(obj){ var flyObj = new fly(); var split_field = obj.id.split('_'); var price_obj = eval(document.getElementById('price_'+split_field[1])); var grandtot_obj = eval(document.getElementById('grandtot')); if(price_obj){ if(obj.value >0){ obj.value--; var unitPriceObj = document.getElementById('unitprice_'+split_field[1]); var grandtotvalObj = document.getElementById('grandtotval'); grandtotvalObj.value = grandtotvalObj.value.replace(',', ''); price_obj.innerHTML = flyObj.currency + number_format(parseFloat(unitPriceObj.value) * parseFloat(obj.value),2); grandtot_obj.innerHTML = number_format(parseFloat(grandtotvalObj.value) - parseFloat(unitPriceObj.value),2); grandtotvalObj.value = grandtot_obj.innerHTML; if(split_field[1]){ var ajaxVar = new ajaxVars(); ajaxVar.vars['action'] = 'runFunction'; ajaxVar.vars['class'] = 'cart'; ajaxVar.vars['func'] = 'decItem'; ajaxVar.vars["args"] = split_field[1]; ajaxVar.gotoFunction = "doNothing"; ajaxVar.AjaxPostSQL(); } } } }