function CalculatorJS(config) {

    this.namespace = config.namespace;

    this.selectedCustomer2 = function(hidId, formId) {
        jQuery.blockUI({
            message:'Wait ....'
        });
        var customerId = jQuery('#' + 'selItemsCustomer').attr('value');
        jQuery('#' + hidId).attr('value', customerId);
        jQuery('#' + formId).submit();
    };

    this.tellMAGo = function(tableId, formId) {
        jQuery.blockUI({
            message:'Wait ....'
        });
        jQuery('#' + this.namespace + 'setCustomerId').attr('value', jQuery('#' + this.namespace + 'selItemsCustomer').val());
        jQuery('#' + this.namespace + formId).submit();

    };

    this.selectedCustomer = function(hidId, formId) {
        jQuery.blockUI({
            message:'Wait ....'
        });
        var customerId = jQuery('#' + this.namespace + 'selItemsCustomer').attr('value');
        alert(customerId);
        jQuery('#' + this.namespace + hidId).attr('value', customerId);
        jQuery('#' + this.namespace + formId).submit();
    };

    this.tellMAGo = function(tableId, formId) {
        jQuery.blockUI({
            message:'Wait ....'
        });
        jQuery('#' + this.namespace + 'setCustomerId').attr('value', jQuery('#' + this.namespace + 'selItemsCustomer').val());
        jQuery('#' + this.namespace + formId).submit();

    };

    this.calculation = function(checkBox1, checkBox2, alternative1Saving, alternative2Saving, customerId) {
        var total = jQuery('#hidTotal').val().replace(',', '');
        var sum = total;
        if (jQuery('#' + this.namespace + checkBox1 + customerId).attr('checked') & jQuery('#' + this.namespace + checkBox2 + customerId).attr('checked')) {
            sum = parseFloat(sum) - parseFloat(alternative2Saving);
        }

        if (jQuery('#' + this.namespace + checkBox1 + customerId).attr('checked')) {
            jQuery('#' + this.namespace + checkBox2 + customerId).removeAttr('checked');
        }

        if (jQuery('#' + this.namespace + checkBox1 + customerId).attr('checked') & !jQuery('#' + this.namespace + checkBox2 + customerId).attr('checked')) {
            sum = parseFloat(sum) + parseFloat(alternative1Saving);
        }

        if (!jQuery('#' + this.namespace + checkBox1 + customerId).attr('checked') & !jQuery('#' + this.namespace + checkBox2 + customerId).attr('checked')) {
            sum = parseFloat(sum) - parseFloat(alternative1Saving);
        }

        jQuery('#hidTotal').attr('value', sum);
        jQuery('#total').html(this.valueFormatedToCurrn(sum));
    };

    this.restatement = function(getSumID, setSumID) {
        var valueTotal = jQuery('#' + this.namespace + getSumID).val();
        this.valueFormatedToCurrn(valueTotal);

    };

    this.valueFormatedToCurrn = function(value) {
        value = new Number(value).numberFormat('$ #,###.##');
        return value;
    };
}