function save_releases_to_contractor(){ 
	var mods 					=	$('#main_page').val();
	var types 					=	$('#main_type').val(); 
	var action 					=	$('#main_action').val();
	var mainid					=	$('#main_id').val(); 
	var releases_to_contractor	=	$('#releases_to_contractor_form').serialize(); 
  
	var dataString				=	releases_to_contractor+"&action="+encodeURIComponent(action)+"&mainid="+encodeURIComponent(mainid)+"&types="+encodeURIComponent(types);  
	$.post('./ajax/releases_to_contractor.php', dataString, function(msg){
		var obj	= $.parseJSON(msg);
 
 
			if(obj.output==true){
				bootbox.alert("Successfully Saved ..."); 
				window.setTimeout(function() { window.location.href = 'index.php?pg='+mods+'&type='+types; }, 1000);
			}else{
				bootbox.alert("Failed in saving.");
			} 
	}); 
  
}

function computeContract(){ 
	$('#net_contract_price').val(0.00);
	$('#withholding_tax').val(0);
	var contract_price = $('#contract_price').val().replace(/,/g, "");
	var withholding_tax = parseFloat((contract_price/1.12)*0.02);

	var cwithholding_tax = Comma(parseFloat(withholding_tax).toFixed(2));

	$('#withholding_tax').val(cwithholding_tax);
	var net_contract_price = parseFloat(contract_price) - parseFloat(withholding_tax);
	 
	var cnet_contract_price = Comma(parseFloat(net_contract_price).toFixed(2));
	$('#net_contract_price').val(cnet_contract_price);


	var ccontract_price = Comma(contract_price); 
	$('#contract_price').val(ccontract_price);

	$('#withholding_tax').attr('readonly',true);
	$('#net_contract_price').attr('readonly',true);
}


reloadContractor();
function reloadContractor(contractor=''){ 
	var dataString = '';
	$.post('./ajax/singleselectcontractor.php', dataString, function(msg){ 
								var obj	=	$.parseJSON(msg);  
								var html	=	'';
								html += '<select class="select2 form-control" id="contractor" name="contractor">';
									html += '<option value="">- Select One -</option>';
								for(var a=0; a<obj.data.length; a++){
									if(contractor==obj.data[a].contractor){
											var selected = 'selected';
									}else{
										var selected = '';
									}
									html += '<option value="'+obj.data[a].contractor+'" '+selected+'>'+obj.data[a].contractor+'</option>';
								}
								html += '</select>'; 
								$('#div_contractor').html(html); 
		});						
}
 
var action 					=	$('#main_action').val();
if(action=='edit' || action=='view'){ 
	load_releases_to_contractor();
}
 
function load_releases_to_contractor(){
				var mods 			=	$('#main_page').val();
				var types 			=	$('#main_type').val(); 
				var action 			=	$('#main_action').val();
				var mainid			=	$('#main_id').val();
				var dataString		=	"action="+encodeURIComponent(action)+"&mainid="+encodeURIComponent(mainid); 
						$.post('./ajax/load_releases_to_contractor.php', dataString, function(msg){ 
								var obj	= $.parseJSON(msg);

								
								var date_po_issued			=	obj.data[0].date_po_issued;
 								var date_issued				=	obj.data[0].date_issued;  
 								var retention_processed		=	obj.data[0].retention_processed;
								

						 		var block					=	obj.data[0].block;
								var lot						=	obj.data[0].lot; 
						 		var units					=	obj.data[0].units; 
						 		var contractor				=	obj.data[0].fullname;
						 		var releases_status			=	obj.data[0].releases_status;
						 		var releases_remarks		=	obj.data[0].releases_remarks;

								var contract_price			=	parseFloat(obj.data[0].contract_price);
								var wht						=	parseFloat(obj.data[0].wht); 
								var net_contract_price		=	parseFloat(obj.data[0].net_contract_price); 

								var downpayment_checkbox	=	obj.data[0].downpayment_checkbox; 
								var downpayment_recoup		=	parseFloat(obj.data[0].downpayment_recoup);
								var downpayment_date		=	obj.data[0].downpayment_date; 
								var downpayment_check		=	obj.data[0].downpayment_check; 
								
								var first_checkbox			=	obj.data[0].first_checkbox; 
								var first_percentage		=	obj.data[0].first_percentage; 
								var first_amount			=	parseFloat(obj.data[0].first_amount);
								var first_wht				=	parseFloat(obj.data[0].first_wht);
								var first_recoup			=	parseFloat(obj.data[0].first_recoup);
								var first_retention			=	parseFloat(obj.data[0].first_retention);
								var first_electricity		=	parseFloat(obj.data[0].first_electricity);
								var first_others			=	parseFloat(obj.data[0].first_others);
								var first_net				=	parseFloat(obj.data[0].first_net);
								var first_date				=	obj.data[0].first_date;  
 
								var second_checkbox			=	obj.data[0].second_checkbox; 
								var second_percentage		=	obj.data[0].second_percentage; 
								var second_amount			=	parseFloat(obj.data[0].second_amount);
								var second_wht				=	parseFloat(obj.data[0].second_wht);
								var second_recoup			=	parseFloat(obj.data[0].second_recoup);
								var second_retention		=	parseFloat(obj.data[0].second_retention);
								var second_electricity		=	parseFloat(obj.data[0].second_electricity);
								var second_others			=	parseFloat(obj.data[0].second_others);
								var second_net				=	parseFloat(obj.data[0].second_net);
								var second_date				=	obj.data[0].second_date;  
								
								var third_checkbox			=	obj.data[0].third_checkbox; 
								var third_percentage		=	obj.data[0].third_percentage; 
								var third_amount			=	parseFloat(obj.data[0].third_amount);
								var third_wht				=	parseFloat(obj.data[0].third_wht);
								var third_recoup			=	parseFloat(obj.data[0].third_recoup);
								var third_retention			=	parseFloat(obj.data[0].third_retention);
								var third_electricity		=	parseFloat(obj.data[0].third_electricity);
								var third_others			=	parseFloat(obj.data[0].third_others);
								var third_net				=	parseFloat(obj.data[0].third_net);
								var third_date				=	obj.data[0].third_date; 
								
								var fourth_checkbox			=	obj.data[0].fourth_checkbox; 
								var fourth_percentage		=	obj.data[0].fourth_percentage; 
								var fourth_amount			=	parseFloat(obj.data[0].fourth_amount);
								var fourth_wht				=	parseFloat(obj.data[0].fourth_wht);
								var fourth_recoup			=	parseFloat(obj.data[0].fourth_recoup);
								var fourth_retention		=	parseFloat(obj.data[0].fourth_retention);
								var fourth_electricity		=	parseFloat(obj.data[0].fourth_electricity);
								var fourth_others			=	parseFloat(obj.data[0].fourth_others);
								var fourth_net				=	parseFloat(obj.data[0].fourth_net);
								var fourth_date				=	obj.data[0].fourth_date; 

								var fifth_checkbox			=	obj.data[0].fifth_checkbox; 
								var fifth_percentage		=	obj.data[0].fifth_percentage; 
								var fifth_amount			=	parseFloat(obj.data[0].fifth_amount);
								var fifth_wht				=	parseFloat(obj.data[0].fifth_wht);
								var fifth_recoup			=	parseFloat(obj.data[0].fifth_recoup);
								var fifth_retention			=	parseFloat(obj.data[0].fifth_retention);
								var fifth_electricity		=	parseFloat(obj.data[0].fifth_electricity);
								var fifth_others			=	parseFloat(obj.data[0].fifth_others);
								var fifth_net				=	parseFloat(obj.data[0].fifth_net);
								var fifth_date				=	obj.data[0].fifth_date; 

								var sixth_checkbox			=	obj.data[0].sixth_checkbox; 
								var sixth_percentage		=	obj.data[0].sixth_percentage; 
								var sixth_amount			=	parseFloat(obj.data[0].sixth_amount);
								var sixth_wht				=	parseFloat(obj.data[0].sixth_wht);
								var sixth_recoup			=	parseFloat(obj.data[0].sixth_recoup);
								var sixth_retention			=	parseFloat(obj.data[0].sixth_retention);
								var sixth_electricity		=	parseFloat(obj.data[0].sixth_electricity);
								var sixth_others			=	parseFloat(obj.data[0].sixth_others);
								var sixth_net				=	parseFloat(obj.data[0].sixth_net);
								var sixth_date				=	obj.data[0].sixth_date; 

								var seventh_checkbox		=	obj.data[0].seventh_checkbox; 
								var seventh_percentage		=	obj.data[0].seventh_percentage; 
								var seventh_amount			=	parseFloat(obj.data[0].seventh_amount);
								var seventh_wht				=	parseFloat(obj.data[0].seventh_wht);
								var seventh_recoup			=	parseFloat(obj.data[0].seventh_recoup);
								var seventh_retention		=	parseFloat(obj.data[0].seventh_retention);
								var seventh_electricity		=	parseFloat(obj.data[0].seventh_electricity);
								var seventh_others			=	parseFloat(obj.data[0].seventh_others);
								var seventh_net				=	parseFloat(obj.data[0].seventh_net);
								var seventh_date			=	obj.data[0].seventh_date; 

								var eight_checkbox			=	obj.data[0].eight_checkbox; 
								var eight_percentage		=	obj.data[0].eight_percentage; 
								var eight_amount			=	parseFloat(obj.data[0].eight_amount);
								var eight_wht				=	parseFloat(obj.data[0].eight_wht);
								var eight_recoup			=	parseFloat(obj.data[0].eight_recoup);
								var eight_retention			=	parseFloat(obj.data[0].eight_retention);
								var eight_electricity		=	parseFloat(obj.data[0].eight_electricity);
								var eight_others			=	parseFloat(obj.data[0].eight_others);
								var eight_net				=	parseFloat(obj.data[0].eight_net);
								var eight_date				=	obj.data[0].eight_date; 

								var nine_checkbox			=	obj.data[0].nine_checkbox; 
								var nine_percentage			=	obj.data[0].nine_percentage; 
								var nine_amount				=	parseFloat(obj.data[0].nine_amount);
								var nine_wht				=	parseFloat(obj.data[0].nine_wht);
								var nine_recoup				=	parseFloat(obj.data[0].nine_recoup);
								var nine_retention			=	parseFloat(obj.data[0].nine_retention);
								var nine_electricity		=	parseFloat(obj.data[0].nine_electricity);
								var nine_others				=	parseFloat(obj.data[0].nine_others);
								var nine_net				=	parseFloat(obj.data[0].nine_net);
								var nine_date				=	obj.data[0].nine_date; 

								var ten_checkbox			=	obj.data[0].ten_checkbox; 
								var ten_percentage			=	obj.data[0].ten_percentage; 
								var ten_amount				=	parseFloat(obj.data[0].ten_amount);
								var ten_wht					=	parseFloat(obj.data[0].ten_wht);
								var ten_recoup				=	parseFloat(obj.data[0].ten_recoup);
								var ten_retention			=	parseFloat(obj.data[0].ten_retention);
								var ten_electricity			=	parseFloat(obj.data[0].ten_electricity);
								var ten_others				=	parseFloat(obj.data[0].ten_others);
								var ten_net					=	parseFloat(obj.data[0].ten_net);
								var ten_date				=	obj.data[0].ten_date; 


								var total_percentage		=	obj.data[0].total_percentage; 
								var total_amount			=	parseFloat(obj.data[0].total_amount);
								var total_wht				=	parseFloat(obj.data[0].total_wht);
								var total_recoup			=	parseFloat(obj.data[0].total_recoup);
								var total_retention			=	parseFloat(obj.data[0].total_retention);
								var total_electricity		=	parseFloat(obj.data[0].total_electricity);
								var total_water				=	parseFloat(obj.data[0].total_water);
								var total_others			=	parseFloat(obj.data[0].total_others);
								var total_net				=	parseFloat(obj.data[0].total_net);
  
								var balance_amount			=	parseFloat(obj.data[0].balance_amount);
								var balance_wht				=	parseFloat(obj.data[0].balance_wht);
								var balance_recoup			=	parseFloat(obj.data[0].balance_recoup);
  
  								$('#downpayment_check').val(downpayment_check); 

  								var first_water				=	parseFloat(obj.data[0].first_water);
 								var first_check				=	obj.data[0].first_check; 
 								first_water 				=  Comma(first_water.toFixed(2)); 
								$('#first_water').val(first_water);
  								$('#first_check').val(first_check);

								var second_water			=	parseFloat(obj.data[0].second_water);
 								var second_check			=	obj.data[0].second_check; 
 								second_water 				=  Comma(second_water.toFixed(2)); 
								$('#second_water').val(second_water);
  								$('#second_check').val(second_check);

  								var third_water				=	parseFloat(obj.data[0].third_water);
 								var third_check				=	obj.data[0].third_check; 
 								third_water 				=  Comma(third_water.toFixed(2)); 
								$('#third_water').val(third_water);
  								$('#third_check').val(third_check);
								
								var fourth_water			=	parseFloat(obj.data[0].fourth_water);
 								var fourth_check			=	obj.data[0].fourth_check; 
 								fourth_water 				=  Comma(fourth_water.toFixed(2)); 
								$('#fourth_water').val(fourth_water);
  								$('#fourth_check').val(fourth_check);

								var fifth_water				=	parseFloat(obj.data[0].fifth_water);
 								var fifth_check				=	obj.data[0].fifth_check; 
 								fifth_water 				=  Comma(fifth_water.toFixed(2)); 
								$('#fifth_water').val(fifth_water);
  								$('#fifth_check').val(fifth_check);

								var sixth_water				=	parseFloat(obj.data[0].sixth_water);
 								var sixth_check				=	obj.data[0].sixth_check; 
 								sixth_water 				=  Comma(sixth_water.toFixed(2)); 
								$('#sixth_water').val(sixth_water);
  								$('#sixth_check').val(sixth_check);

  								var seventh_water			=	parseFloat(obj.data[0].seventh_water);
 								var seventh_check			=	obj.data[0].seventh_check; 
 								seventh_water 				=  Comma(seventh_water.toFixed(2)); 
								$('#seventh_water').val(seventh_water);
  								$('#seventh_check').val(seventh_check);

								var eight_water				=	parseFloat(obj.data[0].eight_water);
 								var eight_check				=	obj.data[0].eight_check; 
 								eight_water 				=  Comma(eight_water.toFixed(2)); 
								$('#eight_water').val(eight_water);
  								$('#eight_check').val(eight_check);

								var nine_water				=	parseFloat(obj.data[0].nine_water);
 								var nine_check				=	obj.data[0].nine_check; 
 								nine_water 					=  Comma(nine_water.toFixed(2)); 
								$('#nine_water').val(nine_water);
  								$('#nine_check').val(nine_check);

								var ten_water				=	parseFloat(obj.data[0].ten_water);
 								var ten_check				=	obj.data[0].ten_check; 
 								ten_water 					=  Comma(ten_water.toFixed(2)); 
								$('#ten_water').val(ten_water);
  								$('#ten_check').val(ten_check);

  								$('#releases_status').val(releases_status);
  								$('#releases_remarks').val(releases_remarks);

								$('#contractor').val(contractor);
								$('#po_issued').val(date_po_issued); 
								$('#date_issued').val(date_issued);

								$('#retention_processed').val(retention_processed);


								$('#block').val(block);
								$('#lot').val(lot);
								$('#number_units').val(units);
								contract_price 			=  Comma(contract_price.toFixed(2)); 
								$('#contract_price').val(contract_price);
								wht 					=  Comma(wht.toFixed(2)); 
								$('#withholding_tax').val(wht);
								net_contract_price 		=  Comma(net_contract_price.toFixed(2)); 
								$('#net_contract_price').val(net_contract_price);

								if(downpayment_checkbox=='on'){
									$('#downpayment_checkbox').attr('checked',true);
								}

								downpayment_recoup 		=  Comma(downpayment_recoup.toFixed(2)); 
								$('#downpayment_recoup').val(downpayment_recoup); 
								$('#downpayment_date').val(downpayment_date); 


								if(first_checkbox=='on'){
									$('#first_checkbox').attr('checked',true);
								} 
								$('#first_percentage').val(first_percentage); 
								first_amount 		=  Comma(first_amount.toFixed(2)); 
								$('#first_amount').val(first_amount); 
								first_wht 			=  Comma(first_wht.toFixed(2)); 
								$('#first_wht').val(first_wht); 
								first_recoup 		=  Comma(first_recoup.toFixed(2)); 
								$('#first_recoup').val(first_recoup); 
								first_retention 	=  Comma(first_retention.toFixed(2)); 
								$('#first_retention').val(first_retention); 
								first_electricity 	=  Comma(first_electricity.toFixed(2)); 
								$('#first_electricity').val(first_electricity); 
								first_others 		=  Comma(first_others.toFixed(2)); 
								$('#first_others').val(first_others); 
								first_net 			=  Comma(first_net.toFixed(2)); 
								$('#first_net').val(first_net); 
								$('#first_date').val(first_date); 


								if(second_checkbox=='on'){
									$('#second_checkbox').attr('checked',true);
								} 
								$('#second_percentage').val(second_percentage); 
								second_amount 		=  Comma(second_amount.toFixed(2)); 
								$('#second_amount').val(second_amount); 
								second_wht 			=  Comma(second_wht.toFixed(2)); 
								$('#second_wht').val(second_wht); 
								second_recoup 		=  Comma(second_recoup.toFixed(2)); 
								$('#second_recoup').val(second_recoup); 
								second_retention 	=  Comma(second_retention.toFixed(2)); 
								$('#second_retention').val(second_retention); 
								second_electricity 	=  Comma(second_electricity.toFixed(2)); 
								$('#second_electricity').val(second_electricity); 
								second_others 		=  Comma(second_others.toFixed(2)); 
								$('#second_others').val(second_others); 
								second_net 			=  Comma(second_net.toFixed(2)); 
								$('#second_net').val(second_net); 
								$('#second_date').val(second_date); 
 
								if(third_checkbox=='on'){
									$('#third_checkbox').attr('checked',true);
								} 
								$('#third_percentage').val(third_percentage); 
								third_amount 		=  Comma(third_amount.toFixed(2)); 
								$('#third_amount').val(third_amount); 
								third_wht 			=  Comma(third_wht.toFixed(2)); 
								$('#third_wht').val(third_wht); 
								third_recoup 		=  Comma(third_recoup.toFixed(2)); 
								$('#third_recoup').val(third_recoup); 
								third_retention 	=  Comma(third_retention.toFixed(2)); 
								$('#third_retention').val(third_retention); 
								third_electricity 	=  Comma(third_electricity.toFixed(2)); 
								$('#third_electricity').val(third_electricity); 
								third_others 		=  Comma(third_others.toFixed(2)); 
								$('#third_others').val(third_others); 
								third_net 			=  Comma(third_net.toFixed(2)); 
								$('#third_net').val(third_net); 
								$('#third_date').val(third_date); 

								if(fourth_checkbox=='on'){
									$('#fourth_checkbox').attr('checked',true);
								} 
								$('#fourth_percentage').val(fourth_percentage); 
								fourth_amount 		=  Comma(fourth_amount.toFixed(2)); 
								$('#fourth_amount').val(fourth_amount); 
								fourth_wht 			=  Comma(fourth_wht.toFixed(2)); 
								$('#fourth_wht').val(fourth_wht); 
								fourth_recoup 		=  Comma(fourth_recoup.toFixed(2)); 
								$('#fourth_recoup').val(fourth_recoup); 
								fourth_retention 	=  Comma(fourth_retention.toFixed(2)); 
								$('#fourth_retention').val(fourth_retention); 
								fourth_electricity 	=  Comma(fourth_electricity.toFixed(2)); 
								$('#fourth_electricity').val(fourth_electricity); 
								fourth_others 		=  Comma(fourth_others.toFixed(2)); 
								$('#fourth_others').val(fourth_others); 
								fourth_net 			=  Comma(fourth_net.toFixed(2)); 
								$('#fourth_net').val(fourth_net); 
								$('#fourth_date').val(fourth_date); 
 
								if(fifth_checkbox=='on'){
									$('#fifth_checkbox').attr('checked',true);
								} 
								$('#fifth_percentage').val(fifth_percentage); 
								fifth_amount 		=  Comma(fifth_amount.toFixed(2)); 
								$('#fifth_amount').val(fifth_amount); 
								fifth_wht 			=  Comma(fifth_wht.toFixed(2)); 
								$('#fifth_wht').val(fifth_wht); 
								fifth_recoup 		=  Comma(fifth_recoup.toFixed(2)); 
								$('#fifth_recoup').val(fifth_recoup); 
								fifth_retention 	=  Comma(fifth_retention.toFixed(2)); 
								$('#fifth_retention').val(fifth_retention); 
								fifth_electricity 	=  Comma(fifth_electricity.toFixed(2)); 
								$('#fifth_electricity').val(fifth_electricity); 
								fifth_others 		=  Comma(fifth_others.toFixed(2)); 
								$('#fifth_others').val(fifth_others); 
								fifth_net 			=  Comma(fifth_net.toFixed(2)); 
								$('#fifth_net').val(fifth_net); 
								$('#fifth_date').val(fifth_date); 

								if(sixth_checkbox=='on'){
									$('#sixth_checkbox').attr('checked',true);
								} 
								$('#sixth_percentage').val(sixth_percentage); 
								sixth_amount 		=  Comma(sixth_amount.toFixed(2)); 
								$('#sixth_amount').val(sixth_amount); 
								sixth_wht 			=  Comma(sixth_wht.toFixed(2)); 
								$('#sixth_wht').val(sixth_wht); 
								sixth_recoup 		=  Comma(sixth_recoup.toFixed(2)); 
								$('#sixth_recoup').val(sixth_recoup); 
								sixth_retention 	=  Comma(sixth_retention.toFixed(2)); 
								$('#sixth_retention').val(sixth_retention); 
								sixth_electricity 	=  Comma(sixth_electricity.toFixed(2)); 
								$('#sixth_electricity').val(sixth_electricity); 
								sixth_others 		=  Comma(sixth_others.toFixed(2)); 
								$('#sixth_others').val(sixth_others); 
								sixth_net 			=  Comma(sixth_net.toFixed(2)); 
								$('#sixth_net').val(sixth_net); 
								$('#sixth_date').val(sixth_date); 

								if(seventh_checkbox=='on'){
									$('#seventh_checkbox').attr('checked',true);
								} 
								$('#seventh_percentage').val(seventh_percentage); 
								seventh_amount 		=  Comma(seventh_amount.toFixed(2)); 
								$('#seventh_amount').val(seventh_amount); 
								seventh_wht 		=  Comma(seventh_wht.toFixed(2)); 
								$('#seventh_wht').val(seventh_wht); 
								seventh_recoup 		=  Comma(seventh_recoup.toFixed(2)); 
								$('#seventh_recoup').val(seventh_recoup); 
								seventh_retention 	=  Comma(seventh_retention.toFixed(2)); 
								$('#seventh_retention').val(seventh_retention); 
								seventh_electricity =  Comma(seventh_electricity.toFixed(2)); 
								$('#seventh_electricity').val(seventh_electricity); 
								seventh_others 		=  Comma(seventh_others.toFixed(2)); 
								$('#seventh_others').val(seventh_others); 
								seventh_net 		=  Comma(seventh_net.toFixed(2)); 
								$('#seventh_net').val(seventh_net); 
								$('#seventh_date').val(seventh_date); 

								if(eight_checkbox=='on'){
									$('#eight_checkbox').attr('checked',true);
								} 
								$('#eight_percentage').val(eight_percentage); 
								eight_amount 		=  Comma(eight_amount.toFixed(2)); 
								$('#eight_amount').val(eight_amount); 
								eight_wht 			=  Comma(eight_wht.toFixed(2)); 
								$('#eight_wht').val(eight_wht); 
								eight_recoup 		=  Comma(eight_recoup.toFixed(2)); 
								$('#eight_recoup').val(eight_recoup); 
								eight_retention 	=  Comma(eight_retention.toFixed(2)); 
								$('#eight_retention').val(eight_retention); 
								eight_electricity 	=  Comma(eight_electricity.toFixed(2)); 
								$('#eight_electricity').val(eight_electricity); 
								eight_others 		=  Comma(eight_others.toFixed(2)); 
								$('#eight_others').val(eight_others); 
								eight_net 			=  Comma(eight_net.toFixed(2)); 
								$('#eight_net').val(eight_net); 
								$('#eight_date').val(eight_date); 

								if(nine_checkbox=='on'){
									$('#nine_checkbox').attr('checked',true);
								} 
								$('#nine_percentage').val(nine_percentage); 
								nine_amount 		=  Comma(nine_amount.toFixed(2)); 
								$('#nine_amount').val(nine_amount); 
								nine_wht 			=  Comma(nine_wht.toFixed(2)); 
								$('#nine_wht').val(nine_wht); 
								nine_recoup 		=  Comma(nine_recoup.toFixed(2)); 
								$('#nine_recoup').val(nine_recoup); 
								nine_retention 		=  Comma(nine_retention.toFixed(2)); 
								$('#nine_retention').val(nine_retention); 
								nine_electricity 	=  Comma(nine_electricity.toFixed(2)); 
								$('#nine_electricity').val(nine_electricity); 
								nine_others 		=  Comma(nine_others.toFixed(2)); 
								$('#nine_others').val(nine_others); 
								nine_net 			=  Comma(nine_net.toFixed(2)); 
								$('#nine_net').val(nine_net); 
								$('#nine_date').val(nine_date); 

								if(ten_checkbox=='on'){
									$('#ten_checkbox').attr('checked',true);
								} 
								$('#ten_percentage').val(ten_percentage); 
								ten_amount 			=  Comma(ten_amount.toFixed(2)); 
								$('#ten_amount').val(ten_amount); 
								ten_wht 			=  Comma(ten_wht.toFixed(2)); 
								$('#ten_wht').val(ten_wht); 
								ten_recoup 			=  Comma(ten_recoup.toFixed(2)); 
								$('#ten_recoup').val(ten_recoup); 
								ten_retention 		=  Comma(ten_retention.toFixed(2)); 
								$('#ten_retention').val(ten_retention); 
								ten_electricity 	=  Comma(ten_electricity.toFixed(2)); 
								$('#ten_electricity').val(ten_electricity); 
								ten_others 			=  Comma(ten_others.toFixed(2)); 
								$('#ten_others').val(ten_others); 
								ten_net 			=  Comma(ten_net.toFixed(2)); 
								$('#ten_net').val(ten_net); 
								$('#ten_date').val(ten_date);


								$('#total_percentage').val(total_percentage); 
								total_amount 			=  Comma(total_amount.toFixed(2)); 
								$('#total_amount').val(total_amount); 
								total_wht 			=  Comma(total_wht.toFixed(2)); 
								$('#total_wht').val(total_wht); 
								total_recoup 			=  Comma(total_recoup.toFixed(2)); 
								$('#total_recoup').val(total_recoup); 
								total_retention 		=  Comma(total_retention.toFixed(2)); 
								$('#total_retention').val(total_retention); 
								total_electricity 	=  Comma(total_electricity.toFixed(2)); 
								$('#total_electricity').val(total_electricity); 

								total_water 	=  Comma(total_water.toFixed(2)); 
								$('#total_water').val(total_water); 

								total_others 			=  Comma(total_others.toFixed(2)); 
								$('#total_others').val(total_others); 
								total_net 			=  Comma(total_net.toFixed(2)); 
								$('#total_net').val(total_net);  
 
 								balance_amount 			=  Comma(balance_amount.toFixed(2)); 
								$('#balance_amount').val(balance_amount);  
 
 								balance_wht 			=  Comma(balance_wht.toFixed(2)); 
								$('#balance_wht').val(balance_wht);  
 
 								balance_recoup 			=  Comma(balance_recoup.toFixed(2)); 
								$('#balance_recoup').val(balance_recoup);  
   

						});
}

     

function releaseStatus(){
	var total_amount	= parseFloat($('#total_amount').val().replace(/,/g, ""));
	var contract_price	= parseFloat($('#contract_price').val().replace(/,/g, ""));

	if(total_amount == contract_price){
		$('#releases_status').val("Fully Paid");
	}else if(total_amount > contract_price){
		$('#releases_status').val("Overpaid");
	}else if(total_amount < contract_price){
		$('#releases_status').val("with Balance");
	} 
}
 

 
function amount_computation(){
	var first_percentage	= $('#first_percentage').val().replace(/,/g, "");
	var second_percentage	= $('#second_percentage').val().replace(/,/g, "");
	var third_percentage	= $('#third_percentage').val().replace(/,/g, "");
	var fourth_percentage	= $('#fourth_percentage').val().replace(/,/g, "");
	var fifth_percentage	= $('#fifth_percentage').val().replace(/,/g, "");
	var sixth_percentage	= $('#sixth_percentage').val().replace(/,/g, "");
	var seventh_percentage	= $('#seventh_percentage').val().replace(/,/g, "");
	var eight_percentage	= $('#eight_percentage').val().replace(/,/g, "");
	var nine_percentage		= $('#nine_percentage').val().replace(/,/g, "");
	var ten_percentage		= $('#ten_percentage').val().replace(/,/g, "");

	var wht 				= $('#withholding_tax').val().replace(/,/g, "");
	var contract_price		= $('#contract_price').val().replace(/,/g, "");
	var downpayment_recoup	= $('#downpayment_recoup').val().replace(/,/g, "");
	var first_wht 			= wht * (first_percentage/100);
	first_wht 				= Comma(parseFloat(first_wht).toFixed(2));
	$('#first_wht').val(first_wht);

	var second_wht 			= wht * (second_percentage/100);
	second_wht 				= Comma(parseFloat(second_wht).toFixed(2));
	$('#second_wht').val(second_wht); 

	var third_wht 			= wht * (third_percentage/100);
	third_wht 				= Comma(parseFloat(third_wht).toFixed(2));
	$('#third_wht').val(third_wht); 

	var fourth_wht 			= wht * (fourth_percentage/100);
	fourth_wht 				= Comma(parseFloat(fourth_wht).toFixed(2));
	$('#fourth_wht').val(fourth_wht); 

	var fifth_wht 			= wht * (fifth_percentage/100);
	fifth_wht 				= Comma(parseFloat(fifth_wht).toFixed(2));
	$('#fifth_wht').val(fifth_wht); 

	var sixth_wht 			= wht * (sixth_percentage/100);
	sixth_wht 				= Comma(parseFloat(sixth_wht).toFixed(2));
	$('#sixth_wht').val(sixth_wht); 

	var seventh_wht 			= wht * (seventh_percentage/100);
	seventh_wht 				= Comma(parseFloat(seventh_wht).toFixed(2));
	$('#seventh_wht').val(seventh_wht); 

	var eight_wht 			= wht * (eight_percentage/100);
	eight_wht 				= Comma(parseFloat(eight_wht).toFixed(2));
	$('#eight_wht').val(eight_wht); 

	var nine_wht 			= wht * (nine_percentage/100);
	nine_wht 				= Comma(parseFloat(nine_wht).toFixed(2));
	$('#nine_wht').val(nine_wht); 
				
	var ten_wht 			= wht * (ten_percentage/100);
	ten_wht 				= Comma(parseFloat(ten_wht).toFixed(2));
	$('#ten_wht').val(ten_wht); 

	/**************/
	var first_amount 			= contract_price * (first_percentage/100);
	first_amount 				= Comma(parseFloat(first_amount).toFixed(2));
	$('#first_amount').val(first_amount); 

	var second_amount 			= contract_price * (second_percentage/100);
	second_amount 				= Comma(parseFloat(second_amount).toFixed(2));
	$('#second_amount').val(second_amount); 

	var third_amount 			= contract_price * (third_percentage/100);
	third_amount 				= Comma(parseFloat(third_amount).toFixed(2));
	$('#third_amount').val(third_amount); 

	var fourth_amount 			= contract_price * (fourth_percentage/100);
	fourth_amount 				= Comma(parseFloat(fourth_amount).toFixed(2));
	$('#fourth_amount').val(fourth_amount); 
	
	var fifth_amount 			= contract_price * (fifth_percentage/100);
	fifth_amount 				= Comma(parseFloat(fifth_amount).toFixed(2));
	$('#fifth_amount').val(fifth_amount); 
	
	var sixth_amount 			= contract_price * (sixth_percentage/100);
	sixth_amount 				= Comma(parseFloat(sixth_amount).toFixed(2));
	$('#sixth_amount').val(sixth_amount); 
	
	var seventh_amount 			= contract_price * (seventh_percentage/100);
	seventh_amount 				= Comma(parseFloat(seventh_amount).toFixed(2));
	$('#seventh_amount').val(seventh_amount); 
	
	var eight_amount 			= contract_price * (eight_percentage/100);
	eight_amount 				= Comma(parseFloat(eight_amount).toFixed(2));
	$('#eight_amount').val(eight_amount); 
	
	var nine_amount 			= contract_price * (nine_percentage/100);
	nine_amount 				= Comma(parseFloat(nine_amount).toFixed(2));
	$('#nine_amount').val(nine_amount); 
	
	var ten_amount 			= contract_price * (ten_percentage/100);
	ten_amount 				= Comma(parseFloat(ten_amount).toFixed(2));
	$('#ten_amount').val(ten_amount); 


	/*************/
	var first_recoup 			= downpayment_recoup * (first_percentage/100);
	first_recoup 				= Comma(parseFloat(first_recoup).toFixed(2));
	$('#first_recoup').val(first_recoup); 

	var second_recoup 			= downpayment_recoup * (second_percentage/100);
	second_recoup 				= Comma(parseFloat(second_recoup).toFixed(2));
	$('#second_recoup').val(second_recoup); 

	var third_recoup 			= downpayment_recoup * (third_percentage/100);
	third_recoup 				= Comma(parseFloat(third_recoup).toFixed(2));
	$('#third_recoup').val(third_recoup); 

	var fourth_recoup 			= downpayment_recoup * (fourth_percentage/100);
	fourth_recoup 				= Comma(parseFloat(fourth_recoup).toFixed(2));
	$('#fourth_recoup').val(fourth_recoup); 

	var fifth_recoup 			= downpayment_recoup * (fifth_percentage/100);
	fifth_recoup 				= Comma(parseFloat(fifth_recoup).toFixed(2));
	$('#fifth_recoup').val(fifth_recoup); 
 
	var sixth_recoup 			= downpayment_recoup * (sixth_percentage/100);
	sixth_recoup 				= Comma(parseFloat(sixth_recoup).toFixed(2));
	$('#sixth_recoup').val(sixth_recoup); 

	var seventh_recoup 			= downpayment_recoup * (seventh_percentage/100);
	seventh_recoup 				= Comma(parseFloat(seventh_recoup).toFixed(2));
	$('#seventh_recoup').val(seventh_recoup); 

	var eight_recoup 			= downpayment_recoup * (eight_percentage/100);
	eight_recoup 				= Comma(parseFloat(eight_recoup).toFixed(2));
	$('#eight_recoup').val(eight_recoup); 

	var nine_recoup 			= downpayment_recoup * (nine_percentage/100);
	nine_recoup 				= Comma(parseFloat(nine_recoup).toFixed(2));
	$('#nine_recoup').val(nine_recoup); 

	var ten_recoup 				= downpayment_recoup * (ten_percentage/100);
	ten_recoup 					= Comma(parseFloat(ten_recoup).toFixed(2));
	$('#ten_recoup').val(ten_recoup);  

	compute_net();
}

function compute_recoup(){
	
	var downpayment_recoup	= $('#downpayment_recoup').val().replace(/,/g, ""); 

	var first_percentage	= $('#first_percentage').val().replace(/,/g, "");
	var first_recoup 		= downpayment_recoup * (first_percentage/100);
	first_recoup 			= Comma(parseFloat(first_recoup).toFixed(2));
	$('#first_recoup').val(first_recoup); 

	var second_percentage	= $('#second_percentage').val().replace(/,/g, "");
	var second_recoup 		= downpayment_recoup * (second_percentage/100);
	second_recoup 			= Comma(parseFloat(second_recoup).toFixed(2));
	$('#second_recoup').val(second_recoup); 

	var third_percentage	= $('#third_percentage').val().replace(/,/g, "");
	var third_recoup 		= downpayment_recoup * (third_percentage/100);
	third_recoup 			= Comma(parseFloat(third_recoup).toFixed(2));
	$('#third_recoup').val(third_recoup); 

	var fourth_percentage	= $('#fourth_percentage').val().replace(/,/g, "");
	var fourth_recoup 		= downpayment_recoup * (fourth_percentage/100);
	fourth_recoup 			= Comma(parseFloat(fourth_recoup).toFixed(2));
	$('#fourth_recoup').val(fourth_recoup); 

	var fifth_percentage	= $('#fifth_percentage').val().replace(/,/g, "");
	var fifth_recoup 		= downpayment_recoup * (fifth_percentage/100);
	fifth_recoup 			= Comma(parseFloat(fifth_recoup).toFixed(2));
	$('#fifth_recoup').val(fifth_recoup); 
 
	var sixth_percentage	= $('#sixth_percentage').val().replace(/,/g, "");
	var sixth_recoup 		= downpayment_recoup * (sixth_percentage/100);
	sixth_recoup 			= Comma(parseFloat(sixth_recoup).toFixed(2));
	$('#sixth_recoup').val(sixth_recoup); 

	var seventh_percentage	= $('#seventh_percentage').val().replace(/,/g, "");
	var seventh_recoup 		= downpayment_recoup * (seventh_percentage/100);
	seventh_recoup 			= Comma(parseFloat(seventh_recoup).toFixed(2));
	$('#seventh_recoup').val(seventh_recoup); 

	var eight_percentage	= $('#eight_percentage').val().replace(/,/g, "");
	var eight_recoup 		= downpayment_recoup * (eight_percentage/100);
	eight_recoup 			= Comma(parseFloat(eight_recoup).toFixed(2));
	$('#eight_recoup').val(eight_recoup); 

	var nine_percentage	= $('#nine_percentage').val().replace(/,/g, "");
	var nine_recoup 		= downpayment_recoup * (nine_percentage/100);
	nine_recoup 			= Comma(parseFloat(nine_recoup).toFixed(2));
	$('#nine_recoup').val(nine_recoup); 

	var ten_percentage	= $('#ten_percentage').val().replace(/,/g, "");
	var ten_recoup 		= downpayment_recoup * (ten_percentage/100);
	ten_recoup 			= Comma(parseFloat(ten_recoup).toFixed(2));
	$('#ten_recoup').val(ten_recoup);  

	compute_net();
}

function compute_net(){
	var first_amount		= $('#first_amount').val().replace(/,/g, "");
	var first_wht			= $('#first_wht').val().replace(/,/g, "");
	var first_recoup		= $('#first_recoup').val().replace(/,/g, "");
	var first_retention		= $('#first_retention').val().replace(/,/g, "");
	var first_electricity	= $('#first_electricity').val().replace(/,/g, "");
	var first_water			= $('#first_water').val().replace(/,/g, "");
	var first_others		= $('#first_others').val().replace(/,/g, "");
	var first_net			= parseFloat(first_amount) - (parseFloat(first_wht) + parseFloat(first_recoup) + parseFloat(first_retention) + parseFloat(first_electricity) + parseFloat(first_water) + parseFloat(first_others));
	
	if(first_net!='NaN'){
		first_net = Comma(parseFloat(first_net).toFixed(2));	
		if(first_net!='0.00' && first_net!='NaN'){  
			$('#first_checkbox').prop("checked",true); 
		}
	}else{
		first_net = 0;
	}

	$('#first_net').val(first_net);

	var second_amount		= $('#second_amount').val().replace(/,/g, "");
	var second_wht			= $('#second_wht').val().replace(/,/g, "");
	var second_recoup		= $('#second_recoup').val().replace(/,/g, "");
	var second_retention	= $('#second_retention').val().replace(/,/g, "");
	var second_electricity	= $('#second_electricity').val().replace(/,/g, "");
	var second_water		= $('#second_water').val().replace(/,/g, "");
	var second_others		= $('#second_others').val().replace(/,/g, "");
	var second_net			= parseFloat(second_amount) - (parseFloat(second_wht) + parseFloat(second_recoup) + parseFloat(second_retention) + parseFloat(second_electricity) + parseFloat(second_water) + parseFloat(second_others));
	 
	if(second_net!='NaN'){
		second_net = Comma(parseFloat(second_net).toFixed(2));	
		
		if(second_net!='0.00' && second_net!='NaN'){ 
			$('#second_checkbox').prop("checked",true); 
		}
	}else{
		second_net = 0;
	}

	$('#second_net').val(second_net);


	var third_amount		= $('#third_amount').val().replace(/,/g, "");
	var third_wht			= $('#third_wht').val().replace(/,/g, "");
	var third_recoup		= $('#third_recoup').val().replace(/,/g, "");
	var third_retention	= $('#third_retention').val().replace(/,/g, "");
	var third_electricity	= $('#third_electricity').val().replace(/,/g, "");
	var third_water	= $('#third_water').val().replace(/,/g, "");
	var third_others		= $('#third_others').val().replace(/,/g, "");
	var third_net			= parseFloat(third_amount) - (parseFloat(third_wht) + parseFloat(third_recoup) + parseFloat(third_retention) + parseFloat(third_electricity) + parseFloat(third_water) + parseFloat(third_others));
	 
	if(third_net!='NaN'){
		third_net = Comma(parseFloat(third_net).toFixed(2));	
		if(third_net!='0.00' && third_net!='NaN'){ 
			$('#third_checkbox').prop("checked",true); 
		}
	}else{
		third_net = 0;
	}

	$('#third_net').val(third_net);

	
	var fourth_amount		= $('#fourth_amount').val().replace(/,/g, "");
	var fourth_wht			= $('#fourth_wht').val().replace(/,/g, "");
	var fourth_recoup		= $('#fourth_recoup').val().replace(/,/g, "");
	var fourth_retention	= $('#fourth_retention').val().replace(/,/g, "");
	var fourth_electricity	= $('#fourth_electricity').val().replace(/,/g, "");
	var fourth_water		= $('#fourth_water').val().replace(/,/g, "");
	var fourth_others		= $('#fourth_others').val().replace(/,/g, "");
	var fourth_net			= parseFloat(fourth_amount) - (parseFloat(fourth_wht) + parseFloat(fourth_recoup) + parseFloat(fourth_retention) + parseFloat(fourth_electricity) + parseFloat(fourth_water) + parseFloat(fourth_others));
	 
	if(fourth_net!='NaN'){
		fourth_net = Comma(parseFloat(fourth_net).toFixed(2));	
		if(fourth_net!='0.00' && fourth_net!='NaN'){ 
			$('#fourth_checkbox').prop("checked",true); 
		}
	}else{
		fourth_net = 0;
	}

	$('#fourth_net').val(fourth_net);


	var fifth_amount		= $('#fifth_amount').val().replace(/,/g, "");
	var fifth_wht			= $('#fifth_wht').val().replace(/,/g, "");
	var fifth_recoup		= $('#fifth_recoup').val().replace(/,/g, "");
	var fifth_retention		= $('#fifth_retention').val().replace(/,/g, "");
	var fifth_electricity	= $('#fifth_electricity').val().replace(/,/g, "");
	var fifth_water			= $('#fifth_water').val().replace(/,/g, "");
	var fifth_others		= $('#fifth_others').val().replace(/,/g, "");
	var fifth_net			= parseFloat(fifth_amount) - (parseFloat(fifth_wht) + parseFloat(fifth_recoup) + parseFloat(fifth_retention) + parseFloat(fifth_electricity) + parseFloat(fifth_water) + parseFloat(fifth_others));
	 
	if(fifth_net!='NaN'){
		fifth_net = Comma(parseFloat(fifth_net).toFixed(2));	
		if(fifth_net!='0.00' && fifth_net!='NaN'){ 
			$('#fifth_checkbox').prop("checked",true); 
		}
	}else{
		fifth_net = 0;
	}

	$('#fifth_net').val(fifth_net);


	var sixth_amount		= $('#sixth_amount').val().replace(/,/g, "");
	var sixth_wht			= $('#sixth_wht').val().replace(/,/g, "");
	var sixth_recoup		= $('#sixth_recoup').val().replace(/,/g, "");
	var sixth_retention		= $('#sixth_retention').val().replace(/,/g, "");
	var sixth_electricity	= $('#sixth_electricity').val().replace(/,/g, "");
	var sixth_water			= $('#sixth_water').val().replace(/,/g, "");
	var sixth_others		= $('#sixth_others').val().replace(/,/g, "");
	var sixth_net			= parseFloat(sixth_amount) - (parseFloat(sixth_wht) + parseFloat(sixth_recoup) + parseFloat(sixth_retention) + parseFloat(sixth_electricity) + parseFloat(sixth_water) + parseFloat(sixth_others));
	  
	if(sixth_net!='NaN'){
		sixth_net = Comma(parseFloat(sixth_net).toFixed(2));	
		if(sixth_net!='0.00' && sixth_net!='NaN'){
			$('#sixth_checkbox').prop("checked",true); 
		}
	}else{
		sixth_net = 0;
	}

	$('#sixth_net').val(sixth_net);


	var seventh_amount		= $('#seventh_amount').val().replace(/,/g, "");
	var seventh_wht			= $('#seventh_wht').val().replace(/,/g, "");
	var seventh_recoup		= $('#seventh_recoup').val().replace(/,/g, "");
	var seventh_retention	= $('#seventh_retention').val().replace(/,/g, "");
	var seventh_electricity	= $('#seventh_electricity').val().replace(/,/g, "");
	var seventh_water		= $('#seventh_water').val().replace(/,/g, "");
	var seventh_others		= $('#seventh_others').val().replace(/,/g, "");
	var seventh_net			= parseFloat(seventh_amount) - (parseFloat(seventh_wht) + parseFloat(seventh_recoup) + parseFloat(seventh_retention) + parseFloat(seventh_electricity) + parseFloat(seventh_water) + parseFloat(seventh_others));
	 
	if(seventh_net!='NaN'){
		seventh_net = Comma(parseFloat(seventh_net).toFixed(2));	
		if(seventh_net!='0.00' && seventh_net!='NaN'){
			$('#seventh_checkbox').prop("checked",true); 
		}
	}else{
		seventh_net = 0;
	}

	$('#seventh_net').val(seventh_net);

	var eight_amount		= $('#eight_amount').val().replace(/,/g, "");
	var eight_wht			= $('#eight_wht').val().replace(/,/g, "");
	var eight_recoup		= $('#eight_recoup').val().replace(/,/g, "");
	var eight_retention		= $('#eight_retention').val().replace(/,/g, "");
	var eight_electricity	= $('#eight_electricity').val().replace(/,/g, "");
	var eight_water			= $('#eight_water').val().replace(/,/g, "");
	var eight_others		= $('#eight_others').val().replace(/,/g, "");
	var eight_net			= parseFloat(eight_amount) - (parseFloat(eight_wht) + parseFloat(eight_recoup) + parseFloat(eight_retention) + parseFloat(eight_electricity) + parseFloat(eight_water) + parseFloat(eight_others));
	 
	if(eight_net!='NaN'){
		eight_net = Comma(parseFloat(eight_net).toFixed(2));	
		if(eight_net!='0.00' && eight_net!='NaN'){
			$('#eight_checkbox').prop("checked",true); 
		}
	}else{
		eight_net = 0;
	}

	$('#eight_net').val(eight_net);


	var nine_amount			= $('#nine_amount').val().replace(/,/g, "");
	var nine_wht			= $('#nine_wht').val().replace(/,/g, "");
	var nine_recoup			= $('#nine_recoup').val().replace(/,/g, "");
	var nine_retention		= $('#nine_retention').val().replace(/,/g, "");
	var nine_electricity	= $('#nine_electricity').val().replace(/,/g, "");
	var nine_water			= $('#nine_water').val().replace(/,/g, "");
	var nine_others			= $('#nine_others').val().replace(/,/g, "");
	var nine_net			= parseFloat(nine_amount) - (parseFloat(nine_wht) + parseFloat(nine_recoup) + parseFloat(nine_retention) + parseFloat(nine_electricity) + parseFloat(nine_water) + parseFloat(nine_others));
	 
	if(nine_net!='NaN'){
		nine_net = Comma(parseFloat(nine_net).toFixed(2));	
		if(nine_net!='0.00' && nine_net!='NaN'){
			$('#nine_checkbox').prop("checked",true); 
		}
	}else{
		nine_net = 0;
	}

	$('#nine_net').val(nine_net);

	var ten_amount		= $('#ten_amount').val().replace(/,/g, "");
	var ten_wht			= $('#ten_wht').val().replace(/,/g, "");
	var ten_recoup		= $('#ten_recoup').val().replace(/,/g, "");
	var ten_retention	= $('#ten_retention').val().replace(/,/g, "");
	var ten_electricity	= $('#ten_electricity').val().replace(/,/g, "");
	var ten_water		= $('#ten_water').val().replace(/,/g, "");
	var ten_others		= $('#ten_others').val().replace(/,/g, "");
	var ten_net			= parseFloat(ten_amount) - (parseFloat(ten_wht) + parseFloat(ten_recoup) + parseFloat(ten_retention) + parseFloat(ten_electricity) + parseFloat(ten_water) + parseFloat(ten_others));
	 
	if(ten_net!='NaN'){
		ten_net = Comma(parseFloat(ten_net).toFixed(2));	
		if(ten_net!='0.00' && ten_net!='NaN'){
			$('#ten_checkbox').prop("checked",true); 
		}
	}else{
		ten_net = 0;
	}

	$('#ten_net').val(ten_net);
	compute_total();
}




function compute_total(){
	 
	var first_percentage	= $('#first_percentage').val().replace(/,/g, "");
	var second_percentage	= $('#second_percentage').val().replace(/,/g, "");
	var third_percentage	= $('#third_percentage').val().replace(/,/g, "");
	var fourth_percentage	= $('#fourth_percentage').val().replace(/,/g, "");
	var fifth_percentage	= $('#fifth_percentage').val().replace(/,/g, "");
	var sixth_percentage	= $('#sixth_percentage').val().replace(/,/g, "");
	var seventh_percentage	= $('#seventh_percentage').val().replace(/,/g, "");
	var eight_percentage	= $('#eight_percentage').val().replace(/,/g, "");
	var nine_percentage		= $('#nine_percentage').val().replace(/,/g, "");
	var ten_percentage		= $('#ten_percentage').val().replace(/,/g, "");
 
	if(first_percentage==''){ first_percentage = 0; }
	if(second_percentage==''){ second_percentage = 0; }
	if(third_percentage==''){ third_percentage = 0; }
	if(fourth_percentage==''){ fourth_percentage = 0; }
	if(fifth_percentage==''){ fifth_percentage = 0; }
	if(sixth_percentage==''){ sixth_percentage = 0; }
	if(seventh_percentage==''){ seventh_percentage = 0; }
	if(eight_percentage==''){ eight_percentage = 0; }
	if(nine_percentage==''){ nine_percentage = 0; }
	if(ten_percentage==''){ ten_percentage = 0; }

	var total_percentage 	= parseFloat(first_percentage) + parseFloat(second_percentage) + parseFloat(third_percentage) + parseFloat(fourth_percentage) + parseFloat(fifth_percentage) + parseFloat(sixth_percentage) + parseFloat(seventh_percentage) + parseFloat(eight_percentage) + parseFloat(nine_percentage) + parseFloat(ten_percentage);
	total_percentage 		= Comma(parseFloat(total_percentage).toFixed(2));
	$('#total_percentage').val(total_percentage);

	var contract_price		= parseFloat($('#contract_price').val().replace(/,/g, ""));
	var withholding_tax		= $('#withholding_tax').val().replace(/,/g, "");
	var downpayment_recoup	= $('#downpayment_recoup').val().replace(/,/g, "");
 	
	var first_amount	= $('#first_amount').val().replace(/,/g, "");
	var second_amount	= $('#second_amount').val().replace(/,/g, "");
	var third_amount	= $('#third_amount').val().replace(/,/g, "");
	var fourth_amount	= $('#fourth_amount').val().replace(/,/g, "");
	var fifth_amount	= $('#fifth_amount').val().replace(/,/g, "");
	var sixth_amount	= $('#sixth_amount').val().replace(/,/g, "");
	var seventh_amount	= $('#seventh_amount').val().replace(/,/g, "");
	var eight_amount	= $('#eight_amount').val().replace(/,/g, "");
	var nine_amount		= $('#nine_amount').val().replace(/,/g, "");
	var ten_amount		= $('#ten_amount').val().replace(/,/g, "");
	 
	var total_amount 	= (parseFloat(first_amount) + parseFloat(second_amount) + parseFloat(third_amount) + parseFloat(fourth_amount) + parseFloat(fifth_amount) + parseFloat(sixth_amount) + parseFloat(seventh_amount) + parseFloat(eight_amount) + parseFloat(nine_amount) + parseFloat(ten_amount));
	total_amount 		= Comma(parseFloat(total_amount).toFixed(2));
	$('#total_amount').val(total_amount);

	var balance_amount 	= parseFloat(contract_price) - (parseFloat(first_amount) + parseFloat(second_amount) + parseFloat(third_amount) + parseFloat(fourth_amount) + parseFloat(fifth_amount) + parseFloat(sixth_amount) + parseFloat(seventh_amount) + parseFloat(eight_amount) + parseFloat(nine_amount) + parseFloat(ten_amount));
	balance_amount 		= Comma(parseFloat(balance_amount).toFixed(2));
	$('#balance_amount').val(balance_amount);

	var first_wht	= $('#first_wht').val().replace(/,/g, "");
	var second_wht	= $('#second_wht').val().replace(/,/g, "");
	var third_wht	= $('#third_wht').val().replace(/,/g, "");
	var fourth_wht	= $('#fourth_wht').val().replace(/,/g, "");
	var fifth_wht	= $('#fifth_wht').val().replace(/,/g, "");
	var sixth_wht	= $('#sixth_wht').val().replace(/,/g, "");
	var seventh_wht	= $('#seventh_wht').val().replace(/,/g, "");
	var eight_wht	= $('#eight_wht').val().replace(/,/g, "");
	var nine_wht		= $('#nine_wht').val().replace(/,/g, "");
	var ten_wht		= $('#ten_wht').val().replace(/,/g, "");
	 
	var total_wht 	= (parseFloat(first_wht) + parseFloat(second_wht) + parseFloat(third_wht) + parseFloat(fourth_wht) + parseFloat(fifth_wht) + parseFloat(sixth_wht) + parseFloat(seventh_wht) + parseFloat(eight_wht) + parseFloat(nine_wht) + parseFloat(ten_wht));
	total_wht 		= Comma(parseFloat(total_wht).toFixed(2));
	$('#total_wht').val(total_wht);
 
	var balance_wht 	= parseFloat(withholding_tax) - (parseFloat(first_wht) + parseFloat(second_wht) + parseFloat(third_wht) + parseFloat(fourth_wht) + parseFloat(fifth_wht) + parseFloat(sixth_wht) + parseFloat(seventh_wht) + parseFloat(eight_wht) + parseFloat(nine_wht) + parseFloat(ten_wht));
	balance_wht 		= Comma(parseFloat(balance_wht).toFixed(2));
	$('#balance_wht').val(balance_wht);
 
	var first_recoup	= $('#first_recoup').val().replace(/,/g, "");
	var second_recoup	= $('#second_recoup').val().replace(/,/g, "");
	var third_recoup	= $('#third_recoup').val().replace(/,/g, "");
	var fourth_recoup	= $('#fourth_recoup').val().replace(/,/g, "");
	var fifth_recoup	= $('#fifth_recoup').val().replace(/,/g, "");
	var sixth_recoup	= $('#sixth_recoup').val().replace(/,/g, "");
	var seventh_recoup	= $('#seventh_recoup').val().replace(/,/g, "");
	var eight_recoup	= $('#eight_recoup').val().replace(/,/g, "");
	var nine_recoup		= $('#nine_recoup').val().replace(/,/g, "");
	var ten_recoup		= $('#ten_recoup').val().replace(/,/g, "");
	 
	var total_recoup 	= (parseFloat(first_recoup) + parseFloat(second_recoup) + parseFloat(third_recoup) + parseFloat(fourth_recoup) + parseFloat(fifth_recoup) + parseFloat(sixth_recoup) + parseFloat(seventh_recoup) + parseFloat(eight_recoup) + parseFloat(nine_recoup) + parseFloat(ten_recoup));
	total_recoup 		= Comma(parseFloat(total_recoup).toFixed(2));
	$('#total_recoup').val(total_recoup);

 	var balance_recoup 	= parseFloat(downpayment_recoup) - (parseFloat(first_recoup) + parseFloat(second_recoup) + parseFloat(third_recoup) + parseFloat(fourth_recoup) + parseFloat(fifth_recoup) + parseFloat(sixth_recoup) + parseFloat(seventh_recoup) + parseFloat(eight_recoup) + parseFloat(nine_recoup) + parseFloat(ten_recoup));
	balance_recoup 		= Comma(parseFloat(balance_recoup).toFixed(2));
	$('#balance_recoup').val(balance_recoup);


	var first_retention	= $('#first_retention').val().replace(/,/g, "");
	var second_retention	= $('#second_retention').val().replace(/,/g, "");
	var third_retention	= $('#third_retention').val().replace(/,/g, "");
	var fourth_retention	= $('#fourth_retention').val().replace(/,/g, "");
	var fifth_retention	= $('#fifth_retention').val().replace(/,/g, "");
	var sixth_retention	= $('#sixth_retention').val().replace(/,/g, "");
	var seventh_retention	= $('#seventh_retention').val().replace(/,/g, "");
	var eight_retention	= $('#eight_retention').val().replace(/,/g, "");
	var nine_retention		= $('#nine_retention').val().replace(/,/g, "");
	var ten_retention		= $('#ten_retention').val().replace(/,/g, "");
	 
	var total_retention 	= (parseFloat(first_retention) + parseFloat(second_retention) + parseFloat(third_retention) + parseFloat(fourth_retention) + parseFloat(fifth_retention) + parseFloat(sixth_retention) + parseFloat(seventh_retention) + parseFloat(eight_retention) + parseFloat(nine_retention) + parseFloat(ten_retention));
	total_retention 		= Comma(parseFloat(total_retention).toFixed(2));
	$('#total_retention').val(total_retention);



	var first_electricity	= $('#first_electricity').val().replace(/,/g, "");
	var second_electricity	= $('#second_electricity').val().replace(/,/g, "");
	var third_electricity	= $('#third_electricity').val().replace(/,/g, "");
	var fourth_electricity	= $('#fourth_electricity').val().replace(/,/g, "");
	var fifth_electricity	= $('#fifth_electricity').val().replace(/,/g, "");
	var sixth_electricity	= $('#sixth_electricity').val().replace(/,/g, "");
	var seventh_electricity	= $('#seventh_electricity').val().replace(/,/g, "");
	var eight_electricity	= $('#eight_electricity').val().replace(/,/g, "");
	var nine_electricity		= $('#nine_electricity').val().replace(/,/g, "");
	var ten_electricity		= $('#ten_electricity').val().replace(/,/g, "");
	 
	var total_electricity 	= (parseFloat(first_electricity) + parseFloat(second_electricity) + parseFloat(third_electricity) + parseFloat(fourth_electricity) + parseFloat(fifth_electricity) + parseFloat(sixth_electricity) + parseFloat(seventh_electricity) + parseFloat(eight_electricity) + parseFloat(nine_electricity) + parseFloat(ten_electricity));
	total_electricity 		= Comma(parseFloat(total_electricity).toFixed(2));
	$('#total_electricity').val(total_electricity);


	var first_water	= $('#first_water').val().replace(/,/g, "");
	var second_water	= $('#second_water').val().replace(/,/g, "");
	var third_water	= $('#third_water').val().replace(/,/g, "");
	var fourth_water	= $('#fourth_water').val().replace(/,/g, "");
	var fifth_water	= $('#fifth_water').val().replace(/,/g, "");
	var sixth_water	= $('#sixth_water').val().replace(/,/g, "");
	var seventh_water	= $('#seventh_water').val().replace(/,/g, "");
	var eight_water	= $('#eight_water').val().replace(/,/g, "");
	var nine_water		= $('#nine_water').val().replace(/,/g, "");
	var ten_water		= $('#ten_water').val().replace(/,/g, "");
	 
	var total_water 	= (parseFloat(first_water) + parseFloat(second_water) + parseFloat(third_water) + parseFloat(fourth_water) + parseFloat(fifth_water) + parseFloat(sixth_water) + parseFloat(seventh_water) + parseFloat(eight_water) + parseFloat(nine_water) + parseFloat(ten_water));
	total_water 		= Comma(parseFloat(total_water).toFixed(2));
	$('#total_water').val(total_water);

	var first_others	= $('#first_others').val().replace(/,/g, "");
	var second_others	= $('#second_others').val().replace(/,/g, "");
	var third_others	= $('#third_others').val().replace(/,/g, "");
	var fourth_others	= $('#fourth_others').val().replace(/,/g, "");
	var fifth_others	= $('#fifth_others').val().replace(/,/g, "");
	var sixth_others	= $('#sixth_others').val().replace(/,/g, "");
	var seventh_others	= $('#seventh_others').val().replace(/,/g, "");
	var eight_others	= $('#eight_others').val().replace(/,/g, "");
	var nine_others		= $('#nine_others').val().replace(/,/g, "");
	var ten_others		= $('#ten_others').val().replace(/,/g, "");
	 
	var total_others 	= (parseFloat(first_others) + parseFloat(second_others) + parseFloat(third_others) + parseFloat(fourth_others) + parseFloat(fifth_others) + parseFloat(sixth_others) + parseFloat(seventh_others) + parseFloat(eight_others) + parseFloat(nine_others) + parseFloat(ten_others));
	total_others 		= Comma(parseFloat(total_others).toFixed(2));
	$('#total_others').val(total_others);


	var first_net	= $('#first_net').val().replace(/,/g, "");
	var second_net	= $('#second_net').val().replace(/,/g, "");
	var third_net	= $('#third_net').val().replace(/,/g, "");
	var fourth_net	= $('#fourth_net').val().replace(/,/g, "");
	var fifth_net	= $('#fifth_net').val().replace(/,/g, "");
	var sixth_net	= $('#sixth_net').val().replace(/,/g, "");
	var seventh_net	= $('#seventh_net').val().replace(/,/g, "");
	var eight_net	= $('#eight_net').val().replace(/,/g, "");
	var nine_net		= $('#nine_net').val().replace(/,/g, "");
	var ten_net		= $('#ten_net').val().replace(/,/g, "");
	 
	var total_net 	= (parseFloat(first_net) + parseFloat(second_net) + parseFloat(third_net) + parseFloat(fourth_net) + parseFloat(fifth_net) + parseFloat(sixth_net) + parseFloat(seventh_net) + parseFloat(eight_net) + parseFloat(nine_net) + parseFloat(ten_net));
	total_net 		= Comma(parseFloat(total_net).toFixed(2));
	$('#total_net').val(total_net);

	releaseStatus();

}	