function CalculateTotal(frm){var total_price=0;var i=0;q_element=eval('frm.line_items_'+i+'_quantity');while(q_element!=undefined)
{q_value=parseInt(q_element.value);q_value=isNaN(q_value)?0:q_value;p_field_value=eval('parseInt(frm.line_items_'+i+'_price1.value)');total_price+=(q_value*p_field_value);q_element=eval('frm.line_items_'+(++i)+'_quantity');}
frm.total.value=round_decimals(total_price,2);}
function round_decimals(original_number,decimals){var result1=original_number*Math.pow(10,decimals);var result2=Math.round(result1);var result3=result2/Math.pow(10,decimals);return pad_with_zeros(result3,decimals);}
function pad_with_zeros(rounded_value,decimal_places){var value_string=rounded_value.toString();var decimal_location=value_string.indexOf(".");if(decimal_location==-1){decimal_part_length=0;value_string+=decimal_places>0?".":"";}
else{decimal_part_length=value_string.length-decimal_location-1;}
var pad_total=decimal_places-decimal_part_length;if(pad_total>0){for(var counter=1;counter<=pad_total;counter++)
value_string+="0";}
return value_string;}