
function showpopupP(obj) {
    obj.getElementsByTagName('p')[0].style.display='block';
}
function hidepopupP(obj) {
    obj.getElementsByTagName('p')[0].style.display='none';
}
function recalculate(self, price, resultId) {
    var quantity = parseInt(parseFloat( self.value )) || 0;
    self.value = quantity;
    var result = document.getElementById(resultId);
    var total = (quantity * price).toFixed(2);
    result.innerHTML = '$' + total;
  
    sumBundles();
    sumPrice();
}
function sumBundles() {
    var bundleIdx = 6;
    var total = 0;
    row = document.getElementById("contents").rows;
    i = row.length;
    while(i--) {
        var child = row[i].cells[bundleIdx].firstChild;
        if (child) {
            total += parseInt(parseFloat( child.value )) || 0;
        }
    }
    document.getElementById('bundlesTotal').innerHTML = total;
}

function sumPrice()
    {
    var bundleIdx = 7;
    var total = 0;
    row = document.getElementById("contents").rows;
    i = row.length;
    while(i--) {
        var child = row[i].cells[bundleIdx].firstChild;
        if (child) {
            total += parseFloat( child.innerHTML.slice(1) ) || 0;
        }
    }
    document.getElementById('total').innerHTML = '$' + total.toFixed(2);
}
