function getCalculator() { $.ajax({ type: 'POST', url: 'ajax_cost_calculator.jsp', dataType: 'xml', data: '', success: updateClient });} function setItem(field, qty, osname) { var productid = -1; productid = $('input[name=' + field + ']:checked').val(); if (productid == -1) { alert ('Warning...invalid field/unable to find product.'); return; } if (productid >= 10005100 && productid <= 10005199) { if ($('#os_pid').data('pid') == 110100) $('#gold_upgrade').dialog('open'); } if (productid >= 10005200 && productid <= 10005299) { if ($('#os_pid').data('pid') == 110100 || $('#os_pid').data('pid') == 110200) $('#platinum_upgrade').dialog('open'); } if (isNaN(qty)) qty = $('#' + qty).val(); setProduct(field, -1, productid, qty, osname); } function setProduct(field, unit, productid, qty, osname) { $.ajax({ type: 'POST', url: 'ajax_cost_calculator.jsp', dataType: 'xml', data: 'set=1&field=' + field + '&unit=' + unit + '&quantity=' + qty + '&osname=' + osname + '&productid=' + productid, success: updateClient });} function updateClient(xml) { var rowCollapse = true; var rowCount = $('#costcalcitems tr').length; if (rowCount != 2 && !$('#toggle_r_calc').hasClass('collapsed')) rowCollapse = false; $('#costcalc').remove().insertAfter('#lastitem'); $('#costcalc').show(); var units = new Array('multiterm', 'monthly', 'other'); var table = document.getElementById('costcalcitems'); // Delete any existing rows $('#costcalcitems').html(''); for (index = 0; index < rowCount; index++) $('#costcalcitems tr:last').remove(); var column = 0; var total = 0; for (var i=0; i'; row += '' + formatFee(unitPrice * quantity, '.', ',') + ''; row += ''; if (unit >= 100) { row += ''; row += ''; row += ''; } } else { var row = ''; row += '' + productDesc + ''; row += '' + formatFee(unitPrice * quantity, '.', ',') + ''; row += ''; } $('#costcalcitems').append(row); if (counter == numberofentries - 1) addSubtotal(subtotal); counter++; if (productId == 1010 | productId == 1020) { } }); total += subtotal; }); } if (column == 0) $('#creditsfromsubscription').html(0); addTotal(table, total); $('.cell').css('backgroundColor', '#FFFFFF'); $('.cell' + column).css('backgroundColor', '#fdfaaa'); $('#totalcredits').html(parseInt($('#creditquantity').val()) * 5 + parseInt($('#creditsfromsubscription').text()) + parseInt($('#creditsfromhardware').text())); } function addHeader(subtitle, product_pid, termPref) { var header = ''; var priceDesc = 'One-Time Support Add Ons'; var clearsdnoptions = new Array(1000, 3000, 5000); if (subtitle == 'other') { header += '' + priceDesc + ''; } else if (subtitle == 'multiterm' || subtitle == 'monthly') { header += ''; var options = ''; for (key in clearsdnoptions) { if (clearsdnoptions[key] == termPref) options += ''; } header += ''; } header += ''; $('#costcalcitems').append(header); } function addSubtotal(subtotal) { var row = ''; row += 'Subtotal'; row += '' + formatFee(subtotal, '.', ',') + ''; row += ''; $('#costcalcitems').append(row); } function addTotal(table, total) { var row = ''; row += 'Total Due on Checkout'; row += '' + formatFee(total, '.', ',') + ''; row += ''; $('#costcalcitems').append(row); } function formatFee(n, d, t) { var d = d == undefined ? ',' : d, t = t == undefined ? '.' : t, s = n < 0 ? '-' : '', i = parseInt(n = Math.abs(+n || 0).toFixed(2)) + '', j = (j = i.length) > 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + t) + (2 ? d + Math.abs(n - i).toFixed(2).slice(2) : ''); }