﻿// JScript File

function ProductAdd(productId, variantId, inventory) 
{
     var quantity;
     if (isInteger(Trim(document.getElementById('txtQuantity').value)))
     {
        quantity = Trim(document.getElementById('txtQuantity').value);
        if (quantity > inventory) 
        {
            alert('Sorry, there is currently not enough stock for that transaction.');
            document.getElementById('txtQuantity').value = inventory;
        }
        else
        {
            window.location = '/addtocart.aspx?productid=' + productId + '&variantid='+variantId+'&quantity='+quantity;
        }
     } 
     else 
     {
        alert ('Please enter a whole number for the quantity.');     
     }
}

function ProductVariantAdd(productId, inventory) 
{
     var variantId = document.getElementById('ddlVariants').value;
     ProductAdd(productId, variantId, inventory);
}

