var products = [];
products[211] = ["Blue Light Glasses", 59.99, "Cloud Brands", "Blue light blocking glasses may help reduce eye strain and discomfort that can arise from prolonged exposure to digital screens. By filtering out a portion of the blue light emitted by devices like computers, smartphones, and tablets, these glasses may contribute to a more comfortable viewing experience, especially during evening hours. While individual results can vary, many users report feeling a difference in their eyes after incorporating blue light blocking glasses into their daily routine.", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "", "access" ] ;
products[212] = ["Reading Glasses", 19.99, "Cloud Brands", "Reading glasses may offer a practical solution for the common experience of needing to hold reading material further away to see it clearly. As a natural part of aging, our eyes can gradually lose their ability to focus up close, and these magnifying lenses may help compensate for this change. By making text and small objects appear larger, reading glasses may provide increased comfort and clarity for everyday tasks such as reading, crafting, or using digital devices, potentially reducing the strain that can come with struggling to see fine print.", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "", "access" ] ;
products[213] = ["Eye Glass Repair Kit", 29.99, "Cloud Brands", "This all-inclusive eyeglasses repair kit ensures you can quickly fix or maintain your glasses anywhere. It features eight types of eyeglass screwdrivers, including a 3-in-1 tiny screwdriver, alongside 16 sizes of eyeglass screws and 12 pairs of silicone nose pads in three styles. The set also contains a curved tweezer for precision, 20 silicone screw caps/shims, 20 metal nuts/shims, four anti-slip covers, a magnetizer to simplify handling tiny screws, and a cleaning cloth, all neatly organized for easy portability. This set of tools basically meets various needs for repairing glasses, which can be used for eyeglass, sunglasses, watches, clocks and some other small electronics.", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "", "access" ] ;
products[214] = ["Eye Glass Cleaner", 14.99, "Cloud Brands", "This gentle and effective cleaning spray may help keep your eyeglasses, phone screens, and other delicate glass surfaces pristine. Its balanced formula is designed to remove smudges, dirt, and grime without harming coatings or leaving streaks. Trusted by professionals and made in the USA, this versatile spray may help you achieve a crystal-clear, invisible clean on a variety of devices.", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "", "access" ] ;
products[215] = ["Eye Glass Cloth", 4.99, "Cloud Brands", "This value pack of four microfiber cleaning cloths may help you keep various surfaces spotless. The ultra-soft material effectively removes fingerprints, dust, and smudges without scratching. Individually packed for convenience, these durable and washable cloths may help maintain clarity on eyeglasses, phone screens, camera lenses, and more, offering a cost-effective and versatile cleaning solution.", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "", "access" ] ;
products[216] = ["Contact Lens Case", 4.99, "Cloud Brands", "This contact lens case may help simplify your lens care on the go. Its small, travel-sized design and no-leak seal may help keep your lenses secure and your bag dry. Easy to clean and sanitize, with a durable build and soft-grip lids, this case may help you maintain hygiene and convenience for your contact lenses.", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "", "access" ] ;
products[217] = ["Contact Lens Solution", 14.99, "Cloud Brands", "This preservative-free saline solution may help maximize comfort and clarity for contact lens wearers, especially those with dry and sensitive eyes. Its pH-balanced formula is designed to mimic your eyes' natural tears, making it gentle for daily use and ideal as an insertion solution for scleral lenses.", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "", "access" ] ;
products[218] = ["Safety Glasses", 19.99, "Cloud Brands", "Safety glasses may help protect your eyes from various hazards in many environments. They are crucial for preventing injuries from flying debris, dust, and chemical splashes, significantly reducing the risk of permanent eye damage. Furthermore, specialized safety glasses may help shield your eyes from harmful light radiation, such as intense UV or infrared light. By wearing appropriate safety eyewear, you may help ensure long-term vision health and overall personal safety during hazardous tasks.", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "", "access" ] ;
products[219] = ["ACV Gummies", 79.99, "Cloud Brands", "The ACV gummies may help you enjoy the benefits of Apple Cider Vinegar in the form of delicious gummies without the foul taste & smell of liquid ACV. For best results it is essential to include a healthy diet & regular exercise in your daily routine along with supplementation.", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "1 Bottle", "supplement" ] ;
products[220] = ["ACV Gummies", 129.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "2 Bottles", "supplement" ] ;
products[221] = ["ACV Gummies", 169.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "3 Bottles", "supplement" ] ;
products[222] = ["ACV Gummies", 189.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "4 Bottles", "supplement" ] ;
products[223] = ["ACV Gummies", 219.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "5 Bottles", "supplement" ] ;
products[224] = ["ACV Gummies", 239.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "6 Bottle", "supplement" ] ;
products[225] = ["Detox", 39.99, "Cloud Brands", "The Detox supplement is crafted with a blend of gut-friendly fiber extracts designed to support internal cleansing and promote digestive health. When used as part of a balanced lifestyle, it may help improve digestion, enhance nutrient absorption, and contribute to overall wellness. For optimal results, itâs recommended to pair this supplement with a healthy diet and regular exercise. By incorporating these habits into your daily routine, you may maximize the potential benefits of the supplement and maintain a healthier, more balanced system.", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "1 Bottle", "supplement" ] ;
products[226] = ["Detox", 59.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "2 Bottles", "supplement" ] ;
products[227] = ["Blood Formula", 79.99, "Cloud Brands", "The Blood Formula is formulated with a blend of mulberry & cinnamon extract which may help keep blood sugar levels in the normal range. For best results it is essential to include a healthy diet & regular exercise in your daily routine along with supplementation.", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "1 Bottle", "supplement" ] ;
products[228] = ["Blood Formula", 129.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "2 Bottles", "supplement" ] ;
products[229] = ["Blood Formula", 169.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "3 Bottles", "supplement" ] ;
products[230] = ["Blood Formula", 189.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "4 Bottles", "supplement" ] ;
products[231] = ["Blood Formula", 219.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "5 Bottles", "supplement" ] ;
products[232] = ["Blood Formula", 239.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "6 Bottles", "supplement" ] ;
products[236] = ["CBD Gummies", 79.99, "Cloud Brands", "The chewable fast absorption CBD gummies can be taken on-the-go for rapid relief from stress and inflammation. Enriched with pure hemp extracts, the chewable CBD gummies may help the body promptly respond to the therapeutic benefits of cannabidiol. For best results it is essential to include a healthy diet & regular exercise in your daily routine along with supplementation.", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "1 Bottle", "supplement" ] ;
products[237] = ["CBD Gummies", 129.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "2 Bottles", "supplement" ] ;
products[238] = ["CBD Gummies", 169.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "3 Bottles", "supplement" ] ;
products[239] = ["CBD Gummies", 189.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "4 Bottles", "supplement" ] ;
products[240] = ["CBD Gummies", 219.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "5 Bottles", "supplement" ] ;
products[241] = ["CBD Gummies", 239.99, "Cloud Brands", "", "
", "By placing an order with us you will be charged $ __prc__ + $0.00 for S&H for One Time for __prdqty__ of Cloud Brands __prdname__. If you are not completely satisfied with your purchase of Cloud Brands __prdname__ at any time, please call  (833) 496-1989 or email care@getcloudbrands.com, Monday to Friday : 24 Hours | Sat & Sun : 7AM - 11PM (EST). You will receive your package within 2-5 business days of payment via USPS First Class Mail. I agree that my credit card charge will appear as Cloud Brands.", "6 Bottles", "supplement" ] ;
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 addItem = function(itemId, Qty) {
	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(false, '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();
		emptyCart();
	}
	
    $.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 prodType = '';
	
	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));
            var prodType = products[prodId][7];
			if (prodId != "" && quantity > 0) {
				
                if(prodType == "access"){ 
                    sub_total = round((quantity * products[prodId][1]), 2);
                }else{
                   sub_total = round((products[prodId][1]), 2);
                }
                //sub_total_gbp = round((quantity * products[prodId][6]), 2);
                if(prodType == "access"){ 
                    total += (quantity * products[prodId][1]);
                }else{
                    total += (products[prodId][1]);
                }
				//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];
    prodType = products[prodId][7];
    if(prodType == "access"){ 
		sub_total = round((quantity * products[pid][1]), 2);
    }else{
    	sub_total = round((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] + " Qty: " + quantity + "