var globalTotalDecimalPlaces=2,globalIntermediumDecimalPlaces=2;function checkMultiplyOverflow(a,b){return 999999999999<a/1E3*(b/1E3)?(alert(NextWay.Localization.JavascriptOverflowErrorText),!1):!0}function checkSumOverflow(a,b){return 0>999999999999999-a-b?(alert(NextWay.Localization.JavascriptOverflowErrorText),!1):!0}function ChangeGlobalTotalDecimalPlaces(a){globalTotalDecimalPlaces=parseInt(a);OnChangeGlobalTotalDecimalPlaces()}
function ChangeGlobalIntermediumDecimalPlaces(a){globalIntermediumDecimalPlaces=parseInt(a);OnChangeGlobalIntermediumDecimalPlaces()}function OnChangeGlobalTotalDecimalPlaces(){$.each($(".TotalDecimalType"),function(a,b){DoAutoNumericUpdate(b,{mDec:globalTotalDecimalPlaces})})}function OnChangeGlobalIntermediumDecimalPlaces(){$.each($(".IntermediumDecimalType"),function(a,b){DoAutoNumericUpdate(b,{mDec:globalIntermediumDecimalPlaces})})}
function DoAutoNumericUpdate(a,b){var c=$(a).data("AutoNumericOptions");b=$.extend({},c,b);$(a).unbind("keydown");$(a).unbind("keypress");$(a).unbind("keyup");$(a).unbind("focusout");$(a).unbind("focusin");$(a).autoNumeric(b);$(a).val($.fn.autoNumeric.Format($(a).attr("id"),$(a).val(),b))}
function GeneralPriceListItemProperties_Calc_CeilingPriceTotal(a){var b=void 0,c=a.FindValue("Quantity");a=a.FindValue("CeilingPrice");isNaN(c)||isNaN(a)||(b=checkMultiplyOverflow(c,a)?RoundNumber(c*a,globalTotalDecimalPlaces):0);return isNaN(b)?0:b}function GeneralPriceListItemProperties_Calc_CostPriceTotal(a){var b=void 0,c=a.FindValue("Quantity");a=a.FindValue("CostPrice");isNaN(c)||isNaN(a)||(b=checkMultiplyOverflow(c,a)?RoundNumber(c*a,globalTotalDecimalPlaces):0);return isNaN(b)?0:b}
function GeneralPriceListItemProperties_Calc_SalesPriceTotal(a){var b=void 0,c=a.FindValue("Quantity");a=a.FindValue("SalesPrice");isNaN(c)||isNaN(a)||(b=checkMultiplyOverflow(c,a)?RoundNumber(c*a,globalTotalDecimalPlaces):0);return isNaN(b)?0:b}
function GeneralPriceListItemProperties_Calc_BillingDiscountValue(a){var b=void 0,c=a.FindValue("BillingQuantity"),d=a.FindValue("BillingPrice");a=a.FindValue("BillingDiscountPercentage");isNaN(a)&&(a=0);isNaN(c)||isNaN(d)||(b=RoundNumber(a/100*d*c,globalTotalDecimalPlaces));return isNaN(b)?0:b}
function GeneralPriceListItemProperties_Calc_BillingPriceTotal(a){var b=void 0,c=a.FindValue("BillingQuantity"),d=a.FindValue("BillingDiscountValue");a=a.FindValue("BillingPrice");isNaN(d)&&(d=0);isNaN(c)||isNaN(a)||(b=RoundNumber(c*a-d,globalTotalDecimalPlaces));return isNaN(b)?0:b}
function GeneralPriceListItemProperties_Calc_ReplyLineDiscountValue(a){var b=void 0,c=a.FindValue("Quantity"),d=a.FindValue("ReplyPrice");a=a.FindValue("LineDiscountPercentage");isNaN(a)&&(a=0);isNaN(c)||isNaN(d)||(b=checkMultiplyOverflow(c,d)?RoundNumber(a/100*d*c,globalTotalDecimalPlaces):0);return isNaN(b)?0:b}
function GeneralPriceListItemProperties_Calc_TotalPriceLabor(a){var b=a.FindValue("UnitPriceLabor");a=a.FindValue("Quantity");isNaN(b)&&(b=new BigDecimal("0"));isNaN(a)&&(a=new BigDecimal("0"));totalPriceLabor=checkMultiplyOverflow(a,b)?a*b:0;return isNaN(totalPriceLabor)?0:totalPriceLabor}
function GeneralPriceListItemProperties_Calc_TotalPriceOther(a){var b=a.FindValue("UnitPriceOther");a=a.FindValue("Quantity");isNaN(b)&&(b=new BigDecimal("0"));isNaN(a)&&(a=new BigDecimal("0"));totalPriceOther=checkMultiplyOverflow(a,b)?a*b:0;return isNaN(totalPriceOther)?0:totalPriceOther}
function GeneralPriceListItemProperties_Calc_ReplyPrice(a){var b=a.FindValue("UnitPriceOther");a=a.FindValue("UnitPriceLabor");void 0==b&&(b=new BigDecimal("0"));void 0==a&&(a=new BigDecimal("0"));return a.add(b)}
function GeneralPriceListItemProperties_Calc_ReplyPriceTotal(a){var b=void 0,c=a.FindValue("Quantity"),d=a.FindValue("ReplyPrice");a=a.FindValue("LineDiscountPercentage");isNaN(a)&&(a=0);isNaN(d)&&(d=new BigDecimal("0"));isNaN(c)||(b=checkMultiplyOverflow(c,d)?RoundNumber(c*d-a/100*d*c,globalTotalDecimalPlaces):0);return isNaN(b)?0:b}
function GeneralPriceListItemProperties_Calc_VATPrice(a){var b=void 0,b=a.FindValue("ReplyPriceTotal");a=a.FindValue("VAT");isNaN(b)||isNaN(a)?b=isNaN(b)?NaN:b:(b=new BigDecimal(b.toString()),checkMultiplyOverflow(a,b)?(a=a/100*b,b=RoundNumber(b.add(new BigDecimal(a.toString())),globalTotalDecimalPlaces)):b=NaN);return isNaN(b)?0:b}
function GeneralPriceListItemProperties_Calc_TotalLowestPrice(a){var b=void 0,c=a.FindValue("Quantity");a=a.FindValue("LowestPrice");isNaN(a)||isNaN(c)||(b=checkMultiplyOverflow(c,a)?RoundNumber(c*a,globalTotalDecimalPlaces):0);return isNaN(b)?0:b}
function GeneralPriceListItemProperties_Calc_TotalBudget(a){var b=void 0,c=a.FindValue("Quantity"),d=a.FindValue("ProfitMargin"),e=a.FindValue("ComercialDiscount"),f=a.FindValue("ReplyPrice");a=a.FindValue("GlobalDiscount");isNaN(d)&&(d=0);isNaN(e)&&(e=0);isNaN(a)&&(a=0);isNaN(c)||isNaN(f)||(b=RoundNumber((f+f*d/100-f*a/100-f*e/100)*c,globalTotalDecimalPlaces));return isNaN(b)?0:b}
function GeneralPriceListItemProperties_Calc_TotalUnitPriceBudget(a){var b=void 0,c=a.FindValue("Quantity");a=a.FindValue("TotalBudget");isNaN(c)&&(profitMargin=0);isNaN(a)&&(comercialDiscount=0);isNaN(c)||isNaN(a)||(b=RoundNumber(a/c,globalTotalDecimalPlaces));return isNaN(b)?0:b}
function GeneralPriceListItemProperties_Save_Formated_BillingDiscountValue(a){var b;void 0!=a.Find("BillingDiscountValue")&&(b=GeneralPriceListItemProperties_Calc_BillingDiscountValue(a),a.SaveFormatedValue("BillingDiscountValue",b,$.format(b,"n"+globalTotalDecimalPlaces.toString())))}
function GeneralPriceListItemProperties_Save_Formated_BillingPriceTotal(a){var b;void 0!=a.Find("BillingPriceTotal")&&(b=GeneralPriceListItemProperties_Calc_BillingPriceTotal(a),a.SaveFormatedValue("BillingPriceTotal",b,$.format(b,"n"+globalTotalDecimalPlaces.toString())))}
function GeneralPriceListItemProperties_Save_Formated_CeilingPriceTotal(a){var b;void 0!=a.Find("CeilingPriceTotal")&&(b=GeneralPriceListItemProperties_Calc_CeilingPriceTotal(a),a.SaveFormatedValue("CeilingPriceTotal",b,$.format(b,"n"+globalTotalDecimalPlaces.toString())))}
function GeneralPriceListItemProperties_Save_Formated_CostPriceTotal(a){var b;void 0!=a.Find("CostPriceTotal")&&(b=GeneralPriceListItemProperties_Calc_CostPriceTotal(a),a.SaveFormatedValue("CostPriceTotal",b,$.format(b,"n"+globalTotalDecimalPlaces.toString())))}
function GeneralPriceListItemProperties_Save_Formated_SalesPriceTotal(a){var b;void 0!=a.Find("SalesPriceTotal")&&(b=GeneralPriceListItemProperties_Calc_SalesPriceTotal(a),a.SaveFormatedValue("SalesPriceTotal",b,$.format(b,"n"+globalTotalDecimalPlaces.toString())))}
function GeneralPriceListItemProperties_Save_Formated_ReplyLineDiscountValue(a){var b;void 0!=a.Find("ReplyLineDiscountValue")&&(b=GeneralPriceListItemProperties_Calc_ReplyLineDiscountValue(a),a.SaveFormatedValue("ReplyLineDiscountValue",b,$.format(b,"n"+globalTotalDecimalPlaces.toString())))}
function GeneralPriceListItemProperties_Save_Formated_ReplyPriceTotal(a){var b;void 0!=a.Find("ReplyPriceTotal")&&(b=GeneralPriceListItemProperties_Calc_ReplyPriceTotal(a),a.SaveFormatedValue("ReplyPriceTotal",b,$.format(b,"n"+globalTotalDecimalPlaces.toString())));void 0!=a.Find("TotalPriceVAT")&&(b=GeneralPriceListItemProperties_Calc_VATPrice(a),a.SaveFormatedValue("TotalPriceVAT",b,$.format(b,"n"+globalTotalDecimalPlaces.toString())))}
function GeneralpriceListItemProperties_Save_Formatted_ReplyPrice(a){var b;b=GeneralPriceListItemProperties_Calc_ReplyPrice(a);a.SaveFormatedValue("ReplyPrice",b,$.format(b,"n"+globalTotalDecimalPlaces.toString()))}function GeneralPriceListItemProperties_Save_Formated_TotalPriceLabor(a){var b;void 0!=a.Find("TotalPriceLabor")&&(b=GeneralPriceListItemProperties_Calc_TotalPriceLabor(a),a.SaveFormatedValue("TotalPriceLabor",b,$.format(b,"n"+globalTotalDecimalPlaces.toString())))}
function GeneralPriceListItemProperties_Save_Formated_TotalPriceOther(a){var b;void 0!=a.Find("TotalPriceOther")&&(b=GeneralPriceListItemProperties_Calc_TotalPriceOther(a),a.SaveFormatedValue("TotalPriceOther",b,$.format(b,"n"+globalTotalDecimalPlaces.toString())))}
function GeneralPriceListItemProperties_Save_Formated_VATPrice(a){var b;void 0!=a.Find("TotalPriceVAT")&&(b=GeneralPriceListItemProperties_Calc_VATPrice(a),a.SaveFormatedValue("TotalPriceVAT",b,$.format(b,"n"+globalTotalDecimalPlaces.toString())))}
function GeneralPriceListItemProperties_Save_Formated_TotalLowestPrice(a){var b;void 0!=a.Find("TotalLowestPrice")&&(b=GeneralPriceListItemProperties_Calc_TotalLowestPrice(a),a.SaveFormatedValue("TotalLowestPrice",b,$.format(b,"n"+globalTotalDecimalPlaces.toString())))}
function GeneralPriceListItemProperties_Save_Formated_TotalBudget(a){var b;void 0!=a.Find("TotalBudget")&&(b=GeneralPriceListItemProperties_Calc_TotalBudget(a),a.SaveFormatedValue("TotalBudget",b,$.format(b,"n"+globalTotalDecimalPlaces.toString())));void 0!=a.Find("TotalUnitPriceBudget")&&(b=GeneralPriceListItemProperties_Calc_TotalUnitPriceBudget(a),a.SaveFormatedValue("TotalUnitPriceBudget",b,$.format(b,"n"+globalTotalDecimalPlaces.toString())))}
function GeneralPriceListItemProperties_Update_BillingDiscountPercentage(a){var b=DefaultValues_GeneralPriceListItemProperties();a=CreateSandBox(a,b);GeneralPriceListItemProperties_Save_Formated_BillingDiscountValue(a);GeneralPriceListItemProperties_Save_Formated_BillingPriceTotal(a);a.SetPreviousValue("BillingDiscountValue");b=$(a.Find("BillingDiscountValue"));b.trigger("onchange");a.SetPreviousValue("BillingPriceTotal");b=$(a.Find("BillingPriceTotal"));b.trigger("onchange")}
function GeneralPriceListItemProperties_Update_BillingQuantity(a){GeneralPriceListItemProperties_Update_BillingDiscountPercentage(a)}function GeneralPriceListItemProperties_Update_Quantity(a){var b=DefaultValues_GeneralPriceListItemProperties();a=CreateSandBox(a,b);void 0!=a.Find("ReplyPriceTotal")?UpdateSupplierProperties_Quantity(a):UpdateBuyerProperties_Quantity(a)}
function UpdateSupplierProperties_Quantity(a){var b;void 0!=a.Find("ReplyPriceTotal")&&(b=$.parseFloat($(a.Find("ReplyPriceTotal")).val()));isNaN(b)&&(b=0);GeneralPriceListItemProperties_Save_Formated_ReplyLineDiscountValue(a);GeneralPriceListItemProperties_Save_Formated_ReplyPriceTotal(a);GeneralPriceListItemProperties_Save_Formated_TotalBudget(a);GeneralPriceListItemProperties_Update_Totals_ProposalTotal(a,b);a.SetPreviousValue("ReplyLineDiscountValue");$(a.Find("ReplyLineDiscountValue")).trigger("onchange");
a.SetPreviousValue("ReplyPriceTotal");$(a.Find("ReplyPriceTotal")).trigger("onchange");a.SetPreviousValue("TotalBudget");$(a.Find("TotalBudget")).trigger("onchange");var c=a.Find("Chk_Sel_ReplyPrice");void 0!=c&&c.is(":checked")&&(c=$(a.Find("Quantity")).parent().parent().parent().parent().parent().parent().parent(),GeneralPriceListItemProperties_Update_AwardPrice(a,c,b))}
function UpdateBuyerProperties_Quantity(a){var b,c,d;b=void 0==a.Find("CostPriceTotal")||""===a.Find("CostPriceTotal").val()||isNaN($.parseFloat(a.Find("CostPriceTotal").val()))?0:$.parseFloat($(a.Find("CostPriceTotal")).val());c=void 0==a.Find("TotalLowestPrice")||""===a.Find("TotalLowestPrice").val()||isNaN($.parseFloat(a.Find("TotalLowestPrice").val()))?0:$.parseFloat($(a.Find("TotalLowestPrice")).val());d=void 0==a.Find("SalesPriceTotal")||""===a.Find("SalesPriceTotal").val()||isNaN($.parseFloat(a.Find("SalesPriceTotal").val()))?
0:$.parseFloat($(a.Find("SalesPriceTotal")).val());GeneralPriceListItemProperties_Save_Formated_CeilingPriceTotal(a);GeneralPriceListItemProperties_Save_Formated_CostPriceTotal(a);GeneralPriceListItemProperties_Save_Formated_SalesPriceTotal(a);GeneralPriceListItemProperties_Save_Formated_TotalLowestPrice(a);GeneralPriceListItemProperties_Update_Totals_CostPriceTotal(a,b);GeneralPriceListItemProperties_Update_Totals_TotalLowestPriceTotal(a,c);GeneralPriceListItemProperties_Update_Totals_SalesPriceTotalTotal(a,
d);a.SetPreviousValue("CeilingPriceTotal");$(a.Find("CeilingPriceTotal")).trigger("onchange");a.SetPreviousValue("CostPriceTotal");$(a.Find("CostPriceTotal")).trigger("onchange");a.SetPreviousValue("TotalLowestPrice");$(a.Find("TotalLowestPrice")).trigger("onchange");a.SetPreviousValue("SalesPriceTotal");$(a.Find("SalesPriceTotal")).trigger("onchange")}
function GeneralPriceListItemProperties_Update_Totals_CostPriceTotal(a,b){var c,d;void 0!=a.Find("CostPriceTotal")&&(c=$.parseFloat($(a.Find("CostPriceTotal")).val()));d=$.parseFloat($('[contextid="TOTAL_BUYER"]').find('[contextvarid="CostPriceTotal"]').val());isNaN(d)&&(d=0);isNaN(c)||isNaN(b)?$('[contextid="TOTAL_BUYER"]').find('[contextvarid="CostPriceTotal"]').val(void 0):(c>b&&(d+=c-b),c<b&&(d-=b-c),$('[contextid="TOTAL_BUYER"]').find('[contextvarid="CostPriceTotal"]').val($.format(d,"n"+globalTotalDecimalPlaces.toString())))}
function GeneralPriceListItemProperties_Update_Totals_ProposalTotal(a,b){var c;void 0!=a.Find("ReplyPriceTotal")&&(c=GeneralPriceListItemProperties_Calc_ReplyPriceTotal(a));isNaN(c)&&(c=0);void 0==a.parentSandBox||void 0==a.parentSandBox.Find("ReplyPriceTotal")||""===a.parentSandBox.Find("ReplyPriceTotal").val()||isNaN($.parseFloat(a.parentSandBox.Find("ReplyPriceTotal").val()))||(previousProposalTotalValue=$.parseFloat($(a.parentSandBox.Find("ReplyPriceTotal")).val()),c=previousProposalTotalValue+
(c-b),a.parentSandBox.SaveFormatedValue("ReplyPriceTotal",c,$.format(c,"n"+globalTotalDecimalPlaces.toString())))}
function GeneralPriceListItemProperties_Update_Totals_TotalLowestPriceTotal(a,b){var c,d;void 0!=a.Find("TotalLowestPrice")&&(c=$.parseFloat($(a.Find("TotalLowestPrice")).val()));d=$.parseFloat($('[contextid="TOTAL_BUYER"]').find('[contextvarid="TotalLowestPrice"]').val());isNaN(d)&&(d=0);isNaN(c)||isNaN(b)?$('[contextid="TOTAL_BUYER"]').find('[contextvarid="TotalLowestPrice"]').val(void 0):(c>b&&(d+=c-b),c<b&&(d-=b-c),$('[contextid="TOTAL_BUYER"]').find('[contextvarid="TotalLowestPrice"]').val($.format(d,
"n"+globalTotalDecimalPlaces.toString())))}
function GeneralPriceListItemProperties_Update_Totals_SalesPriceTotalTotal(a,b){var c,d;void 0!=a.Find("SalesPriceTotal")&&(c=$.parseFloat($(a.Find("SalesPriceTotal")).val()));d=$.parseFloat($('[contextid="TOTAL_BUYER"]').find('[contextvarid="SalesPriceTotal"]').val());isNaN(d)&&(d=0);isNaN(c)||isNaN(b)?$('[contextid="TOTAL_BUYER"]').find('[contextvarid="SalesPriceTotal"]').val(void 0):(c>b&&(d+=c-b),c<b&&(d-=b-c),$('[contextid="TOTAL_BUYER"]').find('[contextvarid="SalesPriceTotal"]').val($.format(d,"n"+
globalTotalDecimalPlaces.toString())))}function GeneralPriceListItemProperties_Update_CeilingPrice(a){var b=DefaultValues_GeneralPriceListItemProperties();a=CreateSandBox(a,b);GeneralPriceListItemProperties_Save_Formated_CeilingPriceTotal(a);a.SetPreviousValue("CeilingPriceTotal");$(a.Find("CeilingPriceTotal")).trigger("onchange")}
function GeneralPriceListItemProperties_Update_CostPrice(a){var b=DefaultValues_GeneralPriceListItemProperties();a=CreateSandBox(a,b);b=void 0==a.Find("CostPriceTotal")||""===a.Find("CostPriceTotal").val()||isNaN($.parseFloat(a.Find("CostPriceTotal").val()))?0:$.parseFloat($(a.Find("CostPriceTotal")).val());GeneralPriceListItemProperties_Save_Formated_CostPriceTotal(a);GeneralPriceListItemProperties_Update_Totals_CostPriceTotal(a,b);a.SetPreviousValue("CostPriceTotal");$(a.Find("CostPriceTotal")).trigger("onchange")}
function GeneralPriceListItemProperties_Update_SalesPrice(a){var b=DefaultValues_GeneralPriceListItemProperties();a=CreateSandBox(a,b);b=void 0==a.Find("SalesPriceTotal")||""===a.Find("SalesPriceTotal").val()||isNaN($.parseFloat(a.Find("SalesPriceTotal").val()))?0:$.parseFloat($(a.Find("SalesPriceTotal")).val());GeneralPriceListItemProperties_Save_Formated_SalesPriceTotal(a);GeneralPriceListItemProperties_Update_Totals_SalesPriceTotalTotal(a,b);a.SetPreviousValue("SalesPriceTotal");$(a.Find("SalesPriceTotal")).trigger("onchange")}
function GeneralPriceListItemProperties_Update_LineDiscountPercentage(a){var b=DefaultValues_GeneralPriceListItemProperties();a=CreateSandBox(a,b);GeneralPriceListItemProperties_Save_Formated_ReplyLineDiscountValue(a);GeneralPriceListItemProperties_Save_Formated_ReplyPriceTotal(a);GeneralPriceListItemProperties_Save_Formated_VATPrice(a);a.SetPreviousValue("ReplyLineDiscountValue");$(a.Find("ReplyLineDiscountValue")).trigger("onchange");a.SetPreviousValue("ReplyPriceTotal");$(a.Find("ReplyPriceTotal")).trigger("onchange");
a.SetPreviousValue("TotalPriceVAT");$(a.Find("TotalPriceVAT")).trigger("onchange")}function GeneralPriceListItemProperties_Update_UnitPriceLabor(a){var b=DefaultValues_GeneralPriceListItemProperties(),b=CreateSandBox(a,b);GeneralPriceListItemProperties_Save_Formated_TotalPriceLabor(b);GeneralpriceListItemProperties_Save_Formatted_ReplyPrice(b);GeneralPriceListItemProperties_Update_ReplyPrice(a)}
function GeneralPriceListItemProperties_Update_UnitPriceOther(a){var b=DefaultValues_GeneralPriceListItemProperties(),b=CreateSandBox(a,b);GeneralPriceListItemProperties_Save_Formated_TotalPriceOther(b);GeneralpriceListItemProperties_Save_Formatted_ReplyPrice(b);GeneralPriceListItemProperties_Update_ReplyPrice(a)}
function GeneralPriceListItemProperties_Update_ReplyPrice(a){var b=DefaultValues_GeneralPriceListItemProperties();a=CreateSandBox(a,b);var c;void 0!=a.Find("ReplyPriceTotal")&&(c=$.parseFloat($(a.Find("ReplyPriceTotal")).val()));isNaN(c)&&(c=0);GeneralPriceListItemProperties_Save_Formated_ReplyLineDiscountValue(a);GeneralPriceListItemProperties_Save_Formated_ReplyPriceTotal(a);GeneralPriceListItemProperties_Save_Formated_TotalBudget(a);GeneralPriceListItemProperties_Update_Totals_ProposalTotal(a,
c);a.SetPreviousValue("ReplyLineDiscountValue");$(a.Find("ReplyLineDiscountValue")).trigger("onchange");a.SetPreviousValue("ReplyPriceTotal");$(a.Find("ReplyPriceTotal")).trigger("onchange");if($(a.Find("ReplyPrice")).parent().parent().parent().parent().parent().hasClass("BusinessItemLineMap")){var b=$(a.Find("ReplyPrice")).parent().parent().parent().parent().parent().parent().parent(),d=b.find('[contextvarid="LowestPrice"]'),e=$.parseFloat($(d).val()),f=0;$(b).find('[contextvarid="ReplyPrice"]').each(function(){var a=
$.parseFloat(this.value);if(0<a&&a<$.parseFloat(f)||0==$.parseFloat(f))f=this.value});$.parseFloat(f)!=e&&($(d).val(f),d.trigger("onchange"));d=a.Find("Chk_Sel_ReplyPrice");void 0!=d&&d.is(":checked")&&GeneralPriceListItemProperties_Update_AwardPrice(a,b,c)}}function GeneralPriceListItemProperties_Update_ReplyPriceTotal(a){}function GeneralPriceListItemProperties_Update_ReplyPriceSelectedTotal(a){}
function GeneralPriceListItemProperties_Update_VAT(a){var b=DefaultValues_GeneralPriceListItemProperties();a=CreateSandBox(a,b);GeneralPriceListItemProperties_Save_Formated_VATPrice(a)}function GeneralPriceListItemProperties_Update_LowestPrice(a){var b=DefaultValues_GeneralPriceListItemProperties();a=CreateSandBox(a,b);GeneralPriceListItemProperties_Save_Formated_TotalLowestPrice(a);a.SetPreviousValue("TotalLowestPrice");$(a.Find("TotalLowestPrice")).trigger("onchange")}
function GeneralPriceListItemProperties_Update_AwardPrice(a,b,c){if(3==arguments.length){var d=$('tr[contextid="TOTAL_BUYER"]'),e=getElementValue(d,"TotalAwardPrice");isNaN(e)&&(e=0);var f=$(a.Find("ReplyPriceTotal")),g=$.parseFloat($(f).val());isNaN(g)&&(g=0);var h=b.find('[contextvarid="AwardPrice"]'),k=$.parseFloat($(h).val());isNaN(k)&&(k=0);var f=$(a.Find("ReplyPriceSelectedTotal")),l=$.parseFloat($(f).val());isNaN(l)&&(l=0);var m=g-c,g=k+m,l=l+m;$(h).data("previous_value",k);$(h).val($.format(g,
"n"+globalTotalDecimalPlaces.toString()));h.trigger("onchange");e=e+g-k;$(f).val($.format(l,"n"+globalTotalDecimalPlaces.toString()));f.trigger("onchange");setElementValue(d,"TotalAwardPrice",$.format(e,"n3"))}}function GeneralPriceListItemProperties_Update_ProfitMargin(a){var b=DefaultValues_GeneralPriceListItemProperties();a=CreateSandBox(a,b);GeneralPriceListItemProperties_Save_Formated_TotalBudget(a);a.SetPreviousValue("TotalBudget");$(a.Find("TotalBudget")).trigger("onchange")}
function GeneralPriceListItemProperties_Update_ComercialDiscount(a){var b=DefaultValues_GeneralPriceListItemProperties();a=CreateSandBox(a,b);GeneralPriceListItemProperties_Save_Formated_TotalBudget(a);a.SetPreviousValue("TotalBudget");$(a.Find("TotalBudget")).trigger("onchange")}
function GeneralPriceListItemProperties_Update_GlobalDiscount(a){var b=DefaultValues_GeneralPriceListItemProperties();a=CreateSandBox(a,b);GeneralPriceListItemProperties_Save_Formated_TotalBudget(a);a.SetPreviousValue("TotalBudget");$(a.Find("TotalBudget")).trigger("onchange")}
function DefaultValues_GeneralPriceListItemProperties(){var a=new SandBox("defaultValues");a.AddValue("Quantity",void 0);a.AddValue("Sale_Price",void 0);a.AddValue("Base_Price",void 0);a.AddValue("Total_Unit_Min_Price",void 0);a.AddValue("Total_Buyer_SalePrice",void 0);a.AddValue("Price_Per_Unit",void 0);a.AddValue("VAT",void 0);a.AddValue("Total_Supplier",void 0);a.AddValue("TotalPriceVAT",0);a.AddValue("Lowest_Price",void 0);a.AddValue("Total_Buyer_LowestPrice",0);a.AddValue("ProfitMargin",void 0);
a.AddValue("ComercialDiscount",void 0);a.AddValue("GlobalDiscount",void 0);a.AddValue("Total_Budget",0);return a}
function GeneralPriceListItemProperties_Award_Calc_SumReplyPriceTotal(a){var b=DefaultValues_GeneralPriceListItemProperties(),b=CreateSandBox(a,b),c=0;a=GetElements(a,"ReplyPriceTotal");if(void 0!=a&&0<a.length){var d;$.each(a,function(){d=$.parseFloat(this.val());isNaN(d)||(c+=d)})}b.SaveFormatedValue("ReplyPriceTotal",c,$.format(c,"n"+globalTotalDecimalPlaces.toString()));b.SetPreviousValue("ReplyPriceTotal");c=$(b.Find("ReplyPriceTotal"));c.trigger("onchange")}
function GetElements(a,b){var c=$("[parentcontextid="+a+"]"),d=[];void 0!=c&&0<c.length&&c.each(function(){var a=$(this).find("[contextvarid="+b+"]");void 0!=a&&d.push(a)});return d}function GetRestrictedElements(a,b){var c=$("[restrictedctxt="+a+"]"),d=[];void 0!=c&&0<c.length&&c.each(function(){var a=$(this),c=a.find("[contextvarid= Restricted"+b+"]");void 0!=c&&c.is(":checked")&&(a=a.find("[contextvarid="+b+"]"),void 0!=a&&d.push(a))});return d}
function GeneralPriceListItemProperties_Award_Update_Quantity(a){var b=$('tr[contextid="'+a+'"]'),c=getElementValue(b,"ReplyPriceTotal"),d=!0;"False"==b.attr("countsToTotal")&&(d=!1);var e=DefaultValues_GeneralPriceListItemProperties(),e=CreateSandBox(a,e);GeneralPriceListItemProperties_Save_Formated_ReplyPriceTotal(e);e.SetPreviousValue("ReplyPriceTotal");a=$(e.Find("ReplyPriceTotal"));$(e.Find("TotalPriceVAT")).trigger("onchange");a.trigger("onchange");if(void 0!=e.parentSandBox&&d){var d=$('tr[contextid="'+
e.parentSandBox.contextId+'"]'),f=getElementValue(d,"ReplyPriceTotal");isNaN(f)||isNaN($.parseFloat(a.text()))||isNaN(c)||(delta=$.parseFloat(a.text())-c,f+=delta,setElementValue(d,"ReplyPriceTotal",$.format(f,"n2")));f=getElementValue(b,"TotalPriceVAT");setElementValue(b,"TotalPriceVAT",$.format(f,"n2"))}b=e.Find("RestrictedReplyPriceTotal");void 0!=b&&b.is(":checked")?(b=$('tr[contextid="'+e.restrictedContextId+'"]'),e=getElementValue(b,"ReplyPriceSelectedTotal"),isNaN(e)||isNaN($.parseFloat(a.text()))||
isNaN(c)||(delta=$.parseFloat(a.text())-c,e+=delta,setElementValue(b,"ReplyPriceSelectedTotal",$.format(e,"n2")))):void 0!=b&&!0==b.attr("disabled")?""!=$(e.Find("Quantity")).val()&&""!=$(e.Find("ReplyPrice")).val()&&b.attr("disabled",!1):void 0!=b&&!1==b.attr("disabled")&&(""!=$(e.Find("Quantity")).val()&&""!=$(e.Find("ReplyPrice")).val()||b.attr("disabled",!0))}function GeneralPriceListItemProperties_Award_Update_TotalPriceVAT(){}
function GeneralPriceListItemProperties_Award_Update_ReplyPrice(a){var b=$('tr[contextid="'+a+'"]'),c=getElementValue(b,"ReplyPriceTotal"),d=!0;"False"==b.attr("countsToTotal")&&(d=!1);var e=DefaultValues_GeneralPriceListItemProperties(),e=CreateSandBox(a,e);GeneralPriceListItemProperties_Save_Formated_ReplyPriceTotal(e);e.SetPreviousValue("ReplyPriceTotal");a=$(e.Find("ReplyPriceTotal"));a.trigger("onchange");$(e.Find("TotalPriceVAT")).trigger("onchange");if(void 0!=e.parentSandBox&&d){var d=$('tr[contextid="'+
e.parentSandBox.contextId+'"]'),f=getElementValue(d,"ReplyPriceTotal");isNaN(f)||isNaN($.parseFloat(a.text()))||isNaN(c)||(delta=$.parseFloat(a.text())-c,f+=delta,setElementValue(d,"ReplyPriceTotal",$.format(f,"n2")));f=getElementValue(b,"TotalPriceVAT");setElementValue(b,"TotalPriceVAT",$.format(f,"n2"))}b=e.Find("RestrictedReplyPriceTotal");void 0!=b&&b.is(":checked")?(b=$('tr[contextid="'+e.restrictedContextId+'"]'),e=getElementValue(b,"ReplyPriceSelectedTotal"),isNaN(e)||isNaN($.parseFloat(a.text()))||
isNaN(c)||(delta=$.parseFloat(a.text())-c,e+=delta,setElementValue(b,"ReplyPriceSelectedTotal",$.format(e,"n2")))):void 0!=b&&!0==b.attr("disabled")?""!=$(e.Find("Quantity")).val()&&""!=$(e.Find("ReplyPrice")).val()&&b.attr("disabled",!1):void 0!=b&&!1==b.attr("disabled")&&(""!=$(e.Find("Quantity")).val()&&""!=$(e.Find("ReplyPrice")).val()||b.attr("disabled",!0))}
function GeneralPriceListItemProperties_Award_Update_RestrictedReplyPriceTotal(a){var b=DefaultValues_GeneralPriceListItemProperties(),b=CreateSandBox(a,b),c=0;a=GetRestrictedElements(a,"ReplyPriceTotal");if(void 0!=a&&0<a.length){var d;$.each(a,function(){d=$.parseFloat(this.val());isNaN(d)||(c+=d)})}b.SaveFormatedValue("ReplyPriceSelectedTotal",c,$.format(c,"n"+globalTotalDecimalPlaces.toString()));b.SetPreviousValue("ReplyPriceSelectedTotal");c=$(b.Find("ReplyPriceSelectedTotal"));c.trigger("onchange")}
function getElement(a,b){return a.find("[contextvarid="+b+"]")}function getElementValue(a,b){var c=getElement(a,b),d=0;void 0!=c&&(c=c.is("span")?c.text():$.getVal(c),d=$.parseFloat(c));return d}function setElementValue(a,b,c){a=a.find('[contextvarid="'+b+'"]');debugger;void 0!=a&&(a.is("span")?a.text(c):a.val(c),a.change())}
function updateSupplierCellCss(a,b){var c=a.parent().parent().parent();b&&!c.hasClass("SelectedRow")?c.addClass("SelectedRow"):c.hasClass("SelectedRow")&&c.removeClass("SelectedRow")}function checkUncheckAllItemsInComparativeMap(a,b,c){b=$("#"+b);c=b.find('tr[contextid^="'+c+'_"]');void 0!=c&&0<c.length&&updateAwardPriceColumns(c,a.checked,b)}
function checkUncheckItemInComparativeMap(a,b){var c=$(window),d=$(a),e=c.data(d.attr("id")),f=c.data(d.attr("id")+"_to");if((null==e||e!=a.checked)&&"complete"===document.readyState){c.data(d.attr("id"),a.checked);var e=$('tr[contextid="'+b+'"]'),g=$('table[contextid="'+e.attr("parentcontextid")+'"]'),h=$('tr[contextid="'+e.attr("bctxid")+'"]');UpdateAwardPriceValue(e,g,h,a.checked);updateSupplierCellCss(e,a.checked);$("#"+a.id).removeAttr("disabled");null!=f&&(clearTimeout(f),c.removeData(d.attr("id")+
"_to"));c.data(d.attr("id")+"_to",setTimeout('$(window).removeData("'+d.attr("id")+'_to");$(window).removeData("'+d.attr("id")+'");',500))}}function uncheckItemInComparativeMapWhenRemovingLine(a,b){if("complete"===document.readyState)for(var c=0;c<b.length;c++){var d=$('tr[contextid="'+b[c]+'"]'),e=$('table[contextid="'+d.attr("parentcontextid")+'"]'),f=$('tr[contextid="'+d.attr("bctxid")+'"]');getElement(d,"Chk_Sel_ReplyPrice").attr("checked")&&UpdateAwardPriceValue(d,e,f,!1)}}
function removeItemInComparativeMap(a,b){var c=$("#"+a);c.val("");for(var d=0;d<b.length;d++){var e=$('tr[contextid="'+b[d]+'"]'),e=getElement(e,"Chk_Sel_ReplyPrice");if(null!=e&&0<e.length)for(var f=0;f<e.length;f++)if(null!=e[f]&&e[f].checked){var g=$(e[f]);g.attr("checked",!1);c.val(c.val()+g.attr("ctrlinfo")+";");checkUncheckItemInComparativeMap(e[f],b[d])}}}
function updateAwardPriceColumns(a,b,c){a.each(function(){var a=$(this),e=$('table[contextid="'+a.attr("parentcontextid")+'"]'),f=c.find('tr[contextid="'+a.attr("bctxid")+'"]');UpdateAwardPriceColumn(a,e,f,b)})}function UpdateAwardPriceColumn(a,b,c,d){var e=getElement(a,"Chk_Sel_ReplyPrice");if(void 0!=e){var e=$(e),f=e.attr("checked");f&&d||!f&&!d||(UpdateAwardPriceValue(a,b,c,d),e.attr("checked",d),updateSupplierCellCss(a,d))}}
function UpdateAwardPriceValue(a,b,c,d){var e=0,f=getElementValue(a,"ReplyPriceTotal");a=getElementValue(a,"TotalPriceVAT");var g=getElementValue(c,"AwardPrice");isNaN(g)&&(g=0);isNaN(f)||isNaN(g)?isNaN(g)||(e=g):e=d?g+f:g-f;UpdateBuyerAwardedTotalValue(g,e);setElementValue(c,"AwardPrice",$.format(e,"n"+globalTotalDecimalPlaces.toString()));void 0!=b&&isNaN(a)?updateSupplierAwardTotalValue(b,f,d):updateSupplierAwardTotalValueWithVATPrice(b,f,d,a)}
function updateSupplierAwardTotalValueWithVATPrice(a,b,c,d){var e=getElementValue(a,"ReplyPriceSelectedTotal"),f=getElementValue(a,"TotalPriceVATSelected");isNaN(b)||isNaN(e)||setElementValue(a,"ReplyPriceSelectedTotal",$.format(c?e+b:e-b,"n3"));isNaN(f)||isNaN(f)||setElementValue(a,"TotalPriceVATSelected",$.format(c?f+d:f-d,"n3"))}
function updateSupplierAwardTotalValue(a,b,c){var d=getElementValue(a,"ReplyPriceSelectedTotal"),e=getElementValue(a,"TotalPriceVATSelected");isNaN(b)||isNaN(d)||setElementValue(a,"ReplyPriceSelectedTotal",$.format(c?d+b:d-b,"n"+globalTotalDecimalPlaces.toString()));isNaN(e)||isNaN(e)||setElementValue(a,"TotalPriceVATSelected",$.format(c?e+b:e-b,"n3"))}
function UpdateBuyerAwardedTotalValue(a,b){var c=$('tr[contextid="TOTAL_BUYER"]'),d=0,e=getElementValue(c,"TotalAwardPrice");isNaN(e)||isNaN(a)||(d=e-a+b);setElementValue(c,"TotalAwardPrice",$.format(d,"n"+globalTotalDecimalPlaces.toString()))};
