var CloseBut1 = new Image();
var CloseBut2 = new Image();
var plusImg = new Image();
var plusImgOver = new Image();
var minusImg = new Image();
var minusImgOver = new Image();
CloseBut1.src = "/proimages/closeButton.gif";
CloseBut2.src = "/proimages/closeButton.gif";
plusImg.src = "/proimages/plusnew.gif";
plusImgOver.src = "/proimages/plusnew.gif";
minusImg.src = "/proimages/minusnew.gif";
minusImgOver.src = "/proimages/minusnew.gif";
function startFlying(flyId, prodId){
if(document.getElementById('product_availability_'+ prodId).value == 1){
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();
}else{
alert('Product is not available in stock');
}
}
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 rowObj = cartTbl.tBodies[0].rows[0];
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) ) {
statusObj.innerHTML = '';
statusObj.style.paddingRight = "10px";
statusObj.style.textAlign = 'right';
statusObj.style.color = '#ff0000';
statusObj.className = 'crtEmpty';
statusObj.innerHTML = 'Your shopping cart is empty.';
cartTbl.deleteRow(1);
cartTbl.deleteRow(1);
cartTbl.deleteRow(1);
cartTbl.deleteRow(1);
document.getElementById('total_items').innerHTML = 0;
document.getElementById('total_cart_amount').innerHTML = format_number(0,2,'.','.');
}else if(cartTbl.tBodies[0].rows.length > 1) {
if (cartTbl.tBodies[0].rows[0].childNodes.length>1){
rowObj.removeChild(rowObj.childNodes[1]);
}
statusObj.innerHTML = '';
statusObj.colSpan = 7;
statusObj.style.paddingTop = "10px";
statusObj.style.paddingBottom = "10px";
statusObj.innerHTML = '
| Shopping Cart |  |
';
statusObj.style.textAlign = 'left';
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 totalQty = 0;
var maxRows = cartTbl.tBodies[0].rows.length;
if(cartTbl.tBodies[0].rows[maxRows-1].innerHTML.indexOf('orders_upsell_products.html') < 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);
}
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);
var Qty = parseFloat(document.getElementById('qtyx_image_' + prodId).value);
totalCur += parseFloat(curStr);
totalQty += parseFloat(Qty);
}
}
totalCellObj.innerHTML = flyObj.currency + format_number(totalCur,2,'.','.');
if((dummyRows-2) == 1){
document.getElementById('total_items').innerHTML = dummyRows-2;
}else if((dummyRows-2) >1){
document.getElementById('total_items').innerHTML = dummyRows-2;
}else{
document.getElementById('total_items').innerHTML = 0;
}
document.getElementById('total_cart_amount').innerHTML = format_number(totalCur,2,'.','.');
var maxRows = cartTbl.tBodies[0].rows.length;
if(cartTbl.tBodies[0].rows[maxRows-1].innerHTML.indexOf('orders_upsell_products.html') < 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_upsell_products.html') < 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 = "10px";
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 = '';
}
}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.style.color = '#ff0000';
statusObj.className = 'crtEmpty';
statusObj.innerHTML = 'Your shopping cart is empty.';
document.getElementById('total_items').innerHTML = 0;
document.getElementById('total_cart_amount').innerHTML = format_number(0,2,'.','.');
}
}
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 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.style.paddingLeft = '16px';
prodImageObj.style.paddingBottom = '2px';
prodImageObj.className = 'pname';
var prodNameObj = prodObj.insertCell(prodObj.cells.length);
prodNameObj.id = 'name_' + flyId;
prodNameObj.className = 'crtName';
var prodColorObj = prodObj.insertCell(prodObj.cells.length);
prodColorObj.id = 'color_' + flyId;
prodColorObj.className = 'crtColorName';
var minusObj = prodObj.insertCell(prodObj.cells.length);
minusObj.id = 'minus_' + flyId;
minusObj.style.paddingTop = "5px";
minusObj.className = 'crtPlus';
minusImgObj = document.createElement('IMG');
minusImgObj.id = 'minusx_' + flyId;
minusImgObj.src = minusImg.src;
minusImgObj.onmouseover = function (e){
this.src = minusImgOver.src;
}
minusImgObj.onmouseout = function (e){
this.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.style.paddingTop = "5px";
plusObj.style.paddingLeft = '4px';
plusObj.id = 'plus_' + flyId;
plusObj.className = 'crtPlus';
plusImgObj = document.createElement('IMG');
plusImgObj.id = 'plusx_' + flyId;
plusImgObj.src = plusImg.src;
plusImgObj.onmouseover = function (e){
this.src = plusImgOver.src;
}
plusImgObj.onmouseout = function (e){
this.src = plusImg.src;
}
plusObj.appendChild(plusImgObj);
var prodPriceObj = prodObj.insertCell(prodObj.cells.length);
prodPriceObj.id = 'price_' + flyId;
prodPriceObj.className = 'crtPrice';
prodPriceObj.style.width = '140px';
if(productColorObj.innerHTML == 'no'){
productColorObj.innerHTML = "";
}
prodImageObj.innerHTML = productImgObj.innerHTML;
prodNameObj.innerHTML = productNameObj.innerHTML;
prodColorObj.innerHTML = productColorObj.innerHTML;
qtyTextObj.value = qty;
if(productPriceObj.innerHTML >0){
prodPriceObj.innerHTML = flyObj.currency + format_number(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 + format_number(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 if(this.qty > 1){
this.qty--;
qty = this.qty;
document.getElementById(this.qtyId).value = this.qty;
document.getElementById(this.priceId).innerHTML = this.flyObj.currency + format_number(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 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]"] = 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 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 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.style.paddingLeft = '16px';
prodImageObj.style.paddingBottom = '2px';
prodImageObj.className = 'pname';
var prodNameObj = prodObj.insertCell(prodObj.cells.length);
prodNameObj.id = 'name_' + flyObj.flyId;
prodNameObj.className = 'crtName';
var prodColorObj = prodObj.insertCell(prodObj.cells.length);
prodColorObj.id = 'color_' + flyObj.flyId;
prodColorObj.className = 'crtColorName';
var minusObj = prodObj.insertCell(prodObj.cells.length);
minusObj.style.paddingTop = "5px";
minusObj.id = 'minus_' + flyObj.flyId;
minusObj.className = 'crtPlus';
minusImgObj = document.createElement('IMG');
minusImgObj.id = 'minusx_' + flyObj.flyId;
minusImgObj.src = minusImg.src;
minusImgObj.onmouseover = function (e){
minusImgObj.src = minusImgOver.src;
}
minusImgObj.onmouseout = function (e){
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.style.paddingTop = "5px";
plusObj.style.paddingLeft = '4px';
plusObj.id = 'plus_' + flyObj.flyId;
plusObj.className = 'crtPlus';
plusImgObj = document.createElement('IMG');
plusImgObj.id = 'plusx_' + flyObj.flyId;
plusImgObj.src = plusImg.src;
plusImgObj.onmouseover = function (e){
plusImgObj.src = plusImgOver.src;
}
plusImgObj.onmouseout = function (e){
plusImgObj.src = plusImg.src;
}
plusObj.appendChild(plusImgObj);
var prodPriceObj = prodObj.insertCell(prodObj.cells.length);
prodPriceObj.id = 'price_' + flyObj.flyId;
prodPriceObj.style.width = '140px';
prodPriceObj.className = 'crtPrice';
}
if(productColorObj.innerHTML == 'no'){
productColorObj.innerHTML = "";
}
prodImageObj.innerHTML = flyObject.innerHTML;
prodNameObj.innerHTML = productNameObj.innerHTML;
prodColorObj.innerHTML = productColorObj.innerHTML;
var qty = (parseFloat(qtyTextObj.value)) ? parseFloat(parseFloat(qtyTextObj.value) + 1) : 1;
if(productPriceObj.innerHTML){
prodPriceObj.innerHTML = flyObj.currency + format_number(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 + format_number(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 + format_number(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_' + 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.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--;
if(qty == 0){
alert('Quantity cannot be less then 1');
return false;
}
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();
}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[1].length>0 && colArr[2]>0) {
var qty = Number(document.getElementById('qty_' + colArr[1]).innerHTML);
document.getElementById('price_' + colArr[1]).innerHTML = format_number(parseFloat(0 * qty) + parseFloat(colArr[2] * qty),2,'.','.');
total += parseFloat(0 * qty) + parseFloat(colArr[2] * qty);
}else{
if(document.getElementById('qty_' + colArr[1])){
var qty = Number(document.getElementById('qty_' + colArr[1]).innerHTML);
document.getElementById('price_' + colArr[1]).innerHTML = "0.00";
}
}
val++;
}
//here i need to split the values
var rowNew = data.split("#||#");
document.getElementById('shipping_cost_id').innerHTML = rowNew[1];
var ajaxVar = new ajaxVars();
ajaxVar.phpFile = "/vouchercalc.php";
ajaxVar.gotoFunction = "OrderDisplayData";
ajaxVar.vars['total'] = total;
ajaxVar.fnVars['total'] = total;
ajaxVar.AjaxPostSQL();
}
function OrderDisplayData(data,fnVars){
var values = data.split("||");
var total = fnVars['total'];
if(document.getElementById('gift_wrap').checked == true && total>0){
total = parseFloat(total) + parseFloat(values['3']);
}
document.getElementById('shipping_cost_id').innerHTML = number_format(values[2],2);
if(values['1'] == 0){
document.getElementById('promot_code_disdata').style.visibility = "hidden";
document.getElementById('promot_code_disdata').style.display = "none";
document.getElementById('promot_code_data').style.visibility = "visible";
document.getElementById('promot_code_data').style.display = "block";
document.getElementById('voucher').value ="";
}
if (total>0) {
document.getElementById('disp_value').innerHTML = format_number(values['1'],2,'.','.');
var discount = values['1'];
if(discount!=0){
total -= parseFloat(values['1']);
}
total = parseFloat(total) + parseFloat(values['2']);
if(document.getElementById('nextDay').checked == true){
total = parseFloat(total) + parseFloat(document.getElementById('nextDelv').innerHTML);
}
document.getElementById('final_total').innerHTML = format_number(total,2,'.','.');
//document.getElementById('odForm').style.visibility = 'visible';
//document.getElementById('odForm').style.display = 'block';
}else{
document.getElementById('final_total').innerHTML = 0.00;
msg='Shopping cart is empty currently.
';
//document.getElementById('odForm').style.visibility = 'hidden';
//document.getElementById('odForm').style.display = 'none';
}
}