﻿function addToCart(element) {
    // Check for add-to-cart link
    if (element == null)
        return;

    // Get product quantity
    var amountElement = document.getElementById("productAmount");
    if (amountElement != null)
        element.href = element.href.replace("count=1", "count=" + amountElement.value);
    
    // Request add to shopping cart
    $.ajax(
    {
        url: element.href,
        context: document.body,
        success: function() {
            window.location.reload();
        }
    });
    
    // Don't redirect
    return false;
}

function continueShopping(element) {
    if (window.history.length > 1) {
        window.history.back();
        return false;
    }
    return true;
}
