﻿function CheckDiscountCode(discountCode, bizformName) {
    $$.ajax({
        type: 'POST',
        contentType: "application/json; charset=utf-8",
        url: '/CMSPages/CustomFunctions.aspx/CheckDiscountCode',
        dataType: "json",
        success: DiscountCodeSuccess,
        data: '{ discountCode: "' + discountCode + '",bizformName:"' + bizformName + '"}'
    });
}

function DiscountCodeSuccess(data) {
    var quantity = $$('.theQuantity').first().val();
    var runningTotal = quantity * costPerItem;
    if (data.d == -1) {
        runningTotal = 0;
    }
    else {
        runningTotal -= quantity * data.d;
    }
    runningTotal *= 1.03;
    $$(".theTotal").first().text("$" + runningTotal.toFixed(2));
}
