var products = [];
products[101] = ["Thumb Saver Massage Tool", 4.95, "Performance Depo", "The Thumb Saver Massage Tool is an ergonomically shaped tool that may help protect your hands while delivering deep, precise massage. Designed to mimic the natural pressure of a thumb, it may help relieve muscle tension and trigger points without causing hand strain, making it ideal for therapists or for self-care.", "
", "", "", "equpment"] ;
products[102] = ["Acupuncture Pen", 7.95, "Performance Depo", "The Acupuncture Pen is a portable, non-invasive tool that may help stimulate pressure points and promote circulation. By targeting key meridian points, it may help relieve tension and support both relaxation and pain reduction, making it ideal for at-home acupressure sessions.", "
", "", "", "equpment"] ;
products[103] = ["Chiropractic Adjusting Tool", 8.95, "Performance Depo", "Experience a sense of relief from sore, tense, and overworked muscles. This lightweight, ergonomic massager mimics a deep-tissue treatment and may help boost circulation, reduce fatigue, and melt away tensionâno therapist required. Compact enough to take anywhere, it is designed to handle your toughest knots.", "
", "", "", "equpment"] ;
products[104] = ["Hard Peanut Massage Ball", 9.99, "Performance Depo", "Crafted from high-quality, non-slip TPR, this durable tool is designed for deep tissue and myofascial release. By using your own body weight to target tight knots, it may help relax muscle tissue, reduce soreness, and improve overall flexibility. Compact and safe for all ages, itâs the perfect portable solution for daily tension.", "
", "", "", "equpment"] ;
products[105] = ["Muscle Recovery Massage Stick", 11.95, "Performance Depo", "Featuring nine independent rotating heads, this massager mimics professional techniques to pinpoint stubborn knots. Deep-tissue pressure may help break down muscle tension and ease soreness after training. By increasing localized circulation, it may help support the natural repair process, making it a perfect addition to your daily recovery routine.", "
", "", "", "equpment"] ;
products[106] = ["Cervical Neck & Shoulder Relaxer", 19.95, "Performance Depo", "Reclaim your comfort in just 10 minutes a day. Crafted from high-density polyurethane foam, this ergonomic stretcher provides vertical and horizontal support to the cervical spine. Regular use may help relieve neck pressure, soothe stiffness from poor posture, and support the restoration of the neck's natural C-shaped curve.", "
", "", "", "equpment"] ;
products[107] = ["4D Kneading Massager", 19.99, "Performance Depo", "Experience professional-grade relaxation with this 4D Kneading Massager. Designed to mimic the techniques of a trained therapist, this corded electric massager may help provide targeted relief for the neck, back, and legs.", "
", "", "", "equpment"] ;
products[108] = ["3 in 1 Muscle Scraper Tools Set", 24.95, "Performance Depo", "Experience professional-quality recovery with this durable, mirror-polished muscle scraper set. Designed to glide smoothly over the skin, these precision tools may help relieve muscle soreness, break down soft tissue tension, and promote healthy circulation. With three specialized shapes and a protective felt bag, this versatile set may help you target everything from large muscle groups to delicate joints for total body revitalization.", "
", "", "", "equpment"] ;
products[109] = ["Massage Roller for Neck", 29.99, "Performance Depo", "Crafted from high-strength, eco-friendly polymers and hypoallergenic silicone, this massager is built for longevity and performance. Its unique flexible frame allows for a wide range of motion, which may help you adapt the tool for use on your calves, forearms, and thighs, making it a truly multi-purpose recovery instrument.", "
", "", "", "equpment"] ;
products[110] = ["Deep Tissue Massage Gun", 34.95, "Performance Depo", "Elevate your recovery routine with this powerful percussion massager. Featuring 7 adjustable speed levels and 10 specialized massage heads, this tool may help relieve deep muscle tension and relax the body after strenuous activity. With an ultra-quiet motor and an ergonomic, non-slip grip, it may help soothe soreness and revitalize tired muscles whether you are at home, the gym, or the office.", "
", "", "", "equpment"] ;
products[111] = ["Adjustable Hip Flexor Release Tool", 39.95, "Performance Depo", "The portable psoas release tool is meticulously designed for maximum convenience and personalized customization. By simulating the precise touch of a professional therapist, this tool may help alleviate chronic discomfort in the hips, back, and neck. Integrating this into your routine may help you stay on top of your recovery goals and may help maintain your physical well-being wherever your day takes you.", "
", "", "", "equpment"] ;
products[112] = ["Needleless Tension Relief Tool", 39.99, "Performance Depo", "Experience the benefits of acupuncture without the needles. This therapist-trusted device uses a plunger-activated stimulus that may help encourage natural healing and relieve stubborn tension points. With no batteries required, this portable tool may help soothe sore muscles and revitalize your body whether you are at home or in the clinic.", "
", "", "", "equpment"] ;
products[113] = ["Pro-Support SOT Blocks", 44.95, "Performance Depo", "These premium SOT blocks are designed for both professional and home use. Featuring a durable wood core and high-resilience foam, they may help promote better spinal alignment and provide targeted support during pelvic adjustments. Lightweight and portable, they are a reliable tool for your daily wellness routine.", "
", "", "", "equpment"] ;
products[114] = ["Back Wheel Foam Roller", 49.95, "Performance Depo", "Designed for deep tissue relief, this 6 inch roller features a specialized spine groove and wavy bumps. It may help alleviate muscle tension in the neck and shoulders while supporting spinal stretching. Built from high-impact materials, it provides a sturdy, reliable surface that may help improve comfort and mobility after long periods of sitting.", "
", "", "", "equpment"] ;
products[115] = ["Cordless Back Massager", 59.99, "Performance Depo", "The Cordless Back Massager offers a sophisticated way to manage daily tension with the complete freedom of a high-capacity, rechargeable design. Meticulously engineered to contour to your bodyâs natural curves, this versatile device may help provide a professional-style experience for the neck, shoulders, and back, wherever you are.", "
", "", "", "equpment"] ;
products[116] = ["Chiropractic Massager with Heat and Adjustable Vibration", 69.95, "Performance Depo", "This Chiropractic Massager with Heat and Adjustable Vibration may help ease tight muscles and reduce chronic pain. The device is designed for deep tissue therapy, and its combination of soothing heat and customizable intensity may help stimulate circulation and support relaxation at home or in a clinical setting.", "
", "", "", "equpment"] ;
console.log(products);
var orderedItems = [];
var orderedTotQty = 0;
var maxQty = 10;
var shipRates = false;
var handling = 0;
var carturl = "cart.php";
// Function to check item exists in cart
var checkItemExists = function(itemId) {
var order = $.cookie('order');
if (!order) {
return false;
} else {
var itemExists = false;
var items = order.split("|");
order = "";
for (var i = 0; i < items.length; i = i + 1) {
var position = items[i].indexOf("-");
var prodId = items[i].substring(0, position);
var quantity = parseInt(items[i].substring(position + 1));
if (order != "") {
order += "|";
}
if (prodId == itemId) {
return true;
}
}
}
return false;
}
//Funtion adds Items to Cart
var addItem = function(itemId, Qty, showFullCart) {
if (typeof showFullCart === "undefined") {
showFullCart = false;
}
orderedTotQty = $.cookie('orderedTotQty');
if (!orderedTotQty) {
orderedTotQty = 0;
}
Qty = parseInt(Qty);
if(Qty > maxQty) {
alert("Maximum " + maxQty + " of this product can be selected in a single order");
return false;
}
var order = $.cookie('order');
if (!order) {
order = itemId + "-" + Qty;
orderedItems[itemId] = Qty;
} else {
var itemExists = false;
var items = order.split("|");
order = "";
for (var i = 0; i < items.length; i = i + 1) {
var position = items[i].indexOf("-");
var prodId = items[i].substring(0, position);
var quantity = parseInt(items[i].substring(position + 1));
if (order != "") {
order += "|";
}
if (prodId == itemId) {
alert("Product already exist in cart");
return false;
if((quantity + Qty) > maxQty) {
alert("Maximum " + maxQty + " of this product can be selected in a single order");
return false;
}
quantity += Qty;
order += prodId + "-" + quantity;
itemExists = true;
} else {
order += prodId + "-" + quantity;
}
orderedItems[prodId] = quantity;
}
if (!itemExists) {
if (order != "") {
order += "|";
}
order += itemId + "-" + Qty;
orderedItems[itemId] = Qty;
}
}
orderedTotQty = parseInt(orderedTotQty);
orderedTotQty += Qty;
$('.cartqty').html(orderedTotQty);
$.cookie('order', order);
$.cookie('orderedTotQty', orderedTotQty);
var url = window.location.pathname;
var filename = url.substring(url.lastIndexOf('/') + 1);
if (filename == carturl) {
showCart(showFullCart, 'add', itemId);
} else {
$(location).attr('href', carturl);
}
};
//Funtion decrements Items to Cart
var removeItem = function(itemId, Qty) {
Qty = parseInt(Qty);
var order = $.cookie('order');
if (!order) {
orderedItems[itemId] = 0;
refreshRow(itemId);
} else {
var items = order.split("|");
order = "";
for (var i = 0; i < items.length; i = i + 1) {
var position = items[i].indexOf("-");
var prodId = items[i].substring(0, position);
var quantity = parseInt(items[i].substring(position + 1));
if (prodId == itemId) {
quantity -= Qty;
if (quantity > 0) {
if (order != "") {
order += "|";
}
order += prodId + "-" + quantity;
}
itemExists = true;
orderedItems[prodId] = quantity;
refreshRow(itemId);
} else {
if (order != "") {
order += "|";
}
order += prodId + "-" + quantity;
orderedItems[prodId] = quantity;
}
}
}
orderedTotQty -= Qty;
$('.cartqty').html(orderedTotQty);
$.cookie('order', order);
$.cookie('orderedTotQty', orderedTotQty);
var url = window.location.pathname;
var filename = url.substring(url.lastIndexOf('/') + 1);
if (filename == carturl) {
showCart(false, 'remove', itemId);
} else {
$(location).attr('href', carturl);
}
};
//Funtion sets Item quantity on the Cart
var setItemQty = function(itemId, Qty) {
Qty = parseInt(Qty);
if(Qty > maxQty || Qty < 0) {
return false;
}
var order = $.cookie('order');
orderedTotQty = 0;
if (!order) {
orderedItems[itemId] = 0;
} else {
var items = order.split("|");
order = "";
for (var i = 0; i < items.length; i = i + 1) {
var position = items[i].indexOf("-");
var prodId = items[i].substring(0, position);
var quantity = parseInt(items[i].substring(position + 1));
if (prodId == itemId) {
quantity = Qty;
if (order != "") {
order += "|";
}
order += prodId + "-" + quantity;
itemExists = true;
} else {
if (order != "") {
order += "|";
}
order += prodId + "-" + quantity;
}
orderedItems[prodId] = quantity;
orderedTotQty += quantity;
}
}
$('.cartqty').html(orderedTotQty);
$.cookie('order', order);
$.cookie('orderedTotQty', orderedTotQty);
var url = window.location.pathname;
var filename = url.substring(url.lastIndexOf('/') + 1);
if (filename == carturl) {
showCart(false, 'set', itemId);
} else {
$(location).attr('href', carturl);
}
};
var removeRowItem = function(itemId, showFullCart) {
if (typeof showFullCart === "undefined") {
showFullCart = false;
}
var order = $.cookie('order');
if (!order)
{
orderedTotQty = 0;
} else {
var items = order.split("|");
order = "";
orderedTotQty = 0;
orderedItems = null;
orderedItems = new Array();
for (var i = 0; i < items.length; i = i + 1) {
var position = items[i].indexOf("-");
var prodId = items[i].substring(0, position);
var quantity = parseInt(items[i].substring(position + 1));
if (prodId == itemId) {
} else {
if (order != "") {
order += "|";
}
order += prodId + "-" + quantity;
orderedTotQty += quantity;
orderedItems[prodId] = quantity;
}
}
}
if($('#prow-' + itemId).length == 1) {
$('#prow-' + itemId).remove();
}
$.cookie('order', order);
$.cookie('orderedTotQty', orderedTotQty);
showCart(true, 'removerow', itemId);
};
//Emptying the cart
var emptyCart = function() {
var order = $.cookie('order');
order = "";
orderedTotQty = 0;
orderedItems = null;
orderedItems = new Array();
$.cookie('order', order);
$.cookie('orderedTotQty', orderedTotQty);
if($('[id^="prow-"]').length > 0) {
$('[id^="prow-"]').each(function(){
$(this).remove();
});
}
$('.trm_1').hide();
showCart(false, 'empty');
};
//Displaying the cart items & calculations
function showTotalPrice() {
var cartHtml = "";
var total = 0;
//var total_gbp = 0;
var shipping = 0;
var grand_total = 0;
//var grand_total_gbp = 0;
var sub_total = 0;
//var sub_total_gbp = 0;
var shippingType = '';
var order = $.cookie('order');
orderedTotQty = $.cookie('orderedTotQty');
if($('#shippingCountry').val() == '') {
shippingType = '';
} else if($('#shippingCountry').val() == 'US') {
shippingType = 'US';
} else {
shippingType = 'INTERNATIONAL';
}
if (!order) {
orderedTotQty = 0;
} else {
var items = order.split("|");
if(shipRates) {
shipping = shipRates * 1.0;
}
for (var i = 0; i < items.length; i = i + 1) {
var position = items[i].indexOf("-");
var prodId = items[i].substring(0, position);
var quantity = parseInt(items[i].substring(position + 1));
if (prodId != "" && quantity > 0) {
sub_total = round((quantity * products[prodId][1]), 2);
//sub_total_gbp = round((quantity * products[prodId][6]), 2);
total += (quantity * products[prodId][1]);
//total_gbp +=(quantity * products[prodId][6])
}
}
total = round(total, 2);
//total_gbp = round(total_gbp, 2);
}
var snh = shipping + handling;
//if(shipping == 0) {
// snh = shipping;
//}
console.log(snh);
grand_total = total + snh;
$('#total-price').html('$ ' + total.toFixed(2));
$('#shipping-price').html('$ ' + snh.toFixed(2));
$('#grand-total').html('$ ' + grand_total.toFixed(2));
};
// Refresh row content with updated quantity / price for a product
function refreshRow(pid) {
pid = parseInt(pid);
quantity = orderedItems[pid];
sub_total = round((quantity * products[pid][1]), 2);
$('#prow-' + pid + ' .tot-price').html('$' + sub_total.toFixed(2) + ' USD');
$('#prow-' + pid + ' .qtybox').val(quantity);
$('#prow-' + pid + ' .dispqty').html(quantity);
}
function replaceAllStr(str, find, rstr) {
//return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
//return str.replace(/find/g, '\\$&');
return str.replace(new RegExp(find, "g"), rstr);
}
//Displaying the cart items & calculations
function showCart(showFullCart, act, itm) {
var cartHtml = "";
var order = $.cookie('order');
orderedTotQty = $.cookie('orderedTotQty');
if (!order)
{
orderedTotQty = 0;
if($('[id^="prow-"]').length == 0) {
$("#cartBox").html("
You have not selected any product...
  Browse Products"); } showTotalPrice(); return false; } else { var items = order.split("|"); var total = 0; var total_gbp = 0; var shipping = 0; var grand_total = 0; orderedTotQty = parseInt(orderedTotQty); if (typeof showFullCart === "undefined") { return false; } else if(showFullCart == false) { if ((typeof act !== "undefined") && (typeof itm !== "undefined")) { if((act == 'add' || act == 'set' || act == 'remove') && itm > 0) { refreshRow(itm); } else if(act == 'removerow' && itm > 0) { itm = parseInt(itm); } } showTotalPrice(); return false; } orderedItems = null; orderedItems = new Array(); cartHtml += "
" + products[prodId][0] + "