﻿/* Handles product weight update in AddToCartCnD user control. */

// Returns true if character is a digit.
function isNumberKey(evt) {

    var charCode = (evt.which) ? evt.which : event.keyCode

    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

    return true;
}

// Update the Product total weight.
function updateWeight() {

    //Weight info is rendered by server only when product is in stock and has weight info attached.
    if (totalWeightSpanId && unitWeight && txtQuantityId) {

        var spanQuantity = document.getElementById(totalWeightSpanId);
        var txtQuantity = document.getElementById(txtQuantityId);

        spanQuantity.innerHTML  = (unitWeight * txtQuantity.value).toFixed(1);
    }
}