function updateTotal() {
    var form = document.forms['prices_form'];
    var total = 0, i, el, val;
    for (i=0; el = form.elements[i]; i++) {
        if ( el.type == "checkbox" && el.checked ) {
            val = parseFloat( el.value );
            if ( !isNaN(val) ) {
                total += val;
            }
        }
    }
    form.total.value = formatDecimal(total);
}

// format val to n number of decimal places
// modified version of Danny Goodman's (JS Bible)
function formatDecimal(val, n) {
    n = n || 2;
    var str = "" + Math.round ( parseFloat(val) * Math.pow(10, n) );
    while (str.length <= n) str = "0" + str;
    var pt = str.length - n;
    return str.slice(0,pt) + "." + str.slice(pt);
}

function attachClickHandlers() {
    if ( document.getElementsByTagName ) {
        var frm = document.forms['prices_form'];
        var tag_list = frm.getElementsByTagName('input');
        for (var i=0; tag_list[i]; i++) {
            if ( tag_list[i].type == 'checkbox') {
                tag_list[i].onclick = updateTotal;
            }
        }
    }
}

dw_Event.add(window, 'load', attachClickHandlers);

//tooltips for license types
dw_Tooltip.defaultProps = {
    //hoverable: true
}

var LICENSE_TYPE_LINK = ''; //' <a href="/business/purchase.php#types">More info</a>';

dw_Tooltip.content_vars = {
    sd: '<strong>Single-domain License</strong>: For use on one web site or intranet.' + LICENSE_TYPE_LINK,
    md: '<strong>Multi-domain License</strong>: Allows use on up to four domains.' + LICENSE_TYPE_LINK,
    rs: '<strong>Reseller\'s License</strong>: The equivalent of ten single domain licenses.' + LICENSE_TYPE_LINK,
    ul: {
        str: '<strong>Unlimited Corporate License</strong>: For use throughout a company\'s web sites and/or intranet applications.'
             + LICENSE_TYPE_LINK,
        w: 260,
        wrapFn: dw_Tooltip.wrapToWidth
    },
    dev: {
        str: '<strong>Developer\'s License</strong>: For use in distributed applications and/or an unlimited number of sites and intranets.'
             + LICENSE_TYPE_LINK,
        w: 280,
        wrapFn: dw_Tooltip.wrapToWidth
    }
}