function AddToCart(ProductId,Quantity){ 
    $.get(`/cart/add/${ProductId}/${Quantity}`,function(data,status){
        if(status=="success"){
            console.log(data);
            document.getElementById('cart-items').innerHTML=data;
        }
    });
}
function RemoveFromCart(ProductId){
    $.get(`/cart/remove/${ProductId}`,function(data,status){
        if(status=="success"){
            document.getElementById('cart-items').innerHTML=data;
        }
    });
}
var CurrentQuantity=0;
var changedQuantity=0;
var isEditing=false;
function BeginChangeCart(inputNumber,ProductId)
{
    isEditing=true;
     CurrentQuantity=inputNumber.value;
     console.log("Current",CurrentQuantity);
}
function ChangedCart(inputNumber,ProductId)
{
    changedQuantity=inputNumber.value;
    console.log("Changed",changedQuantity);
}
function UpdateCart(ProductId)
{
    if(isEditing)
    {        
        var balance=changedQuantity-CurrentQuantity;
        $.get(`/cart/add/${ProductId}/${balance}`,function(data,status){
            if(status=="success"){
                document.getElementById('cart-items').innerHTML=data;
            }
        });
    }
    isEditing=false;
}
function CartAProduct(ProductId,Quantity=1)
{
    window.location.href=`/cart/checkout-a-product/${ProductId}/${Quantity}`;
}